@devries-cameron20 / composio Mirror · read-only / commits / f4c107037
Fork 0

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

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 16:00 UTC

fix: use Tool Router schemas for custom MCP search

shams haroon committed Aug 20, 2026 at 13:39 UTC f4c1070377f157aeb0a824287bc38bd1e100281e
4 files changed +107 -2
ts/packages/cli/CHANGELOG.md
+2
@@ -2,6 +2,8 @@
2
3 ## Unreleased
4
5 +- `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.
6 +
7 ## 0.3.3
8
9 ### Patch Changes
ts/packages/cli/src/commands/tools/commands/tools.search.cmd.ts
+15 -2
@@ -23,7 +23,10 @@ import {
23 writeConsumerConnectedToolkitsCache,
24 } from 'src/services/consumer-short-term-cache';
25 import { appendCliSessionHistory } from 'src/services/cli-session-artifacts';
26 -import { getOrFetchToolInputDefinition } from 'src/services/tool-input-validation';
26 +import {
27 + cacheToolInputDefinition,
28 + getOrFetchToolInputDefinition,
29 +} from 'src/services/tool-input-validation';
30
31 const query = Args.repeated(Args.text({ name: 'query' })).pipe(
32 Args.withDescription(
@@ -93,6 +96,9 @@ const stripSearchResultMetadata = <
96
97 const TOOL_SCHEMA_PATH_FORMAT = '~/.composio/tool_definitions/<TOOL_SLUG>.json';
98
99 +const isRemoteCustomToolSlug = (slug: string): boolean =>
100 + slug.toUpperCase().startsWith('CUSTOM_');
101 +
102 const toHomeRelativePath = (cacheDir: string, absolutePath: string) =>
103 absolutePath.startsWith(cacheDir) ? absolutePath.replace(cacheDir, '~/.composio') : absolutePath;
104
@@ -183,7 +189,14 @@ const buildSearchJsonPayload = (params: {
189 const primaryToolSchemaPaths = Object.fromEntries(
190 yield* Effect.forEach(primaryToolSlugs, slug =>
191 Effect.gen(function* () {
186 - const definition = yield* getOrFetchToolInputDefinition(slug, params.projectScope);
192 + const searchSchema = params.searchResponse.tool_schemas[slug];
193 + const definition =
194 + isRemoteCustomToolSlug(slug) && searchSchema?.input_schema
195 + ? yield* cacheToolInputDefinition({
196 + slug,
197 + schema: searchSchema.input_schema,
198 + })
199 + : yield* getOrFetchToolInputDefinition(slug, params.projectScope);
200 return [slug, toHomeRelativePath(cacheDir, definition.schemaPath)] satisfies readonly [
201 string,
202 string,
ts/packages/cli/src/services/tool-input-validation.ts
+27
@@ -142,6 +142,33 @@ export const getToolDefinitionCachePath = (slug: string) =>
142 return toolDefinitionPath(path, cacheDir, slug);
143 });
144
145 +export const cacheToolInputDefinition = (params: {
146 + readonly slug: string;
147 + readonly schema: Record<string, unknown>;
148 + readonly version?: string | null;
149 +}) =>
150 + Effect.gen(function* () {
151 + const fs = yield* FileSystem.FileSystem;
152 + const path = yield* Path.Path;
153 + const cacheDir = yield* setupCacheDir;
154 + const schemaPath = toolDefinitionPath(path, cacheDir, params.slug);
155 +
156 + yield* ensureToolDefinitionsDir(fs, path, cacheDir);
157 + yield* fs.writeFileString(
158 + schemaPath,
159 + serializeCachedToolDefinition({
160 + version: params.version ?? null,
161 + inputSchema: params.schema,
162 + })
163 + );
164 +
165 + return {
166 + schemaPath,
167 + schema: params.schema,
168 + version: params.version ?? null,
169 + };
170 + });
171 +
172 export const invalidateToolInputDefinition = (slug: string) =>
173 Effect.gen(function* () {
174 const fs = yield* FileSystem.FileSystem;
ts/packages/cli/test/src/commands/tools/tools.search.cmd.test.ts
+63
@@ -136,6 +136,69 @@ describe('CLI: composio search', () => {
136 );
137 });
138
139 + layer(TestLive(testLiveOptions))(
140 + '[Given] a remote custom tool schema [Then] search uses the Tool Router schema',
141 + it => {
142 + it.scoped('does not refetch custom tool schemas through the legacy tools endpoint', () =>
143 + Effect.gen(function* () {
144 + const customSlug = 'CUSTOM_DEEPWIKI_READ_WIKI_CONTENTS';
145 + const live = TestLive({
146 + ...testLiveOptions,
147 + toolRouter: {
148 + search: async (_sessionId, params) => ({
149 + success: true,
150 + error: null,
151 + results: [
152 + {
153 + index: 1,
154 + use_case: params.queries[0]?.use_case ?? '',
155 + primary_tool_slugs: [customSlug],
156 + related_tool_slugs: [],
157 + toolkits: ['CUSTOM_DEEPWIKI'],
158 + },
159 + ],
160 + tool_schemas: {
161 + [customSlug]: {
162 + tool_slug: customSlug,
163 + toolkit: 'CUSTOM_DEEPWIKI',
164 + description: 'Read wiki contents',
165 + hasFullSchema: true,
166 + input_schema: {
167 + type: 'object',
168 + properties: { repo: { type: 'string' } },
169 + required: ['repo'],
170 + },
171 + output_schema: { type: 'object', properties: {} },
172 + },
173 + },
174 + toolkit_connection_statuses: [],
175 + next_steps_guidance: [],
176 + session: {
177 + id: 'trs_test_session',
178 + generate_id: false,
179 + instructions: 'Reuse this session id for follow-up calls.',
180 + },
181 + time_info: {
182 + current_time_utc: '2026-01-01T00:00:00.000Z',
183 + current_time_utc_epoch_seconds: 1767225600,
184 + message: 'UTC time',
185 + },
186 + }),
187 + },
188 + });
189 +
190 + yield* cli(['search', 'read wiki contents']).pipe(Effect.provide(live));
191 + const output = (yield* MockConsole.getLines({ stripAnsi: true })).join('\n');
192 +
193 + expect(output).toContain(customSlug);
194 + expect(output).toContain(
195 + `~/.composio/tool_definitions/${customSlug}.json`
196 + );
197 + })
198 + );
199 + }
200 + );
201 +
202 layer(TestLive(testLiveOptions))(
203 '[Given] multiple queries [Then] the CLI returns a batched JSON response',
204 it => {