Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

docs(developing): document loadable modules and mcp server

Steven Enamakel949af8d019ad
diff --git a/gitbooks/developing/loadable-modules.md b/gitbooks/developing/loadable-modules.md
index f92d0dae8c..0bbe97332c 100644
--- a/gitbooks/developing/loadable-modules.md
+++ b/gitbooks/developing/loadable-modules.md
@@ -1,19 +1,19 @@
---
description: >-
- How capability arrives at runtime instead of compile time: the TinyBus module
- ABI, the pinned registry, admission checks, and what happens when one faults.
+ How OpenHuman loads optional native modules at runtime: the registry,
+ admission checks and what happens when a module faults.
icon: puzzle-piece
---
# Loadable modules
-Feature gates decide what compiles into the binary. Modules decide what the binary can *reach* once it is running. A module is a first-party native library, loaded into the core process, serving a small typed interface over TinyBus.
+Feature gates decide what compiles into the binary. Modules decide what the running binary can reach. A module is a first-party native library, loaded into the core process, that serves a small typed interface over TinyBus.
-The trade is explicit: a module shares the core's address space and its crash domain, so it is trusted code and the admission checks matter. In exchange, a user who never generates a document never pays for the document writer, in download size, in resident memory, or in dependency surface.
+The trade is explicit. A module shares the core's address space and crash domain, so it is trusted code and the admission checks matter. In return, a user who never generates a document never pays for the document writer in download size, memory or dependencies.
## The registry
-`crates/openhuman-core/src/modules/registry/` compiles in **fourteen** records. Only this registry may select an artifact; nothing reads a module name from config and goes looking.
+`crates/openhuman-core/src/modules/registry/` compiles in fourteen records. Only this registry may select an artifact. Nothing reads a module name from config and goes looking for it.
| Module | Provides |
| --- | --- |
@@ -30,13 +30,13 @@ The trade is explicit: a module shares the core's address space and its crash do
| `tinychannels` | Messaging channel transports |
| `tinyhosts` | Hosting provider operations |
-Each record carries a version, the release it came from, and one **`PlatformAsset` per supported build**: thirteen of the fourteen publish eleven (`ubuntu-24.04` and `ubuntu-22.04` × `x86_64`/`arm64`, `macos-26` and `macos-15` × `arm64`/`x86_64`, `windows-2025-x86_64`, `windows-2022-x86_64`, `windows-11-arm64`), and `tinycomputer` publishes seven because it has no Linux backend.
+Each record carries a version, the release it came from, and one `PlatformAsset` per supported build. Thirteen of the fourteen publish eleven builds: `ubuntu-24.04` and `ubuntu-22.04` on `x86_64` and `arm64`, `macos-26` and `macos-15` on `arm64` and `x86_64`, `windows-2025-x86_64`, `windows-2022-x86_64` and `windows-11-arm64`. `tinycomputer` publishes seven because it has no Linux backend.
-Every asset carries a SHA-256 **copied verbatim from the published release's own checksum file**. Do not compute a replacement pin from a local build: the point of the digest is that it describes the artifact the release workflow signed, not the one on your machine.
+Every asset carries a SHA-256 copied verbatim from the published release's own checksum file. Do not compute a replacement pin from a local build. The digest must describe the artifact the release workflow signed, not the one on your machine.
## Resolution order
-Each step exists to avoid the cost of the next:
+Each step avoids the cost of the next:
1. Already serving on the host's broker.
2. An operator override: a path in `[modules].overrides`, or a `*_TEST_MODULE` environment variable.
@@ -44,28 +44,28 @@ Each step exists to avoid the cost of the next:
4. Bundled releases staged into the app at build time.
5. The release cache, downloading only if `[modules].allow_download` is true.
-An override **bypasses the digest check**, because the artifact is whatever is at that path. That is acceptable only because it is the operator's own file named by the operator's own config, and it is why the block cannot *add* a module that is not already in the registry.
+An override bypasses the digest check, because the artifact is whatever sits at that path. That is acceptable only because it is the operator's own file, named in the operator's own config. It also means an override cannot add a module that is not already in the registry.
-Platform candidates are ordered newest-first with fallthrough. On Linux, glibc 2.39 or newer prefers the 24.04 build and falls back to 22.04; 2.35 or newer gets 22.04; anything older, and musl or an unknown libc, gets an **empty** candidate list, so no published artifact can load there by design.
+Platform candidates are ordered newest first, with fallthrough. On Linux, glibc 2.39 or newer prefers the 24.04 build and falls back to 22.04. glibc 2.35 or newer gets 22.04. Anything older, plus musl or an unknown libc, gets an empty candidate list, so no published artifact loads there by design.
## Admission
-In order, and all of it before any module code runs:
+These checks run in order, all before any module code runs:
1. Directory ownership and mode, and a regular platform library file within the size cap.
2. The digest allowlist beside the artifact, when present, which is authoritative for its directory.
3. Resolve the ABI descriptor symbol, and validate its frozen 16-byte prefix before reading the rest.
-4. Validate the full descriptor: matching pointer width, endianness and target triple, a compatible TinyBus series, and module feature bits that are a subset of the host's. A module built with `panic = "abort"` is **refused**, because a panic that aborts takes the host with it.
+4. Validate the full descriptor: matching pointer width, endianness and target triple, a compatible TinyBus series, and module feature bits that are a subset of the host's. A module built with `panic = "abort"` is refused, because an aborting panic takes the host down with it.
5. Parse the manifest and resolve dependencies, rejecting missing providers, cycles and name clashes.
6. Initialize, take the vtable, attach the transport.
-Each module declares its interface in its own small `*-bus` contract crate: the interface name, the object path, one constant per member, and a contract version. The bind rule is majors equal **and** the module's minor at least the host's, so a newer module serves an older host and the reverse is refused rather than half-working. Never redeclare a contract type in OpenHuman, and call members through the contract's constants rather than string literals.
+Each module declares its interface in its own small `*-bus` contract crate: the interface name, the object path, one constant per member, and a contract version. The bind rule is that majors are equal and the module's minor is at least the host's. A newer module serves an older host, and the reverse is refused instead of half working. Never redeclare a contract type in OpenHuman, and call members through the contract's constants, not string literals.
## Faults are terminal
-Of the eleven lifecycle states, five are terminal: rejected, faulted, failed, stopped and disabled. A module in one of those answers "unavailable" immediately and is **never retried in the same process**.
+Of the eleven lifecycle states, five are terminal: rejected, faulted, failed, stopped and disabled. A module in one of those answers "unavailable" immediately and is never retried in the same process.
-That is the direct consequence of the other rule: **the loader never unloads a library.** A stopped module releases its transport and its names, but its code, thread-locals, panic metadata and callback addresses stay mapped until the process exits. Replacing an artifact needs a restart. Retrying a faulted module in place would be running code whose invariants you already know are broken.
+This follows from a second rule: the loader never unloads a library. A stopped module releases its transport and its names, but its code, thread-locals, panic metadata and callback addresses stay mapped until the process exits. Replacing an artifact needs a restart. Retrying a faulted module in place would run code whose invariants you already know are broken.
Untrusted code does not belong here. It belongs in a separate process, which is what the sandbox backends are for.
@@ -73,23 +73,23 @@ Untrusted code does not belong here. It belongs in a separate process, which is
```toml
[modules]
-enabled = true # off means the features say so, rather than failing at use
+enabled = true # when off, features report it instead of failing at use
allow_download = true # false suits an air-gapped or reproducible deployment
-# install_dir = "…" # defaults to the user cache dir, then the workspace
+# install_dir = "..." # defaults to the user cache dir, then the workspace
```
-Nothing is downloaded silently either way: the digest comes from the compiled-in registry rather than from the release being fetched.
+Nothing is downloaded silently either way. The digest comes from the compiled-in registry, not from the release being fetched.
-The `modules` RPC namespace exposes `list`, `status` and `load` (by id, never by path), plus `computer_status` and `browser_check_readiness` for the computer module's own readiness, and `browser_forget_sites`, which forgets what browser tasks learned about one site or every site (see [jev.md](jev.md)).
+The `modules` RPC namespace exposes `list`, `status` and `load` (by id, never by path), plus `computer_status` and `browser_check_readiness` for the computer module's readiness. `browser_forget_sites` forgets what browser tasks learned about one site or every site (see [Jev](jev.md)).
## Adding or moving one
-A module's behaviour belongs in the submodule that owns it, not here. The host side is the adapter: the proxy, the config it pushes at initialization, and the policy around the call. When you change a module:
+A module's behavior belongs in the submodule that owns it. The host side is the adapter: the proxy, the config it pushes at initialization and the policy around the call. When you change a module:
1. Land the change upstream and cut a release there.
2. Move the gitlink under `vendor/`.
3. Update the record's version, release URL and digests from that release's checksum file.
-4. Test both the gate-on and gate-off builds, since a leaf gate's absence should mean "absent", not "present and failing".
+4. Test both the gate-on and gate-off builds, because a missing leaf gate should mean the module is absent, not present and failing.
## See also
diff --git a/gitbooks/developing/mcp-server.md b/gitbooks/developing/mcp-server.md
index a2cafb7466..66398a3084 100644
--- a/gitbooks/developing/mcp-server.md
+++ b/gitbooks/developing/mcp-server.md
@@ -1,43 +1,27 @@
---
-description: Run OpenHuman Core as a read-only stdio Model Context Protocol server.
+description: Run OpenHuman Core as a stdio Model Context Protocol server for local MCP clients.
icon: plug
---
-# MCP Server
+# MCP server
-OpenHuman Core can run as an opt-in stdio MCP server for local MCP clients such
-as Claude Desktop, Cursor, or Zed.
+OpenHuman Core can run as an opt-in stdio MCP server. Local MCP clients such as Claude Desktop, Cursor or Zed can then use its search, memory and sub-agent tools.
```bash
openhuman-core mcp
```
-The command does not start the HTTP JSON-RPC server. It reads newline-delimited
-JSON-RPC 2.0 messages from stdin and writes MCP responses to stdout. Logs go to
-stderr; add `--verbose` for debug output.
+The command does not start the HTTP JSON-RPC server. It reads newline-delimited JSON-RPC 2.0 messages from stdin and writes MCP responses to stdout. Logs go to stderr. Add `--verbose` for debug output.
## Client provenance
-During `initialize`, the MCP server captures `params.clientInfo.name` for the
-stdio session. The name is normalized by trimming leading and trailing
-whitespace, converting to lowercase, replacing each sequence of
-non-ASCII-alphanumeric characters with a single hyphen, then trimming leading
-and trailing hyphens. For example, `Claude Desktop` becomes `claude-desktop`,
-`Cursor` becomes `cursor`, and `Windsurf` becomes `windsurf`.
+During `initialize`, the server captures `params.clientInfo.name` for the stdio session. It normalizes the name in four steps: trim whitespace, lowercase, replace each run of non-ASCII-alphanumeric characters with one hyphen, then trim leading and trailing hyphens. `Claude Desktop` becomes `claude-desktop`, `Cursor` becomes `cursor` and `Windsurf` becomes `windsurf`.
-If the client omits `clientInfo.name`, sends an empty value, or sends a name
-that normalizes to nothing, the session falls back to the bare `mcp` source
-label. Write-capable MCP tools should use this session source label for memory
-provenance so old clients keep the existing `mcp` behavior and identifiable
-clients can write as `mcp:<client>`.
+If the client omits `clientInfo.name`, sends an empty value, or sends a name that normalizes to nothing, the session uses the bare `mcp` source label. Write-capable MCP tools use this label for memory provenance. Unidentified clients write as `mcp`, and identifiable clients write as `mcp:<client>`.
## Tools
-The MCP surface routes through the existing controller registry plus the core
-security policy: read tools pass the read gate, and three tools pass the act
-gate. Two of them, `memory.learn` and `memory.forget`, are also recorded on the
-MCP write-audit path; `agent.run_subagent` is not, because the sub-agent's own
-side-effecting calls are audited through the approval gate instead:
+The MCP surface routes through the controller registry and the core security policy. Read tools pass the read gate. Three tools pass the act gate. Two of them, `memory.learn` and `memory.forget`, are also recorded on the MCP write-audit path. `agent.run_subagent` is not, because the sub-agent's own side-effecting calls are audited through the approval gate instead.
| MCP tool | Backing RPC | Purpose |
| ------------------- | ------------------------------------ | ----------------------------------------------------------------------- |
@@ -54,30 +38,22 @@ side-effecting calls are audited through the approval gate instead:
| `agent.list_subagents` | served in-layer | The registered sub-agent definitions the core can dispatch. |
| `agent.run_subagent` | served in-layer | Run a registered sub-agent and return its final response (act-gated). |
-- Tools marked \* are listed only when a provider can serve them: `web_search`
- and `web_answer` when their search role has a usable provider (a signed-in
- session, or a provider with your own key), `searxng_search` when SearXNG is
- enabled in search settings.
-
-`web_search` accepts `query`, optional `max_results` (1-20) and optional
-`provider` (pins one provider and disables fallback). `web_answer` accepts
-`query` and optional `depth` (`quick` or `deep`). `searxng_search` accepts
-`query` and optional `max_results` (1-20).
-`memory.recall` accepts `question` plus optional `filter` and `limit`.
-`memory.fetch` accepts `query` plus optional `mode`, `filter`, `limit` and
-`cursor`; `mode` must be one the active memory engine supports, and both launch
-engines (`tinyhumans`, `cortexdb`) support only `hybrid`, so leave it out
-unless you know otherwise. `memory.list` accepts optional `filter`, `limit` and
-`cursor`. `limit` defaults to 10 and is capped at 100. `filter` takes any of
-`workspace`, `folder`, `file_path`, `language`, `repo`, `commit`, `url`,
-`thread_id`, `agent_id`, `kinds` (`document`, `conversation`, `learning`),
-`sources`, `tags_any`, `observed_after` and `observed_before` (RFC 3339).
-`memory.learn` accepts `text` plus optional `kind` (`preference`, `fact`,
-`procedure`, `correction`, `other`) and `confidence` (0 to 1). `memory.forget`
-accepts `ids` (1 to 100). Memory tools answer `MEMORY_OFF` when no memory engine
-is usable. See [Memory v2](https://github.com/tinyhumansai/openhuman/blob/main/docs/specs/memory-v2.md) for the model.
-
-Enable SearXNG under Connections → Search, in `config.toml`, or via environment:
+Tools marked \* are listed only when a provider can serve them. `web_search` and `web_answer` need a usable provider for their search role, which is a signed-in session or a provider with your own key. `searxng_search` needs SearXNG enabled in search settings.
+
+Arguments:
+
+- `web_search`: `query`, optional `max_results` (1 to 20), and optional `provider` (pins one provider and disables fallback).
+- `web_answer`: `query` and optional `depth` (`quick` or `deep`).
+- `searxng_search`: `query` and optional `max_results` (1 to 20).
+- `memory.recall`: `question`, plus optional `filter` and `limit`.
+- `memory.fetch`: `query`, plus optional `mode`, `filter`, `limit` and `cursor`. `mode` must be one the active memory engine supports. Both launch engines (`tinyhumans`, `cortexdb`) support only `hybrid`, so leave it out unless you know otherwise.
+- `memory.list`: optional `filter`, `limit` and `cursor`.
+- `memory.learn`: `text`, plus optional `kind` (`preference`, `fact`, `procedure`, `correction`, `other`) and `confidence` (0 to 1).
+- `memory.forget`: `ids` (1 to 100).
+
+`limit` defaults to 10 and is capped at 100. `filter` takes any of `workspace`, `folder`, `file_path`, `language`, `repo`, `commit`, `url`, `thread_id`, `agent_id`, `kinds` (`document`, `conversation`, `learning`), `sources`, `tags_any`, `observed_after` and `observed_before` (RFC 3339). Memory tools answer `MEMORY_OFF` when no memory engine is usable. See the [memory spec](https://github.com/tinyhumansai/openhuman/blob/main/docs/specs/memory-v2.md) for the model.
+
+Enable SearXNG under Connections > Search, in `config.toml`, or with environment variables:
```toml
[search.providers.searxng]
@@ -102,9 +78,7 @@ OPENHUMAN_SEARXNG_TIMEOUT_SECONDS=10
## Resources
-The MCP server exposes the bundled prompt assets as static resources. Clients
-that support `resources/list` and `resources/read` can inspect the full agent
-personality and subagent prompt templates without executing any tool calls.
+The server exposes the bundled prompt assets as static resources. Clients that support `resources/list` and `resources/read` can read the agent personality and sub-agent prompt templates without running any tool.
### Capability advertisement
@@ -132,19 +106,13 @@ All resources have `mimeType: "text/markdown"`.
### Catalog parity
-A unit test (`catalog_mirrors_builtins`) cross-references the resource catalog
-against the `BUILTINS` slice in `loader.rs`. Adding a new built-in subagent
-without a matching catalog entry fails CI.
+A unit test (`catalog_mirrors_builtins`) checks the resource catalog against the `BUILTINS` slice in `loader.rs`. Adding a built-in sub-agent without a matching catalog entry fails CI.
### Resource templates
-The catalog is fully static (every URI is concrete, none are templated), so
-`resources/templates/list` always returns an empty `resourceTemplates` array.
-The handler exists for MCP-spec compliance: clients that probe
-`resources/templates/list` after seeing the `resources` capability get a
-well-formed result instead of `-32601 Method not found`.
+The catalog is static: every URI is concrete and none are templated. `resources/templates/list` therefore always returns an empty `resourceTemplates` array. The handler exists so clients that probe it after seeing the `resources` capability get a valid result instead of `-32601 Method not found`.
-### Smoke test
+### Smoke test for resources
```bash
printf '%s\n' \
@@ -158,9 +126,7 @@ printf '%s\n' \
## Tool registry
-The HTTP JSON-RPC server also exposes a read-only global tool registry for
-agents and dashboards that need discovery metadata without opening an MCP stdio
-session:
+The HTTP JSON-RPC server also exposes a read-only tool registry. Agents and dashboards can use it to discover tools without opening an MCP stdio session:
| RPC method | Purpose |
| ------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -168,15 +134,11 @@ session:
| `openhuman.tool_registry_get` | Return one registry entry by `tool_id`, for example `memory.recall` or `tools.web_search`. |
| `openhuman.tool_registry_diagnostics` | Return redacted inventory counts, write-surface candidates, policy surfaces, and external capability-provider diagnostics. |
-The registry is discovery-only. It does not change tool dispatch or permission
-checks; MCP calls still go through `tools/call`, and controller-backed tools
-still route through their existing JSON-RPC methods.
+The registry is for discovery only. It does not change tool dispatch or permission checks. MCP calls still go through `tools/call`, and controller-backed tools still use their own JSON-RPC methods.
### External capability providers
-OpenHuman can record trusted external capability providers in `config.toml`.
-This is governance metadata only: it does not install packages, execute remote
-code, or bypass the existing MCP/controller dispatch paths.
+You can record trusted external capability providers in `config.toml`. This is governance metadata only. It does not install packages, run remote code or bypass the MCP and controller dispatch paths.
```toml
[[capability_providers]]
@@ -188,13 +150,9 @@ trust_state = "trusted"
enabled = true
```
-Provider ids are normalized before policy checks. For example, `Acme Tools`
-becomes `acme-tools`; duplicates after normalization are rejected. A provider is
-eligible for future admission checks only when it is both `enabled = true` and
-`trust_state = "trusted"`. Missing provider config preserves the previous
-behavior: the provider registry is empty and no existing tools are hidden.
+Provider ids are normalized before policy checks, so `Acme Tools` becomes `acme-tools`. Duplicates after normalization are rejected. A provider is eligible for future admission checks only when it has both `enabled = true` and `trust_state = "trusted"`. With no provider config, the registry is empty and no existing tools are hidden.
-## Smoke test
+## Smoke test for tools
```bash
printf '%s\n' \
@@ -204,10 +162,7 @@ printf '%s\n' \
| openhuman-core mcp
```
-The response should include `capabilities.tools` from `initialize` and the
-curated tool names from `tools/list`. A successful run writes exactly two compact
-JSON response lines to stdout; the `notifications/initialized` message is a
-notification and has no response.
+The response should include `capabilities.tools` from `initialize` and the tool names from `tools/list`. A successful run writes exactly two compact JSON lines to stdout. `notifications/initialized` is a notification and has no response.
```text
{"jsonrpc":"2.0","id":1,"result":{"protocolVersion":"2025-06-18","capabilities":{"tools":{},"resources":{"subscribe":false,"listChanged":false}},"serverInfo":{"name":"openhuman-core","version":"<crate version>"},"instructions":"..."}}