Skip to content

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

ParameterTypeRequiredDescription
querystringYesNatural-language question
pathsstring[]NoWiki article paths to ground the answer in (skips master-index navigation, reads those pages in full)
modelstringNoChat model override (defaults to the configured LLM_MODEL)

Return Value

A JSON object:

json
{
  "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
}
FieldTypeDescription
answerstringMarkdown answer with inline [Title](path) citations and a Sources: footer
sourcesarrayStructured list of cited articles (title + path)
cost_usdnumberEstimated 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.

bash
kb-ai mcp [--kb-dir /path/to/data]

Claude Code setup:

bash
claude mcp add kaas -- kb-ai mcp --kb-dir /path/to/data

Environment variables required:

VariableDescription
KAAS_KB_DIRKnowledge-base root (or use --kb-dir flag)
LLM_API_KEYLLM provider API key
LLM_BASE_URLLLM provider base URL
LLM_MODELModel name

streamable-http (remote)

Published through the Go backend at /mcp when [ai.mcp] enabled = true.

URL: http://<host>:8080/mcp

Claude Code setup:

bash
claude mcp add --transport http kaas http://host:8080/mcp

Authentication: 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:

toml
[ai.mcp]
enabled = false          # set true to expose /mcp endpoint
token = ""               # bearer token (empty = no auth)
timeout_sec = 120        # tools/call timeout in seconds

Environment variable overrides:

VariableDescriptionDefault
KAAS_MCP_ENABLEDEnable the /mcp endpointfalse
KAAS_MCP_TOKENBearer token for authentication(empty = no auth)

How It Works

  1. The client sends a tools/call request with name: "ask" and the query parameters.
  2. 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.
  3. An LLM generates an answer with inline [Title](path) citations.
  4. The complete answer (with a Sources: footer) and structured source list are returned as the tool result.