Skip to content

feat(platform): author automations over MCP at the editor's parity - #4592

Merged
yannickmonney merged 77 commits into
mainfrom
feat/mcp-authoring
Oct 9, 2026
Merged

yannickmonney merged 77 commits into
mainfrom
feat/mcp-authoring

Conversation

@yannickmonney

@yannickmonney yannickmonney commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

What changes

Tale's MCP endpoint becomes the guided way to author automations with a coding agent (Claude Code, Codex, Cursor, …): the agent can do everything the automation editor does for the same person, and every write is attributed and audited as the agent's.

Authoring at the editor's parity

  • save_automation takes baseVersion (a version saved since → AUTOMATION_VERSION_STALE with latestVersion), create, projectId, and the version's settings, taskContract and presentation; fields left out are carried from the latest version and named in carried.
  • get_automation answers the whole version and its metadata; test_automation tests a saved version and records the verdict that deploy_automation gates on; deploy_automation takes expectedDeployedVersion; start_run takes mode (live / mock); list_runs filters and pages; get_run names a waiting run's question (run.ask) and takes detail ([] answers the status alone, for polling).
  • New tools: delete_automation, set_automation_projects, answer_run_ask, get_automation_metrics, and discovery tools for what a document may name — list_models, list_harnesses, list_skills, list_connectors, list_agent_secrets (masked, owners/admins/developers only), list_projects, list_events.
  • Validation warns when a document names what the organization lacks (SKILL_UNKNOWN, CONNECTOR_NOT_CONNECTED, SECRET_UNKNOWN, HARNESS_UNKNOWN, EVENT_UNKNOWN), each with its closest name.

Protocol

  • MCP 2025-11-25 beside the older 2025 revisions, plus 2026-07-28 request by request (server/discover, header/body agreement, no initialize).
  • initialize answers instructions; read tools declare outputSchema and answer structuredContent.
  • Arguments are checked with zod: INVALID_ARGUMENTS lists every issue, cross-field rules included. An unexpected failure is INTERNAL_ERROR with a request id, never raw error text.
  • Resources (tale://docs/…, tale://catalog/…, automations, versions, runs), prompts (edit_automation, debug_failed_run, add_trigger), and the downloadable Tale skill (SKILL.md).
  • The MCP contract is pinned by a fingerprint and a schema snapshot; the inventory holds 40 tools with short descriptions.

Attribution, audit and budgets

  • Every write during an MCP call is audited via: mcp with the tool, the key id and the client name. REST definition writes are audited as the key's (via: api-key).
  • A version records the door it was saved through (createdVia) and the client: migration 0181, three nullable columns.
  • Each call is counted per person, key and day in mcp_client_activity (migration 0180).
  • Executions and answer_run_ask draw from the rest:execute budget.
  • Requests from browser origins the deployment does not accept are logged, and refused where TALE_MCP_ORIGIN_ENFORCE is set.

Visibility

  • An automation installed only in projects the key holder cannot read is hidden from MCP and REST reads (AUTOMATION_NOT_FOUND / 404), including its runs by name.

Docs and contract

  • The docs make the coding agent the AI path for automations.
  • The MCP endpoint page's tool tables are held to the inventory by a test.
  • New manual boxes for five clients, stale saves and asks.
  • API contract 3.27.0 (main took 3.22.0–3.26.0 while this was in review).

Verification

  • Real Postgres, 12 integration lanes, 177/177 checks: checkMcp, checkMcpAuthoringParity, checkMcpDiscovery, checkMcpResourcesPrompts, checkMcpEras, automations, run lifecycle, project visibility, managed configuration, REST door, asks, trigger pause. These cover the carry-save race and the tenant isolation of the new reads and writes.
  • Platform server 4443 tests, UI 2290; typecheck, oxlint, knip, lint:manual, lint:links clean after merging main (3.20.0–3.26.0: quarantine, API key owners, budgets, knowledge-entry writes, mentions, agent workers, embedding budgets; quarantined is now one shared run-status list for REST and MCP). The MCP app routes have their own telemetry route class, the CLI's turbo inputs hash the request-channel module it now imports, and a capability called over MCP books what it spends to the calling key.
  • Three adversarial reviews (protocol + security, contract + parity, agent experience) produced 26 findings, all fixed with tests except the two below. The worst: no MCP answer named the askId, so answer_run_ask could not be used.

Notes

  • A client on the 2025 revisions is named only on initialize, so its later rows may not carry its name (the docs say so). OAuth connections, which carry the client on every request, come in the follow-up.
  • Follow-ups: settings tools over MCP; agent-requested changes; OAuth sign-in and connected agents; guided setup in the setup wizard; subscription broker per harness.

The MCP door's JSON-RPC layer (mcp_http.ts and its 62 tests) moves by
git mv from backend/core/automations_builder/ to the new MCP domain as
protocol.ts; imports and the references to the old path follow. No
behaviour changes.
The MCP door no longer reuses the 0.4 ctx shim. callerFromRest turns what
the REST door proved (organization, person, live member role, API key,
request id) into one McpCaller, and the protocol layer reaches the engine
and the capability surface through an McpHost the door binds to the
database (engine-host.ts), so its tests need no shim. The developer gate
reads the role the door already read for the request instead of reading
it again, with the same refusal words.

RestCredential (the api-key arm) lives beside the door's other shared
types. The MCP-only RestContext and requireRestDeveloper leave the 0.4
rest helpers, and the three handler names only the shim answered leave
the vocabulary. New tests hold the caller, the engine scope
(api-key:<userId> with the key) and the door's seam (the proven caller
reaches the engine, a batch's further calls charge rest:api, the
Idempotency-Key header is refused). No answer on the wire changes.
The new MCP domain gets its spec (prefix MCP-) with the rules the door
keeps today, each named by the test that holds it: only owners, admins
and developers save, deploy or set a trigger (MCP-R17); a refusal is an
answer the agent reads (MCP-R18); a batch costs one request per call and
holds at most 20 (MCP-R19); an Idempotency-Key header is refused
(MCP-R20); an unknown protocol revision is answered with the ones the
endpoint speaks (MCP-R16). MCP-R1 to MCP-R15 stay free for the authoring
rules this endpoint is gaining.

