forked from cardosofelipe/fast-next-template
feat(mcp): Implement Knowledge Base MCP Server #57
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Implement the Knowledge Base MCP server that provides RAG (Retrieval Augmented Generation) capabilities using pgvector for semantic search. This enables agents to search and retrieve project-specific knowledge.
Sub-Tasks
1. Project Setup
mcp-servers/knowledge-base/pyproject.tomlwith dependenciesfastmcp>=0.4.0,asyncpg>=0.29.0,pgvector>=0.2.0tiktoken>=0.5.0for token countingDockerfile,.dockerignore)docker-compose.dev.ymlREADME.mdwith setup instructions2. Database Schema (
migrations/)knowledge_embeddingstableid(UUID, primary key)project_id(UUID, foreign key to projects)collection(VARCHAR(100), e.g., 'code', 'docs', 'conversations')source_path(VARCHAR(500), file path or URL)source_type(VARCHAR(50), 'file', 'url', 'conversation')chunk_index(INTEGER, position in source)chunk_hash(VARCHAR(64), SHA256 for dedup)content(TEXT, the actual text)embedding(vector(1536), OpenAI ada-002 dimension)metadata(JSONB, custom attributes)token_count(INTEGER, cached token count)created_at,updated_at(TIMESTAMPTZ)embeddingcolumn(project_id, collection)source_pathfor lookupscontentfor full-text search3. Embedding Generation (
embeddings.py)EmbeddingServiceclass4. Code Chunking Strategy (
chunking/code.py)CodeChunkerclass5. Markdown Chunking Strategy (
chunking/markdown.py)MarkdownChunkerclass6. Text Chunking Strategy (
chunking/text.py)TextChunkerclass7. Document Ingestion Pipeline (
ingestion.py)IngestionPipelineclass8. Semantic Search (
search/semantic.py)SemanticSearchclass9. Keyword Search (
search/keyword.py)KeywordSearchclass10. Hybrid Search (
search/hybrid.py)HybridSearchclass11. Collection Management (
collections.py)CollectionManagerclass12. MCP Tools Implementation (
server.py)ingest_documenttoolingest_filetoolsearchtooldelete_documenttoolget_collectionstoolget_documenttool13. Project Isolation
14. Performance Optimization
15. Docker & Deployment
Dockerfile16. Testing
17. Documentation
Technical Specifications
Database Schema
MCP Tools
Acceptance Criteria
Dependencies
Assignable To
backend-engineer agent