kaaroMCP

karx/kaaroMCP

3.2

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.

Tools
2
Resources
0
Prompts
0

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

  1. Clone the repository:
git clone <repository-url>
cd kaaroMCP
  1. Install dependencies:
npm install
  1. 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:

VariableDefaultDescription
PORT3000Server port
NODE_ENVdevelopmentEnvironment mode
DEBUGfalseEnable debug logging
ALLOWED_HOSTS127.0.0.1,localhostComma-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

  1. Modify src/services/mcpServer.ts
  2. Add tool registration in setupTools()
  3. Include logging and error handling
  4. Add unit tests

Adding New Resources

  1. Modify src/services/mcpServer.ts
  2. Add resource registration in setupResources()
  3. Include proper URI templates
  4. Add integration tests

Code Style

  • Use TypeScript strict mode
  • Follow ESLint configuration
  • Include comprehensive error handling
  • Add logging for all major operations

๐Ÿ“ Scripts

ScriptDescription
npm startStart production server
npm run devStart development server
npm run buildBuild TypeScript to JavaScript
npm testRun all tests
npm run test:watchRun tests in watch mode
npm run test:coverageGenerate test coverage
npm run lintType check without compilation
npm run cleanClean build and coverage

๐Ÿ› Troubleshooting

Common Issues

  1. Port already in use:

    PORT=8080 npm start
    
  2. TypeScript compilation errors:

    npm run lint
    
  3. Test failures:

    DEBUG=true npm test
    

Debug Mode

Enable detailed logging:

DEBUG=true npm run dev

๐Ÿค Contributing

  1. Create a feature branch
  2. Write tests for new functionality
  3. Ensure all tests pass
  4. Update documentation
  5. 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:

  1. Check the troubleshooting section
  2. Review the logs with DEBUG=true
  3. Check existing issues
  4. Create a new issue with detailed information

Made with โค๏ธ for the Kaaro Brain project