# @knolo/mcp `@knolo/mcp` is how an agent consumes knowledge another agent shared. It is a read-only [MCP](https://modelcontextprotocol.io) server for a pinned Knolo V5 Knowledge Image. It exposes `knolo_search`, `knolo_get`, `knolo_verify`, and `knolo_status`, the same four tools as `@knolo/openclaw`. Pins, policy checks, and query receipts come from `@knolo/tools`. When at least one mount includes a `kar` block, the server also exposes `knolo_kar_evaluate`, `knolo_kar_verify`, and `knolo_cortex_verify`. A mount with an empty `kite` block also exposes `knolo_kite_evaluate` and `knolo_kite_verify`. The server speaks stdio only. It does not download images, open a runtime network connection, write or compile knowledge, or expose MCP resources or prompts. Install and pin each image before starting it. A hash, state-root, or policy-root mismatch exits non-zero before the MCP connection starts. Optional mount fields `builtAt`, `sourceDigest`, and `sourceRoots`, plus `grokHome`, let `knolo_status` and `knolo_verify` report a stale source tree. Without those fields the status object stays `imageId`, `stateRoot`, `source`, and `status`. A stale source does not make a matching pin invalid. Caller identity is `agentId` in the config file, default `mcp`. That id must be listed in at least one mount's `agents` array. The CLI exits with `IMAGE_INVALID` before MCP stdio starts when no mount allows it. Tool arguments cannot set it. An optional config `sessionId` is stored on the receipt instead of the MCP client name when it is set. Otherwise the client's `clientInfo.name` is stored as `sessionId`. Neither value is used for authorization. `sessionId` is captured when the process starts. One shared stdio process cannot see a different session id for each chat. One `principal` per mount is what policy evaluation sees. Runtime config reloads still use the startup identity. `knolo_search` lowercases the query. A quoted phrase is one contiguous whole phrase. Unquoted `OR` selects any remaining term. Unquoted stopwords and terms shorter than 3 characters are dropped. A query that drops every term matches nothing. Each kept term must appear as a whole word. `match` is `all`, `any`, `partial`, or `none`. Hits with more matched terms come first, then matches in the path's final segment and the first line, then matches in the rest of the text, then object id. The stopword list is in the [box doc](../../docs/box/README.md). A direct EQL `SEARCH` string is a different matcher: every space-separated term is a substring, in object id order. Every search writes an `openclaw-knolo-query-v1` receipt before it returns hits. The receipt records `match`, `hitCount`, `durationMs`, and the plan. `hitCount` is the number of allowed hits. `durationMs` times the query and the policy check, not the audit write. Verify checks `hitCount` against the stored result and does not replay the clock. Older receipts without those fields still verify. An unwritable `auditDir` returns `AUDIT_UNAVAILABLE` and no hits. Before each tool call, a server started from a config file stats that config, every mounted image, every mount's policy file, and any pinned KAR graph. An unchanged size and modification time keeps the loaded image. A changed file is checked against the pin and policy root in that config. A match replaces the loaded mounts atomically. A mount removed from the config is no longer served, even when its image file is still on disk. A mismatch on an image, policy file, or KAR graph returns `IMAGE_INVALID`, does not serve the previous image on that call, and leaves the previously loaded mounts intact if the config rolls back. A config file that cannot be read fails that call. `agentId`, `sessionId`, and `maxHits` stay at the values from process start. KAR graphs are authorized with that same startup `agentId`. An optional top-level `autoRebuild` object, `{ "command", "args" }`, runs a local command without a shell before `knolo_search` and `knolo_status`. A run is killed after `timeoutMs`, default 60000 and at most 600000, together with the processes it started. A spawn error, a nonzero exit, or a timeout does not fail the call. The installed files are then checked against their pins as above. npm `latest` is `@knolo/mcp@0.2.4`. This tree sets `server.json` and the MCP server version to `0.2.4`. `@knolo/mcp@0.2.3` has no KITE evaluate or verify tools. The published `0.2.1` tarball still reports `0.2.0` in those two fields. A mount without a `kar` block exposes the four tools above. A mount with a `kar` block also exposes `knolo_kar_evaluate`, `knolo_kar_verify`, and `knolo_cortex_verify`. The registry name in `server.json` is `io.github.HiveForensics-AI/knolo`. The official MCP Registry serves that name at `0.2.4`, marked latest, with npm package `@knolo/mcp@0.2.4`: [io.github.HiveForensics-AI/knolo](https://registry.modelcontextprotocol.io/v0/servers?search=io.github.HiveForensics-AI%2Fknolo&version=latest). Published `@knolo/mcp@0.1.0` remains the four-tool server and stays in the Registry as the older version. When a later `@knolo/mcp` npm publish changes `server.json`, publish that same file to the official MCP Registry in the same change. The [Google ADK examples](../../docs/integrations/google-adk.md) start this server over stdio and run one search. The [Microsoft Agent Framework example](../../docs/integrations/microsoft-agent-framework.md) starts it with `MCPStdioTool` and runs one search and one verify. [Python](../../examples/google_adk_python/README.md) and [TypeScript](../../examples/google_adk_js/README.md) both use MCP. The [OpenAI Agents SDK example](../../docs/integrations/openai-agents.md) uses the same server. The [Pydantic AI example](../../docs/integrations/pydantic-ai.md), the [Langflow example](../../docs/integrations/langflow.md), the [Dify example](../../docs/integrations/dify.md), and the [CrewAI example](../../docs/integrations/crewai.md) use the same server. The [Vercel AI SDK example](../../docs/integrations/ai-sdk.md) calls the same service through `@knolo/ai-sdk`. `@knolo/ai-sdk@0.1.1` is published. The [Mastra example](../../docs/integrations/mastra.md) calls the same service through `@knolo/mastra`. `@knolo/mastra@0.1.1` is published. The [OpenAI Agents native tools](../../docs/integrations/openai-agents.md) call the same service through `@knolo/openai-agents`. `@knolo/openai-agents@0.1.1` is published. The [Anthropic Agent Skill](../../docs/integrations/anthropic-skills.md) registers this server from a Claude Code plugin. The stdio image is built from [`packages/mcp/Dockerfile`](Dockerfile) in this repository. It is not on Docker Hub. The container reads `KNOLO_MCP_CONFIG`, does not listen on a port, and runs as a non-root user. A bad pin exits before the server accepts a tool call. An unwritable audit directory returns `AUDIT_UNAVAILABLE` and no hits. Publishing the image and opening the `docker/mcp-registry` pull request are separate steps. The draft catalog entry is [`listings/docker/server.yaml`](listings/docker/server.yaml). The integration note is [Docker](../../docs/integrations/docker.md). The Glama catalog check uses the pinned demo in [`examples/glama`](../../examples/glama/README.md). Its start command is `node examples/glama/start.mjs`. A start with no config still fails closed. The demo server does not listen on a port. [Goose](../../docs/integrations/goose.md) launches this server as a stdio extension. The draft is [`listings/goose/extension.yaml`](listings/goose/extension.yaml). Goose does not receive a URL. The server does not listen on a port. Submitting the extension is a separate pull request. The [awesome-mcp-servers](listings/awesome-mcp-servers.md) line belongs under Knowledge & Memory. It names this package as a local TypeScript server and pins `@knolo/mcp@0.2.4`. There is no badge, because Knolo is not listed there yet. Submitting the line is a separate pull request. ## Policy file Every mount needs a `policyPath`. The file is not free-standing configuration. Its policy root must equal the `policyRoot` committed in the image, so the policy is chosen when the image is built. To change it, build a new image and update the `sha256` and `stateRoot` pins. This script builds a one-chunk image, writes the matching policy file, and prints both pins. It requires `@knolo/core`. ```js import { createHash } from 'node:crypto'; import { writeFileSync } from 'node:fs'; import { createKnowledgeImageV5 } from '@knolo/core'; const policy = { version: 1, default: 'deny', rules: [ { effect: 'allow', action: 'query', principal: 'mcp:reader', kind: 'chunk', }, { effect: 'allow', action: 'read', principal: 'mcp:reader', kind: 'chunk', }, ], }; const image = createKnowledgeImageV5({ policy, objects: [ { kind: 'chunk', bytes: new TextEncoder().encode( 'Annual enterprise refunds are available within 30 days.' ), meta: { namespace: 'support' }, }, ], }); writeFileSync('handbook.knolo', image.bytes); writeFileSync('handbook.policy.json', JSON.stringify(policy, null, 2)); console.log('sha256', createHash('sha256').update(image.bytes).digest('hex')); console.log('stateRoot', image.stateRoot); ``` Use the absolute paths of the two files and the two printed values in the mount, and set its `principal` to `mcp:reader`. | Field | Values | | ----------- | --------------------------------------------------------------- | | `version` | `1` | | `default` | `allow` or `deny`. Applies when no rule matches. | | `rules` | Optional array. | | `effect` | `allow` or `deny`. A matching `deny` overrides every `allow`. | | `action` | `query` for `knolo_search`. `read` for `knolo_get`. | | `principal` | Optional. Compared with the mount's `principal`, not `agentId`. | | `kind` | Optional object kind, such as `chunk`. | JSON formatting and rule order do not change the policy root. A mount with a `kar` block also needs `query` access to `chunk` objects. An image built without a `policy` commits a default-deny root. The file `{ "version": 1, "default": "deny" }` matches it, but allows no access. | Result | Cause | | -------------------------------------------------- | ---------------------------------------------------------------------------------------- | | `IMAGE_INVALID`, "Policy for image ... is invalid" | The file is unreadable, is not a valid policy, or does not match the image `policyRoot`. | | `ACCESS_DENIED` from `knolo_search` | The file matches, and the policy denies every matched object to this `principal`. | | `ACCESS_DENIED` from `knolo_get` | No `read` access to that object for this `principal`. | A search that matches nothing returns no hits, even under a policy that allows no access. The format and its root are specified in [KIP-0008](../../spec/KIP-0008-policy-authorization-v1.md). ## Config Paths are absolute. `sha256` is 64 lowercase hex characters. `stateRoot` is `sha256-` plus 64 lowercase hex characters. ```json { "agentId": "mcp", "auditDir": "/var/lib/knolo/receipts", "mounts": [ { "id": "handbook", "path": "/opt/knolo/handbook.knolo", "sha256": "<64 hex>", "stateRoot": "sha256-<64 hex>", "policyPath": "/opt/knolo/handbook.policy.json", "agents": ["mcp"], "principal": "", "kar": { "graphPath": "/opt/knolo/handbook.kar.json", "graphSha256": "<64 hex>" } } ] } ``` `kar` is optional. `graphSha256` is the raw file SHA-256, 64 lowercase hex characters, without a `sha256-` prefix. The server hashes that file and binds it to the mount before it accepts a connection. A hash or binding mismatch exits before MCP starts. A call for a mount that has no `kar` block fails closed when the three tools are enabled by another mount. `knolo_kar_evaluate` takes `mountId`, `proposition`, and an inline `plan` object of at most 65536 UTF-8 bytes. `SATISFIED` means evidence requirements were met. It does not mean a claim is proven. `UNSATISFIED_EVIDENCE_REQUIREMENTS` is a completed evaluation. The plan is parsed by the KAR plan parser. Domain Pack template names are not accepted. `knolo_kar_verify` takes the same mount, proposition, and plan, plus exactly one of `result` or `dossier`. `knolo_cortex_verify` takes `mountId`, an `answer` trace, and an optional `question`. It uses the pinned graph when the trace references KAR or its image identity has a `knowledgeRoot`. A Cortex session with a bound graph records that root even when no KAR evaluation ran. These tools do not call a model and do not run `askCortex`. `kite` is an empty object. It does not pin a file. `knolo_kite_evaluate` takes `mountId`, an inline `knolo-kite-contract-1` contract, and inline rules, plus optional completeness, changes, bounds, graph, question, and `asOf`. `knolo_kite_verify` takes those same fields and a certificate. The image is the pinned mount. Each JSON argument is at most 65536 UTF-8 bytes. A caller may lower a KITE bound and may not raise one. `BOUND_EXCEEDED` returns no certificate. A verdict describes that contract. It does not describe real-world truth. `SATISFIED` is a KAR word. A matching certificate is an integrity check. It does not mean the claim is true. A mount without `kite` is rejected when another mount enabled the tools. The receipt is the same `knolo-mcp-evidence-receipt-v1` record, with `graphSha256` set only when a graph was supplied. Query receipts stay `openclaw-knolo-query-v1`. KAR and Cortex tools write `knolo-mcp-evidence-receipt-v1` in `auditDir` before they return a result. An unwritable audit directory returns `AUDIT_UNAVAILABLE` and no result. ### Limits Six optional top-level fields bound what one server reads, returns, and keeps. Each is a positive integer. A value above its maximum is `IMAGE_INVALID` at startup. | Field | Default | Maximum | Bounds | | ----------------- | --------------------- | --------------------- | ---------------------------------------------- | | `maxHits` | `8` | `1000` | Hits returned by one `knolo_search` | | `maxExcerptBytes` | `1600` | `65536` | UTF-8 bytes of one search excerpt or one `get` | | `maxQueryBytes` | `4096` | `16384` | UTF-8 bytes of one `knolo_search` query | | `maxImageBytes` | `262144000` (250 MiB) | `536870912` (512 MiB) | Size of each mounted image file | | `maxAuditRecords` | `10000` | `1000000` | Receipt files kept in `auditDir` | | `maxAuditBytes` | `268435456` (256 MiB) | `1073741824` (1 GiB) | Total bytes of receipt files in `auditDir` | A `knolo_search` `limit` above `maxHits` is lowered to `maxHits`. It is not an error. Without `limit`, a search returns up to `maxHits` hits. The query is measured after NFKC normalization and whitespace collapsing. A longer query is `QUERY_INVALID`. `knolo_get` returns at most `maxExcerptBytes` from `start`. The result `end` is where the excerpt stopped. It can be less than the requested `end`, and it never splits a UTF-8 character. Call `knolo_get` again with `start` set to that `end` to read the rest. An image file larger than `maxImageBytes` is `IMAGE_UNAVAILABLE`. At startup the process exits. When a rebuilt image grows past the limit, the next tool call that reloads it returns `IMAGE_UNAVAILABLE`. Receipt retention deletes receipts. Before each receipt is written, the server removes the oldest receipt files in `auditDir`, by modification time, until the new one fits under both `maxAuditRecords` and `maxAuditBytes`. Query receipts (`qr_`) and KAR, Cortex, and KITE evidence receipts (`er_`) share that one budget. A removed receipt can no longer be verified and returns `NOT_FOUND`. Copy receipts out of `auditDir` before they age out if they must stay verifiable. A single receipt larger than `maxAuditBytes` returns `AUDIT_UNAVAILABLE` and no result. Start it with `knolo-mcp --config /absolute/knolo-mcp.json` or `KNOLO_MCP_CONFIG`. Logs go to stderr. Stdout is JSON-RPC only. ## Clients Pin the image and write `knolo-mcp.json` first. The file hash, the `stateRoot` from `knolo verify`, and a working config are in [llms-install.md](llms-install.md). Claude Desktop, Claude Code, and Cursor: ```json { "mcpServers": { "knolo": { "command": "npx", "args": ["-y", "@knolo/mcp@0.2.4", "--config", "/absolute/knolo-mcp.json"] } } } ``` Claude Desktop reads this block from `claude_desktop_config.json`: - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json` - Windows: `%APPDATA%\Claude\claude_desktop_config.json` Add `knolo` under the existing `mcpServers` key if the file already has one. Quit Claude Desktop fully and start it again. The server list is read only at startup. The Cursor plugin in [`plugins/cursor-knolo`](../../plugins/cursor-knolo) starts `npx -y @knolo/mcp@0.2.4 --config ${KNOLO_MCP_CONFIG}`. A missing config fails closed. The server does not listen on a port. Claude Code CLI: ```sh claude mcp add knolo -- npx -y @knolo/mcp@0.2.4 --config /absolute/knolo-mcp.json ``` `claude mcp list` shows `knolo` and its connection state. Inside a session, `/mcp` lists the server and its tools. VS Code (`.vscode/mcp.json`): ```json { "servers": { "knolo": { "type": "stdio", "command": "npx", "args": [ "-y", "@knolo/mcp@0.2.4", "--config", "${workspaceFolder}/knolo-mcp.json" ] } } } ``` Cline uses the same stdio server. The file hash, `knolo verify`, and the Cline settings block are in [llms-install.md](llms-install.md). The published server pin is `@knolo/mcp@0.2.4`. The CLI pin for `stateRoot` is `@knolo/cli@6.2.11`. Pins, the policy file, and the audit directory stay in the config. ```json { "mcpServers": { "knolo": { "command": "npx", "args": ["-y", "@knolo/mcp@0.2.4", "--config", "/absolute/knolo-mcp.json"] } } } ``` The 400×400 listing logo is [logo.png](https://raw.githubusercontent.com/HiveForensics-AI/knolo-core/main/packages/mcp/listings/cline/logo.png). The marketplace submission is [cline/mcp-marketplace#3696](https://github.com/cline/mcp-marketplace/issues/3696). Codex CLI installs this server from the repository marketplace: ```sh codex plugin marketplace add HiveForensics-AI/knolo-core ``` The plugin is `codex-knolo`. It starts `npx -y @knolo/mcp@0.2.4 --config ${KNOLO_MCP_CONFIG}`. A missing `KNOLO_MCP_CONFIG` fails closed. The server does not listen on a port. Continue loads this server from `.continue/mcpServers/knolo.yaml` or from `~/.continue/config.yaml`. The draft block is [`listings/continue/knolo.yaml`](listings/continue/knolo.yaml). The integration note is [Continue](../../docs/integrations/continue.md). MCP tools load only in Continue agent mode. Replace `/absolute/knolo-mcp.json` with the absolute path of `knolo-mcp.json`. A missing or invalid config fails closed. The server does not listen on a port. Publishing the block to Continue Hub is a separate account step. ```yaml name: Knolo version: 0.0.1 schema: v1 mcpServers: - name: Knolo type: stdio command: npx args: - '-y' - '@knolo/mcp@0.2.4' - '--config' - /absolute/knolo-mcp.json ``` OpenCode loads this server from `mcp.servers.knolo` in `opencode.json`. The example is [`examples/opencode/opencode.json`](../../examples/opencode/opencode.json). The integration note is [OpenCode](../../docs/integrations/opencode.md). `codemode` is `false`. Replace `/absolute/knolo-mcp.json` with the absolute path of `knolo-mcp.json`. A missing or invalid config fails closed. The server does not listen on a port. ```sh opencode mcp add knolo -- npx -y @knolo/mcp@0.2.4 --config /absolute/knolo-mcp.json ``` Kilo Code loads this server from `mcp.servers.knolo` in `kilo.jsonc`. The example is [`examples/kilo/kilo.jsonc`](../../examples/kilo/kilo.jsonc). The integration note is [Kilo Code](../../docs/integrations/kilo-code.md). `codemode` is `false`. Replace `/absolute/knolo-mcp.json` with the absolute path of `knolo-mcp.json`. A missing or invalid config fails closed. The server does not listen on a port. The CLI, VS Code, and JetBrains clients read that same file. OpenHands loads this server from `mcpServers.knolo` in `mcp_config`. Agent Canvas uses the same command under Customize > MCP Servers. The example is [`examples/openhands/mcp_config.json`](../../examples/openhands/mcp_config.json). The integration note is [OpenHands](../../docs/integrations/openhands.md). Replace `/absolute/knolo-mcp.json` with the absolute path of `knolo-mcp.json`. The path and the pinned image must be readable inside the sandbox. A missing or invalid config fails closed. The server does not listen on a port. Gemini CLI loads this server from `mcpServers.knolo` in [`examples/gemini/gemini-extension.json`](../../examples/gemini/gemini-extension.json). The gallery copy of that manifest is `gemini-extension.json` at the repository root. It declares `KNOLO_MCP_CONFIG` and does not pass `--config`. Antigravity CLI, the Antigravity App, and the Antigravity IDE load the command from `mcpServers.knolo` in [`examples/antigravity/mcp_config.json`](../../examples/antigravity/mcp_config.json). The integration note is [Gemini CLI and Antigravity CLI](../../docs/integrations/gemini-cli.md). Replace `/absolute/knolo-mcp.json` with the absolute path of `knolo-mcp.json` when you paste the Antigravity command. A missing or invalid config fails closed. The server does not listen on a port. Zed loads this server from `context_servers.knolo` in [`examples/zed/settings.json`](../../examples/zed/settings.json). The integration note is [Zed](../../docs/integrations/zed.md). The `args` array is required. Replace `/absolute/knolo-mcp.json` with the absolute path of `knolo-mcp.json`. A missing or invalid config fails closed. The server does not listen on a port. AnythingLLM loads this server from `mcpServers.knolo` in `plugins/anythingllm_mcp_servers.json`. The sample is [`examples/anythingllm/anythingllm_mcp_servers.json`](../../examples/anythingllm/anythingllm_mcp_servers.json). Desktop storage is under `anythingllm-desktop/storage` on macOS, Linux, and Windows. Docker reads the same file from `STORAGE_LOCATION` and reaches it at `/app/server/storage`. Mount the Knowledge Image and `knolo-mcp.json` into the container, and use those in-container absolute paths. A missing or relative path fails closed. The server does not listen on a port. LobeHub can install this server from [`lhm.plugin.json`](../../lhm.plugin.json). The command is `npx -y @knolo/mcp@0.2.4 --config ${KNOLO_MCP_CONFIG}`. `KNOLO_MCP_CONFIG` is required. A missing config fails closed. The server does not listen on a port. Publishing the listing is a separate maintainer step. The package requires Node 20 or newer, `@knolo/core` `^6.2.1`, and `@knolo/tools` `^0.2.2`. Coverage, composition, and authoring stay outside this server. Verification checks integrity. It does not decide that a claim or an answer is true. ## Troubleshooting Errors print as `CODE: message`. A startup error goes to stderr as `knolo-mcp: CODE: message` and the process exits 1 before MCP starts. A tool error is returned as the tool result. Server not listed or not connected: run the configured command by hand to see stderr. ```sh npx -y @knolo/mcp@0.2.4 --config /absolute/knolo-mcp.json ``` A working server prints `knolo-mcp: serving stdio` and waits on stdin. Stop it with Ctrl+C. In Claude Desktop, check that `claude_desktop_config.json` is valid JSON and restart the app after each change. `claude mcp add` uses local scope by default, so the server is listed only in the directory where it was added. Add `--scope user` to list it in every directory. Config path errors: - `QUERY_INVALID: Set --config or KNOLO_MCP_CONFIG to an absolute config path.` Neither the flag nor the variable is set. - `QUERY_INVALID: Knolo MCP config path must be absolute.` JSON client blocks do not expand `~` or relative paths. - `IMAGE_UNAVAILABLE: Could not read Knolo MCP config: ...` The file is missing or not readable by the client's user. - `IMAGE_INVALID: Knolo MCP config is invalid: ...` The message names the field, for example a relative `auditDir` or a malformed `sha256`. Error codes: | Code | Cause | | --------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | | `IMAGE_INVALID` | Invalid config, the image does not match its `sha256` or `stateRoot` pin, or the policy file cannot be read or its root mismatches | | `IMAGE_UNAVAILABLE` | The config or image file cannot be read, or the requested image is not mounted | | `ACCESS_DENIED` | `agentId` is not in the mount's `agents`, or the policy denies the mount's `principal` | | `AUDIT_UNAVAILABLE` | `auditDir` is not writable. No hits are returned | | `STATE_ROOT_MISMATCH` | The image is no longer mounted at the requested or recorded state root | | `NOT_FOUND` | The requested object or receipt does not exist | | `QUERY_INVALID` | Invalid command-line or tool arguments | For a pin mismatch, hash the image and run `knolo verify` again as shown in [llms-install.md](llms-install.md), then update `sha256` and `stateRoot`.