feat: Initial implementation of mentor-mcp-server

Implements a Model Context Protocol (MCP) server that provides AI-powered mentorship and feedback tools.

Core Features:
- TypeScript implementation with ES modules
- MCP server setup with stdio transport
- Deepseek API integration with rate limiting and retry logic
- Secure environment configuration management
- Comprehensive utility functions for file and prompt handling

Tools:
- second-opinion: Provides critical analysis of user requests
  - Input validation
  - Rate limiting
  - Error handling
  - Sanitized inputs
  - Structured prompt templates

Infrastructure:
- Atomic design directory structure
- Type-safe implementation
- Proper error handling
- Security measures (input sanitization, rate limiting)
- Development scripts and configuration

Security Features:
- API key protection
- Input sanitization
- Rate limiting
- Error message sanitization
- Secure file path validation

This implementation follows MCP best practices and provides a foundation for adding additional tools:
- code-review
- design-critique
- writing-feedback
- brainstorm-enhancements
This commit is contained in:
cyanheads
2025-01-25 18:58:47 -08:00
commit 8968a96a98
14 changed files with 1367 additions and 0 deletions

27
src/config.ts Normal file
View File

@@ -0,0 +1,27 @@
import dotenv from 'dotenv';
import type { ServerConfig, APIConfig } from './types/index.js';
// Load environment variables
dotenv.config();
function requireEnv(name: string): string {
const value = process.env[name];
if (!value) {
throw new Error(`Missing required environment variable: ${name}`);
}
return value;
}
const apiConfig: APIConfig = {
apiKey: requireEnv('DEEPSEEK_API_KEY'),
baseUrl: process.env.DEEPSEEK_API_BASE_URL || 'https://api.deepseek.com/v1',
model: process.env.DEEPSEEK_MODEL || 'deepseek-coder',
maxRetries: parseInt(process.env.DEEPSEEK_MAX_RETRIES || '3', 10),
timeout: parseInt(process.env.DEEPSEEK_TIMEOUT || '30000', 10),
};
export const config: ServerConfig = {
serverName: process.env.SERVER_NAME || 'mentor-mcp-server',
serverVersion: process.env.SERVER_VERSION || '1.0.0',
api: apiConfig,
};