Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
TypeScript agentic-aiagentsaiai-agentsaiagentsdeveloper-toolsfunction-callinggpt-4javascriptjsllmllmopsmcppythonremote-mcp-serverssetypescript
fix: use Tool Router schemas for custom MCP search
shams haroonf4c1070377f1
diff --git a/ts/packages/cli/CHANGELOG.md b/ts/packages/cli/CHANGELOG.mdindex 8c552e307..acde92bc0 100644--- a/ts/packages/cli/CHANGELOG.md+++ b/ts/packages/cli/CHANGELOG.md@@ -2,6 +2,8 @@## Unreleased+- `composio search` now uses schemas returned by Tool Router for dashboard-registered custom MCP tools instead of querying the legacy managed-tool endpoint, which returned 404 for `CUSTOM_*` tool slugs.+## 0.3.3### Patch Changesdiff --git a/ts/packages/cli/src/commands/tools/commands/tools.search.cmd.ts b/ts/packages/cli/src/commands/tools/commands/tools.search.cmd.tsindex d486e5b74..dc6b4da9f 100644--- a/ts/packages/cli/src/commands/tools/commands/tools.search.cmd.ts+++ b/ts/packages/cli/src/commands/tools/commands/tools.search.cmd.ts@@ -23,7 +23,10 @@ import {writeConsumerConnectedToolkitsCache,} from 'src/services/consumer-short-term-cache';import { appendCliSessionHistory } from 'src/services/cli-session-artifacts';-import { getOrFetchToolInputDefinition } from 'src/services/tool-input-validation';+import {+ cacheToolInputDefinition,+ getOrFetchToolInputDefinition,+} from 'src/services/tool-input-validation';const query = Args.repeated(Args.text({ name: 'query' })).pipe(Args.withDescription(@@ -93,6 +96,9 @@ const stripSearchResultMetadata = <const TOOL_SCHEMA_PATH_FORMAT = '~/.composio/tool_definitions/<TOOL_SLUG>.json';+const isRemoteCustomToolSlug = (slug: string): boolean =>+ slug.toUpperCase().startsWith('CUSTOM_');+const toHomeRelativePath = (cacheDir: string, absolutePath: string) =>absolutePath.startsWith(cacheDir) ? absolutePath.replace(cacheDir, '~/.composio') : absolutePath;@@ -183,7 +189,14 @@ const buildSearchJsonPayload = (params: {const primaryToolSchemaPaths = Object.fromEntries(yield* Effect.forEach(primaryToolSlugs, slug =>Effect.gen(function* () {- const definition = yield* getOrFetchToolInputDefinition(slug, params.projectScope);+ const searchSchema = params.searchResponse.tool_schemas[slug];+ const definition =+ isRemoteCustomToolSlug(slug) && searchSchema?.input_schema+ ? yield* cacheToolInputDefinition({+ slug,+ schema: searchSchema.input_schema,+ })+ : yield* getOrFetchToolInputDefinition(slug, params.projectScope);return [slug, toHomeRelativePath(cacheDir, definition.schemaPath)] satisfies readonly [string,string,diff --git a/ts/packages/cli/src/services/tool-input-validation.ts b/ts/packages/cli/src/services/tool-input-validation.tsindex a05e8bc6e..90ef84342 100644--- a/ts/packages/cli/src/services/tool-input-validation.ts+++ b/ts/packages/cli/src/services/tool-input-validation.ts@@ -142,6 +142,33 @@ export const getToolDefinitionCachePath = (slug: string) =>return toolDefinitionPath(path, cacheDir, slug);});+export const cacheToolInputDefinition = (params: {+ readonly slug: string;+ readonly schema: Record<string, unknown>;+ readonly version?: string | null;+}) =>+ Effect.gen(function* () {+ const fs = yield* FileSystem.FileSystem;+ const path = yield* Path.Path;+ const cacheDir = yield* setupCacheDir;+ const schemaPath = toolDefinitionPath(path, cacheDir, params.slug);++ yield* ensureToolDefinitionsDir(fs, path, cacheDir);+ yield* fs.writeFileString(+ schemaPath,+ serializeCachedToolDefinition({+ version: params.version ?? null,+ inputSchema: params.schema,+ })+ );++ return {+ schemaPath,+ schema: params.schema,+ version: params.version ?? null,+ };+ });+export const invalidateToolInputDefinition = (slug: string) =>Effect.gen(function* () {const fs = yield* FileSystem.FileSystem;diff --git a/ts/packages/cli/test/src/commands/tools/tools.search.cmd.test.ts b/ts/packages/cli/test/src/commands/tools/tools.search.cmd.test.tsindex a96260329..5a776ee8c 100644--- a/ts/packages/cli/test/src/commands/tools/tools.search.cmd.test.ts+++ b/ts/packages/cli/test/src/commands/tools/tools.search.cmd.test.ts@@ -136,6 +136,69 @@ describe('CLI: composio search', () => {);});+ layer(TestLive(testLiveOptions))(+ '[Given] a remote custom tool schema [Then] search uses the Tool Router schema',+ it => {+ it.scoped('does not refetch custom tool schemas through the legacy tools endpoint', () =>+ Effect.gen(function* () {+ const customSlug = 'CUSTOM_DEEPWIKI_READ_WIKI_CONTENTS';+ const live = TestLive({+ ...testLiveOptions,+ toolRouter: {+ search: async (_sessionId, params) => ({+ success: true,+ error: null,+ results: [+ {+ index: 1,+ use_case: params.queries[0]?.use_case ?? '',+ primary_tool_slugs: [customSlug],+ related_tool_slugs: [],+ toolkits: ['CUSTOM_DEEPWIKI'],+ },+ ],+ tool_schemas: {+ [customSlug]: {+ tool_slug: customSlug,+ toolkit: 'CUSTOM_DEEPWIKI',+ description: 'Read wiki contents',+ hasFullSchema: true,+ input_schema: {+ type: 'object',+ properties: { repo: { type: 'string' } },+ required: ['repo'],+ },+ output_schema: { type: 'object', properties: {} },+ },+ },+ toolkit_connection_statuses: [],+ next_steps_guidance: [],+ session: {+ id: 'trs_test_session',+ generate_id: false,+ instructions: 'Reuse this session id for follow-up calls.',+ },+ time_info: {+ current_time_utc: '2026-01-01T00:00:00.000Z',+ current_time_utc_epoch_seconds: 1767225600,+ message: 'UTC time',+ },+ }),+ },+ });++ yield* cli(['search', 'read wiki contents']).pipe(Effect.provide(live));+ const output = (yield* MockConsole.getLines({ stripAnsi: true })).join('\n');++ expect(output).toContain(customSlug);+ expect(output).toContain(+ `~/.composio/tool_definitions/${customSlug}.json`+ );+ })+ );+ }+ );+layer(TestLive(testLiveOptions))('[Given] multiple queries [Then] the CLI returns a batched JSON response',it => {