Skip to main content
Glama

ref_search_documentation

Search for documentation across public web, GitHub, or private resources like repos and PDFs. Use queries with programming language and framework details to retrieve relevant documentation efficiently.

Instructions

Search for documentation on the web or github as well from private resources like repos and pdfs. Use Ref 'ref_read_url' to read the content of a url.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesQuery for documentation. Should include programming language and framework or library names. Searches public only docs by default, include ref_src=private to search a user's private docs.

Implementation Reference

  • The handler function that implements the core logic of 'ref_search_documentation'. It sends a query to the Ref API endpoint '/search_documentation' and formats the results based on the client type (OpenAI or default).
    async function doSearch(query: string, mcpClient: string = 'unknown', sessionId?: string) {
      const url = getRefUrl() + '/search_documentation?query=' + encodeURIComponent(query)
      console.error('[search]', url)
    
      if (!getApiKey()) {
        return {
          content: [
            {
              type: 'text',
              text: 'Ref is not correctly configured. Reach out to hello@ref.tools for help.',
            },
          ],
        }
      }
    
      try {
        const response = await axios.get(url, {
          headers: getAuthHeaders(sessionId),
        })
    
        const data = response.data
    
        if (data.docs.length === 0) {
          return {
            content: [{ type: 'text', text: 'No results found' }],
          }
        }
    
        // Return different formats based on client type
        if (mcpClient === 'openai-mcp') {
          return {
            content: [
              {
                type: 'text' as const,
                text: JSON.stringify(data.docs.map(toDeepResearchShape)),
              },
            ],
          }
        } else {
          return {
            content: data.docs.map((doc: any) => ({
              type: 'text' as const,
              text: `overview: ${doc.overview || ''}
    url: ${doc.url}
    moduleId: ${doc.moduleId || ''}`,
            })),
          }
        }
      } catch (error) {
        if (axios.isAxiosError(error) && error.response?.status === 401) {
          return {
            content: [
              {
                type: 'text',
                text: 'Please verify your email at https://ref.tools/dashboard to search documentation',
              },
            ],
          }
        }
    
        console.error('[search-error]', error)
        return {
          content: [
            {
              type: 'text',
              text: `Error during documentation search: ${axios.isAxiosError(error) ? error.message : (error as Error).message}`,
            },
          ],
        }
      }
    }
  • The Tool definition including name, description, inputSchema (with 'query' parameter), and annotations for 'ref_search_documentation'.
    const searchTool: Tool = {
      name: toolConfig.searchToolName,
      description: `Search for documentation on the web or github as well from private resources like repos and pdfs. Use Ref '${toolConfig.readToolName}' to read the content of a url.`,
      inputSchema: {
        type: 'object',
        properties: {
          query: {
            type: 'string',
            description: `Query for documentation. Should include programming language and framework or library names. Searches public only docs by default, include ref_src=private to search a user's private docs.`,
          },
        },
        required: ['query'],
      },
      annotations: {
        readOnlyHint: true,
      },
    }
  • index.ts:34-37 (registration)
    Configuration object that sets the tool name to 'ref_search_documentation' for default clients.
    const DEFAULT_TOOL_CONFIG: ToolConfig = {
      searchToolName: 'ref_search_documentation',
      readToolName: 'ref_read_url',
    }
  • index.ts:119-121 (registration)
    Registration of the tool in the ListToolsRequestSchema handler, exposing 'ref_search_documentation' in the tools list.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [searchTool, readTool],
    }))
  • index.ts:198-204 (registration)
    Registration of the tool handler in the CallToolRequestSchema: maps calls to 'ref_search_documentation' to the doSearch function.
    if (request.params.name === toolConfig.searchToolName) {
      console.error('[search_documentation] arguments', request.params.arguments)
      const input = request.params.arguments as {
        query: string
      }
      return doSearch(input.query, mcpClient, sessionId)
    }
Behavior2/5

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

With no annotations provided, the description carries full burden but only mentions searching capabilities and a related tool. It fails to disclose critical behavioral traits like whether this is a read-only operation, potential rate limits, authentication needs for private resources, or what the search results look like (e.g., format, pagination).

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 concise with two sentences that directly state the tool's function and a usage tip. It's front-loaded and avoids unnecessary words, though it could be slightly more structured for clarity.

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

Completeness2/5

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

Given the complexity of a search tool with no annotations and no output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., search results format), how private resources are accessed, or error handling, leaving significant gaps for an AI agent to use it effectively.

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 100% coverage, fully describing the single 'query' parameter with details on including language/framework names and the 'ref_src=private' option. The description adds no additional parameter semantics beyond what the schema provides, so it meets the baseline for high schema coverage.

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 documentation across web, GitHub, and private resources, which is specific and actionable. However, it doesn't explicitly differentiate from its sibling 'ref_read_url', which is for reading URL content rather than searching, so it misses full sibling distinction.

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

Usage Guidelines3/5

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

The description implies usage by mentioning 'ref_read_url' for reading content, suggesting a workflow, but lacks explicit guidance on when to use this tool versus alternatives or any exclusions. It provides some context but no clear when/when-not rules.

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

Related 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/ref-tools/ref-tools-mcp'

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