MCP Server
KaaS exposes a Model Context Protocol server that lets any MCP-capable client (Claude Code, Codex, openclaw, etc.) query the compiled wiki through a single ask tool.
Tool: ask
Ask the compiled KaaS wiki a question. Returns a cited Markdown answer grounded in the wiki articles.
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
query | string | Yes | Natural-language question |
paths | string[] | No | Wiki article paths to ground the answer in (skips master-index navigation, reads those pages in full) |
model | string | No | Chat model override (defaults to the configured LLM_MODEL) |
Return Value
A JSON object:
{
"answer": "Markdown text with inline [Title](path) citations...\n\nSources:\n- [Article Title](wiki/path.md)",
"sources": [
{"title": "Article Title", "path": "wiki/path.md"}
],
"cost_usd": 0.003
}| Field | Type | Description |
|---|---|---|
answer | string | Markdown answer with inline [Title](path) citations and a Sources: footer |
sources | array | Structured list of cited articles (title + path) |
cost_usd | number | Estimated LLM cost for this query |
Transports
stdio (default)
The client spawns the MCP server as a child process. Fully self-contained — no network surface, no authentication required.
kb-ai mcp [--kb-dir /path/to/data]Claude Code setup:
claude mcp add kaas -- kb-ai mcp --kb-dir /path/to/dataEnvironment variables required:
| Variable | Description |
|---|---|
KAAS_KB_DIR | Knowledge-base root (or use --kb-dir flag) |
LLM_API_KEY | LLM provider API key |
LLM_BASE_URL | LLM provider base URL |
LLM_MODEL | Model name |
streamable-http (remote)
Published through the Go backend at /mcp when [ai.mcp] enabled = true.
URL: http://<host>:8080/mcp
Claude Code setup:
claude mcp add --transport http kaas http://host:8080/mcpAuthentication: When KAAS_MCP_TOKEN is set, clients must include:
Authorization: Bearer <token>Requests without a valid token receive a 401 Unauthorized response.
Configuration
Relevant configuration in etc/kaas.toml:
[ai.mcp]
enabled = false # set true to expose /mcp endpoint
token = "" # bearer token (empty = no auth)
timeout_sec = 120 # tools/call timeout in secondsEnvironment variable overrides:
| Variable | Description | Default |
|---|---|---|
KAAS_MCP_ENABLED | Enable the /mcp endpoint | false |
KAAS_MCP_TOKEN | Bearer token for authentication | (empty = no auth) |
How It Works
- The client sends a
tools/callrequest withname: "ask"and the query parameters. - The MCP server runs the same LLM-iterative retrieval used by the chat API: reads the master index, selects relevant wiki pages, loads full article content.
- An LLM generates an answer with inline
[Title](path)citations. - The complete answer (with a
Sources:footer) and structured source list are returned as the tool result.