@zenera/cli 1.3.3 → 1.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/ask.d.ts +5 -5
  2. package/dist/ask.js +56 -18
  3. package/dist/catalog.d.ts +1 -1
  4. package/dist/catalog.js +11 -5
  5. package/dist/commands/init.js +8 -9
  6. package/dist/commands/inspect.js +12 -5
  7. package/dist/commands/key.js +2 -2
  8. package/dist/commands/models.js +9 -6
  9. package/dist/liveness.js +3 -2
  10. package/dist/modelref.d.ts +11 -6
  11. package/dist/modelref.js +23 -23
  12. package/dist/scaffold.js +16 -8
  13. package/dist/trace.js +1 -0
  14. package/dist/validate.js +107 -9
  15. package/package.json +6 -6
  16. package/templates/editor/.github/copilot-instructions.md +60 -20
  17. package/templates/editor/.github/skills/add-mcp/SKILL.md +43 -0
  18. package/templates/editor/.github/skills/finetune/SKILL.md +2 -1
  19. package/templates/editor/.github/skills/zen-analyze-run/SKILL.md +4 -2
  20. package/templates/editor/.github/skills/zen-cli/references/keys.md +1 -1
  21. package/templates/editor/.github/skills/zen-cli/references/models.md +8 -8
  22. package/templates/editor/.github/skills/zen-cli/references/projects.md +2 -0
  23. package/templates/editor/.github/skills/zen-cli/references/rag.md +1 -1
  24. package/templates/editor/.github/skills/zen-finetune/SKILL.md +2 -1
  25. package/templates/editor/.github/skills/zen-finetune-apply/SKILL.md +3 -2
  26. package/templates/editor/.github/skills/zen-inspect-ask/SKILL.md +2 -1
  27. package/templates/editor/.github/skills/zen-instructions/SKILL.md +50 -37
  28. package/templates/editor/.github/skills/zen-mcp/SKILL.md +142 -0
  29. package/templates/editor/.github/skills/zen-mcp/references/discovery.md +120 -0
  30. package/templates/editor/.github/skills/zen-mcp/references/install.md +159 -0
  31. package/templates/editor/.github/skills/zen-mcp/references/memory-cache.md +73 -0
  32. package/templates/editor/.github/skills/zen-memory/SKILL.md +2 -2
  33. package/templates/editor/.github/skills/zen-memory-warmup/SKILL.md +3 -3
  34. package/templates/editor/.github/skills/zen-rag-docs/SKILL.md +6 -6
  35. package/templates/editor/.github/skills/zen-rag-schema/SKILL.md +5 -5
  36. package/templates/editor/.github/skills/zen-review/SKILL.md +5 -3
  37. package/templates/editor/.github/skills/zen-review/scripts/check-paths.sh +3 -2
  38. package/templates/editor/.github/skills/zen-spec-sync/SKILL.md +2 -1
  39. package/templates/editor/.github/skills/zen-spec-sync/scripts/snapshot.sh +1 -1
  40. package/templates/parts/memory-terms.yaml.tmpl +1 -1
  41. package/templates/parts/models.yaml.tmpl +1 -1
  42. package/templates/project/agents/mcp-instructions.md +66 -0
  43. package/templates/project/agents/mcp-memory-instructions.md +28 -0
  44. package/templates/project/scripts/_setup.sh +1 -1
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: zen-instructions
3
- description: The house rules - `agents/instructions.md` and every `agents/<topic>-instructions.md` prepended to every agent's system prompt. How the set is discovered and ordered, the `requires:` frontmatter and its closed vocabulary (`files`, `files-write`, `fork`, `memory`, `memory-write`, `memory-forget`), which four documents are `zen`'s own and are replaced by `zen check --fix`, how a project writes its own customisable topic prompts beside them (`files-policy-instructions.md`, `memory-policy-instructions.md`, `fork-<topic>-instructions.md`, `tools-<topic>-instructions.md`) without losing the copy, what belongs in a house rule as against an agent prompt or a skill, and every `zen check` finding these files can produce. Load before creating, editing, reviewing or deleting any `agents/*instructions.md`, before adding a capability whose rules arrive as one, and whenever `rules.stale`, `rules.unreached`, `files.uninstructed`, `memory.uninstructed` or `fork.uninstructed` is reported.
3
+ description: The house rules - `agents/instructions.md` and every `agents/<topic>-instructions.md` prepended to every agent's system prompt. How the set is discovered and ordered, the `requires:` frontmatter and its closed vocabulary (`files`, `files-write`, `fork`, `memory`, `memory-write`, `memory-forget`, `tools:<group>`), which six documents are `zen`'s own and are replaced by `zen check --fix`, how a project writes its own customisable topic prompts beside them (`memory-policy-instructions.md`, `mcp-policy-instructions.md`, any `<topic>-policy-instructions.md`) without losing the copy, what belongs in a house rule as against an agent prompt or a skill, and every `zen check` finding these files can produce. Load before creating, editing, reviewing or deleting any `agents/*instructions.md`, before adding a capability whose rules arrive as one, and whenever `rules.stale`, `rules.unreached` or any `*.uninstructed` finding (`files`, `memory`, `fork`, `mcp`, `mcp-memory`) is reported.
4
4
  user-invocable: false
5
5
  ---
6
6
 
