--- title: "Local Tools" sidebarTitle: "Local Tools" icon: "gear" description: "What are Local tools and how to add new capabilities to your Agents." --- Composio provides you with hundreds of tools and thousands of prebuilt actions, which contains both: 1. Managed and run at Composio's end, 2. Running and executed locally at the user's machine. The second kind is termed as **Local Tools** and some of its advantages are: * The execution data does not need to leave user's machine, * User can add as many new Tools and Actions by themselves, and once added, can use with any of Composio's supported platforms. We have already added a number of local tools and are continuously adding more. Manage your local files with actions like `ReadFile`, `WriteFile`. Code understanding and conversation with codebase using tools like `CodeQuery`. Manage your workspace with actions like `CreateWorkspaceAction`, `WorkspaceStatusAction` Retrieval Augmented Generation with `RagToolQuery`, `AddContentToRagTool` Interact with internet with tools like `ScrapeWebsiteContent`, `ScrapeWebsiteElement` Various mathematical functionalities such as `Calculator` ## Adding a Custom Local tool In addition to the existing tools, a user can easily create their own tool and use with any of the supported frameworks of composio. **Pre-requisites:** * [Clone the Composio repo](https://github.com/composiohq/composio) * [Setting up the development environment](https://github.com/composiohq/composio/blob/master/CONTRIBUTING.md#development-setup) Your local tool and its actions should be organized as follows: ```bash File Structure of a local tool and its Actions files. composio/ └── tools/ └── local/ └── / ├── __init__.py ├── tool.py └── actions/ ├── __init__.py └── .py ``` **Files and their Contents:** **`composio/tools/local//tool.py`** ```python Defines the tool class import typing as t from composio.tools.local.base import Action, Tool from .actions. import # Import your action class class (Tool): """ Description of your tool. """ def actions(self) -> list[t.Type[Action]]: return [] def triggers(self) -> list: return [] # If applicable, define triggers here ``` **`composio/tools/local//__init__.py`:** ```python Exports the tool class from .tool import ``` **`composio/tools/local//actions/.py`** ```python Defines an action for your tool from pydantic import BaseModel, Field from composio.tools.local.base import Action class (BaseModel): # Define input schema for your action # Example: # text: str = Field(..., description="Input text for the action") class (BaseModel): # Define output schema for your action # Example: # result: str = Field(..., description="Result of the action") class (Action[, ]): """ Description of your action. """ display_name = "Friendly name of your action" _request_schema = _response_schema = _tags = ["tag1", "tag2"] # Optional tags to categorize your action _tool_name = "" # Tool name, same as directory name def execute( self, request_data: , authorisation_data: dict = {} ) -> : # Implement logic to process input and return output # Example: # response_data = {"result": "Processed text: " + request_data.text} return {"execution_details": {"executed": True}, "response_data": response_data} ``` **`composio/tools/local//actions/__init__.py`:** ```python Exports the action class from . import ``` **`composio/tools/local/__init__.py`:** ```python Add your tool from pathlib import Path from composio.tools.local.filetool import FileTool from composio.tools.local.greptile import Greptile from composio.tools.local. import # Import your tool class TOOLS_PATH = Path(__file__).parent TOOLS = [ FileTool, Greptile, , # Add your tool here ] ``` Run the below command to add a new tool and action to the enum values. ```bash composio apps update ``` If this command fails or you still don't see your tool and action in the enum values, then update the enum values manually via below steps: **`composio/client/enums.py`:** ```python Add new App & Action entry class App(str, Enum): """Composio App.""" ABLY = "ably" ACCELO = "accelo" = <_tool_name_> class Action(tuple, Enum): """App action.""" MATHEMATICAL_CALCULATOR = ("mathematical", "mathematical_calculator", True, True) LOCALWORKSPACE_WORKSPACESTATUSACTION = ("localworkspace", "localworkspace_workspacestatusaction", True, True) LOCALWORKSPACE_CREATEWORKSPACEACTION = ("localworkspace", "localworkspace_createworkspaceaction", True, True) = ( <_tool_name>, <_action_name>, True, True) ``` Make sure `_tool_name` is always the lowercase of the `` class we defined in the previous steps. E.g if we defined `` as `MyTool`, then _tool_name should be `mytool`. Make sure `TOOL_ENUM_NAME` and `ACTION_ENUM_NAME` is always one or more uppercase words separated by _. **Examples/Sample Code:** There are lot of local tools available in `composio/tools/local` directory, that you can use as a reference. To get started, you should check out the below two tools: - [Mathematical tool](https://github.com/composiohq/composio/blob/master/python/composio/tools/local/mathematical/tool.py): Simple tool to perform mathematical operations. - [Greptile tool](https://github.com/composiohq/composio/blob/master/python/composio/tools/local/greptile/tool.py): Tool to integrate with [Greptile](https://www.greptile.com/) framework. **Key Points:** * Replace placeholders ``, ``, ``, ``, ``, `` with your own names and logic. * Use the Composio documentation for further details on defining tools and actions: [https://docs.composio.dev/](https://docs.composio.dev/) * Install any required dependencies for your tools and actions.