ai_search_api_reference
Search API documentation and usage examples by specifying the API name and platform to quickly find technical reference materials and implementation guidance.
Instructions
🔗 API参考搜索 - 快速查找API文档和使用示例
【重要】此工具会返回API文档搜索URL,Claude Code应该使用WebFetch工具访问该URL以获取真实搜索结果。
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| api_name | Yes | API名称或方法名 | |
| platform | Yes | 平台或库名称(如:express、axios、lodash) |
Input Schema (JSON Schema)
{
"properties": {
"api_name": {
"description": "API名称或方法名",
"type": "string"
},
"platform": {
"description": "平台或库名称(如:express、axios、lodash)",
"type": "string"
}
},
"required": [
"api_name",
"platform"
],
"type": "object"
}
Implementation Reference
- mcp_server_node.js:672-744 (handler)Handler for the 'ai_search_api_reference' tool. Normalizes inputs, constructs various search URLs (Google, DevDocs, GitHub, platform-specific), builds a detailed markdown response with WebFetch instructions, saves to file, and returns a text response.case 'ai_search_api_reference': { const rawApiName = normalizeString(args.api_name); const rawPlatform = normalizeString(args.platform); if (!rawApiName) { throw new Error('API名称不能为空'); } if (!rawPlatform) { throw new Error('平台/库名称不能为空'); } const searchUrls = { google: `https://www.google.com/search?q=${encodeURIComponent(`${rawPlatform} ${rawApiName} API documentation`)}`, devdocs: `https://devdocs.io/#q=${encodeURIComponent(`${rawPlatform} ${rawApiName}`)}`, github: `https://github.com/search?q=${encodeURIComponent(`${rawPlatform} ${rawApiName}`)}&type=code` }; // 常见平台的直接文档链接 const platformDocs = { express: `https://expressjs.com/en/api.html`, axios: `https://axios-http.com/docs/api_intro`, lodash: `https://lodash.com/docs/`, mongoose: `https://mongoosejs.com/docs/api.html`, sequelize: `https://sequelize.org/api/`, 'socket.io': `https://socket.io/docs/v4/`, jwt: `https://github.com/auth0/node-jsonwebtoken#readme` }; const directDoc = platformDocs[rawPlatform.toLowerCase()]; const detailsContent = `🔗 API 参考搜索\n\n` + `**平台/库**: ${rawPlatform}\n` + `**API名称**: ${rawApiName}\n\n` + `---\n\n` + `🔍 **搜索资源**:\n` + `• Google: ${searchUrls.google}\n` + `• DevDocs: ${searchUrls.devdocs}\n` + `• GitHub: ${searchUrls.github}\n` + (directDoc ? `• 官方文档: ${directDoc}\n` : '') + `\n⚠️ **请使用 WebFetch 工具获取API文档**:\n` + `\`\`\`javascript\n` + `// 推荐:先搜索官方文档\n` + `WebFetch({\n` + ` url: "${directDoc || searchUrls.google}",\n` + ` prompt: "查找'${rawApiName}'的:函数签名、参数说明、返回值、使用示例、注意事项"\n` + `})\n\n` + `// 备选:在DevDocs搜索\n` + `WebFetch({\n` + ` url: "${searchUrls.devdocs}",\n` + ` prompt: "提取${rawPlatform}的${rawApiName} API详细文档"\n` + `})\n` + `\`\`\`\n\n` + `---\n\n` + `💡 **查询提示**:\n` + `• 精确搜索: "${rawPlatform}.${rawApiName}()"\n` + `• 示例代码: ${rawPlatform} ${rawApiName} example\n` + `• 参数说明: ${rawPlatform} ${rawApiName} parameters\n` + `• 错误处理: ${rawPlatform} ${rawApiName} error handling\n\n` + `📚 **相关资源**:\n` + `• NPM包: https://www.npmjs.com/package/${rawPlatform}\n` + `• GitHub仓库: https://github.com/search?q=${encodeURIComponent(rawPlatform)}&type=repositories\n` + `• StackOverflow: https://stackoverflow.com/search?q=${encodeURIComponent(`${rawPlatform} ${rawApiName}`)}`; const filepath = await saveSearchResult('api-search', rawApiName, detailsContent); return makeTextResponse( `🔗 **API参考搜索**\n\n` + `**关键词**: ${rawApiName}\n` + `**搜索链接**: ${directDoc || searchUrls.google}\n\n` + `✅ 详细信息已保存至: ${filepath || '保存失败'}\n` + `💡 使用 WebFetch 工具访问搜索链接获取结果` ); }
- mcp_server_node.js:141-152 (schema)Tool definition including name, description, and input schema for 'ai_search_api_reference' in the AI_TOOLS array used for tool listing.{ name: 'ai_search_api_reference', description: '🔗 API参考搜索 - 快速查找API文档和使用示例\n\n【重要】此工具会返回API文档搜索URL,Claude Code应该使用WebFetch工具访问该URL以获取真实搜索结果。', inputSchema: { type: 'object', properties: { api_name: { type: 'string', description: 'API名称或方法名' }, platform: { type: 'string', description: '平台或库名称(如:express、axios、lodash)' } }, required: ['api_name', 'platform'] } },
- mcp_server_node.js:252-254 (registration)Registers all tools including 'ai_search_api_reference' for the ListToolsRequestSchema handler.server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: AI_TOOLS, }));