The manual layer gains suites/mcp.md with MCP-F1 (connect Claude Code
with a key), listed in the guide's tables, and a register row for what
the unit tests own. The automations spec points at the MCP spec.
The MCP endpoint now records every answered request in
app.mcp_client_activity (migration 0180): one counter row per
organization, person, API key, method, tool and UTC day, with refusals
and unexpected failures counted apart and the name the client gave
itself on initialize, cleaned by the new displayClientName. Each call
also writes one log line. Neither keeps an argument, a result or an
address, and a failed count never fails the call.

Counters are swept after 90 days (maintenance.mcp_activity_ttl), erased
with the person, and deleted with the organization through its org_id
column. MCP-R21 states the rule; checkMcp probes it on Postgres.
Each MCP tool call now runs inside a request channel (AsyncLocalStorage,
backend/lib/request-channel.ts) naming the door, the request id, the
tool and the API key. createAuditLog reads it: a row written anywhere
during the call gains via: mcp, the tool, the key and the client in its
metadata, and the request id, before it is hashed, so the stored row
still verifies. A writer that names its own via or request id keeps
them, and nothing changes outside a channel.
Each tool's arguments are now one zod schema (lib/mcp/args.ts, the
trigger shape isolated in trigger-args.ts so the shared trigger contract
can replace it); tools/list advertises the JSON Schema generated from
it. A call that misses the schema is answered with one tool error,
INVALID_ARGUMENTS, listing every problem sorted by path (at most 50,
unknown keys named, values never echoed) instead of the first problem as
a -32602 protocol error. An unknown tool stays -32602.

