minimal-server.ts•8.15 kB
#!/usr/bin/env node
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import {
ListToolsRequestSchema,
CallToolRequestSchema,
} from '@modelcontextprotocol/sdk/types.js';
// Create server with minimal config
const server = new Server(
{
name: 'mcp-context-manager',
version: '2.0.2',
},
{
capabilities: {
tools: {},
},
}
);
// Define all 15 tools inline to avoid import issues
const tools = [
{
name: 'check_before_suggesting',
description: 'CRITICAL: AI must use this before suggesting any code to prevent hallucinations',
inputSchema: {
type: 'object',
properties: {
imports: { type: 'array', items: { type: 'string' } },
methods: { type: 'array', items: { type: 'string' } },
patterns: { type: 'array', items: { type: 'string' } },
},
required: ['imports', 'methods', 'patterns'],
},
},
{
name: 'validate_generated_code',
description: 'Validate generated code for patterns, security, and best practices',
inputSchema: {
type: 'object',
properties: {
code: { type: 'string' },
type: { type: 'string', enum: ['component', 'function', 'service', 'test', 'config'] },
targetFile: { type: 'string' },
},
required: ['code', 'type'],
},
},
{
name: 'get_pattern_for_task',
description: 'Get the correct pattern to use for a specific task',
inputSchema: {
type: 'object',
properties: {
taskType: { type: 'string', enum: ['component', 'api', 'test', 'hook', 'service', 'utility'] },
context: { type: 'object' },
},
required: ['taskType'],
},
},
{
name: 'check_security_compliance',
description: 'Check code for security vulnerabilities and compliance',
inputSchema: {
type: 'object',
properties: {
code: { type: 'string' },
checkTypes: { type: 'array', items: { type: 'string' } },
},
required: ['code'],
},
},
{
name: 'detect_existing_patterns',
description: 'Analyze existing codebase to detect patterns and conventions',
inputSchema: {
type: 'object',
properties: {
directory: { type: 'string' },
patternTypes: { type: 'array', items: { type: 'string' } },
},
required: ['directory'],
},
},
{
name: 'initialize_agent_workspace',
description: 'Initialize AI agent workspace with template files and context',
inputSchema: {
type: 'object',
properties: {
projectPath: { type: 'string' },
projectName: { type: 'string' },
techStack: { type: 'object' },
},
required: ['projectPath', 'projectName'],
},
},
{
name: 'generate_tests_for_coverage',
description: 'Generate intelligent tests to achieve 80%+ coverage',
inputSchema: {
type: 'object',
properties: {
targetFile: { type: 'string' },
testFramework: { type: 'string', enum: ['jest', 'vitest', 'mocha'] },
coverageTarget: { type: 'number' },
includeEdgeCases: { type: 'boolean' },
includeAccessibility: { type: 'boolean' },
},
required: ['targetFile'],
},
},
{
name: 'track_agent_performance',
description: 'Track and analyze AI agent performance metrics',
inputSchema: {
type: 'object',
properties: {
featureName: { type: 'string' },
timestamp: { type: 'string' },
metrics: { type: 'object' },
},
required: ['featureName', 'timestamp', 'metrics'],
},
},
{
name: 'create_conversation_starters',
description: 'Create conversation starters to help AI understand project context quickly',
inputSchema: {
type: 'object',
properties: {
projectPath: { type: 'string' },
analysisId: { type: 'string' },
includeQuickTasks: { type: 'boolean' },
includeCurrentWork: { type: 'boolean' },
tokenLimit: { type: 'number' },
customTasks: { type: 'array', items: { type: 'string' } },
},
required: ['projectPath'],
},
},
{
name: 'create_token_optimizer',
description: 'Create tiered context files for token optimization with ROI tracking',
inputSchema: {
type: 'object',
properties: {
projectPath: { type: 'string' },
analysisId: { type: 'string' },
tiers: { type: 'array', items: { type: 'string' } },
trackUsage: { type: 'boolean' },
generateMetrics: { type: 'boolean' },
},
required: ['projectPath'],
},
},
{
name: 'create_ide_configs',
description: 'Create IDE-specific configurations for Cursor, VS Code, and IntelliJ',
inputSchema: {
type: 'object',
properties: {
projectPath: { type: 'string' },
analysisId: { type: 'string' },
ide: { type: 'string', enum: ['cursor', 'vscode', 'intellij', 'all'] },
autoLoadContext: { type: 'boolean' },
customRules: { type: 'array', items: { type: 'string' } },
includeDebugConfigs: { type: 'boolean' },
},
required: ['projectPath', 'ide'],
},
},
{
name: 'setup_persistence_automation',
description: 'Set up automated context updates with monitoring and validation',
inputSchema: {
type: 'object',
properties: {
projectPath: { type: 'string' },
analysisId: { type: 'string' },
updateSchedule: { type: 'string', enum: ['daily', 'weekly', 'on-change', 'manual'] },
gitHooks: { type: 'boolean' },
monitoring: { type: 'boolean' },
notifications: { type: 'object' },
},
required: ['projectPath', 'updateSchedule'],
},
},
{
name: 'create_maintenance_workflows',
description: 'Create team workflows for maintaining AI context quality over time',
inputSchema: {
type: 'object',
properties: {
projectPath: { type: 'string' },
analysisId: { type: 'string' },
teamSize: { type: 'number' },
updateFrequency: { type: 'string', enum: ['daily', 'weekly', 'biweekly', 'monthly'] },
includeChecklists: { type: 'boolean' },
includeMetrics: { type: 'boolean' },
includeTraining: { type: 'boolean' },
},
required: ['projectPath', 'teamSize', 'updateFrequency'],
},
},
{
name: 'analyze_codebase_deeply',
description: 'Perform comprehensive analysis of codebase to understand patterns and architecture',
inputSchema: {
type: 'object',
properties: {
projectPath: { type: 'string' },
maxDepth: { type: 'number' },
excludePatterns: { type: 'array', items: { type: 'string' } },
},
required: ['projectPath'],
},
},
{
name: 'complete_setup_workflow',
description: 'Complete MCP setup workflow: analyze codebase, create all context files, and configure automation',
inputSchema: {
type: 'object',
properties: {
projectPath: { type: 'string' },
projectName: { type: 'string' },
teamSize: { type: 'number' },
updateSchedule: { type: 'string', enum: ['daily', 'weekly', 'on-change', 'manual'] },
ide: { type: 'string', enum: ['cursor', 'vscode', 'intellij', 'all'] },
includeAll: { type: 'boolean' },
},
required: ['projectPath', 'projectName'],
},
},
];
// Register handlers
server.setRequestHandler(ListToolsRequestSchema, async () => {
return { tools };
});
server.setRequestHandler(CallToolRequestSchema, async (request) => {
return {
content: [
{
type: 'text',
text: `Tool ${request.params.name} called with args: ${JSON.stringify(request.params.arguments)}`,
},
],
};
});
// Start server
async function main() {
const transport = new StdioServerTransport();
await server.connect(transport);
console.error('MCP Context Manager Server started (minimal version)');
}
main().catch((error) => {
console.error('Failed to start server:', error);
process.exit(1);
});