karx/kaaroMCP
If you are the rightful owner of kaaroMCP and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The Kaaro MCP Server is a robust implementation of the Model Context Protocol designed for AI agent communication, offering features like session management, comprehensive logging, and health monitoring.
Kaaro MCP Server
A robust Model Context Protocol (MCP) server implementation for the Kaaro Brain agent interface. This project has been refactored for maintainability, observability, and team collaboration.
๐ Features
- MCP Protocol Support: Full implementation of the Model Context Protocol for AI agent communication
- Session Management: Robust session handling with automatic cleanup
- Comprehensive Logging: Detailed logging for debugging and monitoring
- Health Monitoring: Built-in health check endpoints
- TypeScript: Full type safety and modern development experience
- Testing: Comprehensive unit and integration tests
- Modular Architecture: Clean separation of concerns for maintainability
๐ Project Structure
kaaroMCP/
โโโ src/
โ โโโ types/ # TypeScript type definitions
โ โโโ utils/ # Utility functions (logger, etc.)
โ โโโ services/ # Business logic services
โ โโโ routes/ # HTTP route handlers
โ โโโ middleware/ # Express middleware
โ โโโ app.ts # Main application class
โ โโโ index.ts # Application entry point
โโโ tests/ # Unit and integration tests
โโโ dist/ # Compiled JavaScript output
โโโ package.json # Dependencies and scripts
โโโ tsconfig.json # TypeScript configuration
โโโ jest.config.js # Test configuration
โโโ README.md # This file
๐ ๏ธ Installation
- Clone the repository:
git clone <repository-url>
cd kaaroMCP
- Install dependencies:
npm install
- Build the project:
npm run build
๐โโ๏ธ Running the Server
Development Mode
npm run dev
Production Mode
npm start
The server will start on port 3000 by default. You can configure this using environment variables:
PORT=8080 npm start
๐ก API Endpoints
MCP Protocol
- POST /mcp - Client-to-server communication
- GET /mcp - Server-to-client notifications (SSE)
- DELETE /mcp - Session termination
Health & Monitoring
- GET /health - Health check endpoint
- GET / - Server information
Example Health Response
{
"status": "healthy",
"timestamp": "2024-01-14T01:38:00.000Z",
"server": {
"name": "kaaro-mcp-server",
"version": "1.0.0",
"uptime": 125.5
},
"sessions": {
"activeSessions": 2,
"sessionIds": ["session-123", "session-456"]
}
}
๐ง Configuration
The server can be configured through environment variables:
Variable | Default | Description |
---|---|---|
PORT | 3000 | Server port |
NODE_ENV | development | Environment mode |
DEBUG | false | Enable debug logging |
ALLOWED_HOSTS | 127.0.0.1,localhost | Comma-separated allowed hosts |
Production Configuration
NODE_ENV=production
PORT=8080
ALLOWED_HOSTS=yourdomain.com,api.yourdomain.com
๐งช Testing
Run all tests
npm test
Run tests in watch mode
npm run test:watch
Generate coverage report
npm run test:coverage
Test Structure
- Unit Tests: Individual component testing
- Integration Tests: End-to-end API testing
- Mocking: Console output and external dependencies
๐ Logging & Observability
The server includes comprehensive logging for observability:
Log Levels
- INFO: General information
- WARN: Warning conditions
- ERROR: Error conditions
- DEBUG: Debug information (development only)
Log Context
All logs include contextual information:
{
"timestamp": "2024-01-14T01:38:00.000Z",
"level": "info",
"message": "Session initialized",
"sessionId": "abc-123",
"method": "POST",
"path": "/mcp"
}
Monitoring Events
- Session lifecycle (created, initialized, closed)
- Request/response timing
- Tool invocations
- Resource access
- Error conditions
๐ MCP Tools & Resources
Available Tools
- add: Addition calculator
- multiply: Multiplication calculator
Available Resources
- greeting://{name}: Dynamic greeting generator
- status://server: Server status information
Example Tool Usage
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "add",
"arguments": {
"a": 5,
"b": 3
}
}
}
๐ Development
Adding New Tools
- Modify
src/services/mcpServer.ts
- Add tool registration in
setupTools()
- Include logging and error handling
- Add unit tests
Adding New Resources
- Modify
src/services/mcpServer.ts
- Add resource registration in
setupResources()
- Include proper URI templates
- Add integration tests
Code Style
- Use TypeScript strict mode
- Follow ESLint configuration
- Include comprehensive error handling
- Add logging for all major operations
๐ Scripts
Script | Description |
---|---|
npm start | Start production server |
npm run dev | Start development server |
npm run build | Build TypeScript to JavaScript |
npm test | Run all tests |
npm run test:watch | Run tests in watch mode |
npm run test:coverage | Generate test coverage |
npm run lint | Type check without compilation |
npm run clean | Clean build and coverage |
๐ Troubleshooting
Common Issues
-
Port already in use:
PORT=8080 npm start
-
TypeScript compilation errors:
npm run lint
-
Test failures:
DEBUG=true npm test
Debug Mode
Enable detailed logging:
DEBUG=true npm run dev
๐ค Contributing
- Create a feature branch
- Write tests for new functionality
- Ensure all tests pass
- Update documentation
- Submit a pull request
Development Workflow
# Start development server
npm run dev
# Run tests
npm test
# Check types
npm run lint
# Build for production
npm run build
๐ License
This project is licensed under the ISC License.
๐โโ๏ธ Support
For questions or issues:
- Check the troubleshooting section
- Review the logs with
DEBUG=true
- Check existing issues
- Create a new issue with detailed information
Made with โค๏ธ for the Kaaro Brain project