Skip to main content
Glama

Demo MCP Server

by kylekanouse
code-review-prompts.tsโ€ข4.98 kB
/** * Code Review Prompts * * Example MCP prompts for code analysis and review tasks. */ import { z } from "zod"; import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import type { MCPModule } from "../types/index.js"; /** * Prompt registration function for code review prompts */ async function register(server: McpServer): Promise<void> { // Register code review prompt server.registerPrompt( "review-code", { title: "Code Review Prompt", description: "Generate a comprehensive code review focusing on best practices, security, and performance", argsSchema: { code: z.string().describe("The code to review"), language: z.string().optional().describe("Programming language (auto-detected if not provided)"), focus: z.enum([ "general", "security", "performance", "maintainability", "style" ]).optional().describe("Focus area for the review") } }, ({ code, language, focus }) => { const actualFocus = focus || "general"; const focusInstructions = { general: "Provide a comprehensive review covering all aspects", security: "Focus primarily on security vulnerabilities and best practices", performance: "Analyze performance implications and optimization opportunities", maintainability: "Evaluate code readability, structure, and maintainability", style: "Review coding style, conventions, and formatting" }; return { messages: [ { role: "user", content: { type: "text", text: `Please review the following ${language || "code"} with a focus on ${actualFocus}: ${focusInstructions[actualFocus as keyof typeof focusInstructions]} Code to review: \`\`\`${language || ""} ${code} \`\`\` Please provide: 1. Overall assessment 2. Specific issues found 3. Suggestions for improvement 4. Best practices recommendations 5. Any security concerns (if applicable)` } } ] }; } ); // Register refactoring prompt server.registerPrompt( "refactor-code", { title: "Code Refactoring Prompt", description: "Generate suggestions and examples for refactoring code", argsSchema: { code: z.string().describe("The code to refactor"), language: z.string().optional().describe("Programming language"), goal: z.enum([ "readability", "performance", "modularity", "testability", "solid-principles" ]).describe("Primary refactoring goal") } }, ({ code, language, goal }) => { const goalDescriptions = { readability: "improve code readability and clarity", performance: "optimize for better performance", modularity: "break down into more modular components", testability: "make the code more testable", "solid-principles": "apply SOLID design principles" }; return { messages: [ { role: "user", content: { type: "text", text: `Please help refactor the following ${language || "code"} to ${goalDescriptions[goal]}: Original code: \`\`\`${language || ""} ${code} \`\`\` Please provide: 1. Analysis of current issues 2. Refactored version with explanations 3. Key improvements made 4. Additional recommendations` } } ] }; } ); // Register documentation prompt server.registerPrompt( "document-code", { title: "Code Documentation Prompt", description: "Generate comprehensive documentation for code", argsSchema: { code: z.string().describe("The code to document"), language: z.string().optional().describe("Programming language"), style: z.enum([ "jsdoc", "typescript", "pydoc", "javadoc", "markdown" ]).optional().describe("Documentation style") } }, ({ code, language, style }) => { const actualStyle = style || "markdown"; return { messages: [ { role: "user", content: { type: "text", text: `Please generate comprehensive documentation for the following ${language || "code"} in ${actualStyle} format: Code to document: \`\`\`${language || ""} ${code} \`\`\` Please include: 1. Overview and purpose 2. Function/method descriptions 3. Parameter and return value documentation 4. Usage examples 5. Any important notes or warnings` } } ] }; } ); } /** * Export the MCP module */ export const codeReviewPrompts: MCPModule = { register, metadata: { name: "code-review-prompts", description: "Code review and analysis prompts for MCP", version: "1.0.0", author: "PCN" } }; export default codeReviewPrompts;

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/kylekanouse/Test-MCP---DEMO-MCP-Dev-1'

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