@@ -69,9 +69,15 @@ condition and the prose it guards are one edit.
69
69
  | `memory` | it declares `memory:` in any form |
70
70
  | `memory-write` | its memory `access` is `read-write` or `full` |
71
71
  | `memory-forget` | its memory `access` is `full` |
72
+ | `tools:<group>` | its `tools:` grants any tool of that group (`tools:mcp`) |
72
73
 
73
74
  Legacy aliases `workspace` and `workspace-write` match `files` and `files-write`.
74
75
 
76
+ `tools:<group>` is read from `agents.yaml` alone, like the rest: `<group>:*`,
77
+ `<group>:<name>` and `*` grant the group, `-<group>:*` takes it back, and a bare
78
+ name counts when it starts `<group>_` (`mcp_call`). Withholding some of a
79
+ group's tools by name (`-mcp_call`) still leaves the group granted.
80
+
75
81
  The vocabulary is **closed**. A name outside it is a load error
76
82
  (`rules.requires.unknown`), not a rule that silently never fires. A list means
77
83
  _all of it_ has to hold. There is no `not`: a rule for agents _without_ a
@@ -85,24 +91,28 @@ confused by.
85
91
 
86
92
  ## Two owners, in the same directory
87
93
 
88
- | File | Whose | `requires:` | Is |
89
- | --------------------------------------- | --------- | ----------- | --------------------------------------------------------- |
90
- | `agents/instructions.md` | project's | - | identity, shared model of the system, global constraints |
91
- | `agents/tools-instructions.md` | **ours** | - | how tools are called: narrate, batch the independent ones |
92
- | `agents/files-instructions.md` | **ours** | `files` | how files are read, searched and patched; safety, mounts |
93
- | `agents/memory-instructions.md` | **ours** | `memory` | how the graph is reached, what to commit, how to correct |
94
- | `agents/fork-instructions.md` | **ours** | `fork` | what a branch is, what returns, when it is worth it |
95
- | `agents/tools-<topic>-instructions.md` | project's | yours | **this project's** tool policy |
96
- | `agents/files-<topic>-instructions.md` | project's | `files` | **this project's** file policy |
97
- | `agents/memory-<topic>-instructions.md` | project's | `memory` | **this project's** memory policy |
98
- | `agents/fork-<topic>-instructions.md` | project's | `fork` | **this project's** forking policy |
99
-
100
- The four marked **ours** describe _this version of `zen`_ - how the memory
94
+ | File | Whose | `requires:` | Is |
95
+ | --------------------------------------- | --------- | --------------------- | --------------------------------------------------------- |
96
+ | `agents/instructions.md` | project's | - | identity, shared model of the system, global constraints |
97
+ | `agents/tools-instructions.md` | **ours** | - | how tools are called: narrate, batch the independent ones |
98
+ | `agents/files-instructions.md` | **ours** | `files` | how files are read, searched and patched; safety, mounts |
99
+ | `agents/memory-instructions.md` | **ours** | `memory` | how the graph is reached, what to commit, how to correct |
100
+ | `agents/fork-instructions.md` | **ours** | `fork` | what a branch is, what returns, when it is worth it |
101
+ | `agents/mcp-instructions.md` | **ours** | `tools:mcp` | finding, describing and calling a service; connect pause |
102
+ | `agents/mcp-memory-instructions.md` | **ours** | `tools:mcp`, `memory` | commit MCP routes, never results |
103
+ | `agents/tools-<topic>-instructions.md` | project's | yours | **this project's** tool policy |
104
+ | `agents/files-<topic>-instructions.md` | project's | `files` | **this project's** file policy |
105
+ | `agents/memory-<topic>-instructions.md` | project's | `memory` | **this project's** memory policy |
106
+ | `agents/fork-<topic>-instructions.md` | project's | `fork` | **this project's** forking policy |
107
+ | `agents/mcp-<topic>-instructions.md` | project's | `tools:mcp` | **this project's** services: which servers, for what |
108
+
109
+ The six marked **ours** describe _this version of `zen`_ - how the memory
101
110
  graph works, how its tools are called, what survives a join, how files are safely
102
- handled. They land under `agents/` only because that is where a document has to
103
- be to reach a prompt. They are not the project's to maintain:
111
+ handled, how Zenera's MCP tools behave. They land under `agents/` only because
112
+ that is where a document has to be to reach a prompt. They are not the project's
113
+ to maintain:
104
114
 
105
- - `zen check --fix` **replaces all four** with the bytes this `zen` ships.
115
+ - `zen check --fix` **replaces all six** with the bytes this `zen` ships.
106
116
  - A copy that differs - edited in place, or scaffolded by an older `zen` - is
107
117
  reported as `rules.stale`, because prose about a runtime that has since moved
108
118
  reads exactly as authoritative as the version that is true.
@@ -119,12 +129,13 @@ inside. Anything this project decides for itself on a subject one of ours
119
129
  covers - which audience holds what, what must never be written down, how wide a
120
130
  fan-out may go, which tools are off limits here - is its own document:
121
131
 
