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;
    };
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden. It discloses that the tool returns documentation search URLs (not the actual content), which is a key behavioral trait. However, it doesn't mention rate limits, authentication needs, error handling, or what happens with invalid inputs, leaving gaps for a mutation-like search operation.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized with two sentences: one stating the purpose and one with a critical usage note. It's front-loaded with the main function, though the emoji and formatting (brackets) add slight noise without essential information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given no annotations and no output schema, the description is incomplete for a search tool. It explains the return type (URLs) and post-processing step (use WebFetch), but lacks details on output format, error cases, or how results are filtered/scoped. The framework enum helps, but more context on behavior is needed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents both parameters (query and framework with enum values). The description adds minimal value beyond this by implying the framework parameter targets 'official documentation' for those tools, but doesn't explain semantics like what 'general' means or how queries are processed.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose as searching official documentation for common frameworks and tools (React, Vue, Node.js, etc.), which is specific and actionable. However, it doesn't explicitly differentiate from sibling tools like 'ai_search_api_reference' or 'ai_search_web', which might have overlapping domains.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool (searching official docs for specified frameworks) and includes an important note about using WebFetch to access the returned URLs. It doesn't explicitly state when not to use it or name alternatives among siblings, but the framework focus offers implicit guidance.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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