get_documentation
Retrieve API, library, or technology documentation with usage examples and version details. Specify your query and context to access precise information for integration or troubleshooting.
Instructions
Automatically call this tool when working with unfamiliar APIs/libraries, needing usage examples, or checking version specifics as this can access web. Example: When adding a payment gateway, ask "Get Stripe API documentation for creating charges".
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| context | No | Additional context or specific aspects to focus on | |
| query | Yes | The technology, library, or API to get documentation for |
Implementation Reference
- src/server/PerplexityServer.ts:122-128 (handler)The main handler function for the 'get_documentation' tool. It extracts the query and optional context from args, constructs a search prompt, calls the search engine, and returns the result.private async handleGetDocumentation(args: Record<string, unknown>): Promise<string> { const typedArgs = args as { query: string; context?: string }; const searchResult = await this.searchEngine.performSearch( `Documentation for ${typedArgs.query}: ${typedArgs.context || ""}`, ); return searchResult; }
- src/schema/toolSchemas.ts:197-239 (schema)JSON schema definition for the get_documentation tool, including description, input/output schemas, examples, and metadata.name: "get_documentation", description: 'Automatically call this tool when working with unfamiliar APIs/libraries, needing usage examples, or checking version specifics as this can access web. Example: When adding a payment gateway, ask "Get Stripe API documentation for creating charges".', category: "Technical Reference", keywords: ["docs", "documentation", "api", "reference", "examples", "usage", "version"], use_cases: ["Learning new technologies", "API integration", "Troubleshooting code"], inputSchema: { type: "object", properties: { query: { type: "string", description: "The technology, library, or API to get documentation for", examples: ["React hooks", "Python pandas", "REST API best practices"], }, context: { type: "string", description: "Additional context or specific aspects to focus on", examples: ["focus on performance optimization", "include TypeScript examples"], }, }, required: ["query"], }, outputSchema: { type: "object", properties: { response: { type: "string", description: 'The raw text response from Perplexity containing documentation, examples, and potentially source URLs prefixed with "Official URL(s):". The calling agent should parse this text to extract URLs if needed for further processing.', }, }, }, examples: [ { description: "Basic documentation request", input: { query: "React useEffect hook" }, output: { response: "The useEffect hook lets you perform side effects in function components...", }, }, ], related_tools: ["search", "check_deprecated_code"], },
- src/server/PerplexityServer.ts:175-186 (registration)Registers all tool handlers, including get_documentation, with the MCP server using the setupToolHandlers function.private setupToolHandlers(): void { const toolHandlers = createToolHandlersRegistry({ chat_perplexity: this.handleChatPerplexity.bind(this), get_documentation: this.handleGetDocumentation.bind(this), find_apis: this.handleFindApis.bind(this), check_deprecated_code: this.handleCheckDeprecatedCode.bind(this), search: this.handleSearch.bind(this), extract_url_content: this.handleExtractUrlContent.bind(this), }); setupToolHandlers(this.server, toolHandlers); }
- src/types/tools.ts:39-42 (schema)TypeScript interface defining the input arguments for the get_documentation tool.export interface GetDocumentationArgs { query: string; context?: string; }
- src/tools/getDocumentation.ts:10-32 (helper)Detailed helper function for generating documentation prompts and performing search, matching the tool's intended comprehensive output. Potentially an alternative or modular implementation.export default async function getDocumentation( args: { query: string; context?: string }, ctx: PuppeteerContext, performSearch: (prompt: string, ctx: PuppeteerContext) => Promise<string>, ): Promise<string> { const { query, context = "" } = args; const prompt = `Provide comprehensive documentation and usage examples for ${query}. ${ context ? `Focus on: ${context}` : "" } Include: 1. Basic overview and purpose 2. Key features and capabilities 3. Installation/setup if applicable 4. Common usage examples with code snippets 5. Best practices and performance considerations 6. Common pitfalls to avoid 7. Version compatibility information 8. Links to official documentation 9. Community resources (forums, chat channels) 10. Related tools/libraries that work well with it Crucially, also provide the main official URL(s) for this documentation on separate lines, prefixed with 'Official URL(s):'.`; return await performSearch(prompt, ctx); }