Skip to content

Commit 86b23ff

Browse files
feat(mcp): enable experimental docs search tool
1 parent 7f71235 commit 86b23ff

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2+
3+
import { Metadata, asTextContentResult } from './tools/types';
4+
5+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
6+
7+
export const metadata: Metadata = {
8+
resource: 'all',
9+
operation: 'read',
10+
tags: [],
11+
httpMethod: 'get',
12+
};
13+
14+
export const tool: Tool = {
15+
name: 'search_docs',
16+
description:
17+
'Search for documentation for how to use the client to interact with the API.\nThe tool will return an array of Markdown-formatted documentation pages.',
18+
inputSchema: {
19+
type: 'object',
20+
properties: {
21+
query: {
22+
type: 'string',
23+
description: 'The query to search for.',
24+
},
25+
language: {
26+
type: 'string',
27+
description: 'The language for the SDK to search for.',
28+
enum: ['http', 'python', 'go', 'typescript', 'terraform', 'ruby', 'java', 'kotlin'],
29+
},
30+
},
31+
required: ['query', 'language'],
32+
},
33+
annotations: {
34+
readOnlyHint: true,
35+
},
36+
};
37+
38+
export const handler = async (_: unknown, args: Record<string, unknown> | undefined) => {
39+
const body = args as any;
40+
const query = new URLSearchParams(body).toString();
41+
const result = await fetch('https://api.stainless.com/api/projects/cas-parser/docs/search?' + query);
42+
return asTextContentResult(await result.json());
43+
};
44+
45+
export default { metadata, tool, handler };

packages/mcp-server/src/server.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
} from './compat';
2222
import { dynamicTools } from './dynamic-tools';
2323
import { codeTool } from './code-tool';
24+
import docsSearchTool from './docs-search-tool';
2425
import { McpOptions } from './options';
2526

2627
export { McpOptions } from './options';
@@ -159,7 +160,7 @@ export async function selectTools(endpoints: Endpoint[], options?: McpOptions):
159160
} else if (options?.includeDynamicTools) {
160161
includedTools = dynamicTools(endpoints);
161162
} else if (options?.includeCodeTools) {
162-
includedTools = [await codeTool()];
163+
includedTools = [await codeTool(), docsSearchTool];
163164
} else {
164165
includedTools = endpoints;
165166
}

0 commit comments

Comments
 (0)