Skip to main content
Glama

get_python_docs

Fetch Python documentation directly using natural language queries. This tool helps developers quickly access relevant Python documentation by integrating with the Brave Search API.

Instructions

Get Python documentation for a given query

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe search query for Python documentation

Implementation Reference

  • The main handler function for the CallToolRequestSchema that implements the 'get_python_docs' tool. It validates the tool name and arguments, performs a web search via the 'brave-search' server's 'search_web' tool for Python documentation matching the query, and returns the search results or handles 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, } } });
  • The input schema definition for the 'get_python_docs' tool, specifying the expected 'query' parameter.
    inputSchema: { type: 'object', properties: { query: { type: 'string', description: 'The search query for Python documentation', }, }, required: ['query'], },
  • Type guard function used to validate the arguments passed to the 'get_python_docs' tool handler.
    const isValidGetPythonDocsArgs = (args: any): args is { query: string } => typeof args === 'object' && args !== null && typeof args.query === 'string';
  • src/index.ts:27-44 (registration)
    The request handler for ListToolsRequestSchema that registers and advertises the 'get_python_docs' tool with its 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'], }, }, ], }));

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/AnuragRai017/python-docs-server-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server