Skip to main content
Glama

Search PDFDancer documentation

search-docs

Search PDFDancer SDK documentation to find API references, feature details, and usage examples by keyword. Returns relevant documentation routes with content snippets and relevance scores.

Instructions

Search the official PDFDancer SDK documentation by keyword. Returns matching documentation routes with titles, content snippets, and relevance scores. Use this to find information about PDFDancer features, APIs, and usage examples.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
queryYes
maxResultsNo

Implementation Reference

  • The core handler function for the 'search-docs' tool. It makes an API call to the search endpoint with the provided query and optional maxResults, then formats the response using helper functions and returns both markdown content and structured data.
    async ({query, maxResults}) => {
        const data = await callApi<SearchResponse>('/search', {
            searchParams: {
                q: query,
                maxResults
            }
        });
    
        return {
            content: [
                {
                    type: 'text' as const,
                    text: `${summarizeSearchResponse(data)}\n\n${formatJsonBlock('Raw search response', data)}`
                }
            ],
            structuredContent: data
        };
    }
  • Input schema and metadata for the 'search-docs' tool, defining title, description, and Zod validation for parameters: required 'query' string and optional 'maxResults' integer (1-10).
    {
        title: 'Search PDFDancer documentation',
        description: 'Search the official PDFDancer SDK documentation by keyword. Returns matching documentation routes with titles, content snippets, and relevance scores. Use this to find information about PDFDancer features, APIs, and usage examples.',
        inputSchema: {
            query: z.string().min(1, 'query is required'),
            maxResults: z.number().int().min(1).max(10).optional()
        }
  • src/index.ts:235-263 (registration)
    Complete registration of the 'search-docs' tool via server.registerTool(), including schema, title, description, and inline handler implementation.
    server.registerTool(
        'search-docs',
        {
            title: 'Search PDFDancer documentation',
            description: 'Search the official PDFDancer SDK documentation by keyword. Returns matching documentation routes with titles, content snippets, and relevance scores. Use this to find information about PDFDancer features, APIs, and usage examples.',
            inputSchema: {
                query: z.string().min(1, 'query is required'),
                maxResults: z.number().int().min(1).max(10).optional()
            }
        },
        async ({query, maxResults}) => {
            const data = await callApi<SearchResponse>('/search', {
                searchParams: {
                    q: query,
                    maxResults
                }
            });
    
            return {
                content: [
                    {
                        type: 'text' as const,
                        text: `${summarizeSearchResponse(data)}\n\n${formatJsonBlock('Raw search response', data)}`
                    }
                ],
                structuredContent: data
            };
        }
    );
  • Helper function used by the handler to create a human-readable summary of search results, showing top 5 matches with titles, routes, and scores.
    function summarizeSearchResponse(data: SearchResponse): string {
        if (!data.results?.length) {
            return `No matches for "${data.query}".`;
        }
    
        const lines = data.results.slice(0, 5).map((result, index) => {
            const title = result.pageTitle ?? result.sectionTitle ?? result.sectionRoute;
            const score = typeof result.score === 'number' ? `score=${result.score.toFixed(3)}` : '';
            return `${index + 1}. ${title} → ${result.sectionRoute} ${score}`.trim();
        });
    
        const summary = `${data.total} result(s) for "${data.query}" (showing ${lines.length}, ${data.took}ms).`;
        return `${summary}\n${lines.join('\n')}`;
    }
  • Generic API client helper function used by the handler to make HTTP requests to the PDFDancer docs search backend, handling params, JSON, errors.
    async function callApi<T>(path: string, options: ApiRequestOptions = {}): Promise<T> {
        const url = new URL(path, apiBase);
        if (options.searchParams) {
            Object.entries(options.searchParams).forEach(([key, value]) => {
                if (value !== undefined && value !== null && value !== '') {
                    url.searchParams.set(key, String(value));
                }
            });
        }
    
        const method = options.method ?? 'GET';
        const init: RequestInit = {
            method,
            headers: {
                Accept: 'application/json',
                ...(options.body ? {'Content-Type': 'application/json'} : {})
            }
        };
    
        if (options.body && method === 'POST') {
            init.body = JSON.stringify(options.body);
        }
    
        const response = await fetch(url, init);
        const text = await response.text();
    
        if (!response.ok) {
            throw new Error(
                `Request to ${url.toString()} failed with status ${response.status}: ${
                    text || response.statusText
                }`
            );
        }
    
        if (!text) {
            return undefined as T;
        }
    
        try {
            return JSON.parse(text) as T;
        } catch (error) {
            throw new Error(`Failed to parse JSON response from ${url.toString()}: ${error}`);
        }
    }
Behavior3/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. It discloses key behavioral traits: it returns 'matching documentation routes with titles, content snippets, and relevance scores', which helps the agent understand the output format. However, it lacks details on permissions, rate limits, error handling, or pagination (though 'maxResults' in schema hints at result limiting), leaving some gaps for a search tool.

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 appropriately sized and front-loaded: the first sentence states the core purpose, the second describes the return format, and the third provides usage context. Each sentence adds distinct value without redundancy, making it efficient and easy to parse 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 with 2 parameters), no annotations, and no output schema, the description is fairly complete: it covers purpose, return format, and usage context. However, it lacks details on behavioral aspects like error cases or performance, and the output schema absence means return values are only partially described, leaving minor gaps.

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 0%, so the description must compensate. It mentions 'keyword' which relates to the 'query' parameter, adding semantic context. However, it does not explain the 'maxResults' parameter or provide details on query syntax, format, or relevance scoring. The description adds some value but does not fully compensate for the low schema coverage, meeting the baseline for partial compensation.

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 specific action ('Search'), resource ('PDFDancer SDK documentation'), and scope ('by keyword'), distinguishing it from sibling tools like 'get-docs' (likely for retrieving specific docs), 'help' (general assistance), and 'version' (system info). It explicitly mentions what it searches for ('features, APIs, and usage examples'), making the purpose unambiguous and well-differentiated.

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 ('to find information about PDFDancer features, APIs, and usage examples'), which implicitly suggests it's for exploratory searches rather than direct retrieval. However, it does not explicitly state when not to use it or name alternatives (e.g., 'get-docs' for known documentation routes), missing full explicit 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/MenschMachine/pdfdancer-mcp'

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