The tools/call path moves into domains/mcp/tools.ts. A refusal a
surface throws keeps its code and its own sentence: an AppError is read
from its payload, never its serialized message, in the protocol and in
the engine's dispatch alike. Any other thrown error is a fault, answered
as INTERNAL_ERROR with the request id and reported server-side.
MCP-R7 and MCP-R8 state the rules.
Every MCP tool that executes an automation (run_automation,
test_automation, deploy_automation, run_deployed, start_run,
invoke_capability) now draws one rest:execute, the budget the REST
API's run starts draw from, once its role check has passed. A spent
budget is refused as RATE_LIMITED with data.retryAfterMs and nothing
runs; reads, validation, saving and refused calls draw nothing.

The inventory now carries each tool's role and lane. The door's
developer gate also covers run_deployed, start_run, cancel_run and
delete_trigger, which the store already refused for members, so a
member's start is refused before it is charged. MCP-R5 states the rule
and MCP-R17 names the live-run tools.
Every MCP read tool now states its answer: tools/list advertises an
outputSchema generated from lib/mcp/results.ts, and an answer that is
not a refusal carries the same object as structuredContent. The schemas
hold only what every answer carries, open to the rest, because a client
that validates refuses a call whose answer misses them; a test drives
each read tool through the real dispatch on the selftest host and checks
the answers with draft-07 and 2020-12 validators. Refusals and the tools
that act carry text only.

The text block is compact JSON now: 44% fewer characters on the six
golden fixtures (get_catalog 252k to 139k). Tools carry _meta hints:
deploy_automation and set_trigger ask the person before every call, and
the tools with large answers name the size a client should keep inline.
The MCP endpoint now speaks protocol revision 2025-11-25 beside
2025-06-18 and 2025-03-26, and refuses a header naming another revision
with -32022 and data.supported, the error a client speaking several
revisions retries on. initialize answers server instructions, built
from fragments that each name their tools so a sentence ships only with
its tools (lib/mcp/instructions.ts), and reports the API contract
version as serverInfo.version.

The inventory's fingerprint (protocol revisions, capabilities, every
tool's schemas, annotations and hints, prose excluded) is pinned to the
contract version in lib/mcp/contract-fingerprint.json, and every
advertised schema is kept in a reviewed snapshot. The contract moves to
3.20.0 with a paragraph naming every client-visible change of the MCP
endpoint so far; public/openapi.json follows.
The OpenAPI text named INVALID_ARGUMENTS in backticks, which the REST
error-code registry guard reads as a REST code the registry must carry.
It is a tool-result code of the MCP endpoint, never a REST envelope's,
so the text names it plainly.
MAX_ARGUMENT_ISSUES and refusalFromThrown are read only inside
domains/mcp/tools.ts, so they are no longer exported (knip).
…ions

Cursor offers a model at most 40 tools across its servers and Claude
Code keeps the first 2,048 characters of a description. The inventory
guard now fails when the list grows past 40 tools, when a description
runs longer, or when one names a snake_case tool the inventory does not
hold.
A request to /api/v1/mcp that carries an Origin header must come from
SITE_URL, ADDITIONAL_SITE_URLS or an origin listed in the new
TALE_MCP_ALLOWED_ORIGINS. From anywhere else it is logged as
[mcp] origin-mismatch with the origin, organization and person, and
answered; with TALE_MCP_ORIGIN_ENFORCE=true it is refused with 403
ORIGIN_FORBIDDEN before anything runs. Coding agents in a terminal and
server clients send no Origin and are never judged. The log line prints
only a normalized origin, never a caller's free text, and a malformed
origin list fails boot.