122
- | Instead of editing | Write |
123
- | ------------------------ | -------------------------------------- |
124
- | `files-instructions.md` | `agents/files-policy-instructions.md` |
125
- | `memory-instructions.md` | `agents/memory-policy-instructions.md` |
126
- | `fork-instructions.md` | `agents/fork-policy-instructions.md` |
127
- | `tools-instructions.md` | `agents/tools-policy-instructions.md` |
132
+ | Instead of editing | Write |
133
+ | ------------------------ | ------------------------------------------------------------- |
134
+ | `files-instructions.md` | `agents/files-policy-instructions.md` |
135
+ | `memory-instructions.md` | `agents/memory-policy-instructions.md` |
136
+ | `fork-instructions.md` | `agents/fork-policy-instructions.md` |
137
+ | `tools-instructions.md` | `agents/tools-policy-instructions.md` |
138
+ | `mcp-instructions.md` | `agents/mcp-policy-instructions.md` (`requires: [tools:mcp]`) |
128
139
 
129
140
  `<topic>` is yours; `policy` is the convention and needs no explaining. Then a
130
141
  `zen check --fix`, a `zen init` or a `zen open` refreshes our copy and takes
@@ -191,20 +202,22 @@ It reads `agents/*instructions.md` and exits `1` on any candidate.
191
202
 
192
203
  ## What `zen check` reports
193
204
 
194
- | Finding | Severity | Means |
195
- | ------------------------ | -------- | ---------------------------------------------------------------- |
196
- | `rules.requires.unknown` | error | `requires:` names no capability - the loader refuses the project |
197
- | `files.uninstructed` | error | an agent has file tools and `files-instructions.md` is absent |
198
- | `memory.uninstructed` | error | memory is on and `memory-instructions.md` is missing or empty |
199
- | `fork.uninstructed` | error | an agent can fork and `fork-instructions.md` is missing or empty |
200
- | `rules.stale` | warning | one of ours is not the copy this `zen` ships |
201
- | `house-rules.empty` | warning | a document contributes nothing but a prompt section |
202
- | `rules.unreached` | note | a document of **yours** whose `requires:` no agent satisfies |
203
- | `house-rules.missing` | note | no house rules at all, which is allowed |
204
-
205
- `zen check --fix` answers the first five between them: it rewrites all four of
206
- ours and the whole `.github/` tree, then validates, so the report and its exit
207
- code describe the repaired project.
205
+ | Finding | Severity | Means |
206
+ | ------------------------- | -------- | ------------------------------------------------------------------------ |
207
+ | `rules.requires.unknown` | error | `requires:` names no capability - the loader refuses the project |
208
+ | `files.uninstructed` | error | an agent has file tools and `files-instructions.md` is absent |
209
+ | `memory.uninstructed` | error | memory is on and `memory-instructions.md` is missing or empty |
210
+ | `fork.uninstructed` | error | an agent can fork and `fork-instructions.md` is missing or empty |
211
+ | `mcp.uninstructed` | error | an agent has `mcp` tools and `mcp-instructions.md` is absent |
212
+ | `mcp-memory.uninstructed` | error | an agent has `mcp` tools and memory, `mcp-memory-instructions.md` absent |
213
+ | `rules.stale` | warning | one of ours is not the copy this `zen` ships |
214
+ | `house-rules.empty` | warning | a document contributes nothing but a prompt section |
215
+ | `rules.unreached` | note | a document of **yours** whose `requires:` no agent satisfies |
216
+ | `house-rules.missing` | note | no house rules at all, which is allowed |
217
+
218
+ `zen check --fix` answers every `*.uninstructed` and `rules.stale` between them:
219
+ it rewrites all six of ours and the whole `.github/` tree, then validates, so the
220
+ report and its exit code describe the repaired project.
208
221
 
209
222
  Two silences to know about. **There is no `tools.uninstructed`** - that document
210
223
  is unconditional and its absence is not reported, so a project that deleted it
