Skip to main content

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_graph and query_kb, plus list_kbs for 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 kb parameter.
  • 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:

  1. --config CLI argument
  2. EWANKB_SERVER_CONFIG environment variable
  3. ~/.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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ewan_kb_server-0.1.1.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ewan_kb_server-0.1.1-py3-none-any.whl (8.7 kB view details)

Uploaded Python 3

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

Hashes for ewan_kb_server-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e432cc8791fbf4581ad5f5ef44dcd3b6104ca6cb578f1446fa360fdef3581f95
MD5 1befe859bd0747000a923a3962feafcc
BLAKE2b-256 90e3672a1880f82e23b8cd179fb87550110101f68cdc9a3308b05a6f09494e7f

See more details on using hashes here.

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

Hashes for ewan_kb_server-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e6fe8fd6a97500a0d94ce8e768206afb114eccfd4f1bcdd44fb96b20c0bd68ef
MD5 9d63fe735f85adf4e56e76883a5e8033
BLAKE2b-256 9fceeda2869e9c9319f9e32e5e2a3ca393d49c4a2a27bb7eacabfda591d0d1fd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page