lookup
Fetch precise, source-backed facts from official documentation for API syntax, config keys, CLI flags, runtime compatibility, and package metadata.
Instructions
Fetch precise, source-backed facts from official sources. Use for API syntax/params, config keys/defaults, CLI flags, runtime compatibility, and package metadata (types, ESM/CJS, side-effects). Returns short, factual answers. No recommendations or comparisons.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | What fact to look up from docs |
Implementation Reference
- src/tools/lookup.ts:25-35 (handler)The asynchronous handler function for the 'lookup' tool. It takes a query, performs a chat completion using Perplexity's 'sonar-pro' model with the LOOKUP_SYSTEM_PROMPT, and returns the result as text content.async ({ query }) => { const result = await performChatCompletion( [{ role: "user", content: query }], { model: "sonar-pro", system: LOOKUP_SYSTEM_PROMPT, searchContextSize: "medium", }, ); return { content: [{ type: "text", text: result }] }; },
- src/tools/lookup.ts:13-24 (schema)The schema definition for the 'lookup' tool, including description and inputSchema using Zod for the 'query' parameter.{ description: ` Fetches precise, source-backed facts from official sources. Use for API syntax/params, config keys/defaults, CLI flags, runtime compatibility, and package metadata (types, ESM/CJS, side-effects). Returns short, factual answers. No recommendations or comparisons. Examples: "What's the default timeout for fetch()?", "What parameters does useState accept?", "Show me how Zod validates email addresses" One question per call—split combined requests into separate queries. `.trim(), inputSchema: { query: z.string().describe("The documentation query to look up"), }, },
- src/tools/lookup.ts:10-37 (registration)The registerLookupTool function that registers the 'lookup' tool with the MCP server, including its schema and handler.export function registerLookupTool(server: McpServer) { server.registerTool( "lookup", { description: ` Fetches precise, source-backed facts from official sources. Use for API syntax/params, config keys/defaults, CLI flags, runtime compatibility, and package metadata (types, ESM/CJS, side-effects). Returns short, factual answers. No recommendations or comparisons. Examples: "What's the default timeout for fetch()?", "What parameters does useState accept?", "Show me how Zod validates email addresses" One question per call—split combined requests into separate queries. `.trim(), inputSchema: { query: z.string().describe("The documentation query to look up"), }, }, async ({ query }) => { const result = await performChatCompletion( [{ role: "user", content: query }], { model: "sonar-pro", system: LOOKUP_SYSTEM_PROMPT, searchContextSize: "medium", }, ); return { content: [{ type: "text", text: result }] }; }, ); }
- src/server.ts:17-17 (registration)The call to register the 'lookup' tool during server setup.registerLookupTool(server);
- src/prompts.ts:45-68 (helper)The system prompt used by the 'lookup' tool handler for guiding fact extraction from sources.export const LOOKUP_SYSTEM_PROMPT = ` # Role: Fact Extraction Agent Extract precise, verifiable facts from source code and documentation. Optimized for quick lookups of: - API signatures and parameter types - Configuration keys and default values - CLI flags and options - Package metadata (versions, exports, compatibility) - Exact error messages and codes # Instructions - Search GitHub source code FIRST - find the exact line where something is defined/used - Return the specific fact requested, nothing more - Include file path and line numbers when citing code - State "Not found in available sources" if information doesn't exist - Avoid explanations unless the fact itself is ambiguous ${AUTHORITATIVE_SOURCES} # Output Format - Direct answer with source citation: "The default value is X [repo/file.ts:123]" - For code usage: Show the exact line(s) from source - For missing info: "Not found in available sources" - No preamble, no "Based on my search...", just the fact `.trim();