Code Knowledge MCP Server
by davidvc
# Code Knowledge Tool Requirements
## Overview
A tool that manages and provides access to code knowledge through a local vector database and embedding engine, exposed as an MCP server.
## Core Requirements
### 1. Knowledge Source Support
- Must support storing knowledge from:
- Memory bank files (markdown)
- Code documentation
- Project summaries
- Design decisions
- Knowledge management should:
- Support markdown formatting
- Handle metadata
- Enable updates and evolution
- Maintain consistency
### 2. Local Infrastructure
- Vector Database:
- Use ChromaDB as the vector database
- Store in persistent repository location
- Support efficient similarity search
- Handle metadata storage
- Embedding Engine:
- Use local Ollama service
- Support configurable base URL
- Maintain consistent embedding dimensions
- Handle batch operations
### 3. MCP Server Integration
- Tool Registration:
- Register as "code_knowledge_tool" MCP server
- Expose multiple tools for different operations
- Support resource access
- Handle async operations
- Available Tools:
- add_knowledge: Add new knowledge entries
- search_knowledge: Search existing knowledge
- get_context: Get relevant context for tasks
- list_knowledge: List available entries
- update_knowledge: Update existing entries
- Resource Access:
- URI format: knowledge://{path}
- Support reading knowledge entries
- List available resources
- Handle metadata
### 4. Performance Requirements
- Response time: < 3 seconds for typical operations
- Memory usage: < 500MB for typical usage
- Support knowledge bases up to 1GB in size
- Efficient batch operations
### 5. Error Handling
- Clear error messages for:
- Invalid knowledge paths
- Duplicate entries
- Ollama service issues
- Embedding generation failures
- Vector database errors
- Resource access failures
## Technical Requirements
### Dependencies
- chromadb: For vector database operations
- modelcontextprotocol: For MCP server implementation
- Required Python version: 3.8+
- Ollama service: For embedding generation
### Storage
- Persistent storage for knowledge entries
- Vector database persistence
- Clean environment for testing
- Configurable storage location
### Configuration
- Storage directory configuration
- Ollama service URL configuration
- Support for environment variables
- MCP server settings
### Security
- Local file system access control
- Resource URI validation
- Input sanitization
- Error isolation
## Integration Requirements
### MCP Server
- Async operation support
- Standard tool registration
- Resource management
- Error reporting through MCP protocol
### Local Environment
- Ollama service must be running
- Sufficient disk space for storage
- Adequate memory for operations
- Clean test environment
## Testing Requirements
### Integration Testing
- MCP contract verification
- Tool functionality testing
- Resource access testing
- Error handling verification
### Package Testing
- Installation verification
- Dependency resolution
- Server initialization
- Basic functionality
### Test Environment
- Isolated storage directory
- Clean environment between tests
- Ollama service availability
- Resource cleanup
## Future Considerations
- Enhanced search capabilities
- Improved context retrieval
- Batch operations optimization
- Advanced metadata handling
- Caching mechanisms