Query server for ewankb knowledge bases — MCP + HTTP interface.
Project description
ewan-kb-server
Query server for ewankb knowledge bases, providing MCP (Model Context Protocol) and HTTP interfaces.
Why
ewankb queries currently run as CLI subprocesses, which means every query re-loads the graph, BM25 index, and jieba tokenizer from scratch. This server keeps them in memory, eliminating cold-start overhead and enabling sub-second queries.
Architecture
- MCP server — primary interface for Claude Code and other MCP clients. Two tools:
query_graphandquery_kb, pluslist_kbsfor discovery. - HTTP server — debug interface bound to
127.0.0.1. REST endpoints mirror the MCP tools for easy curl/browser testing. - Multi-KB support — serve multiple knowledge bases simultaneously. Each KB is pre-loaded at startup. Specify which KB to query via the
kbparameter. - Build stays with CLI — knowledge base construction is still done via
ewankb build. After rebuilding, restart the server to reload the updated graph and index.
Install
pip install ewan-kb-server
This also installs ewankb as a dependency.
Configure
Create a config file at ~/.config/ewankb-server/config.toml:
[server]
port = 3000
host = "127.0.0.1"
[kbs.default]
name = "default"
dir = "/path/to/your/knowledge-base"
[kbs.wms]
name = "wms"
dir = "/path/to/wms-knowledge-base"
Or copy the example:
mkdir -p ~/.config/ewankb-server
cp config.example.toml ~/.config/ewankb-server/config.toml
Config file search order:
--configCLI argumentEWANKB_SERVER_CONFIGenvironment variable~/.config/ewankb-server/config.toml(default)
Run
MCP mode (for Claude Code)
ewankb-server
Runs as a stdio MCP server. Add to your Claude Code MCP settings:
{
"mcpServers": {
"ewankb-server": {
"command": "ewankb-server",
"args": []
}
}
}
HTTP mode (for debugging)
ewankb-server --transport http --port 3000
Then test with curl:
# List available KBs
curl http://127.0.0.1:3000/kbs
# Query graph
curl "http://127.0.0.1:3000/query/graph?text=付款额度怎么计算&kb=default"
# Query KB documents
curl "http://127.0.0.1:3000/query/kb?text=付款额度&kb=default&domain=收付款管理"
# Health check
curl http://127.0.0.1:3000/health
MCP Tools
query_graph
Query the knowledge graph for code relationships and semantic connections.
| Parameter | Type | Default | Description |
|---|---|---|---|
| query_text | string | required | Natural language query |
| kb | string | "default" | Knowledge base name |
| traversal | string | "bfs" | "bfs" for overview, "dfs" for path tracing |
| max_nodes | int | 50 | Maximum nodes to visit |
query_kb
Search knowledge base documents using BM25 keyword ranking.
| Parameter | Type | Default | Description |
|---|---|---|---|
| query_text | string | required | Search keywords or question |
| kb | string | "default" | Knowledge base name |
| max_results | int | 8 | Maximum documents to return |
| domain | string | "" | Optional domain filter |
list_kbs
List all available knowledge bases with status (node count, edge count, document count).
Development
cd ewan-kb-server
pip install -e .
ewankb-server --transport http --port 3000
Rebuilding Knowledge Bases
After running ewankb build to update a knowledge base, restart the server:
# Rebuild the KB (using ewankb CLI)
cd /path/to/knowledge-base
ewankb build
# Restart the server to reload
ewankb-server # or kill + restart if running in background
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ewan_kb_server-0.1.1.tar.gz.
File metadata
- Download URL: ewan_kb_server-0.1.1.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e432cc8791fbf4581ad5f5ef44dcd3b6104ca6cb578f1446fa360fdef3581f95
|
|
| MD5 |
1befe859bd0747000a923a3962feafcc
|
|
| BLAKE2b-256 |
90e3672a1880f82e23b8cd179fb87550110101f68cdc9a3308b05a6f09494e7f
|
File details
Details for the file ewan_kb_server-0.1.1-py3-none-any.whl.
File metadata
- Download URL: ewan_kb_server-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e6fe8fd6a97500a0d94ce8e768206afb114eccfd4f1bcdd44fb96b20c0bd68ef
|
|
| MD5 |
9d63fe735f85adf4e56e76883a5e8033
|
|
| BLAKE2b-256 |
9fceeda2869e9c9319f9e32e5e2a3ca393d49c4a2a27bb7eacabfda591d0d1fd
|