UNPKG

mcp-codesentry

Version:

CodeSentry MCP - AI-powered code review assistant with 5 specialized review tools for security, best practices, and comprehensive code analysis

90 lines 3.6 kB
/** * Core MCP Server implementation * Handles tool registration and request processing */ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'; import { z } from 'zod'; import { logger } from '../utils/logger.js'; import { StorageManager } from '../storage/manager.js'; import { GeminiClient } from '../gemini/client.js'; export class MCPServer { server; storage; gemini; config; constructor(config) { this.config = config; this.server = new McpServer({ name: config.name, version: config.version }); // Initialize storage with default config this.storage = new StorageManager({ basePath: '/tmp/software-architect-mcp', encrypt: false, maxSizeMB: 100 }); // Initialize Gemini client this.gemini = new GeminiClient(config.gemini); this.setupTools(); } setupTools() { // Define review_plan tool this.server.tool('review_plan', 'Review an implementation plan before coding', { taskId: z.string().describe('Unique identifier for the task'), taskDescription: z.string().describe('Description of the task to be implemented'), implementationPlan: z.string().describe('Detailed plan for implementing the task'), codebaseContext: z.string().describe('Relevant codebase context') }, async (params) => { logger.info('Handling review_plan request', { taskId: params.taskId }); try { // Use actual Gemini client for review const response = await this.gemini.reviewPlan(params); return { content: [{ type: 'text', text: JSON.stringify(response, null, 2) }] }; } catch (error) { logger.error('Error in review_plan', error); throw error; } }); // Define review_implementation tool this.server.tool('review_implementation', 'Review completed implementation against the original plan', { taskId: z.string().describe('Unique identifier for the task'), taskDescription: z.string().describe('Description of the task that was implemented'), originalPlan: z.string().describe('Original implementation plan'), implementationSummary: z.string().describe('Summary of what was actually implemented'), codebaseSnapshot: z.string().describe('Current state of the codebase') }, async (params) => { logger.info('Handling review_implementation request', { taskId: params.taskId }); try { // Use actual Gemini client for review const response = await this.gemini.reviewImplementation(params); return { content: [{ type: 'text', text: JSON.stringify(response, null, 2) }] }; } catch (error) { logger.error('Error in review_implementation', error); throw error; } }); } async start(transport) { logger.info('Starting MCP server'); await this.storage.initialize(); await this.server.connect(transport); logger.info('MCP server connected'); } getServer() { return this.server; } } //# sourceMappingURL=server.js.map