Content
# MaxKB MCP Server
MaxKB's MCP (Model Context Protocol) service, supporting access to MaxKB knowledge base via SSE or stdio.
## Features
- **list_knowledge_bases** - List all knowledge bases
- **get_knowledge_base_info** - Get knowledge base details
- **search_knowledge_base** - Search knowledge base content (supporting vector search and keyword search)
## Installation
```bash
pip install -r requirements.txt
```
## Configuration
Edit `.env` file:
```env
# MaxKB API Configuration
MAXKB_BASE_URL=https://mk2.lovekd.top:20000
MAXKB_API_KEY=your-api-key
# MaxKB Workspace Configuration
MAXKB_WORKSPACE_ID=default
# MCP Server Configuration
MCP_SERVER_NAME=maxkb-knowledge-base
MCP_SERVER_VERSION=0.1.0
# Transport Configuration
# Options: stdio, sse
MCP_TRANSPORT=sse
MCP_HOST=0.0.0.0
MCP_PORT=3000
```
## Running Modes
### Mode 1: SSE Mode (Recommended)
```bash
python -m src
```
After service starts:
- SSE endpoint: `http://0.0.0.0:3000/sse`
- Message endpoint: `http://0.0.0.0:3000/messages/`
### Mode 2: stdio Mode
```bash
python -m src
```
(Requires setting `MCP_TRANSPORT=stdio`)
## External System Configuration
### Claude Desktop Configuration
```json
{
"mcpServers": {
"maxkb": {
"command": "python",
"args": ["-m", "src"],
"cwd": "/path/to/maxkb_mcpserver",
"env": {
"MAXKB_BASE_URL": "https://mk2.lovekd.top:20000",
"MAXKB_API_KEY": "your-api-key",
"MCP_TRANSPORT": "stdio"
}
}
}
}
```
## Project Structure
```
maxkb_mcpserver/
├── src/
│ ├── __init__.py
│ ├── __main__.py # Entry file
│ ├── server.py # MCP Server implementation
│ ├── client.py # MaxKB API client
│ ├── config.py # Configuration management
│ └── models.py # Data models
├── .env # Environment variable configuration
├── requirements.txt # Dependency list
└── README.md # This file
```
## Testing
```bash
# Test knowledge base list
python -c "import asyncio; from src.client import MaxKBClient; c = MaxKBClient(); print(asyncio.run(c.list_knowledge_bases()))"
# Test search
python test_search2.py
```
## Prompt Templates
See `prompt_external.md` file for complete MCP call prompt templates.
## Notes
1. Ensure MaxKB API Key is valid
2. Ensure firewall allows access to port 3000 (SSE mode)
3. It is recommended to call `list_knowledge_bases` to get knowledge base list for the first use