Skip to content

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

docs(python): align generated custom tool references

Dhawal Upadhyay128c6364849b
diff --git a/docs/content/reference/sdk-reference/python/session-context-impl.mdx b/docs/content/reference/sdk-reference/python/session-context-impl.mdx
index 59d90b1da..1962a4c28 100644
--- a/docs/content/reference/sdk-reference/python/session-context-impl.mdx
+++ b/docs/content/reference/sdk-reference/python/session-context-impl.mdx
@@ -3,6 +3,12 @@ title: SessionContextImpl
description: Concrete implementation of SessionContext. One instance is created per session (singleton) and shared across all custom tool invocations. When ``c...
---
+## Properties
+
+| Name | Type | Description |
+|------|------|-------------|
+| `user_id` | `str` | The user ID for the current session. |
+
## Methods
### execute()
diff --git a/docs/content/reference/sdk-reference/python/tool-router-session.mdx b/docs/content/reference/sdk-reference/python/tool-router-session.mdx
index a3db0598f..079f56c84 100644
--- a/docs/content/reference/sdk-reference/python/tool-router-session.mdx
+++ b/docs/content/reference/sdk-reference/python/tool-router-session.mdx
@@ -3,6 +3,14 @@ title: ToolRouterSession
description: "Tool router session containing session information and methods. Generic Parameters: TTool: The individual tool type returned by the provider. TToo..."
---
+## Properties
+
+| Name | Type |
+|------|------|
+| `session_id` | `str` |
+| `mcp` | `Any` |
+| `experimental` | `'ToolRouterSessionExperimental'` |
+
## Methods
### tools()
@@ -51,7 +59,7 @@ def authorize(toolkit: str, callback_url: str | None = ...) -> ConnectionRequest
Get toolkit connection states for the session.
```python
-def toolkits(toolkits: List[str | None] = ..., next_cursor: str | None = ..., limit: int | None = ..., is_connected: bool | None = ..., search: str | None = ...)
+def toolkits(toolkits: List[str | None] = ..., next_cursor: str | None = ..., limit: int | None = ..., is_connected: bool | None = ..., search: str | None = ...) -> ToolkitConnectionsDetails
```
**Parameters**
@@ -64,6 +72,10 @@ def toolkits(toolkits: List[str | None] = ..., next_cursor: str | None = ..., li
| `is_connected?` | `bool \| None` |
| `search?` | `str \| None` |
+**Returns**
+
+`ToolkitConnectionsDetails`
+
---
### search()
@@ -71,7 +83,7 @@ def toolkits(toolkits: List[str | None] = ..., next_cursor: str | None = ..., li
Search for tools by semantic use case. Returns relevant tools for the given query with schemas and guidance.
```python
-def search(query: str, model: str | None = ...)
+def search(query: str, model: str | None = ...) -> SessionSearchResponse
```
**Parameters**
@@ -81,6 +93,10 @@ def search(query: str, model: str | None = ...)
| `query` | `str` |
| `model?` | `str \| None` |
+**Returns**
+
+`SessionSearchResponse`
+
---
### execute()
@@ -162,4 +178,4 @@ def proxy_execute(toolkit: str, endpoint: str, method: Literal['GET', 'POST', 'P
---
-[View source](https://github.com/composiohq/composio/blob/next/python/composio/core/models/tool_router_session.py#L47)
+[View source](https://github.com/composiohq/composio/blob/next/python/composio/core/models/tool_router_session.py#L53)
diff --git a/python/composio/core/models/session_context.py b/python/composio/core/models/session_context.py
index fe1969b0f..e0ea91aeb 100644
--- a/python/composio/core/models/session_context.py
+++ b/python/composio/core/models/session_context.py
@@ -107,6 +107,7 @@ class SessionContextImpl:
@property
def user_id(self) -> str:
+ """The user ID for the current session."""
return self._user_id
def execute(
diff --git a/python/composio/core/models/tool_router_session.py b/python/composio/core/models/tool_router_session.py
index 681c57233..a1587fe57 100644
--- a/python/composio/core/models/tool_router_session.py
+++ b/python/composio/core/models/tool_router_session.py
@@ -18,6 +18,9 @@ from composio_client.types.tool_router.session_execute_response import (
from composio_client.types.tool_router.session_proxy_execute_response import (
SessionProxyExecuteResponse,
)
+from composio_client.types.tool_router.session_search_response import (
+ SessionSearchResponse,
+)
from composio.client import HttpClient
from composio.core.models.connected_accounts import ConnectionRequest
@@ -38,7 +41,10 @@ from composio.core.provider import TTool, TToolCollection
from composio.core.provider.base import BaseProvider
if t.TYPE_CHECKING:
- from composio.core.models.tool_router import ToolRouterSessionExperimental
+ from composio.core.models.tool_router import (
+ ToolRouterSessionExperimental,
+ ToolkitConnectionsDetails,
+ )
COMPOSIO_MULTI_EXECUTE_TOOL = "COMPOSIO_MULTI_EXECUTE_TOOL"
MAX_PARALLEL_WORKERS = 5
@@ -58,6 +64,13 @@ class ToolRouterSession(t.Generic[TTool, TToolCollection]):
experimental: Experimental features (files, assistive prompt, etc.)
"""
+ #: Unique session identifier.
+ session_id: str
+ #: MCP server configuration for this session.
+ mcp: t.Any
+ #: Experimental capabilities available on this session.
+ experimental: "ToolRouterSessionExperimental"
+
def __init__(
self,
*,
@@ -399,7 +412,7 @@ class ToolRouterSession(t.Generic[TTool, TToolCollection]):
limit: t.Optional[int] = None,
is_connected: t.Optional[bool] = None,
search: t.Optional[str] = None,
- ) -> t.Any:
+ ) -> ToolkitConnectionsDetails:
"""
Get toolkit connection states for the session.
"""
@@ -480,7 +493,7 @@ class ToolRouterSession(t.Generic[TTool, TToolCollection]):
*,
query: str,
model: t.Optional[str] = None,
- ) -> t.Any:
+ ) -> SessionSearchResponse:
"""
Search for tools by semantic use case.
diff --git a/python/scripts/generate-docs.py b/python/scripts/generate-docs.py
index 6d04a457f..cb316d643 100644
--- a/python/scripts/generate-docs.py
+++ b/python/scripts/generate-docs.py
@@ -272,23 +272,51 @@ def generate_class_mdx(
source_link = info.get("source_link", "")
- # Properties - as table for Composio class
- if prop_to_class:
- prop_rows = []
- for prop in info["properties"]:
- prop_name = prop["name"]
- if prop_name in prop_to_class:
- class_name = prop_to_class[prop_name]
- link = f"/reference/sdk-reference/python/{to_kebab_case(class_name)}"
- prop_rows.append(f"| [`{prop_name}`]({link}) | `{class_name}` |")
-
- if prop_rows:
- lines.append("## Properties")
- lines.append("")
+ # Properties
+ property_rows = []
+ if info["properties"]:
+ if prop_to_class:
+ for prop in info["properties"]:
+ prop_name = prop["name"]
+ if prop_name in prop_to_class:
+ class_name = prop_to_class[prop_name]
+ link = (
+ f"/reference/sdk-reference/python/{to_kebab_case(class_name)}"
+ )
+ property_rows.append(
+ {
+ "name": f"[`{prop_name}`]({link})",
+ "type": f"`{class_name}`",
+ "description": prop["description"],
+ }
+ )
+ elif info["name"] in ADDITIONAL_CLASSES:
+ for prop in info["properties"]:
+ property_rows.append(
+ {
+ "name": f"`{prop['name']}`",
+ "type": f"`{prop['type']}`",
+ "description": prop["description"],
+ }
+ )
+
+ if property_rows:
+ include_descriptions = any(row["description"] for row in property_rows)
+ lines.append("## Properties")
+ lines.append("")
+ if include_descriptions:
+ lines.append("| Name | Type | Description |")
+ lines.append("|------|------|-------------|")
+ for row in property_rows:
+ lines.append(
+ f"| {row['name']} | {row['type']} | {row['description']} |"
+ )
+ else:
lines.append("| Name | Type |")
lines.append("|------|------|")
- lines.extend(prop_rows)
- lines.append("")
+ for row in property_rows:
+ lines.append(f"| {row['name']} | {row['type']} |")
+ lines.append("")
# Methods
if info["methods"]: