Skip to main content
Glama

kb_write

Save or correct notebook notes on files, flows, and confirmed absences after finishing work, so later agents reuse what you learned. Batch multiple notes in one call.

Instructions

Save or correct NOTEBOOK notes after finishing real work here — you have the files in context, so no future agent is better placed to record what you learned. Write a file note (what a file is for), a flow note (how a task spans files), or an absence lesson (a confirmed "there is no X"). Pass specs (an ARRAY of specs) to write ALL your notes in ONE call — malformed notes are reported together instead of one hiding the rest, and the result ends with a coverage line naming any worked files still without a note; pass spec (a single object) for a one-off. Also the tool to FIX or RETRACT a note you used that proved wrong: op: "put" replaces; op: "retract" with target: {kind: "note"} removes the whole note (or target: {kind: "anchor"|"facet"|"invariant"|"behavior"|"feature", key: "<value>"} removes one part).

TWO-PHASE reuse gate: a flow/lesson spec sent WITHOUT an id first searches the notebook for the same concept. If plausible matches exist, kb_write returns {status:"candidates", candidates:[...]} INSTEAD of writing — re-call with into: "<id>" to merge into an existing note, or is_new: true to declare a genuinely new one. This makes note identity reliable (matching, not guessing an exact title). File notes skip the gate (id derives from the path).

The spec shape: type ("file"|"flow"|"lesson", or sugar "file-hub"/"file-single"), title, summary, anchors ([{path, symbols?}] — the addresses the note is about, which drive freshness), plus type-specific fields (file: facets/character; flow: steps/verified; lesson: kind:"absence"/scope/body). Call with NO arguments to get the full spec guide.

REQUIRED for the note to be findable at all — file-single: anchors[].symbols; file-hub: facets[].symbol; flow: steps + verified; lesson: scope.terms. Search ranks a note by its title and prose, plus its anchors in kb search: anchor symbols are what answers a query typed as an identifier.

This tool WRITES to the repo notebook; it never commits to git — publishing notes is a human-only step (coldstart kb commit).

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "kb_write"
  }
}

Input Schema

