Skip to main content
Glama
lookup.ts1.39 kB
import { z } from "zod"; import { performChatCompletion } from "../perplexity-client.js"; import { LOOKUP_SYSTEM_PROMPT } from "../prompts.js"; import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; /** * Registers the lookup tool with the MCP server. * Fetches precise, source-backed facts from official sources. */ 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 }] }; }, ); }

Implementation Reference

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/Jercik/perplexity-agent-mcp'

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