Skip to main content
Glama
Vanshika-Rana

Payman AI Documentation MCP Server

get-code-examples

Retrieve Node.js or Python code examples for PaymanAI integration features to help developers implement specific functionality in their projects.

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

  • The handler function that implements the get-code-examples tool. It searches documentation for relevant code blocks in the specified language matching the feature, extracts them using regex, and formats them into a response.
    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 the input parameters for the tool: feature (required string) and language (optional enum defaulting to 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)"),
    },
  • src/index.ts:291-396 (registration)
    The server.tool call that registers the get-code-examples tool with the MCP server, providing name, description, input schema, and 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,
    				},
    			],
    		};
    	}
    );
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool retrieves code examples but doesn't describe behavioral traits like whether it returns formatted snippets, includes comments, handles errors, or has rate limits. For a tool with zero annotation coverage, this is a significant gap, as the agent lacks insight into how the tool behaves beyond its basic purpose.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core purpose without unnecessary details. Every word earns its place by specifying the tool's action, resources, and scope concisely, making it easy for an AI agent to parse quickly. There's no redundancy or wasted phrasing.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (2 parameters, no output schema, no annotations), the description is adequate but incomplete. It covers the basic purpose and parameters but lacks behavioral details and usage guidelines. Without annotations or an output schema, the agent must infer how results are returned and when to use the tool, leaving room for improvement in providing a more comprehensive context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds minimal meaning beyond the input schema, which has 100% coverage. It mentions 'Node.js or Python' and 'PaymanAI integration,' hinting at the 'language' and 'feature' parameters, but doesn't elaborate on parameter semantics like valid feature types or example formats. With high schema coverage, the baseline is 3, as the schema already documents parameters well, and the description provides only marginal additional context.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: 'Get Node.js or Python code examples for PaymanAI integration.' It specifies the verb ('Get'), resource ('code examples'), and scope ('PaymanAI integration'), distinguishing it from sibling tools like 'get-documentation' or 'search-documentation' that likely handle broader documentation. However, it doesn't explicitly differentiate from 'get-sdk-help' or 'solve-problem', which might overlap in providing code assistance.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, such as needing specific PaymanAI features, or compare it to siblings like 'get-sdk-help' (which might offer SDK-specific examples) or 'solve-problem' (which could provide troubleshooting code). The context is implied but not explicit, leaving gaps for an AI agent to infer usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other 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