-
Notifications
You must be signed in to change notification settings - Fork 4.4k
[WIP] Feat: Native + MCP Tool Router with helper methods #2159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: next
Are you sure you want to change the base?
Conversation
| 'COMPOSIO_SEARCH_TOOLS', | ||
| 'COMPOSIO_REMOTE_WORKBENCH', | ||
| 'COMPOSIO_MULTI_EXECUTE_TOOL', | ||
| ]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Cross-language tool inconsistency.
The TypeScript tool router excludes COMPOSIO_REMOTE_BASH_TOOL from the default tool list, while the Python implementation includes it. This cross-language inconsistency means sessions created via TypeScript vs Python will have different available tools, potentially breaking feature parity.
Add provider-aware
|
|
|
||
| def __getitem__(self, key: str) -> str: | ||
| """Support dict-style access like session['url']""" | ||
| return getattr(self, key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__getitem__ claims dict-style access but uses getattr, which raises AttributeError on missing keys. Consider raising KeyError instead to match dict semantics (e.g., check hasattr and raise KeyError).
| return getattr(self, key) | |
| if hasattr(self, key): | |
| return getattr(self, key) | |
| raise KeyError(key) |
🚀 Reply to ask Macroscope to explain or update this suggestion.
👍 Helpful? React to give us feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Issue on line in ts/packages/core/src/composio.ts:221:
Tools/ToolRouter read config.provider, but the default provider isn’t synced into this.config, causing ComposioProviderNotDefinedError when none is passed. Suggest syncing: set this.config.provider = this.provider before constructing (or pass provider explicitly).
this.provider = (config?.provider ?? new OpenAIProvider()) as TProvider;
+ this.config.provider = this.provider;
const defaultHeaders = getDefaultHeaders(this.config.defaultHeaders, this.provider);🚀 Reply to ask Macroscope to explain or update this suggestion.
👍 Helpful? React to give us feedback.
| the Composio platform with proper authentication and configuration. | ||
| """ | ||
|
|
||
| def __init__(self, client: HttpClient): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ToolRouter.__init__ only accepts client, but callers pass provider too. This will raise TypeError. Consider accepting an optional provider arg (and ignore or store it) to keep parity with existing usage.
| def __init__(self, client: HttpClient): | |
| def __init__(self, client: HttpClient, provider: t.Optional[object] = None): |
🚀 Reply to ask Macroscope to explain or update this suggestion.
👍 Helpful? React to give us feedback.
| export * from './types/files.types'; | ||
| export * from './types/connectionRequest.types'; | ||
| export * from './types/toolRouter.types'; | ||
| export * from './types/toolRouter.experimental.types'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: ToolRouter: Essential Types Not Exported
The export statement was changed from ./types/toolRouter.types to ./types/toolRouter.experimental.types, which removes the new types like ToolRouterConfig, ToolRouterSession, MCPServerType, ToolRouterMCPServerConfig, ToolRouterAuthorizeFn, ToolRouterToolkitsFn, etc. from the public API. These types are used by composio.ts and are part of the new ToolRouter feature, so they need to be exported for external consumers.
| manage_connections: t.Optional[ | ||
| t.Union[bool, ToolRouterManageConnectionsConfig] | ||
| ] = None, | ||
| auth_configs: t.Optional[t.Dict[str, str]] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
auth_configs and connected_accounts are accepted in ToolRouter.create(...) but never used. Consider wiring these through to the backend/session (e.g., include them in the API request or persist them on ToolRouterSession) so the user’s auth context and account selection aren’t silently dropped; otherwise consider documenting or removing these args for now.
🚀 Reply to ask Macroscope to explain or update this suggestion.
👍 Helpful? React to give us feedback.
| tools_model = ToolsModel( | ||
| client=self._client, | ||
| provider=self._provider, | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Tools: Missing dependency causes runtime errors.
The ToolsModel is instantiated with provider=self._provider, but self._provider can be None since it's declared as t.Optional[TProvider] in the constructor. The Python Tools class requires a non-None provider and will fail when attempting to wrap tools or execute operations that depend on the provider.
Note
Introduce a first-class Tool Router that creates isolated sessions, wraps tools per provider, exposes authorize/connection helpers, and adds SDK APIs and examples in both Python and TypeScript.
composio.core.models.tool_router.ToolRouterprovidingcreate()to open isolated MCP-backed sessions returning{session_id, mcp, tools(), authorize(), connections()}.tool_router_experimental.pyand expose undercomposio.experimental.tool_router.Composionow exposestool_routerandexperimental.create(proxy to stableToolRouter.create).utils.uuidwithgenerate_uuid/generate_short_idand export viautils.__init__.models/ToolRouterwithcreate()returning session{sessionId, mcp, tools(), authorize(), toolkits()}; new rich config/types intypes/toolRouter.types.models/ToolRouter.experimentalwith types moved totoolRouter.experimental.types.Composionow exposestoolRouterandexperimental.create()(delegates to stable). Export paths updated.Toolsconstructed without direct provider arg and addswrapToolsForProvider(); internal calls updated.ts/examples/tool-routerand simplify Vercel example stream setup.@ai-sdk/[email protected],ora, etc.).Written by Cursor Bugbot for commit decd89f. This will update automatically on new commits. Configure here.