Krep MCP Server
by bmorphism
Verified
# krep-mcp-server Testing Summary
## Overview
This document summarizes the testing process for the krep-mcp-server, focusing on MCP protocol compliance and compatibility with various clients.
## Test Suites
### 1. MCP Inspector Compatibility Test
File: `test-mcp-inspector.js`
This test validates that the krep-mcp-server strictly follows the MCP protocol format required by MCP Inspector.
**Test Components:**
- Exact Content-Length header format (`Content-Length: N\r\n\r\n`)
- Proper JSON-RPC message structure
- UTF-8 and binary data handling
- Error recovery mechanisms
- Capability reporting
**Test Functions:**
- Initialize sequence
- Search function with file paths
- Match function with string content
- Count function for occurrence counting
**Results:**
✅ The server successfully passes all MCP Inspector compatibility tests
### 2. Claude Desktop Integration Test
File: `test-claude-desktop.js`
This test verifies that the krep-mcp-server works properly with Claude Desktop.
**Test Components:**
- Environment variable handling (`CLAUDE_MCP=true`)
- Initialize sequence
- Function execution
- Unicode handling
- Buffer management for large messages
**Test Functions:**
- Initialize with Claude Desktop client info
- Search function for file patterns
- Match function for text patterns
**Results:**
✅ The server successfully passes all Claude Desktop integration tests
### 3. Unit Tests
Directory: `test/unit/`
These tests verify individual components of the server:
- Algorithm selection logic
- API endpoint correctness
- Error handling
- URI parsing
- Performance metrics
### 4. Integration Tests
Directory: `test/integration/`
These tests verify how components work together:
- SDK integration workflows
- MCP URI validation
- MCP protocol compliance
- Client compatibility
## Common Issues Fixed
1. **JSON-RPC Message Format**
- Fixed strict Content-Length header format
- Ensured proper UTF-8 encoding
- Implemented atomic message writing
2. **Output Separation**
- Redirected all debug output to stderr
- Kept stdout clean for JSON-RPC messages only
3. **Buffer Handling**
- Improved handling of binary data
- Added type checking for Buffer.concat
- Enhanced chunk accumulation
4. **Error Recovery**
- Added buffer clearing for large accumulations
- Improved error reporting
- Enhanced message parsing resilience
## Test Environment
- Node.js v23.7.0
- macOS Ventura
- krep 1.2.1
## Running Tests
To run the tests:
```bash
# MCP Inspector compatibility test
node test-mcp-inspector.js
# Claude Desktop integration test
node test-claude-desktop.js
# All unit and integration tests
npm test
```
## Benchmarks
The `test/benchmark.js` and `test/mcp_benchmark.js` files provide performance benchmarks for:
- Search performance across different pattern sizes
- Buffer handling with large messages
- Protocol message parsing speed
Current benchmark results show that the krep-mcp-server maintains high performance while ensuring protocol compliance.