Skip to main content
Glama

docs_searchDocumentation

Read-only

Search SDK documentation to find API references, code examples, and implementation guides with direct links to relevant pages.

Instructions

[SDK Docs] Search across the documentation to find relevant information, code examples, API references, and guides. Use this tool when you need to answer questions about Docs, find specific documentation, understand how features work, or locate implementation details. The search returns contextual content with titles and direct links to the documentation pages.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes

Implementation Reference

  • The registerGitBookProxyTools function dynamically fetches tools from the GitBook MCP server and registers them with a 'docs_' prefix. 'docs_searchDocumentation' would be registered if the GitBook server has a tool named 'searchDocumentation'.
    export async function registerGitBookProxyTools(server: McpServer): Promise<number> {
      let registeredCount = 0;
      
      // Register meta tools (work even if GitBook is down)
      registerGitBookMetaTools(server);
      
      try {
        const tools = await fetchGitBookTools();
        
        if (tools.length === 0) {
          console.error("No tools found from GitBook MCP - meta-tools registered, proxy tools skipped");
          return 0;
        }
        
        console.error(`Registering ${tools.length} GitBook tools as docs_* proxies...`);
        
        for (const tool of tools) {
          try {
            // Prefix with "docs_" to indicate these are from SDK docs
            const proxyToolName = `docs_${tool.name}`;
            const zodSchema = convertToZodSchema(tool.inputSchema);
            
            server.tool(
              proxyToolName,
              `[SDK Docs] ${tool.description}`,
              zodSchema._def.typeName === "ZodObject" 
                ? (zodSchema as z.ZodObject<z.ZodRawShape>).shape 
                : {},
              DOCS_READ_ONLY,
              async (args) => {
                const result = await callGitBookTool(tool.name, args as Record<string, unknown>);
                
                // Add helpful context if the call failed
                if (result.isError) {
                  return {
                    content: [{
                      type: "text" as const,
                      text: `⚠️ docs_${tool.name} failed: ${result.content[0]?.text || "Unknown error"}\n\nTry docs_refresh to reconnect, or visit https://docs.sodax.com directly.`
                    }],
                    isError: true
                  };
                }
                
                return {
                  content: result.content.map(c => ({
                    type: c.type as "text",
                    text: c.text || JSON.stringify(c)
                  })),
                  isError: result.isError
                };
              }
            );
            
            registeredCount++;
          } catch (toolError) {
            console.error(`Failed to register GitBook tool ${tool.name}:`, toolError);
          }
        }
        
        console.error(`Registered ${registeredCount} tools from GitBook MCP`);
      } catch (error) {
        console.error("Failed to register GitBook proxy tools:", error);
      }
      
      return registeredCount;
    }
  • Handler function that executes when any docs_* tool is called. It proxies the call to the GitBook MCP server via callGitBookTool() and returns the result with helpful error context.
    async (args) => {
      const result = await callGitBookTool(tool.name, args as Record<string, unknown>);
      
      // Add helpful context if the call failed
      if (result.isError) {
        return {
          content: [{
            type: "text" as const,
            text: `⚠️ docs_${tool.name} failed: ${result.content[0]?.text || "Unknown error"}\n\nTry docs_refresh to reconnect, or visit https://docs.sodax.com directly.`
          }],
          isError: true
        };
      }
      
      return {
        content: result.content.map(c => ({
          type: c.type as "text",
          text: c.text || JSON.stringify(c)
        })),
        isError: result.isError
      };
    }
  • The convertToZodSchema function converts GitBook tool input schemas (JSON Schema format) to Zod schemas for type validation and schema generation.
    function convertToZodSchema(inputSchema: GitBookTool["inputSchema"]): z.ZodTypeAny {
      if (!inputSchema.properties || Object.keys(inputSchema.properties).length === 0) {
        return z.object({});
      }
      
      const shape: Record<string, z.ZodTypeAny> = {};
      const required = inputSchema.required || [];
      
      for (const [key, prop] of Object.entries(inputSchema.properties)) {
        const propDef = prop as { type?: string; description?: string; default?: unknown };
        let fieldSchema: z.ZodTypeAny;
        
        switch (propDef.type) {
          case "string":
            fieldSchema = z.string();
            break;
          case "number":
          case "integer":
            fieldSchema = z.number();
            break;
          case "boolean":
            fieldSchema = z.boolean();
            break;
          case "array":
            fieldSchema = z.array(z.unknown());
            break;
          case "object":
            fieldSchema = z.record(z.unknown());
            break;
          default:
            fieldSchema = z.unknown();
        }
        
        // Add description if available
        if (propDef.description) {
          fieldSchema = fieldSchema.describe(propDef.description);
        }
        
        // Make optional if not required
        if (!required.includes(key)) {
          fieldSchema = fieldSchema.optional();
        }
        
        shape[key] = fieldSchema;
      }
      
      return z.object(shape);
    }
  • The fetchGitBookTools function fetches the list of available tools from the GitBook MCP server and caches them for 10 minutes. This is where 'searchDocumentation' tool definition comes from.
    export async function fetchGitBookTools(): Promise<GitBookTool[]> {
      // Return cached tools if still valid
      if (cachedTools && Date.now() - toolsCacheTime < TOOLS_CACHE_DURATION) {
        return cachedTools;
      }
      
      try {
        // Initialize connection first
        await initializeConnection();
        
        // Fetch tools list
        const result = await sendMcpRequest("tools/list") as { tools: GitBookTool[] };
        
        cachedTools = result.tools || [];
        toolsCacheTime = Date.now();
        
        if (cachedTools.length > 0) {
          console.error(`✅ Fetched ${cachedTools.length} tools from GitBook MCP`);
        } else {
          console.error(`⚠️ GitBook MCP returned empty tools list`);
        }
        return cachedTools;
      } catch (error) {
        const errorMsg = error instanceof Error ? error.message : "unknown error";
        console.error(`❌ Failed to fetch GitBook tools: ${errorMsg}`);
        // Return cached tools even if expired, or empty array
        return cachedTools || [];
      }
    }
  • The callGitBookTool function sends JSON-RPC requests to the GitBook MCP server to execute the actual tool (e.g., 'searchDocumentation') and returns the result.
    export async function callGitBookTool(
      toolName: string, 
      args: Record<string, unknown>
    ): Promise<GitBookToolResult> {
      try {
        // Ensure connection is initialized
        await initializeConnection();
        
        const result = await sendMcpRequest("tools/call", {
          name: toolName,
          arguments: args
        }) as GitBookToolResult;
        
        return result;
      } catch (error) {
        const message = error instanceof Error ? error.message : "Unknown error";
        return {
          content: [{ type: "text", text: `Error calling GitBook tool: ${message}` }],
          isError: true
        };
      }
    }
