> ## Documentation Index
> Fetch the complete documentation index at: https://llmwiki.atomicstrata.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# llmwiki serve - MCP Server for AI Agent Integration

> llmwiki serve starts an MCP server exposing the full compile pipeline to Claude Desktop, Cursor, Claude Code, and any MCP-compatible agent.

`llmwiki serve` turns your compiled wiki into a live capability for AI agents. It starts an [MCP (Model Context Protocol)](https://modelcontextprotocol.io) server over stdio, exposing the full llmwiki pipeline as structured tools and read-only resources that any MCP-compatible client can call.

With the server running, an agent can ingest new sources, trigger a compile, query the wiki for grounded answers, retrieve citation-aware context packs, run quality checks, and read individual pages - all without touching the CLI or parsing terminal output. Read-only tools work immediately with no credentials; tools that call an LLM check for a configured provider on each invocation.

***

## Syntax

```bash theme={null}
llmwiki serve                        # serve the current directory
llmwiki serve --root /path/to/wiki   # serve a specific project root
```

The server uses stdio transport. It starts immediately and doesn't require LLM credentials at startup - only tools that make LLM calls validate credentials lazily when they're invoked.

***

## Client configuration

To connect Claude Desktop, Cursor, or Claude Code, add llmwiki to your MCP client's server configuration:

```json theme={null}
{
  "mcpServers": {
    "llmwiki": {
      "command": "npx",
      "args": ["llm-wiki-compiler", "serve", "--root", "/path/to/wiki-project"],
      "env": {
        "ANTHROPIC_API_KEY": "sk-ant-..."
      }
    }
  }
}
```

For Claude Desktop this goes in `claude_desktop_config.json`. For Cursor, add it to your MCP settings file. The `env` block is where you supply your LLM provider credentials - the server process inherits them from there.

<Tip>
  If you're using the `claude-agent` provider with a local Claude Code login, you can omit `ANTHROPIC_API_KEY` from the `env` block. Set `LLMWIKI_PROVIDER=claude-agent` instead and the server will authenticate through your existing Claude Code session.
</Tip>

***

## MCP tools

The server registers 11 tools. Read-only tools work without credentials; tools that invoke the LLM pipeline validate provider configuration on each call.

| Tool | What it does | LLM credentials needed? |
| - | - | - |
| `ingest_source` | Fetch a URL or copy a local file into `sources/`. Returns the saved filename, character count, and whether content was truncated. | No |
| `compile_wiki` | Run the incremental compile pipeline: extract concepts from new/changed sources, generate wiki pages, resolve interlinks, rebuild the index. Returns page counts, slugs, and errors. | Yes |
| `query_wiki` | Ask a natural-language question. Returns an answer and advisory citations. `save: true` requests publication after fresh citation validation and the profile gate; a refusal preserves the answer with `publicationRefusal` and no `saved` slug. No review option. Set `debug: true` for retrieval detail. See [publication policy](/cli/query#publication-and-review-policy). | Yes |
| `search_pages` | Return full content of pages relevant to a question. Uses semantic embeddings when available, falls back to LLM-based selection over the wiki index. | Yes |
| `read_page` | Read a single wiki page by slug. Searches `concepts/` first, then `queries/`. Returns parsed frontmatter and body. | No |
| `lint_wiki` | Run rule-based quality checks (broken wikilinks, orphans, duplicates, empty pages, broken citations). Returns structured diagnostics. | No |
| `wiki_status` | Summarize the wiki: page count, source count, last compile time, stale/orphaned pages, `stateStatus`, and `pendingCandidates` queue depth. Lists are capped at 100 entries; `*Count` fields give true totals. | No |
| `get_context_pack` | Build an agent-ready evidence pack: primary pages, semantic chunks, graph neighbors, citations, per-page freshness, warnings, and suggested actions. Same v1 JSON envelope as `llmwiki context --json`. | No (uses lexical fallback when embeddings are unavailable) |
| `run_eval` | Score wiki quality. `fast` suite checks health and citation coverage without LLM calls. `full` suite also LLM-judges a sample of citations. Set `record: true` to persist results to eval history. | `full` suite only |
| `export_okf` | Export the wiki as an Open Knowledge Format bundle. The optional output directory is confined under the project root. | No |
| `import_okf` | Preview or stage an Open Knowledge Format bundle as review candidates. The bundle directory must be inside the project root; no trusted live-write mode is exposed over MCP. | No |

### `get_context_pack` vs. `query_wiki`

These two tools serve different purposes:

* **`get_context_pack`** packages evidence. It assembles a structured pack of relevant pages, semantic chunks, graph neighbors, and citations for the agent to reason over directly. It doesn't generate any prose.
* **`query_wiki`** generates answers. It runs the full two-step retrieval and answer pipeline, returning a grounded natural-language response with citations.

Use `get_context_pack` when you want the agent to do its own reasoning with full source visibility. Use `query_wiki` when you want a ready-made answer.

### `includeSources` opt-in

`get_context_pack` supports an `includeSources: true` parameter that materializes raw source text snippets alongside the primary page citations. This opt-in is disabled by default because it can return content from files under `sources/`.

```json theme={null}
{
  "tool": "get_context_pack",
  "arguments": {
    "prompt": "How does the two-phase compile pipeline work?",
    "includeSources": true
  }
}
```

Path confinement prevents reads outside the `sources/` directory, but only enable source windows for agents you trust with the ingested source text.

### Checking the review queue

`wiki_status` includes a `pendingCandidates` field with the current count of pages waiting in the review queue. Agents can poll this field to decide whether to prompt the user to run `llmwiki review list` before continuing.

### Importing OKF through MCP

`import_okf` is intentionally staging-only. Agents can preview a bundle with `dryRun`, or stage it for human review, but cannot bypass review and write imported knowledge directly into `wiki/`. Use `llmwiki review list/show/approve` to inspect and approve staged imports.

***

## MCP resources

The server exposes 7 read-only resources under the `llmwiki://` URI scheme. MCP clients can attach these as passive context without invoking a tool.

| URI | Returns |
| - | - |
| `llmwiki://index` | Full content of `wiki/index.md` - the auto-generated table of contents. |
| `llmwiki://concept/{slug}` | A single concept page from `wiki/concepts/` - parsed frontmatter plus body. |
| `llmwiki://query/{slug}` | A single saved query page from `wiki/queries/` - parsed frontmatter plus body. |
| `llmwiki://sources` | List of ingested source files with frontmatter metadata (filename, truncation flag, source URL, etc.). |
| `llmwiki://state` | Compilation state from `.llmwiki/state.json` - per-source content hashes, live concept slugs, and last compile times. |
| `llmwiki://eval/report` | The most recent eval report - health score, citation coverage, corpus stats. |
| `llmwiki://eval/history` | Trend of past eval runs from `history.jsonl`. |

***

## `llmwiki next`

When an agent needs to know what to do next but doesn't want to parse terminal output, `llmwiki next` is the right tool:

```bash theme={null}
llmwiki next           # print a human-readable recommendation
llmwiki next --json    # emit a stable JSON envelope for agent consumption
```

`llmwiki next` reads the current project state - including the lint cache, pending source changes, and review queue depth - and recommends the single most useful next action. With `--json`, the output is a stable envelope with a `command` field, an `args` array, and a `reason` string, so an agent can execute the recommendation programmatically without parsing prose.

<Note>
  `llmwiki next` is read-only. It never modifies the workspace. It's safe to call as a status check at any point in an agent workflow.
</Note>

***

For a full walkthrough of connecting llmwiki to Claude Desktop, Cursor, and Claude Code - including multi-project setups and agent workflow patterns - see the [MCP Agent Integration guide](/guides/mcp-agent-integration).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.