Enforcement stays off until the per-client manual rounds record which
clients send an Origin. MCP-R22 states the rule; checkMcp probes that a
foreign origin is still answered. The variables are in .env.example and
the environment reference (EN/DE/FR); ORIGIN_FORBIDDEN joins the REST
code registry and the MCP operation's 403 in the OpenAPI document.
The MCP endpoint page (EN/DE/FR) now names revision 2025-11-25, the
server instructions and serverInfo.version, -32022 with data.supported,
argument problems as one INVALID_ARGUMENTS tool error listing every
issue, outputSchema with structuredContent, compact JSON text, and the
RATE_LIMITED and INTERNAL_ERROR refusals. The rate-limits page names
the MCP tools that draw from the execution budget. The manual error-code
reference says how to provoke INVALID_ARGUMENTS, RATE_LIMITED,
INTERNAL_ERROR and -32022, and set_trigger's wrong-kind key now answers
INVALID_ARGUMENTS.
Saving a version, deploying one, setting or removing a trigger,
installing an automation in a project or removing it, and deleting the
automation wrote no audit row from any door. Each now writes one
`workflow` row in its own transaction (automations/audit.ts), whoever
made the change and through whichever door: the app, an upload, REST,
MCP, managed configuration, the shipped packs. A row names versions,
kinds and project ids, never a document, a webhook token or its hash;
a change that changed nothing writes none (AUTO-R27). Every such
writer now takes the organization's audit chain first, then the
automation's name, then the trigger row, the order trigger-failures.ts
documents.

Migration 0181 records on each version the door it was saved through
(created_via), the API key and the client's name; nullable, so the
previous image's saves read as "unknown door". The REST version list
keeps its documented fields.

The store gains what the MCP authoring tools build on: a carry mode for
saves that keeps the settings, task contract and presentation a save
leaves out (read under the name lock), compare-and-set on the live
version for a deploy (AUTOMATION_DEPLOYMENT_STALE, answering what was
live) and on the latest version for a delete, and a mode filter on run
listings.
The REST catalog listed every definition of the organization, an
automation installed only in projects the key holder cannot read
included (with its installations filtered to none, where it reads as an
organization automation and cannot run), and its read, versions and
triggers answered anyone. Such an automation is now left out of
GET /api/v1/automations, and its read, versions and triggers answer
404 AUTOMATION_NOT_FOUND, as for one that does not exist; one
installed nowhere stays the whole organization's (AUTO-R26). The
visibility rule the app's list and the MCP listing apply is one helper,
automationVisible.

The API reference (EN/DE/FR) and the OpenAPI description say so.
The REST door answered a run's question inline: the answer and its
resume, the audit row in the person's name and the best-effort comment
on the run's task. That body moves into
automations/ask-answer.ts (answerRunAskAs), which the REST door calls
after its own gates, so the MCP door can answer the same way. The REST
answer, its audit row and its mirror are unchanged; only the warning a
failed mirror logs now names the automations domain.
A coding agent's save sent only the document: the version's settings
form, task contract and presentation were lost on every agent save, and
nothing stopped it from overwriting a version saved meanwhile.
save_automation now takes baseVersion (a stale one is refused as data
naming the latest version and how to merge, MCP-R2), create, projectId
(a project the person may edit) and the three version fields, each
checked against the schema the app reads it with; a field left out is
kept from the latest version and named in `carried` (MCP-R1). A version
an agent saves records the door, the key and the client.

