Skip to main content
Glama
Vanshika-Rana

Payman AI Documentation MCP Server

get-code-examples

Generate Node.js or Python code examples for PaymanAI integration based on specific features, aiding developers in building efficient integrations with ease.

Instructions

Get Node.js or Python code examples for PaymanAI integration

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
featureYesThe feature or functionality you need code examples for
languageNoProgramming language (nodejs or python)nodejs

Implementation Reference

  • src/index.ts:291-396 (registration)
    Registers the 'get-code-examples' MCP tool, including schema and inline handler function.
    server.tool( "get-code-examples", "Get Node.js or Python code examples for PaymanAI integration", { feature: z .string() .describe( "The feature or functionality you need code examples for" ), language: z .enum(["nodejs", "python"]) .default("nodejs") .describe("Programming language (nodejs or python)"), }, async ({ feature, language }) => { log(`Getting ${language} code example for: "${feature}"`); const potentialTopics = Object.entries(pathMap) .filter( ([topic]) => topic.toLowerCase().includes(feature.toLowerCase()) || topicMetadata[topic].title .toLowerCase() .includes(feature.toLowerCase()) ) .map(([topic]) => topic); const topicsToSearch = potentialTopics.length > 0 ? potentialTopics : Object.keys(pathMap); const examplesPromises = topicsToSearch.map(async (topic) => { const path = pathMap[topic]; const content = await fetchDocMarkdown(path); const codeBlockRegex = language === "nodejs" ? /```(?:javascript|typescript|js|nodejs|node)([\s\S]*?)```/g : /```(?:python|py)([\s\S]*?)```/g; const matches = [...content.matchAll(codeBlockRegex)]; const relevantBlocks = matches .map((match) => match[1].trim()) .filter( (code) => code.toLowerCase().includes(feature.toLowerCase()) || content .substring( Math.max(0, content.indexOf(code) - 300), content.indexOf(code) ) .toLowerCase() .includes(feature.toLowerCase()) ); if (relevantBlocks.length === 0) return null; return { topic, title: topicMetadata[topic].title, examples: relevantBlocks, }; }); const allExamples = (await Promise.all(examplesPromises)).filter( Boolean ); if (allExamples.length === 0) { return { content: [ { type: "text", text: `No ${language} code examples found for "${feature}". Try searching for a different feature or check the full documentation using get-documentation.`, }, ], }; } let responseText = `# ${language.toUpperCase()} Code Examples for "${feature}"\n\n`; allExamples.forEach((topicExamples) => { if (!topicExamples) return; responseText += `## From ${topicExamples.title}\n\n`; topicExamples.examples.forEach((code, index) => { responseText += `### Example ${index + 1}\n\n`; responseText += `\`\`\`${ language === "nodejs" ? "javascript" : "python" }\n${code}\n\`\`\`\n\n`; }); responseText += `*For more context, check the full documentation: use get-documentation with topic "${topicExamples.topic}".*\n\n---\n\n`; }); return { content: [ { type: "text", text: responseText, }, ], }; } );
  • The handler function that searches documentation for code examples matching the feature in the specified language (nodejs or python) and returns formatted markdown with the examples.
    async ({ feature, language }) => { log(`Getting ${language} code example for: "${feature}"`); const potentialTopics = Object.entries(pathMap) .filter( ([topic]) => topic.toLowerCase().includes(feature.toLowerCase()) || topicMetadata[topic].title .toLowerCase() .includes(feature.toLowerCase()) ) .map(([topic]) => topic); const topicsToSearch = potentialTopics.length > 0 ? potentialTopics : Object.keys(pathMap); const examplesPromises = topicsToSearch.map(async (topic) => { const path = pathMap[topic]; const content = await fetchDocMarkdown(path); const codeBlockRegex = language === "nodejs" ? /```(?:javascript|typescript|js|nodejs|node)([\s\S]*?)```/g : /```(?:python|py)([\s\S]*?)```/g; const matches = [...content.matchAll(codeBlockRegex)]; const relevantBlocks = matches .map((match) => match[1].trim()) .filter( (code) => code.toLowerCase().includes(feature.toLowerCase()) || content .substring( Math.max(0, content.indexOf(code) - 300), content.indexOf(code) ) .toLowerCase() .includes(feature.toLowerCase()) ); if (relevantBlocks.length === 0) return null; return { topic, title: topicMetadata[topic].title, examples: relevantBlocks, }; }); const allExamples = (await Promise.all(examplesPromises)).filter( Boolean ); if (allExamples.length === 0) { return { content: [ { type: "text", text: `No ${language} code examples found for "${feature}". Try searching for a different feature or check the full documentation using get-documentation.`, }, ], }; } let responseText = `# ${language.toUpperCase()} Code Examples for "${feature}"\n\n`; allExamples.forEach((topicExamples) => { if (!topicExamples) return; responseText += `## From ${topicExamples.title}\n\n`; topicExamples.examples.forEach((code, index) => { responseText += `### Example ${index + 1}\n\n`; responseText += `\`\`\`${ language === "nodejs" ? "javascript" : "python" }\n${code}\n\`\`\`\n\n`; }); responseText += `*For more context, check the full documentation: use get-documentation with topic "${topicExamples.topic}".*\n\n---\n\n`; }); return { content: [ { type: "text", text: responseText, }, ], }; }
  • Zod schema defining input parameters: feature (string) and language (enum: nodejs|python, default nodejs).
    { feature: z .string() .describe( "The feature or functionality you need code examples for" ), language: z .enum(["nodejs", "python"]) .default("nodejs") .describe("Programming language (nodejs or python)"), },

Other Tools

Related Tools

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/Vanshika-Rana/payman-mcp-server'

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