A high-performance FastAPI/FastMCP-based Model Context Protocol (MCP) server that provides vector-based knowledge management with document storage, similarity search, and intelligent retrieval capabilities.
- Vector Knowledge Base MCP Server
- FastAPI Backend: High-performance async API server
- Vector Database: ChromaDB integration for semantic search
- Document Storage: MinIO object storage for file management
- PostgreSQL Database: Structured data storage and metadata
- MCP Protocol: Model Context Protocol server implementation using FastMCP
- Admin Interface: PgAdmin for database management (development only)
- Development Ready: Hot-reload and development tools included
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β FastAPI App ββββββ ChromaDB ββββββ PostgreSQL β
β (Port 8100) β β (Port 8101) β β (Port 5432) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β FastMCP App β
β (Port 8100/mcp) β
βββββββββββββββββββ
β
β
βββββββββββββββββββ βββββββββββββββββββ
β MinIO β β PgAdmin β
β (Ports 9100/01) β β (Port 5550) β
βββββββββββββββββββ βββββββββββββββββββAll port described in above schema are for development
- Backend: FastAPI with Python 3.11+
- Vector Database: ChromaDB for embeddings and similarity search
- Database: PostgreSQL 12 with Alpine Linux
- Object Storage: MinIO for file storage
- Containerization: Docker & Docker Compose
- MCP Protocol: FastMCP for model context protocol implementation
- Docker and Docker Compose
- Python 3.11+ (for local development)
- Git
Before running the application, create a .env file based on .env.example:
cp .env.example .envFill in the variables according to your environment:
APP_ENV=dev
APP_PORT=8100
DATABASE_URL=postgresql://akvo:password@db:5432/kb_mcp
# MinIO settings
MINIO_ENDPOINT=minio:9000
MINIO_ACCESS_KEY=minioadmin
MINIO_SECRET_KEY=minioadmin
MINIO_BUCKET_NAME=documents
# Chroma DB settings
CHROMA_DB_HOST=chromadb
CHROMA_DB_PORT=8000
VECTOR_STORE_BATCH_SIZE=100
# OpenAI settings
OPENAI_API_KEY=your-openai-api-key-here
OPENAI_API_BASE=https://api.openai.com/v1
OPENAI_MODEL=gpt-4
OPENAI_EMBEDDINGS_MODEL=text-embedding-ada-002
# Admin Auth
ADMIN_API_KEY=your-admin-api-key-hereNotes
APP_ENVaccepts two values:prodordev.- This variable controls the startup command in
entrypoint.sh, determining whether the application runs in reload mode (dev) or in production mode (prod). VECTOR_STORE_BATCH_SIZEcontrols how many documents are processed in a single batch when adding to the vector store. There is a trade off between performance and hitting limits on the number of chunks that can be stored at once default is 100 but you can tune this setting here.ADMIN_API_KEYcurrently used for authentication to access the CRUD API keys endpoint. With this, the script can create an API key that will be used as the authentication token to access the CRUD Knowledge Base.
-
Clone the repository
git clone [email protected]:akvo/vector-knowledge-base-mcp-server.git cd vector-knowledge-base-mcp-server
-
Set up environment variables
cp .env.example .env # Edit .env with your configurations -
Start the development environment
./dev.sh up -d
-
Verify services are running
docker compose ps
-
Running pytest
- Running FastAPI endpoint test
./dev.sh exec main ./test.sh api- Running e2e test
./dev.sh exec main ./test.sh e2e- Running FastMCP test
./dev.sh exec main ./test.sh mcp- Running All test
./dev.sh exec main ./test.sh all
- Build and start production services
docker compose -f docker-compose.yml up -d
| Service | Development | Production | Description |
|---|---|---|---|
| FastAPI | 8100 | 8000 | Main application API |
| ChromaDB | 8101 | 8001 | Vector database |
| PostgreSQL | 5432 | 5432 | Primary database |
| MinIO API | 9100 | 9000 | Object storage API |
| MinIO Console | 9101 | 9001 | MinIO web interface |
| PgAdmin | 5550 | - | Database admin (dev only) |
This project uses API keys for authentication to access the Knowledge Base and Admin APIs. There are two types of keys:
- Admin API Key (
ADMIN_API_KEY) β Used for administrative actions, such as creating or revoking other API keys. - API Key β Generated via the Admin API to access the Knowledge Base endpoints.
- Your
ADMIN_API_KEYis defined in your.envfile. - To perform administrative tasks, include it in the
Authorizationheader:
Authorization: Admin-API-Key <your_admin_api_key>Example: Create a new API key via Admin endpoint
curl -X POST http://localhost:8100/api/v1/api-key \
-H "Authorization: Admin-Key sk_xxxxxxx" \
-H "Content-Type: application/json" \
-d '{"name": "app-name", "is_active": true}'- The generated API key is used to access protected Knowledge Base endpoints.
- Include it in the
Authorizationheader:
Authorization: API-Key <your_api_key>Example: Query the Knowledge Base
curl -X GET http://localhost:8100/api/v1/knowledge-base \
-H "Authorization: API-Key sk_xxxxxxx"π For the detail of API-Key usage, please read: SECURITY.md
| Key Type | Header Name | Purpose |
|---|---|---|
| Admin API Key | Authorization: Admin-Key <key> |
Manage API keys and administrative tasks |
| User/API Key | Authorization: API-Key <key> |
Access Knowledge Base and perform CRUD ops |
Once the application is running (uvicorn app.main:app --reload or via Docker), the API documentation is automatically available through FastAPI docs:
- Swagger UI β http://localhost:8000/api/docs or http://localhost:8100/api/docs
- ReDoc β http://localhost:8000/redoc or http://localhost:8100/redoc
From these interfaces, you can:
- Try out endpoints directly
- View request and response schemas
- Test the API interactively
vector-knowledge-base-mcp-server/
βββ main/ # FastAPI application
β βββ app/
β β βββ api/ # API routes (endpoint FastAPI)
β β βββ core/ # Core configuration (settings, logging, security)
β β βββ mcp/ # MCP related files (FastMCP server, tools)
β β βββ models/ # Pydantic models / ORM models
β β βββ schemas/ # API schemas (Pydantic / base)
β β βββ services/ # Business logic / service layer
β β βββ utils/ # Helpers / utilities
β βββ tests/ # Unit / integration tests
β βββ Dockerfile
β βββ requirements.txt
βββ db/
β βββ docker-entrypoint-initdb.d/ # Init SQL scripts
β βββ script/ # Migration / seed
βββ pgadmin4/
β βββ servers.json # GUI config
βββ docker-compose.yml # Compose prod
βββ docker-compose.override.yml # Override dev
βββ .env.example # Env vars
βββ README.md# Check all services
curl http://localhost:8100/health
# Check individual components
curl http://localhost:8101/api/v2/heartbeat # ChromaDB
curl http://localhost:9100/minio/health/live # MinIO- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow PEP 8 style guide
- Add tests for new features
- Update documentation for API changes
- Use conventional commits for commit messages
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: Open an issue on GitHub
- Documentation: Check the
/docsendpoint when server is running - Community: Join our discussions in GitHub Discussions
Built with β€οΈ using FastAPI and FastMCP