SDK Reference
Python SDK Reference
Python SDK Reference
Complete API reference for the composio Python package.
Installation
pip install composioOr with uv:
uv add composioClasses
| Class | Description |
|---|---|
Composio | Composio SDK for Python. Generic parameters: TTool: The individual tool type re... |
Tools | Tools class definition This class is used to manage tools in the Composio SDK. ... |
Toolkits | Toolkits are a collectiono of tools that can be used to perform various tasks. T... |
Triggers | Triggers (instance) class |
ConnectedAccounts | Manage connected accounts. This class is used to manage connected accounts in t... |
AuthConfigs | Manage authentication configurations. |
MCP | MCP (Model Control Protocol) class. Provides enhanced MCP server operations Thi... |
ToolRouterSession | Tool router session containing session information and methods. Generic Paramet... |
SessionContextImpl | Concrete implementation of SessionContext. One instance is created per session ... |
Quick Start
from composio import Composio
composio = Composio(api_key="your-api-key")
# Get tools for a user
tools = composio.tools.get("user-123", toolkits=["github"])
# Execute a tool
result = composio.tools.execute(
"GITHUB_GET_REPOS",
arguments={"owner": "composio"},
user_id="user-123"
)Decorators
before_execute
@before_execute(modifier: BeforeExecute | None = ..., tools: List[str | None] = ..., toolkits: List[str | None] = ...)
def my_modifier(...):
...after_execute
@after_execute(modifier: AfterExecute | None = ..., tools: List[str | None] = ..., toolkits: List[str | None] = ...)
def my_modifier(...):
...before_file_upload
Build a Modifier for the file-upload hook (same scoping pattern as :func:before_execute). Your callable may take either: - a single context argument (:class:BeforeFileUploadContext) — the preferred form, exposes context["source"] ("path" or "url"), or - three positional arguments (path, tool, toolkit) — legacy form, kept for back-compat. Return a new path/URL string to substitute, or False to abort the upload (raises :class:~composio.exceptions.FileUploadAbortedError). Pass the returned Modifier in modifiers=[...] on :meth:composio.core.models.tools.Tools.execute or tools.get. Multiple such modifiers are composed in list order.
@before_file_upload(modifier: BeforeFileUploadLike | None = ..., tools: List[str | None] = ..., toolkits: List[str | None] = ...)
def my_modifier(...):
...schema_modifier
@schema_modifier(modifier: SchemaModifier | None = ..., tools: List[str | None] = ..., toolkits: List[str | None] = ...)
def my_modifier(...):
...