get-documentation
Retrieve PaymanAI documentation on specific topics like API reference, setup, or error handling to streamline developer integrations and workflows.
Instructions
Get PaymanAI documentation on a specific topic
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| topic | Yes | The documentation topic to retrieve |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"topic": {
"description": "The documentation topic to retrieve",
"enum": [
"quickstart",
"playground",
"setup-and-installation",
"create-payees",
"send-payments",
"create-payee",
"search-payees",
"check-balances",
"bill-payment-agent",
"api-reference",
"api-keys",
"error-handling"
],
"type": "string"
}
},
"required": [
"topic"
],
"type": "object"
}
Implementation Reference
- src/index.ts:144-168 (handler)Handler function that retrieves documentation for the specified topic by fetching Markdown content from a mapped path, caching it, and appending related topics information.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)Input schema for the tool, defining the 'topic' parameter as a Zod enum based on predefined docTopics.{ topic: z .enum(docTopics) .describe("The documentation topic to retrieve"), },
- src/index.ts:136-169 (registration)Registration of the 'get-documentation' tool on the MCP server, including 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 Markdown documentation from PaymanAI docs site.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:64-77 (helper)Mapping of topics to their corresponding documentation path suffixes used in the handler.const pathMap: Record<string, string> = { quickstart: "/overview/quickstart", playground: "/overview/playground", "setup-and-installation": "/sdks/setup-and-installation", "create-payees": "/sdks/create-payees", "send-payments": "/sdks/send-payments", "create-payee": "/sdks/create-payee", "search-payees": "/sdks/search-payees", "check-balances": "/sdks/check-balances", "bill-payment-agent": "/guides/bill-payment-agent", "api-reference": "/api-reference/introduction", "api-keys": "/api-reference/get-api-key", "error-handling": "/api-reference/error-handling", };