Skip to main content
Glama
tanevanwifferen

DocsScraper

search_docs

Find relevant documentation chunks using semantic search. Specify queries with keywords like 'api' or service names to filter results and retrieve precise information quickly.

Instructions

Search through documentation chunks using semantic search. Make sure your query is specific to get the best results. Forgetting to add 'api' to the query will return ui results etc.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYesThe search query to find relevant documentation
serviceYesService name to filter results by (case-insensitive)
topNoMaximum number of results to return (1-10, default: 5)

Implementation Reference

  • The handler function for the 'search_docs' tool. It extracts parameters, validates input, calls the DocsScraper API for semantic search, formats results, and handles errors.
        case "search_docs": {
          const query = String(request.params.arguments?.query || "");
          const top = Number(request.params.arguments?.top || 5);
          const service = request.params.arguments?.service ? String(request.params.arguments.service) : undefined;
    
          if (!query.trim()) {
            throw new Error("Query parameter is required and cannot be empty");
          }
    
          // Clamp top to safe range
          const clampedTop = Math.max(1, Math.min(10, top));
    
          try {
            // Build request parameters
            const params: any = {
              query: query,
              top: clampedTop
            };
            
            // Include service parameter if provided
            if (service && service.trim()) {
              params.service = service.trim();
            }
    
            // Make request to DocsScraper API
            const response = await axios.get(`${API_BASE_URL}/api/chunks/search`, {
              params,
              headers: {
                'X-API-Key': API_KEY,
                'Content-Type': 'application/json'
              },
              timeout: 180000 // 30 second timeout
            });
    
            const results = response.data;
    
            if (Array.isArray(results) && results.length > 0) {
              // Format results for display
              const formattedResults = results.map((result: SearchResult, index: number) => {
                const chunk = result.chunk;
                const score = result.score ? ` (Score: ${result.score.toFixed(3)})` : '';
                const source = result.source ? ` [Source: ${result.source}]` : '';
                
                return `**Result ${index + 1}${score}${source}**
    Service: ${chunk.service}
    URL: ${chunk.url}
    Summary: ${chunk.oneLiner}
    
    Content:
    ${chunk.fullContent}
    
    ---`;
              }).join('\n\n');
    
              return {
                content: [{
                  type: "text",
                  text: `Found ${results.length} relevant documentation chunk(s) for query: "${query}"\n\n${formattedResults}`
                }]
              };
            } else {
              return {
                content: [{
                  type: "text",
                  text: `No documentation chunks found for query: "${query}". The search may have found no relevant results, or the scraper sources may not have returned any matches.`
                }]
              };
            }
          } catch (error) {
            if (axios.isAxiosError(error)) {
              if (error.response?.status === 401) {
                throw new Error("Authentication failed. Please check your API key.");
              } else if (error.response?.status === 400) {
                throw new Error(`Bad request: ${error.response.data?.message || 'Invalid query parameters'}`);
              } else if (error.response?.status === 404) {
                throw new Error("DocsScraper API endpoint not found. Please check the base URL.");
              } else if (error.code === 'ECONNREFUSED') {
                throw new Error(`Cannot connect to DocsScraper API at ${API_BASE_URL}. Please ensure the service is running.`);
              } else {
                throw new Error(`API request failed: ${error.response?.status} ${error.response?.statusText || error.message}`);
              }
            } else {
              throw new Error(`Search failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
            }
          }
        }
  • Input schema defining parameters for the search_docs tool: query (required string), top (optional number 1-10), service (required string).
    inputSchema: {
      type: "object",
      properties: {
        query: {
          type: "string",
          description: "The search query to find relevant documentation"
        },
        top: {
          type: "number",
          description: "Maximum number of results to return (1-10, default: 5)",
          minimum: 1,
          maximum: 10,
          default: 5
        },
        service: {
          type: "string",
          description: "Service name to filter results by (case-insensitive)"
        }
      },
      required: ["query", "service"]
  • src/index.ts:80-104 (registration)
    Registration of the search_docs tool in the ListTools response, including name, description, and input schema.
    {
      name: "search_docs",
      description: "Search through documentation chunks using semantic search. Make sure your query is specific to get the best results. Forgetting to add 'api' to the query will return ui results etc.",
      inputSchema: {
        type: "object",
        properties: {
          query: {
            type: "string",
            description: "The search query to find relevant documentation"
          },
          top: {
            type: "number",
            description: "Maximum number of results to return (1-10, default: 5)",
            minimum: 1,
            maximum: 10,
            default: 5
          },
          service: {
            type: "string",
            description: "Service name to filter results by (case-insensitive)"
          }
        },
        required: ["query", "service"]
      }
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions that queries should be specific and that omitting 'api' affects results, which adds some context about search behavior. However, it fails to disclose critical traits like whether the search is read-only, if it has rate limits, authentication needs, or what the output format looks like (especially since there's no output schema). This leaves significant gaps for an agent to understand the tool's behavior fully.

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 and front-loaded, starting with the core purpose in the first sentence. The second sentence provides practical advice without unnecessary elaboration. Both sentences earn their place by adding value, though the structure could be slightly improved by explicitly mentioning parameters or output expectations to enhance 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 tool's complexity (semantic search with three parameters) and the absence of both annotations and an output schema, the description is incomplete. It explains the basic purpose and offers usage tips but fails to cover behavioral aspects like safety, performance, or return values. This leaves the agent with insufficient information to use the tool confidently in varied contexts.

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% description coverage, clearly documenting all three parameters (query, service, top) with their types, constraints, and purposes. The description does not add any meaningful parameter semantics beyond what the schema provides; it only references the 'query' parameter indirectly in usage tips. Thus, it meets the baseline score of 3, as the schema adequately covers parameter details without needing extra explanation in the description.

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: 'Search through documentation chunks using semantic search.' It specifies the verb ('search'), resource ('documentation chunks'), and method ('semantic search'), making the function unambiguous. However, without sibling tools for comparison, it cannot demonstrate differentiation, preventing a perfect score.

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 provides implied usage guidance: it advises making queries 'specific to get the best results' and warns that forgetting to add 'api' to the query will return 'ui results etc.' This offers some context on how to use the tool effectively. However, it lacks explicit when-to-use scenarios, prerequisites, or comparisons to alternatives, as no sibling tools exist.

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/tanevanwifferen/DocsScraperMCP'

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