get_automation answers the whole version beside meta/automation;
test_automation tests a saved version and records its verdict;
deploy_automation takes expectedDeployedVersion and answers
previousVersion, so a rollback is a deploy of an older version
(MCP-R3); start_run takes mode, live by default and mock for any saved
version, which every member's agent may start and which is recorded
(MCP-R4); list_runs filters and pages with a cursor signed for its
listing and organization; list_versions answers createdVia, clientName
and the deploy history. New tools: delete_automation (expected latest
version), set_automation_projects (every project's edit gate, one
transaction), answer_run_ask (the REST answer's gates and record) and
get_automation_metrics (the platform's first own tool). Deploy, delete,
set_trigger, installing and answering ask the person first.

Reads over MCP answer only the automations the app would show the
person (MCP-R9), and every write runs in a channel naming the coding
agent (MCP-R14). The inventory fingerprint and schema snapshot move
within the unshipped contract 3.20.0, whose paragraph names it all.
The MCP endpoint page (EN/DE/FR) gains the new tools and answers: a
save that keeps what it leaves out and refuses a stale baseVersion
(#save), the whole version from get_automation, the deploy's
expectedDeployedVersion and previousVersion, delete_automation, mock
starts any member may make, run pages, deploy history, installations,
answering a run's question and the run figures; who may do what,
hidden automations, the audit trail, and the new refusal codes.

The manual references name the specs' new rules beside their tests and
how to provoke each new MCP refusal; the stale-version row no longer
says MCP saves append blindly.
checkMcpAuthoringParity drives the HTTP door against Postgres: an
editor save with settings and a task contract, then an agent save that
keeps both and records created_via 'mcp' and its key (MCP-R1, 0181); a
stale baseVersion and a settings value its reader refuses (MCP-R2); a
deploy against the wrong live version, a rollback and a restore
(MCP-R3); the whole version and the deploy history; a member's recorded
mock start of an undeployed version beside a refused live one (MCP-R4);
an automation installed only in a team project hidden from the member
over MCP and REST (MCP-R9, AUTO-R26); installations, run figures and a
compare-and-set delete; and an audit row stamped via 'mcp' with the
tool and the request for every one of those writes (MCP-R14, AUTO-R27).
Registered after checkMcp; not run here.
… backend

Which agent runtime a listed model is offered to moves from the project
feature into lib/shared/harness-offer.ts, with the default harness the
runtime and the pickers each kept a copy of, so the MCP model listing can
compute the same offer the editor shows. No behaviour changes.
Validation now compares a document with the organization: an agent
step's skill no run can reach (SKILL_UNKNOWN), a connector nobody
connected or the deployment lacks (CONNECTOR_NOT_CONNECTED, also for a
connector action's step), a secret nobody stored (SECRET_UNKNOWN), a
runtime the managed lane cannot run (HARNESS_UNKNOWN), and an event
trigger waiting for an event Tale does not raise (EVENT_UNKNOWN).

The facts come from one batched StoreAdapter.orgFacts call that reads
only what the document names, in the caller's organization, within a
5 s budget; what it cannot tell warns about nothing. Secret names are a
fact only for owners, admins and developers. Warnings never block a
save. The upload door keeps its own carried-skill check and reads no
organization facts, so configuration releases deploy as before.

Catalog entries in en/de/fr (de-CH overrides), golden fixtures, a corpus
organization, spec card MCP-R15, the concepts docs and box AUTO-F69.
Seven MCP discovery tools, in a new discovery group, list what a
document may name, from the readers the editor's pickers use, for the
caller in the caller's organization:

- list_models: the member's governed models, each with its lane, the
  step types it suits and the managed runtimes it is offered to (the
  pickers' offeredToHarness rule); nodeType and harness filter it.
- list_harnesses: the managed runtimes, the default, and which a
  subscription can serve.
- list_skills: the organization's skills, or a readable project's with
  its team skills; any other project is PROJECT_NOT_FOUND.
- list_connectors: the catalog and whether this organization connected
  each.
- list_agent_secrets: names and masked previews for owners, admins and
  developers; anyone else gets an empty list with a note. Never a value.
- list_projects: the readable projects with only the automations the
  person may see.
- list_events: every raised event with one English sentence on when it
  fires (EVENT_DESCRIPTIONS, exhaustive over EventType).

validate_automation takes detail ([] answers the issues alone). The
server instructions gain a fragment naming the tools; the inventory
snapshot and fingerprint are re-recorded. Spec card MCP-R23, the MCP
settings tab's Discovery group in en/de/fr, the endpoint docs in
EN/DE/FR and a manual reference row.
A checkMcpDiscovery lane drives the discovery tools and the validator's
organization warnings through the real MCP door and the editor's
validate route: a connected and an unconnected connector, an agent
secret's name for the owner and an empty list for a member with its
value never in an answer, a team project and its skills not found for
a member, another organization's project, secret and connector
invisible, every raised event, the runtimes and the governed models,
and the five warnings (SKILL_UNKNOWN, CONNECTOR_NOT_CONNECTED,
SECRET_UNKNOWN told only to the owner, HARNESS_UNKNOWN and, through a
legacy trigger row, EVENT_UNKNOWN). The lane removes what it planted.
origin/main published 3.20.0 for quarantined legacy runs, so the MCP
authoring changes move to the next free minor: the contract constant,
both fingerprint records, the published OpenAPI version and the error
code reference. The 3.21.0 paragraph also names the discovery tools,
validate_automation's detail and the organization warnings. Main's
3.20.0 paragraph joins this file at rebase.
…part

The authoring reference keeps its exact text; its four core node-kind
sections and its section on reading validation results become exports,
so the catalog and the validation reference can serve the same words.
The MCP endpoint now answers resources/list, resources/templates/list,
resources/read, prompts/list and prompts/get, and initialize advertises
both. A resource is the read a tool already answers: tale://docs/<topic>
is get_docs, tale://catalog/<kind> get_catalog, tale://automations/<name>
(and /versions/<version>) get_automation, tale://runs/<runId> get_run,
read through callTool with its checks, so a hidden automation is
"resource not found" (-32002, data.code AUTOMATION_NOT_FOUND) exactly as
the tool refuses it. The list names the references, the catalog, then the
automations list_automations answers, 100 a page.

Prompts edit_automation, debug_failed_run and add_trigger attach what
they are about, read with the caller's rights; a required read that fails
refuses the prompt (-32602 with the read's code). Lines of prompts and
the skill ship only when their tools exist, like the instructions.

get_docs takes topic (triggers, validation, skill): the triggers
reference is built from set_trigger's schema, the raised events and the
backend's delivery constants; the validation reference lists every issue
code. get_catalog narrowed to a core kind answers its section of the
reference. The Tale skill (SKILL.md, Agent Skills format, name tale) is
deployment-agnostic and downloads from GET /api/app/mcp/skill.

In a batch, resource reads, listings and prompts are charged like tool
calls after the first, and every new method is counted in the activity
table. Spec cards MCP-R24 and MCP-R25; the contract fingerprint covers
resources, templates and prompts (3.21.0, unshipped).
The MCP endpoint page (EN/DE/FR) gains Resources and prompts: every
address, what it reads like, the -32002 and -32602 answers, the three
prompts and their arguments; get_docs topics, batch charging and the
core-kind reference join the existing sections, and the stale tool count
goes. The editor guide shows the /tale: prompts and @tale: mentions in
Claude Code and how to install the Tale skill for Claude Code and Codex.

Manual suite mcp gains MCP-F3, MCP-F7, MCP-F8 and MCP-F11; the automation
reference gets a row for MCP-R24/R25 and error-codes rows for -32002 and
a refused prompt.
checkMcpResourcesPrompts, after checkMcpDiscovery: initialize advertises
resources and prompts; the list names the references, the catalog and
the automations each person may see (a member never sees one installed
only in a team project they are not in); every kind of address reads as
its tool answers, never with the webhook token; a hidden automation and
another organization's read as -32002 AUTOMATION_NOT_FOUND; prompts
attach what they are about and refuse a member's prompt about the hidden
automation and one about a run that never was; the skill downloads for a
session only, byte for byte the resource; reads are counted. The lane
removes what it creates.
A client that asks for each prompt argument in a form sends one the
person left empty as an empty string. prompts/get refused that as
"must not be blank", so edit_automation without a name, the way to
start a new automation, failed in such a client. An empty argument is
now one that was not given: an optional one is absent, a required one
is missing. The MCP endpoint page says so in EN/DE/FR.
@yannickmonney
yannickmonney marked this pull request as draft October 9, 2026 04:43
@yannickmonney
yannickmonney marked this pull request as ready for review October 9, 2026 04:54
@yannickmonney
yannickmonney merged commit 8c1da44 into main Oct 9, 2026
@yannickmonney
yannickmonney deleted the feat/mcp-authoring branch October 9, 2026 04:55
tale-code-bot added a commit that referenced this pull request Oct 30, 2026
A database restart during an MCP tool call was reported to error
tracking at error level, once per failing call, and the agent got
INTERNAL_ERROR. The catch blocks of callTool (#4592) and of the settings
writer loop (#4685) answered every non-refusal as a fault without asking
db/unavailable.ts, which the REST and app doors have used since #3506.

Both now ask databaseUnavailableCause first, through one helper in
domains/mcp/refusals.ts: such a call writes one warning line, reports
nothing and answers DATABASE_UNAVAILABLE with data.retryAfterMs 5000,
the REST door's Retry-After. A settings write answers it beside what
landed; a resource read, the resource list and a prompt answer -32603
with the code and the wait, never "resource not found". It counts as a
refusal, not a failure. Any other failure keeps INTERNAL_ERROR and its
report, a bare socket error no database client stamped included.

The MCP spec gains MCP-R43 (MCP-R8's example used a database outage as
its fault), the manual suite MCP-B3 and the error-code rows, the Tale
skill, the settings reference and the docs the code, and the contract
moves to 3.50.0.

Closes #4771
tale-review-bot pushed a commit that referenced this pull request Oct 30, 2026
A database restart during an MCP tool call was reported to error
tracking at error level, once per failing call, and the agent got
INTERNAL_ERROR. The catch blocks of callTool (#4592) and of the settings
writer loop (#4685) answered every non-refusal as a fault without asking
db/unavailable.ts, which the REST and app doors have used since #3506.

Both now ask databaseUnavailableCause first, through one helper in
domains/mcp/refusals.ts: such a call writes one warning line, reports
nothing and answers DATABASE_UNAVAILABLE with data.retryAfterMs 5000,
the REST door's Retry-After. A settings write answers it beside what
landed; a resource read, the resource list and a prompt answer -32603
with the code and the wait, never "resource not found". It counts as a
refusal, not a failure. Any other failure keeps INTERNAL_ERROR and its
report, a bare socket error no database client stamped included.

The MCP spec gains MCP-R43 (MCP-R8's example used a database outage as
its fault), the manual suite MCP-B3 and the error-code rows, the Tale
skill, the settings reference and the docs the code, and the contract
moves to 3.50.0.

Closes #4771
Task: TALE-149
yannickmonney pushed a commit that referenced this pull request Oct 30, 2026
A database restart during an MCP tool call was reported to error
tracking at error level, once per failing call, and the agent got
INTERNAL_ERROR. The catch blocks of callTool (#4592) and of the settings
writer loop (#4685) answered every non-refusal as a fault without asking
db/unavailable.ts, which the REST and app doors have used since #3506.

Both now ask databaseUnavailableCause first, through one helper in
domains/mcp/refusals.ts: such a call writes one warning line, reports
nothing and answers DATABASE_UNAVAILABLE with data.retryAfterMs 5000,
the REST door's Retry-After. A settings write answers it beside what
landed; a resource read, the resource list and a prompt answer -32603
with the code and the wait, never "resource not found". It counts as a
refusal, not a failure. Any other failure keeps INTERNAL_ERROR and its
report, a bare socket error no database client stamped included.

The MCP spec gains MCP-R43 (MCP-R8's example used a database outage as
its fault), the manual suite MCP-B3 and the error-code rows, the Tale
skill, the settings reference and the docs the code, and the contract
moves to 3.50.0.

Closes #4771
Task: TALE-149
tale-code-bot added a commit that referenced this pull request Oct 30, 2026
A database restart during an MCP tool call was reported to error
tracking at error level, once per failing call, and the agent got
INTERNAL_ERROR. The catch blocks of callTool (#4592) and of the settings
writer loop (#4685) answered every non-refusal as a fault without asking
db/unavailable.ts, which the REST and app doors have used since #3506.

Both now ask databaseUnavailableCause first, through one helper in
domains/mcp/refusals.ts: such a call writes one warning line, reports
nothing and answers DATABASE_UNAVAILABLE with data.retryAfterMs 5000,
the REST door's Retry-After. A settings write answers it beside what
landed; a resource read, the resource list and a prompt answer -32603
with the code and the wait, never "resource not found". It counts as a
refusal, not a failure. Any other failure keeps INTERNAL_ERROR and its
report, a bare socket error no database client stamped included.

The MCP spec gains MCP-R43 (MCP-R8's example used a database outage as
its fault), the manual suite MCP-B3 and the error-code rows, the Tale
skill, the settings reference and the docs the code, and the contract
moves to 3.50.0.

Closes #4771
Task: TALE-149
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant