get_python_docs
Retrieve Python documentation by searching with natural language queries to find relevant programming information and code examples.
Instructions
Get Python documentation for a given query
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | The search query for Python documentation |
Implementation Reference
- src/index.ts:46-96 (handler)Handler function for CallToolRequestSchema that specifically handles 'get_python_docs' by validating args, calling brave-search web search tool with python documentation query, and returning formatted results or errors.server.setRequestHandler(CallToolRequestSchema, async (request) => { if (request.params.name !== 'get_python_docs') { throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: ${request.params.name}`); } if (!isValidGetPythonDocsArgs(request.params.arguments)) { throw new McpError(ErrorCode.InvalidParams, 'Invalid arguments'); } const query = request.params.arguments.query; try { const searchResult = await (server as any).callMcpTool({ serverName: 'brave-search', toolName: 'search_web', arguments: { query: `python documentation ${query}`, count: 3, }, }); if (searchResult.isError) { return { content: [{ type: 'text', text: `Error searching for documentation: ${searchResult.content[0].text}` }], isError: true, } } const results = searchResult.content[0].text; return { content: [ { type: 'text', text: `Search results for "${query}":\n${results}`, }, ], }; } catch (error: any) { return { content: [{ type: 'text', text: `Error: ${error.message}` }], isError: true, } } });
- src/index.ts:27-44 (registration)Registration of the 'get_python_docs' tool in the ListToolsRequestHandler, including name, description, and input schema.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [ { name: 'get_python_docs', description: 'Get Python documentation for a given query', inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'The search query for Python documentation', }, }, required: ['query'], }, }, ], }));
- src/index.ts:24-25 (schema)Type guard function for validating arguments to 'get_python_docs' tool, ensuring it has a 'query' string.const isValidGetPythonDocsArgs = (args: any): args is { query: string } => typeof args === 'object' && args !== null && typeof args.query === 'string';
- src/index.ts:32-41 (schema)JSON schema definition for the input of 'get_python_docs' tool.inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'The search query for Python documentation', }, }, required: ['query'], },