The MCP (Model Context Protocol) integration for vallm has been successfully implemented and tested.
mcp/server/_tools_vallm.py- Complete MCP tools implementation (509 lines)mcp/server/self_server.py- MCP server with fixed imports (184 lines)mcp_server.py- Startup script for project root (38 lines)
test_mcp.py- Comprehensive manual test suitemcp/tests/quick_test.py- Fast local validation checksmcp/tests/container_e2e.py- Container-side end-to-end runnermcp/tests/test_e2e.py- Host-side Docker build/run checksexamples/mcp_demo.py- Working examples and demonstrationsREADME.md- Updated with MCP integration sectionmcp/README.md- Updated with quick start guide
mcp/tests/Dockerfile.test- Docker image for the container-side e2e runnermcp/tests/Dockerfile.client- Legacy client image kept for reference onlymcp/tests/docker-compose.yml- Single-service Docker Compose configurationmcp/tests/run_e2e.sh- Complete test runner script for build + run automation
| Tool | Description | Status |
|---|---|---|
validate_syntax |
Multi-language syntax checking | ✅ Working |
validate_imports |
Import resolution validation | ✅ Working |
validate_security |
Security issue detection | ✅ Working |
validate_code |
Full pipeline validation | ✅ Working |
python3 mcp_server.py
# Or use the packaged module directly
python3 -m mcp.server.self_server{
"mcpServers": {
"vallm": {
"command": "python3",
"args": ["/path/to/vallm/mcp_server.py"],
"env": {
"PYTHONPATH": "/path/to/vallm/src"
}
}
}
}{
"method": "tools/call",
"params": {
"name": "validate_security",
"arguments": {
"code": "eval('1+1')",
"language": "python"
}
}
}All tests pass successfully:
- ✅ Syntax validation (Python, JavaScript, error detection)
- ✅ Import validation (valid/invalid imports)
- ✅ Security validation (secure/insecure code patterns)
- ✅ Full pipeline validation (multiple validators, selective enabling)
- ✅ MCP server communication (initialize, tools/list, tools/call)
- ✅ Container-side e2e runner (
mcp/tests/container_e2e.py) - ✅ Quick local validation (
mcp/tests/quick_test.py)
- Python, JavaScript, TypeScript, Go, Rust, Java, C/C++, Ruby, PHP, Swift, Kotlin, Scala, and more
- Syntax: AST parsing and tree-sitter error detection
- Imports: Module resolution and dependency checking
- Security: Pattern-based vulnerability detection
- Complexity: Cyclomatic complexity and maintainability metrics
- Full Pipeline: Combined validation with configurable options
Consistent JSON responses with:
- Success status and verdict
- Detailed scores and weights
- Structured issue reporting
- Validator-specific details
_tools_vallm.pyprovides the core validation functionsself_server.pyhandles MCP protocol communicationmcp_server.pyprovides easy startup from project root
- Graceful failure with detailed error messages
- Consistent response format across all tools
- Proper exception handling and logging
- Fast syntax validation (milliseconds)
- Efficient import resolution
- Pattern-based security scanning
- Configurable validation pipeline
The MCP integration includes comprehensive Docker-based testing.
The default flow uses a single container-side runner, so no separate server/client compose split is required.
# Fast local validation
python3 mcp/tests/quick_test.py# Complete test suite with Docker
bash mcp/tests/run_e2e.sh
# With single-service docker-compose
bash mcp/tests/run_e2e.sh --compose- Container Tests: Full MCP protocol validation in isolated environment
- Build Tests: Verify Docker image creation and dependencies
- Integration Tests: Client-server communication validation
- Protocol Tests: JSON-RPC compliance and error handling
- ✅ MCP server startup and initialization
- ✅ All 4 validation tools via MCP protocol
- ✅ Error handling and invalid requests
- ✅ Multi-language validation support
- ✅ Docker container isolation
- ✅ JSON-RPC protocol compliance
The MCP integration is ready for production use. Users can:
- Start the MCP server
- Configure their LLM client (Claude Desktop, etc.)
- Use vallm validation tools directly in conversations
All validation capabilities of vallm are now available through the MCP interface, making it easy to integrate code validation into AI-assisted development workflows.