get-documentation
Retrieve specific PaymanAI documentation topics like API reference, error handling, and setup to streamline integration development with contextual support.
Instructions
Get PaymanAI documentation on a specific topic
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| topic | Yes | The documentation topic to retrieve |
Implementation Reference
- src/index.ts:144-169 (handler)The handler function for the get-documentation tool. It maps the topic to a path, fetches the markdown content using fetchDocMarkdown, appends a list of related topics, and returns it as structured text content.async ({ topic }) => { const path = pathMap[topic]; log(`Getting doc for topic: ${topic}, path: ${path}`); const docContent = await fetchDocMarkdown(path); const relatedTopics = topicMetadata[topic].relatedTopics; const relatedTopicsText = relatedTopics.length > 0 ? `\n\n## Related Topics\n\n${relatedTopics .map( (t) => `- ${topicMetadata[t].title} (use get-documentation with topic "${t}")` ) .join("\n")}` : ""; return { content: [ { type: "text", text: docContent + relatedTopicsText, }, ], }; } );
- src/index.ts:139-143 (schema)Zod input schema for the tool, defining the 'topic' parameter as an enum of predefined documentation topics.{ topic: z .enum(docTopics) .describe("The documentation topic to retrieve"), },
- src/index.ts:136-169 (registration)MCP server tool registration call for 'get-documentation', specifying name, description, input schema, and handler function.server.tool( "get-documentation", "Get PaymanAI documentation on a specific topic", { topic: z .enum(docTopics) .describe("The documentation topic to retrieve"), }, async ({ topic }) => { const path = pathMap[topic]; log(`Getting doc for topic: ${topic}, path: ${path}`); const docContent = await fetchDocMarkdown(path); const relatedTopics = topicMetadata[topic].relatedTopics; const relatedTopicsText = relatedTopics.length > 0 ? `\n\n## Related Topics\n\n${relatedTopics .map( (t) => `- ${topicMetadata[t].title} (use get-documentation with topic "${t}")` ) .join("\n")}` : ""; return { content: [ { type: "text", text: docContent + relatedTopicsText, }, ], }; } );
- src/index.ts:18-47 (helper)Helper function to fetch and cache PaymanAI documentation markdown from https://docs.paymanai.com, used by the handler.async function fetchDocMarkdown(path: string): Promise<string> { const now = Date.now(); const cachedDoc = documentCache.get(path); if (cachedDoc && now - cachedDoc.timestamp < CACHE_TTL) { log(`Using cached content for: ${path}`); return cachedDoc.content; } try { const url = `https://docs.paymanai.com${path}.md`; log(`Fetching: ${url}`); const response = await fetch(url); if (!response.ok) { throw new Error(`Failed to fetch: ${response.status}`); } const content = await response.text(); documentCache.set(path, { content, timestamp: now }); return content; } catch (error) { log(`Error fetching documentation: ${error}`); return `Documentation content not available for path: ${path}.md\nError: ${ error instanceof Error ? error.message : String(error) }`; } }
- src/index.ts:79-134 (helper)Metadata object providing titles and related topics for each documentation topic, used to generate related topics list in handler.const topicMetadata: Record< string, { title: string; relatedTopics: string[]; } > = { quickstart: { title: "Quickstart Guide", relatedTopics: ["setup-and-installation", "api-keys"], }, playground: { title: "API Playground", relatedTopics: ["api-reference", "api-keys"], }, "setup-and-installation": { title: "Setup and Installation", relatedTopics: ["api-keys", "quickstart"], }, "create-payees": { title: "Create Payees", relatedTopics: ["create-payee", "search-payees"], }, "send-payments": { title: "Send Payments", relatedTopics: ["check-balances", "create-payees"], }, "create-payee": { title: "Create Payee", relatedTopics: ["create-payees", "search-payees"], }, "search-payees": { title: "Search Payees", relatedTopics: ["create-payee", "create-payees"], }, "check-balances": { title: "Check Balances", relatedTopics: ["send-payments"], }, "bill-payment-agent": { title: "Bill Payment Agent", relatedTopics: ["send-payments"], }, "api-reference": { title: "API Reference", relatedTopics: ["error-handling", "api-keys"], }, "api-keys": { title: "API Keys", relatedTopics: ["api-reference", "setup-and-installation"], }, "error-handling": { title: "Error Handling", relatedTopics: ["api-reference"], }, };