Skip to main content
Glama

ai_search_docs

Search official documentation for frameworks like React, Vue, and Node.js to find technical answers and code examples.

Instructions

📚 技术文档搜索 - 搜索常见框架和工具的官方文档(React、Vue、Node.js等)

【重要】此工具会返回文档搜索URL,Claude Code应该使用WebFetch工具访问该URL以获取真实搜索结果。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes搜索关键词
frameworkNo指定框架,默认generalgeneral

Implementation Reference

  • The main handler function for the 'ai_search_docs' tool. It processes the input query and optional framework, constructs specific documentation search URLs for various frameworks/languages, generates a detailed markdown response with WebFetch instructions, saves the result to a file, and returns a text response.
    case 'ai_search_docs': { const rawQuery = normalizeString(args.query); const requestedFramework = normalizeString(args.framework).toLowerCase(); if (!rawQuery) { throw new Error('搜索关键词不能为空'); } const docUrls = { react: `https://react.dev/?search=${encodeURIComponent(rawQuery)}`, vue: `https://cn.vuejs.org/search/?query=${encodeURIComponent(rawQuery)}`, angular: `https://angular.io/api?query=${encodeURIComponent(rawQuery)}`, nodejs: `https://nodejs.org/api/all.html`, python: `https://docs.python.org/zh-cn/3/search.html?q=${encodeURIComponent(rawQuery)}`, java: `https://docs.oracle.com/en/java/javase/21/docs/api/search.html?q=${encodeURIComponent(rawQuery)}`, general: `https://developer.mozilla.org/zh-CN/search?q=${encodeURIComponent(rawQuery)}` }; const frameworkNames = { react: 'React', vue: 'Vue.js', angular: 'Angular', nodejs: 'Node.js', python: 'Python', java: 'Java', general: 'MDN Web Docs' }; const frameworkTips = { react: ['Hooks', 'Components', 'Props', 'State', 'Context', 'useEffect'], vue: ['组合式API', '响应式', 'computed', 'watch', '组件', '指令'], angular: ['Directives', 'Services', 'Modules', 'Components', 'Routing'], nodejs: ['fs', 'http', 'path', 'events', 'stream', 'crypto'], python: ['列表推导', '装饰器', '生成器', '异步', 'pandas', 'numpy'], java: ['Collections', 'Stream', 'Optional', 'Lambda', 'Generic'], general: ['HTML', 'CSS', 'JavaScript', 'Web API', 'HTTP'] }; const resolvedFramework = pickKey(docUrls, requestedFramework, 'general'); const detailsContent = `📚 ${frameworkNames[resolvedFramework]} 文档搜索\n\n` + `**搜索关键词**: ${rawQuery}\n` + `**框架/语言**: ${frameworkNames[resolvedFramework]}\n\n` + `---\n\n` + `🔗 **文档链接**: ${docUrls[resolvedFramework]}\n\n` + `⚠️ **请使用 WebFetch 工具获取文档内容**:\n` + `\`\`\`javascript\n` + `WebFetch({\n` + ` url: "${docUrls[resolvedFramework]}",\n` + ` prompt: "查找'${rawQuery}'相关的:API说明、参数列表、返回值、使用示例、注意事项"\n` + `})\n` + `\`\`\`\n\n` + `---\n\n` + `💡 **${frameworkNames[resolvedFramework]} 常用主题**:\n` + frameworkTips[resolvedFramework].map(tip => `• ${tip}`).join(' | ') + `\n\n📚 **其他文档资源**:\n` + Object.keys(docUrls) .filter(f => f !== resolvedFramework) .map(f => `• ${frameworkNames[f]}: ${docUrls[f].replace(/\?.*$/, '')}`) .slice(0, 4) .join('\n'); const filepath = await saveSearchResult('docs-search', rawQuery, detailsContent); return makeTextResponse( `📚 **技术文档搜索**\n\n` + `**关键词**: ${rawQuery}\n` + `**搜索链接**: ${docUrls[resolvedFramework]}\n\n` + `✅ 详细信息已保存至: ${filepath || '保存失败'}\n` + `💡 使用 WebFetch 工具访问搜索链接获取结果` ); }
  • The tool definition including name, description, and input schema for 'ai_search_docs'. Defines the expected input parameters: query (required string) and optional framework enum.
    { name: 'ai_search_docs', description: '📚 技术文档搜索 - 搜索常见框架和工具的官方文档(React、Vue、Node.js等)\n\n【重要】此工具会返回文档搜索URL,Claude Code应该使用WebFetch工具访问该URL以获取真实搜索结果。', inputSchema: { type: 'object', properties: { query: { type: 'string', description: '搜索关键词' }, framework: { type: 'string', enum: ['react', 'vue', 'angular', 'nodejs', 'python', 'java', 'general'], description: '指定框架,默认general', default: 'general' } }, required: ['query'] }
  • Tool registration via the ListToolsRequestSchema handler, which returns the AI_TOOLS array containing the 'ai_search_docs' tool definition.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: AI_TOOLS, }));
  • Helper function used by ai_search_docs (and other tools) to save detailed search results to a markdown file in .search-results directory.
    const saveSearchResult = async (toolName, query, details) => { try { const resultsDir = join(process.cwd(), '.search-results'); if (!existsSync(resultsDir)) { await mkdir(resultsDir, { recursive: true }); } const timestamp = new Date().toISOString().replace(/[:.]/g, '-').slice(0, -5); const filename = `${toolName}-${timestamp}.md`; const filepath = join(resultsDir, filename); await writeFile(filepath, details, 'utf-8'); return filepath; } catch (error) { console.error('Failed to save search result:', error); return null; }
  • Helper utility used in ai_search_docs handler to resolve framework key from input with fallback to 'general'.
    const pickKey = (map, key, fallback) => { if (key && Object.prototype.hasOwnProperty.call(map, key)) { return key; } return fallback; };

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/adminhuan/smart-search-mcp'

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