|
1 | | -# Ensuring `list_mcp_resources` finds tinyMem |
| 1 | +# Exposing tinyMem MCP tools to Codex |
2 | 2 |
|
3 | | -The `list_mcp_resources` lookup that the Codex agent runs before mutating a repository pulls from the shared automation registry (`$CODEX_HOME/automations/*`). In this workspace we only ship the tinyMem code itself, so the registry is empty and the agent cannot find the MCP tool that knows how to validate mutations. |
| 3 | +Codex discovers MCP servers from config files — there is no separate automation |
| 4 | +registry or resource-listing step. Two scopes are supported: |
4 | 5 |
|
5 | | -To keep agents honest when they act in this repo, add a tinyMem automation definition that registers the `tinymem mcp` server (and any helper commands) so `list_mcp_resources` returns a non-empty list. |
| 6 | +| File | Scope | |
| 7 | +|---|---| |
| 8 | +| `~/.codex/config.toml` | global (all projects) | |
| 9 | +| `.codex/config.toml` | project-scoped (can be checked into the repo) | |
6 | 10 |
|
7 | | -## How to register tinyMem in the automation registry |
| 11 | +## Adding tinymem to the config |
8 | 12 |
|
9 | | -1. Locate your Codex automation directory. By default it’s `$CODEX_HOME/automations/`; if that directory does not exist yet, create it. |
10 | | -2. Inside `automations/`, add a folder for this repo (for example, `tinymem`). Place a `automation.toml` file there. |
11 | | -3. Populate `automation.toml` with metadata that exposes the MCP entry point. A minimal example: |
| 13 | +Add the following block to whichever config file applies: |
12 | 14 |
|
13 | | - ```toml |
14 | | - title = "tinyMem MCP" |
15 | | - description = "Exposes the tinyMem MCP server and diagnostics helpers for repository work." |
| 15 | +```toml |
| 16 | +[mcp_servers.tinymem] |
| 17 | +command = "tinymem" |
| 18 | +args = ["mcp"] |
| 19 | +enabled = true |
| 20 | +startup_timeout_sec = 15 |
| 21 | +``` |
16 | 22 |
|
17 | | - [server] |
18 | | - command = "tinymem" |
19 | | - args = ["mcp"] |
20 | | - timeout = 60000 |
21 | | - trust = false |
| 23 | +That is the complete entry. Codex starts the server on session launch and |
| 24 | +exposes every tool the server advertises (`memory_query`, `memory_recent`, |
| 25 | +`memory_write`, `task_add`, `artifact_create`, etc.) alongside its built-in |
| 26 | +tools. |
22 | 27 |
|
23 | | - [[tools]] |
24 | | - name = "tinyMem health" |
25 | | - description = "Verify the database before editing." |
26 | | - command = "tinymem" |
27 | | - args = ["health"] |
28 | | - timeout = 15000 |
| 28 | +## Project-scoped setup (recommended for this repo) |
29 | 29 |
|
30 | | - [[tools]] |
31 | | - name = "tinyMem doctor" |
32 | | - description = "Run the doctor diagnostic from MCP context." |
33 | | - command = "tinymem" |
34 | | - args = ["doctor"] |
35 | | - timeout = 30000 |
36 | | - ``` |
| 30 | +Check a `.codex/config.toml` into the repo root with the block above. Any |
| 31 | +Codex session opened inside the repo will pick it up automatically — no |
| 32 | +per-machine global config needed. |
37 | 33 |
|
38 | | - Adjust the snippet as needed for your environment; the registry that backs `list_mcp_resources` may support additional fields such as `env`, `cwd`, or `trust`. |
| 34 | +## CLI alternative |
39 | 35 |
|
40 | | -4. After the automation file is saved, restart the Codex agent (if necessary) so it notices the new resource. Running `list_mcp_resources` again should now show your tinyMem MCP server and any helper tools. |
| 36 | +If you prefer not to hand-edit the file: |
41 | 37 |
|
42 | | -## Why this matters |
| 38 | +```bash |
| 39 | +codex mcp add tinymem -- tinymem mcp |
| 40 | +``` |
43 | 41 |
|
44 | | -- The root `docs/agents/AGENTS.md` contract mandates that repository mutations happen via the MCP tools; registering `tinymem` here keeps codex obeying that contract. |
45 | | -- Once `list_mcp_resources` returns our entry, we can use the MCP server to call `memory_query`, `memory_recent`, `memory_write`, etc., without manually editing `tinyTasks.md`. |
46 | | -- The automation can bundle other useful wrappers (`health`, `doctor`, `query`) so agents have quick diagnostics at hand before mutating files. |
| 42 | +This appends the equivalent entry to `~/.codex/config.toml`. |
47 | 43 |
|
48 | | -If you need a hand generating the TOML for your automation tool, look for other Codex automation directories on this machine (e.g., `~/.codex/automations/`) for examples, or copy the snippet above and adjust the tool metadata to match. |
| 44 | +## Filtering tools (optional) |
| 45 | + |
| 46 | +If you only want a subset of the tools exposed, use `enabled_tools`: |
| 47 | + |
| 48 | +```toml |
| 49 | +[mcp_servers.tinymem] |
| 50 | +command = "tinymem" |
| 51 | +args = ["mcp"] |
| 52 | +enabled = true |
| 53 | +enabled_tools = ["memory_query", "memory_recent", "memory_write", "task_add"] |
| 54 | +``` |
| 55 | + |
| 56 | +## Why the tools weren't showing up |
| 57 | + |
| 58 | +The server was already running, but no config entry existed — Codex had no |
| 59 | +way to know about it. Once the config block above is in place, the tools |
| 60 | +appear in the next session without any restart. |
0 commit comments