@@ -0,0 +1,142 @@
1
+ ---
2
+ name: zen-mcp
3
+ description: 'MCP servers (GitHub, Linear, Notion, ...) in a Zenera project - the `mcp:*` tool group (`mcp_servers`, `mcp_tools`, `mcp_describe`, `mcp_call`) that Zenera provides, where those tools work and where they only refuse, how to grant them in `agents.yaml`, the house rules `agents/mcp-instructions.md` and `agents/mcp-memory-instructions.md` that reach every agent granted the group, per-workflow skills in `agents/skills`, how an agent discovers, searches and calls a tool, the connect-your-account pause, result limits, and caching tool routes in memory. Load before adding, reviewing or debugging `mcp:*` or any `mcp_*` tool in a project, or a skill or prompt that tells an agent to use an external service through MCP, and whenever `mcp.uninstructed` or `mcp-memory.uninstructed` is reported.'
4
+ user-invocable: false
5
+ ---
6
+
7
+ # MCP tools in a project
8
+
9
+ External services - GitHub, Linear, Notion, Slack, Sentry and the other MCP
10
+ servers an administrator has set up - reach an agent as **four generic tools** in group
11
+ `mcp`. A project does not declare servers, URLs or credentials. It grants the
12
+ group and teaches its agents how to use it.
13
+
14
+ | Tool | Arguments | Returns |
15
+ | -------------- | ----------------------------- | ---------------------------------------------------------------------------------- |
16
+ | `mcp_servers` | none | `{ servers: [{ server, tools }] }`: the servers this run can use, with tool counts |
17
+ | `mcp_tools` | `server` | `{ tools: [{ name, description }] }`: one-line descriptions |
18
+ | `mcp_describe` | `server`, `tool` | `{ name, description, inputSchema }`: full text and JSON schema |
19
+ | `mcp_call` | `server`, `tool`, `arguments` | `{ isError, content, structuredContent? }`, or a connect request |
20
+
21
+ Detail on each reply, the errors and the limits is in
22
+ [references/discovery.md](./references/discovery.md).
23
+
24
+ ## 1. Where they come from, and who decides what is in them
25
+
26
+ - **The tools are Zenera's, not the project's.** Every project running in
27
+ Zenera has them. Nothing goes in `agents.yaml` except the grant, and nothing
28
+ goes in `.env`. How to use them reaches the agent as zen's own house rules,
29
+ `agents/mcp-instructions.md` (and `agents/mcp-memory-instructions.md` with
30
+ memory), which every scaffold carries and which `requires: [tools:mcp]`
31
+ delivers only to agents granted the group.
32
+ - **Which servers exist** is up to the Zenera administrator. **Which of them this
33
+ project may use**, and optionally which of their tools, is set by a project
34
+ editor in the app under _Project settings → MCP servers_. You cannot see or
35
+ change either from the project files. Ask the user which servers are enabled
36
+ before naming one in a skill, or write the skill so it discovers them
37
+ (`mcp_servers`) instead of assuming.
38
+ - **Each call acts as the signed-in user.** Most servers use per-user OAuth.
39
+ The first call to a server the user has not connected **pauses the run**. The
40
+ chat shows a Connect / Not now card, and the same call resumes with the result
41
+ once the user connects, or fails with an error if they decline. With an older
42
+ host, the result is `{ auth_required: true, connect_url, message }` instead,
43
+ and the agent must give the user the link and stop. An agent never needs
44
+ `current_user` to use MCP: identity travels with the run.
45
+
46
+ ## 2. Where they work, and where they only refuse
47
+
48
+ | Run | MCP |
49
+ | ---------------------------------------------------- | -------------------------------------------------------------------------- |
50
+ | A chat in the Zenera app; the editor's Test tab | Works, as the signed-in user |
51
+ | `zen run`, `zen meta`, batches, datasets, gym, a job | Tools are present; every call returns _"MCP is not available in this run"_ |
52
+ | Code in the sandbox (`run_command`, a skill script) | Never: the sandbox has no access to the services |
53
+
54
+ Consequences you must design for:
55
+
56
+ - **You cannot exercise MCP from the terminal.** Check behaviour in the Test
57
+ tab. A dataset case or rubric that depends on an MCP result fails for
58
+ reasons unrelated to the change you are testing.
59
+ - **A script cannot fetch from a service.** The agent calls `mcp_call`, then
60
+ writes what it needs into `/workspace` with the file tools, and the script
61
+ reads it from there.
62
+ - **Outside Zenera, `mcp:*` does not exist.** There, `zen check` and `zen run`
63
+ fail with `unknown tool "mcp:*"`. That is the environment, not the project:
64
+ do not remove the grant. Check the project in Zenera instead.
65
+
66
+ ## 3. What a project with `mcp:*` needs
67
+
68
+ `zen check` reports the house rules missing (`mcp.uninstructed`,
69
+ `mcp-memory.uninstructed`) or edited (`rules.stale`). It does not report the
70
+ rest of this list.
71
+
72
+ 1. **Grant the group only to the agents that act on external services.** Use
73
+ `tools: [mcp:*, ...]`. Grant the group, not a hand-picked subset, because the
74
+ four tools are one procedure and an agent missing `mcp_describe` guesses
75
+ arguments. A router or a summariser does not get it.
76
+ 2. **Keep zen's house rules.** `agents/mcp-instructions.md` is the only thing
77
+ that teaches a running agent the discover → describe → call order, how to
78
+ choose a tool, the connect pause and truncation; with memory,
79
+ `agents/mcp-memory-instructions.md` adds the memory rules. Both are zen's
80
+ copies: never edit them, and restore them with `zen check --fix`. They need
81
+ no binding: the grant is what delivers them.
82
+ 3. **One project skill per recurring workflow** that names the server, the tool
83
+ route and the argument shape, for example `agents/skills/linear_triage/`.
84
+ Name only servers the user has confirmed are enabled, and tell the agent to
85
+ fall back to discovery when the named tool is refused. See
86
+ [references/install.md §4](./references/install.md#4-workflow-skills).
87
+ 4. **A prompt line saying when to reach for it.** For example: _"For anything
88
+ about the user's issues, pull requests or tickets, use the MCP tools."_ A
89
+ grant the prompt never mentions is used at the model's discretion.
90
+ 5. **Project policy beside, not inside.** Which servers this project uses and
91
+ what each is for goes in `agents/mcp-policy-instructions.md` with
92
+ `requires: [tools:mcp]`; project-specific memory policy goes in
93
+ `agents/memory-policy-instructions.md`. See
94
+ [references/memory-cache.md](./references/memory-cache.md).
95
+ 6. **No `mcp_*` in a skill's frontmatter `tools:`.** An agent-level grant of the
96
+ same name wins and is never gated, so the line does nothing except mislead
97
+ the next reader. Gate by binding the skill, not the tool.
98
+ 7. **No credentials or connect URLs anywhere in the project.** Zenera gives each
99
+ run its access. A connect URL belongs to one user's sign-in and expires.
100
+
101
+ A project scaffolded before these files existed has neither: `zen check --fix`
102
+ writes both. A project that installed the older `agents/skills/mcp_tools` skill
103
+ can delete it and its `allow`/`preload` entries once the house rules are there,
104
+ since the two say the same thing twice.
105
+
106
+ ## 4. Review checklist
107
+
108
+ - [ ] `agents/mcp-instructions.md` is present and not `rules.stale`; with
109
+ memory, so is `agents/mcp-memory-instructions.md`.
110
+ - [ ] No leftover `agents/skills/mcp_tools/` duplicating them.
111
+ - [ ] Workflow skills name servers the user confirmed. Each says what to do when
112
+ the server or tool is refused, and none hard-codes an id that belongs to
113
+ one user (a team, repo or workspace of theirs).
114
+ - [ ] No prompt, skill or dataset expects MCP to work in `zen run` or a batch.
115
+ - [ ] No sandbox script expected to call a service itself.
116
+ - [ ] With `memory:`, nothing tells the agent to commit tool results, user
117
+ data or whole tool lists.
118
+ - [ ] `zen check` passes in Zenera; behaviour checked in the Test tab.
119
+
120
+ ## 5. When it goes wrong
121
+
122
+ | Symptom | Cause and fix |
123
+ | --------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
124
+ | `unknown tool "mcp:*"` at load | Not a Zenera environment - §2. Not a project error |
125
+ | Every call: _"MCP is not available in this run"_ | A terminal, batch or job run. Use the chat or Test tab |
126
+ | `<server> is not enabled for this project (enabled: ...)` | Enable it in Project settings → MCP servers, or change the skill to a listed server |
127
+ | `<server>'s tool <tool> is not enabled for this project` | The editor restricted that server's tools. Enable the tool or route around it |
128
+ | `mcp.uninstructed` / `mcp-memory.uninstructed` | A house rules file is missing or empty. `zen check --fix` |
129
+ | Agent guesses arguments, call fails validation | It skipped `mcp_describe`. Check `agents/mcp-instructions.md` is in its prompt (`zen check` lists it) |
130
+ | Result ends with `truncated: true` and a `note` | Over 60,000 characters. Ask for less: filters, fields, smaller pages - discovery.md §5 |
131
+ | Run sits waiting after a call | The user has not connected the service. The card is in the chat; nothing to fix in the project |
132
+ | Agent pastes a link and stops | Older host without pause support: `auth_required` + `connect_url`. Correct behaviour |
133
+ | Agent re-lists every server's tools every turn | No workflow skill for the job, or with memory, routes are not being committed |
134
+ | Agent acts on a recalled route that no longer exists | Memory was trusted over the server. The house rules say to re-describe on any refusal - memory-cache.md |
135
+
136
+ ## References
137
+
138
+ | File | Read when |
139
+ | ---------------------------------------------------------- | -------------------------------------------------------------------------------- |
140
+ | [references/install.md](./references/install.md) | Adding MCP to a project: `tools:`, house rules, policy file, workflow skills |
141
+ | [references/discovery.md](./references/discovery.md) | How a run finds servers and tools, searches, calls, and reads replies and errors |
142
+ | [references/memory-cache.md](./references/memory-cache.md) | The project has `memory:`, or an agent re-discovers the same tools every run |
@@ -0,0 +1,120 @@
1
+ # How a run finds and calls MCP tools
2
+
3
+ This file describes what a running agent sees, so you can write skills and
4
+ prompts that match it. The agent-facing version of the procedure is zen's house
5
+ rules file `agents/mcp-instructions.md`, which reaches every agent granted
6
+ `mcp:*`.
7
+
8
+ Every call is checked against the project's server selection and made as the
9
+ signed-in user. Nothing about this is configurable from the project.
10
+
11
+ ## 1. `mcp_servers` - what this run can use
12
+
13
+ No arguments.
14
+
15
+ ```json
16
+ {
17
+ "servers": [
18
+ { "server": "github", "tools": 41 },
19
+ { "server": "linear", "tools": 23 }
20
+ ]
21
+ }
22
+ ```
23
+
24
+ The servers enabled for the project, and for each the number of tools the
25
+ project allows. This is the authority: a server not listed is refused by every
26
+ other call. It is cheap. Call it once per run, before naming a server that
27
+ memory or a skill did not supply.
28
+
29
+ ## 2. `mcp_tools` - one server's tools
30
+
31
+ `{ "server": "linear" }`
32
+
33
+ ```json
34
+ { "tools": [{ "name": "list_issues", "description": "List issues in the user's workspace..." }] }
35
+ ```
36
+
37
+ The name and the **first line** of each description (up to 200 characters). Only
38
+ tools the project allows are listed. The list is kept for the rest of the
39
+ run, so a second call in the same run is cheap. Across runs nothing is kept
40
+ unless memory keeps it.
41
+
42
+ ## 3. Searching for a tool
43
+
44
+ There is no search endpoint. Searching is the agent reading `mcp_tools` output,
45
+ so the cost is the size of the listings it pulls into context. The procedure
46
+ that keeps that small:
47
+
48
+ 1. **Memory first**, if the project has it. Auto-recall often surfaces a stored
49
+ route before any call. Otherwise use `memory_grep` with the service or verb
50
+ (`linear`, `create_issue`) for an exact hit, or `memory_search` with the
51
+ user's question.
52
+ 2. **A workflow skill** that names the tool. If one matches, use its route.
53
+ 3. **`mcp_servers`**, then `mcp_tools` **only for the servers whose name fits
54
+ the request**: GitHub for pull requests, Linear for issues. Do not list
55
+ every server.
56
+ 4. **Match on verb and object** in the names and one-line descriptions:
57
+ `list_`/`search_`/`get_` to read, `create_`/`update_`/`delete_` to write,
58
+ followed by the object (`issue`, `pull_request`, `page`). Prefer a `search_*`
59
+ tool with a query argument over `list_*` and filtering in the model.
60
+ 5. **Describe only the chosen tool**, never every candidate.
61
+ 6. If nothing fits after one server's list, try the next plausible server.
62
+ After that, tell the user the enabled servers do not offer it. Do not invent
63
+ a tool name.
64
+
65
+ ## 4. `mcp_describe` - read before calling
66
+
67
+ `{ "server": "linear", "tool": "list_issues" }`
68
+
69
+ ```json
70
+ {
71
+ "name": "list_issues",
72
+ "description": "...full text...",
73
+ "inputSchema": { "type": "object", "properties": {}, "required": [] }
74
+ }
75
+ ```
76
+
77
+ Required before the first call of a tool in a run. The schema is the only source
78
+ for argument names, enums, pagination fields and which fields are required. A
79
+ skill or memory naming an argument shape is a hint, and the schema decides.
80
+
81
+ ## 5. `mcp_call` - the call
82
+
83
+ `{ "server": "linear", "tool": "list_issues", "arguments": { "limit": 25 } }`
84
+
85
+ | Reply | Meaning and what the agent does |
86
+ | -------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
87
+ | `{ isError: false, content: [...], structuredContent? }` | Success. Prefer `structuredContent` when present: it is the typed result |
88
+ | `{ isError: true, content: [...] }` | The upstream tool failed: bad argument, not found, permission. Read the text, fix arguments once, then report |
89
+ | `{ ..., truncated: true, note }` | The result exceeded 60,000 characters and was cut. Call again asking for less: a filter, fewer fields, a smaller page size |
90
+ | Run pauses, then the result | The user had not connected the service. They connected from the card, and the call ran |
91
+ | Error after a pause | The user chose _Not now_. Continue without that service and say what is missing |
92
+ | `{ auth_required: true, server, connect_url, message }` | Older host. Give the user `connect_url` as a link, say what it is for, stop. Retry when they say they have connected |
93
+
94
+ **Calls take up to 120 seconds** before they time out. A slow upstream
95
+ looks like a long tool call, not a hang.
96
+
97
+ ## 6. Errors
98
+
99
+ These are thrown, and reach the model as an error result:
100
+
101
+ | Message | Means |
102
+ | ---------------------------------------------------------- | ------------------------------------------------------------------------- |
103
+ | `MCP is not available in this run: ...` | Not a chat or Test-tab run. Say MCP is unavailable here; do not retry |
104
+ | `<server> is not enabled for this project (enabled: a, b)` | Use a listed server, or tell the user an editor must enable it |
105
+ | `<server>'s tool <tool> is not enabled for this project` | The server is on, but this tool is excluded. Find another route or say so |
106
+ | `MCP gateway: ...` | The service failed. Retry once, then report |
107
+ | `MCP broker unreachable: ...` | MCP is briefly unavailable. Retry once, then report |
108
+
109
+ A refusal of a server or tool that **memory or a skill named** means the route is
110
+ stale. Re-discover from step 1, and if memory is on, supersede the old route
111
+ (see [memory-cache.md](./memory-cache.md)).
112
+
113
+ ## 7. Writes
114
+
115
+ Every allowed tool can be called, whether it reads or writes.
116
+ Whether an agent may change something upstream is decided by the project:
117
+
118
+ - in the prompt or skill (_"ask before creating, editing or deleting anything"_),
119
+ - or by taking `mcp_call` away from agents that must only look (`-mcp_call`),
120
+ - or by the project editor excluding the write tools in Project settings.
@@ -0,0 +1,159 @@
1
+ # Installing MCP in a target project
2
+
3
+ Edits in this order, followed by `zen check` and a Test-tab run. Every path
4
+ is relative to the project root, the directory with `agents.yaml`.
5
+
6
+ ## 1. Find out what is enabled
7
+
8
+ The project files do not say which MCP servers the project may use. That is set
9
+ in the app (_Project settings → MCP servers_), and the editor cannot read it.
10
+ Ask the user:
11
+
12
+ - which servers are enabled (as named there: `github`, `linear`, `notion`, ...),
13
+ - whether any server is limited to some of its tools,
14
+ - which jobs the agents should do with them.
15
+
16
+ If they do not know, grant the tools and stop at step 3: the house rules
17
+ discover servers at run time, so the project works whatever is enabled later.
18
+
19
+ ## 2. Grant the tools in `agents.yaml`
20
+
21
+ Add the group to each agent that acts on an external service, and to no other:
22
+
23
+ ```yaml
24
+ agents:
25
+ - name: assistant
26
+ tools: [files:*, mcp:*] # mcp: GitHub and Linear as the signed-in user
27
+ skills:
28
+ allow: [linear_triage, house_style]
29
+ ```
30
+
31
+ - **Grant `mcp:*`, not single tools.** `mcp_servers`, `mcp_tools`,
32
+ `mcp_describe` and `mcp_call` are one procedure. `mcp:mcp_call` alone leaves
33
+ the agent guessing arguments.
34
+ - **Take `mcp_call` away for read-only reviewers**: `tools: [mcp:*, -mcp_call]`
35
+ lets an agent see what exists without acting on it. MCP cannot tell a read
36
+ from a write, so this is the only way to keep an agent from changing
37
+ anything upstream.
38
+ - **Handoffs.** A router that only routes does not get `mcp:*`. Hand off to the
39
+ agent that has it, and say so in that agent's `description:`.
40
+
41
+ ## 3. The house rules
42
+
43
+ Nothing to copy. The grant is what delivers them: `agents/mcp-instructions.md`
44
+ (`requires: [tools:mcp]`) reaches every agent granted the group, and
45
+ `agents/mcp-memory-instructions.md` (`requires: [tools:mcp, memory]`) those that
46
+ also have memory. Both are zen's copies, scaffolded into every project.
47
+
48
+ - If either is missing - a project scaffolded by an older `zen` - run
49
+ `zen check --fix`. `zen check` reports it as `mcp.uninstructed` or
50
+ `mcp-memory.uninstructed`.
51
+ - Never edit them. Project-specific text goes in a file beside them,
52
+ `agents/mcp-policy-instructions.md`:
53
+
54
+ ```markdown
55
+ ---
56
+ requires: [tools:mcp]
57
+ ---
58
+
59
+ # Services in this project
60
+
61
+ - `github` - pull requests, reviews and issues in the user's repositories.
62
+ - `linear` - the user's issues and projects.
63
+ ```
64
+
65
+ List only servers the user confirmed. Leave the file out if none were: the
66
+ agent discovers them. Copy the `requires:` line - without it the file reaches
67
+ every agent.
68
+
69
+ - A project that still has the older `agents/skills/mcp_tools/` skill: delete
70
+ it and its `allow`/`preload` entries. The house rules replace it.
71
+
72
+ ### Skills from somewhere else
73
+
74
+ `skills:` at the top of `agents.yaml` accepts a list, so a team can keep shared
75
+ MCP skills in one directory and use them in several projects:
76
+
77
+ ```yaml
78
+ skills:
79
+ - agents/skills
80
+ - ../shared/mcp-skills # github_review, linear_triage
81
+ ```
82
+
83
+ With several directories the catalog is mounted at `/skills/<folder>` per
84
+ directory, not at `/skills`. Check the path a skill writes for its own files
85
+ (§3.4.1 in `copilot-instructions.md`). A directory outside the project is not
86
+ packaged into a release, so copy the skills in before `zen server build`.
87
+
88
+ ## 4. Workflow skills
89
+
90
+ A recurring job gets its own skill, so the agent goes straight to the right tool
91
+ instead of discovering it every time. One folder per job:
92
+
93
+ ```
94
+ agents/skills/linear_triage/SKILL.md
95
+ ```
96
+
97
+ ```markdown
98
+ ---
99
+ description: Triage the user's open Linear issues - list, group by state and priority, propose next steps.
100
+ ---
101
+
102
+ Needs the `mcp_*` tools. Without them, say MCP is not
103
+ available here and stop.
104
+
105
+ 1. `mcp_call` server `linear`, tool `list_issues`, arguments
106
+ `{ "assignee": "me", "state": "open", "limit": 50 }`.
107
+ Before the first call in a run, `mcp_describe` it to confirm the arguments.
108
+ 2. Group by state, then priority. Do not fetch each issue again: the list has
109
+ what triage needs.
110
+ 3. Propose next steps. Change nothing in Linear unless the user asks.
111
+
112
+ If `linear` or `list_issues` is refused as not enabled, tell the user which one
113
+ and that a project editor enables it in Project settings → MCP servers. Do not
114
+ try a different server.
115
+ ```
116
+
117
+ The server, tool and arguments above are an illustration. Write the ones the
118
+ user confirmed, and leave argument details to `mcp_describe` when unsure.
119
+
120
+ Rules for these skills:
121
+
122
+ - **State the prerequisite first** (the `mcp_*` tools) and what to do without
123
+ it. The catalog is readable by every agent, including ones not granted the
124
+ skill.
125
+ - **Name the tool and argument shape, but still describe once per run.** Tools
126
+ change upstream, and one `mcp_describe` is cheap insurance.
127
+ - **Writes need consent.** Any step that creates, updates or deletes something
128
+ upstream (a comment, an issue, a merge) asks the user first, unless the user's
129
+ request was itself that write.
130
+ - **No user-specific ids.** A team id, repo or workspace belongs to one user.
131
+ The skill tells the agent how to find it (`list_teams`, or memory), not the
132
+ value itself.
133
+ - **Do not restate the house rules.** Discovery, the connect pause and
134
+ truncation are already in every MCP agent's prompt.
135
+ - **Bind it** in `skills.allow` of the agents that hold `mcp:*`.
136
+
137
+ ## 5. A prompt line
138
+
139
+ In `agents/prompts/<name>.md` of each agent from step 2, one line saying when to
140
+ reach for the services - for example _"For anything about the user's issues,
141
+ pull requests or tickets, use the MCP tools."_ A grant the prompt never
142
+ mentions is used at the model's discretion.
143
+
144
+ ## 6. Check
145
+
146
+ ```sh
147
+ zen check
148
+ ```
149
+
150
+ - `unknown tool "mcp:*"` means this is not a Zenera environment. Keep the grant
151
+ and check the project in Zenera.
152
+ - `mcp.uninstructed` or `mcp-memory.uninstructed`: run `zen check --fix`.
153
+ - `skills.allow` / `preload` naming something absent means the folder name and
154
+ the binding differ.
155
+
156
+ Then open the editor's **Test tab** and ask for something that needs the server.
157
+ Expect one connect card the first time per service; after that, the answer. A
158
+ `zen run` from the terminal only proves the project loads: every MCP call there
159
+ returns _"MCP is not available in this run"_.
@@ -0,0 +1,73 @@
1
+ # Caching MCP tools in memory
2
+
3
+ Discovery costs round trips and context: `mcp_servers`, then a tool listing that
4
+ may be thousands of tokens, then `mcp_describe`. The tool list is kept for one
5
+ run only. Memory is what lets the next run skip discovery. The
6
+ principle is the same as memory in front of a `zen rag` index (`zen-memory`
7
+ skill): **keep the route, not the source.**
8
+
9
+ Applies only to a project with a `memory:` block and agents with `read-write`
10
+ access. Without memory, a workflow skill naming the route does the same job, as
11
+ authored text.
12
+
13
+ ## What to commit
14
+
15
+ | Commit | Kind | Because |
16
+ | ------------------------------------------------------------------------------------------------------ | ----------- | -------------------------------------------------- |
17
+ | The question, then the route that answered it: server, tool, argument shape | `operation` | Recall removes the listing and the search entirely |
18
+ | A sequence of calls that was necessary (find the team, then list its issues) | `plan` | No listing shows an order |
19
+ | A convention the schema does not state: pagination style, an id format, which argument filters by "me" | `fact` | Re-deriving it costs a failed call each run |
20
+ | That a capability does **not** exist on the enabled servers | `fact` | Proving a negative twice is waste |
21
+
22
+ Node text: **put the human phrasing first and the identifiers second**, and name
23
+ the server, because the next request arrives as a sentence, not a tool name:
24
+
25
+ ```
26
+ How to list my open Linear issues: mcp_call linear list_issues
27
+ { assignee: "me", state: "open", limit: 50 }. Paginate with `cursor` from the
28
+ reply. Checked against mcp_describe on 2026-11.
29
+ ```
30
+
31
+ Link the `operation` to the `task` that asked (`PRODUCED`), and to any `fact`
32
+ it depended on (`INFORMED`).
33
+
34
+ ## What never to commit
35
+
36
+ - **Tool results.** Issues, pull requests, messages and pages are the user's
37
+ data. Memory lives with the project and every user of the
38
+ project can recall it. Whatever an audience mask allows, the data goes stale
39
+ upstream the moment it is written.
40
+ - **Whole tool listings or schemas.** The project editor or the administrator
41
+ can change them at any time, and `mcp_describe` returns the current one in a
42
+ single call. Commit the route and the one or two arguments that mattered, not
43
+ `inputSchema`.
44
+ - **Connect URLs or anything from `auth_required`.** They are
45
+ per flow, per user, and expire.
46
+ - **User-specific ids** (a team, repo, workspace) in a node with audience `*`.
47
+ Commit how to find them (`list_teams` filtered by name), not the value.
48
+
49
+ ## Trust: a recalled route is a shortcut, not authority
50
+
51
+ A recalled route skips `mcp_servers` and `mcp_tools`, never `mcp_describe`
52
+ before the first call of that tool in a run. Then:
53
+
54
+ 1. If the server or tool is refused as not enabled, or the call fails on
55
+ argument validation, the route is stale.
56
+ 2. Re-discover (discovery.md §3).
57
+ 3. Commit the new route as an `operation` with `SUPERSEDES` pointing at the old
58
+ node. Do not edit or forget the old one.
59
+ 4. If the capability is gone entirely, commit that as a `fact` that supersedes
60
+ the route.
61
+
62
+ `zen memory ls --kind operation` is the review list for routes.
63
+
64
+ ## Where this policy is written
65
+
66
+ - In `agents/mcp-memory-instructions.md`, zen's own house rules file. It has
67
+ `requires: [tools:mcp, memory]`, so it reaches exactly the agents that have
68
+ both, and nothing has to be deleted in a project without `memory:`. Never edit
69
+ it: `zen check --fix` replaces it.
70
+ - Project-specific additions (for example, a team or audience that holds MCP
71
+ routes) go in `agents/memory-policy-instructions.md`, never in
72
+ `agents/memory-instructions.md` or `agents/mcp-memory-instructions.md` (zen's
73
+ own copies, see `zen-instructions`).
@@ -59,7 +59,7 @@ so choose it before the graph has anything in it.
59
59
 
60
60
  ```yaml
61
61
  embeddings:
62
- main: openai:text-embedding-3-small
62
+ main: openai/text-embedding-3-small
63
63
  memory:
64
64
  embedding: main
65
65
  ```
@@ -709,7 +709,7 @@ wants `zen inspect --memory <dir>` to rebuild its report against the same graph.
709
709
 
710
710
  ```yaml
711
711
  embeddings:
712
- main: openai:text-embedding-3-small
712
+ main: openai/text-embedding-3-small
713
713
 
714
714
  memory:
715
715
  dir: memory