Behavior4/5

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

Annotations already declare readOnlyHint=true, openWorldHint=true, and destructiveHint=false. The description adds valuable context beyond annotations by specifying what the search returns ('contextual content with titles and direct links to documentation pages'), which helps the agent understand the output format and behavior. No contradictions with annotations exist.

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 front-loaded with the core purpose in the first sentence, followed by usage guidelines and output details. Every sentence adds value without redundancy, making it efficient and well-structured for an AI agent.

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?

Given the tool's moderate complexity (search function with 1 parameter), rich annotations (readOnly, openWorld, non-destructive), and no output schema, the description is mostly complete. It covers purpose, usage, and output format but lacks details on query parameter semantics. With annotations providing safety context, it's sufficient but not exhaustive.

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 input schema has 1 parameter (query) with 0% description coverage in the schema. The description does not provide any additional details about the query parameter's semantics, format, or constraints. However, since the schema coverage is low, the description does not compensate, but the baseline is 3 as it's a single straightforward parameter.

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

Purpose5/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 with specific verbs ('search across the documentation') and resources ('documentation, code examples, API references, guides'). It distinguishes itself from sibling tools like docs_list_tools or docs_health by focusing on search functionality rather than listing or health checks.

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 explicitly states when to use this tool: 'when you need to answer questions about Docs, find specific documentation, understand how features work, or locate implementation details.' It provides clear use cases without needing to reference alternatives since the purpose clearly differentiates it from siblings like docs_list_tools or sodax tools.

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/gosodax/sodax-builders-mcp'

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