NameRequiredDescriptionDefault
intoNoPhase-2 answer: merge this write into the existing note with this id (from a prior `candidates` response).
specNoA single note spec (JSON object). Fields: type, title, summary, anchors:[{path,symbols?}], and type-specific fields (facets/character for file; steps/verified for flow; kind/scope/body for lesson). REQUIRED for the note to be findable at all — file-single: anchors[].symbols; file-hub: facets[].symbol; flow: steps + verified; lesson: scope.terms. Search ranks a note by its title and prose, plus its anchors in kb search: anchor symbols are what answers a query typed as an identifier. Omit `id` on a new flow/lesson to trigger the reuse gate. Use `specs` instead to write several notes at once.
agentNoOptional agent id (given in a capture prompt, alongside session). Selects THIS agent stream's durable worklist for the coverage line so a subagent does not clear the main agent's list. Defaults to "main".
specsNoThe capture path: an ARRAY of note specs (each the same shape as `spec`), written in ONE call. Order flows before the file notes that reference them. Well-formed notes are written; malformed ones are reported together (not atomic — a bad note never silences a good one); the result ends with a coverage line naming any worked file still without a note. Prefer this over many single-`spec` calls.
is_newNoPhase-2 answer: declare this a genuinely new concept, bypassing the candidate matches from a prior `candidates` response.
sessionNoOptional session id (given in a capture prompt). Enables the flow-evidence check: a flow whose step files this session never actually read gets a warning.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv2.4.0
    • changedInput schema / properties / spec / description
      Previous value: -"A single note spec (JSON object). Fields: type, title, summary, identityAliases (stable — unions forever), incidentAliases (this write's symptom words — replaced by the next write that changes summary/body, omit if this write isn't about an incident), anchors:[{path,symbols?}], and type-specific fields (facets/character for file; steps/verified for flow; kind/scope/body for lesson). REQUIRED for the note to be findable at all — file-single: identityAliases + anchors[].symbols; file-hub: identityAliases + facets[].symbol; flow: identityAliases + steps + verified; lesson: scope.terms. A note missing these is written but unreachable: identityAliases are the only STABLE search surface besides the exact title (incidentAliases are optional — symptom words for a write that describes one, replaced by the next such write, never required), and anchor symbols are the only channel that answers a query typed as an identifier. Omit `id` on a new flow/lesson to trigger the reuse gate. Use `specs` instead to write several notes at once."New value: +"A single note spec (JSON object). Fields: type, title, summary, anchors:[{path,symbols?}], and type-specific fields (facets/character for file; steps/verified for flow; kind/scope/body for lesson). REQUIRED for the note to be findable at all — file-single: anchors[].symbols; file-hub: facets[].symbol; flow: steps + verified; lesson: scope.terms. Search ranks a note by its title and prose, plus its anchors in kb search: anchor symbols are what answers a query typed as an identifier. Omit `id` on a new flow/lesson to trigger the reuse gate. Use `specs` instead to write several notes at once."
  2. Changed1 schema field changedv2.2.16
    • addedInput schema / properties / agent
      Added value: +{
      +  "description": "Optional agent id (given in a capture prompt, alongside session). Selects THIS agent stream's durable worklist for the coverage line so a subagent does not clear the main agent's list. Defaults to \"main\".",
      +  "type": "string"
      +}
  3. Changed2 schema fields changedv2.2.15
    • changedInput schema / properties / spec / description
      Previous value: -"The note spec (JSON object). Fields: type, title, summary, identityAliases (stable — unions forever), incidentAliases (this write's symptom words — replaced by the next write that changes summary/body, omit if this write isn't about an incident), anchors:[{path,symbols?}], and type-specific fields (facets/character for file; steps/verified for flow; kind/scope/body for lesson). REQUIRED for the note to be findable at all — file-single: identityAliases + anchors[].symbols; file-hub: identityAliases + facets[].symbol; flow: identityAliases + steps + verified; lesson: scope.terms. A note missing these is written but unreachable: identityAliases are the only STABLE search surface besides the exact title (incidentAliases are optional — symptom words for a write that describes one, replaced by the next such write, never required), and anchor symbols are the only channel that answers a query typed as an identifier. Omit `id` on a new flow/lesson to trigger the reuse gate."New value: +"A single note spec (JSON object). Fields: type, title, summary, identityAliases (stable — unions forever), incidentAliases (this write's symptom words — replaced by the next write that changes summary/body, omit if this write isn't about an incident), anchors:[{path,symbols?}], and type-specific fields (facets/character for file; steps/verified for flow; kind/scope/body for lesson). REQUIRED for the note to be findable at all — file-single: identityAliases + anchors[].symbols; file-hub: identityAliases + facets[].symbol; flow: identityAliases + steps + verified; lesson: scope.terms. A note missing these is written but unreachable: identityAliases are the only STABLE search surface besides the exact title (incidentAliases are optional — symptom words for a write that describes one, replaced by the next such write, never required), and anchor symbols are the only channel that answers a query typed as an identifier. Omit `id` on a new flow/lesson to trigger the reuse gate. Use `specs` instead to write several notes at once."
    • addedInput schema / properties / specs
      Added value: +{
      +  "description": "The capture path: an ARRAY of note specs (each the same shape as `spec`), written in ONE call. Order flows before the file notes that reference them. Well-formed notes are written; malformed ones are reported together (not atomic — a bad note never silences a good one); the result ends with a coverage line naming any worked file still without a note. Prefer this over many single-`spec` calls.",
      +  "items": {
      +    "type": "object"
      +  },
      +  "type": "array"
      +}
  4. Changed1 schema field changedv0.1.4
    • changedInput schema / properties / spec / description
      Previous value: -"The note spec (JSON object). Fields: type, title, summary, anchors:[{path,symbols?}], and type-specific fields (facets/character for file; steps for flow; kind/scope/body for lesson). See coldstart.md. Omit `id` on a new flow/lesson to trigger the reuse gate."New value: +"The note spec (JSON object). Fields: type, title, summary, identityAliases (stable — unions forever), incidentAliases (this write's symptom words — replaced by the next write that changes summary/body, omit if this write isn't about an incident), anchors:[{path,symbols?}], and type-specific fields (facets/character for file; steps/verified for flow; kind/scope/body for lesson). REQUIRED for the note to be findable at all — file-single: identityAliases + anchors[].symbols; file-hub: identityAliases + facets[].symbol; flow: identityAliases + steps + verified; lesson: scope.terms. A note missing these is written but unreachable: identityAliases are the only STABLE search surface besides the exact title (incidentAliases are optional — symptom words for a write that describes one, replaced by the next such write, never required), and anchor symbols are the only channel that answers a query typed as an identifier. Omit `id` on a new flow/lesson to trigger the reuse gate."
  5. First observedv0.1.0

TDQS

A4.7/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does so well: it discloses the non-atomic batch semantics ('malformed ones are reported together... a bad note never silences a good one'), the `{status:"candidates"}` short-circuit that returns instead of writing, the coverage line naming un-noted worked files, the session-based flow-evidence warning, and the important fact that the tool never commits to git (publishing is human-only). These are behaviors an agent could not infer from any structured field.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

It is long but front-loaded — the action and the `specs` batch path come first, and the retraction, two-phase gate and required-field rules follow in a sensible order. The main waste is redundancy: the 'spec shape' and 'REQUIRED for the note to be findable at all' paragraphs largely repeat the `spec` property description in the schema.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

There is no output schema, so the description must explain return shapes and it does: the candidates envelope, the grouped malformed-note reporting, and the trailing coverage line. Combined with the required-field rules per note type, an agent has everything needed to make a correct first call.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds real meaning on top: it tells the agent to order flows before the file notes that reference them in `specs`, explains `into`/`is_new` as phase-2 answers to a prior candidate response, and clarifies that `agent` selects a stream's durable worklist (defaulting to "main") while `session` enables the flow-evidence check. That is instruction-level semantics, not restatement.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description opens with a concrete verb+resource ('Save or correct NOTEBOOK notes') and then enumerates the exact note kinds it produces (file note, flow note, absence lesson) plus its repair roles (put replaces, retract removes). An agent can tell this is the notebook write path rather than a read/lookup path without opening the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage conditions are stated explicitly: write after finishing real work, prefer `specs` for all notes in one call and `spec` for a one-off, omit `id` to trigger the reuse gate and then answer with `into` or `is_new`. What's missing is any routing to sibling tools — kb_search, kb_lookup, kb_repair, kb_status and kb_search are never named, so the boundary between 'retract here' and 'repair elsewhere' is left to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools