Skip to main content
Glama

ai_search_api_reference

Search API documentation and usage examples by specifying API name and platform to find technical reference information.

Instructions

🔗 API参考搜索 - 快速查找API文档和使用示例

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

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
api_nameYesAPI名称或方法名
platformYes平台或库名称(如:express、axios、lodash)

Implementation Reference

  • Handler for 'ai_search_api_reference' tool. Validates api_name and platform parameters, constructs search URLs for API docs on Google, DevDocs, GitHub, and direct links for popular libraries. Generates detailed markdown with WebFetch usage examples and saves to .search-results directory.
    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 工具访问搜索链接获取结果`
      );
    }
  • Tool definition including name, description, and input schema for 'ai_search_api_reference'. Requires 'api_name' and 'platform' parameters.
    {
      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']
      }
    },
  • Registers the list of tools, including 'ai_search_api_reference', for the ListToolsRequestHandler.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: AI_TOOLS,
    }));
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It clearly states that the tool returns a search URL rather than actual search results, which is important behavioral information. It also implies this is a read-only operation (searching documentation) and provides guidance on how to use the output. However, it doesn't mention potential limitations like rate limits, authentication requirements, or error conditions.

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

Conciseness5/5

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

The description is extremely concise and well-structured. The emoji and title immediately convey the tool's domain. The important behavioral information is highlighted with 【重要】and presented clearly. Every sentence earns its place by providing essential guidance that isn't available elsewhere.

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

Completeness4/5

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

For a search tool with no annotations and no output schema, the description does an excellent job of explaining what the tool does and how to use its output. The critical information about returning URLs rather than content is clearly stated. The main gap is the lack of output format details - while we know it returns URLs, we don't know the exact structure of the response.

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?

The schema description coverage is 100%, with both parameters clearly documented in the schema. The description doesn't add any additional parameter semantics beyond what's already in the schema. It doesn't explain how the two parameters interact or provide examples of valid values. The baseline score of 3 is appropriate when the schema already provides complete parameter documentation.

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 for API documentation and usage examples with the phrase '快速查找API文档和使用示例' (quickly find API documentation and usage examples). It specifies the verb '搜索' (search) and resource 'API文档' (API documentation). However, it doesn't explicitly differentiate from sibling tools like ai_search_docs or ai_search_web, which likely have overlapping functionality.

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

Usage Guidelines5/5

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

The description provides excellent usage guidance with the explicit instruction 'Claude Code应该使用WebFetch工具访问该URL以获取真实搜索结果' (Claude Code should use the WebFetch tool to access this URL to get real search results). This tells the agent exactly how to use the output and what the next step should be, which is crucial for proper tool chaining.

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