Skip to content

Commit 5157070

Browse files
authored
Merge pull request #122 from Accenture/feat/mcp-binding-function-per-tool
feat(mcp-binding): a tool is a composable function - a preload function per tool, bound in code
2 parents 741d91b + 73837c9 commit 5157070

10 files changed

Lines changed: 558 additions & 419 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -43,28 +43,37 @@
4343
`retention` are now fields of the loop contract: on `llm.chat` they need `tools`, and on `llm.stream` any of them is a
4444
400. A loop turn needs `llm.transcript.store`; the sample configuration sets `memory`.
4545

46-
3. **The MCP binding: `extensions/mcp-binding/`, one composable route per allowlisted MCP tool (RFC-0011 / ADR-0033,
47-
build plan step 4).** A polyglot function host on the official MCP SDK (`@modelcontextprotocol/sdk`, a dev dependency
48-
of this repository and the app's own dependency outside it). Servers are named in `resources/mcp-servers.yml`, each with
49-
its transport (`stdio` with a command this process starts, or `http` with a streamable HTTP URL), its credential
50-
references (`${VAR}` placeholders resolved from the environment at boot, never logged; a stdio subprocess gets the
51-
SDK's minimal environment plus the variables listed), and its allowlist mapping each remote tool name to a route and
52-
the SHA-256 digest of the tool's input schema in canonical JSON. Boot connects every server before the host listens,
53-
lists its tools, and refuses to start - by name - when an allowlisted tool is missing or its schema no longer matches
54-
the digest, so a server-side change stops a deploy instead of reaching a model at run time. A route's body is the
55-
tool's arguments; its reply is the server's structured content, else the text of its content blocks; a result marked
56-
`isError` is a 400 carrying the server's text (the agent loop returns it to the model as that call's error), a slow
57-
call a 408, a protocol failure a 502, a lost connection a 503. `node mcp-binding.mjs describe [server]` prints each
58-
tool's digest and a catalog row for the graph, for the developer to review: the model reads the graph's descriptions,
59-
never the server's. `mcp.health` reports each server and its connection. The shared vector file
60-
`test/vectors/mcp-binding-vectors.json` (the Python twin runs the same bytes) pins the digest, the allowlist
61-
verification and the result mapping; the rest of the tests drive a fixture MCP server of this repository over both
62-
transports. Every bound route is an alias of one `preload` function, `mcp.tool` (private, bound to no tool), registered
63-
at boot with the server's `instances`; the function reads the route it was called as from its execution context
64-
(`getTrace().route`). **With it, `Platform` gains `onStartup(callback)`, `onCleanup(callback)` and `shutdown()`** - async
65-
callbacks run before the host listens and at shutdown (SIGINT and SIGTERM are handled only when a cleanup callback is
66-
registered), the place for an extension's asynchronous boot work; the routes a callback registers are announced with
67-
the others. **Upgrade note:** none - nothing changes for an application that registers no callback.
46+
3. **The MCP binding: `extensions/mcp-binding/`, a composable function per MCP tool (RFC-0011 / ADR-0033, build plan
47+
step 4; the declaration shape of the engines' `draft-design-specs/agent-tool-use.md`, 2026-11-16)** - in lockstep with
48+
the Python pack. A library and a function host on the official MCP SDK (`@modelcontextprotocol/sdk`, a dev dependency
49+
of this repository and the app's own dependency outside it). A tool of an MCP server is declared where every route is
50+
declared, in the code: `const render = bind('mermaid', 'validate_and_render_mermaid_diagram', { schemaSha256: '5ae6…' })`
51+
names the server, the remote tool and the SHA-256 digest of its input schema in canonical JSON and returns the tool as
52+
an async function, and an ordinary `preload` function (`mermaid.render`) calls it - passing the arguments through,
53+
shaping them or adding behaviour around the call. A route names the capability, never the transport: a tool may start
54+
as an MCP tool and later be implemented another way, and the graph must not know. Servers are named in
55+
`resources/mcp-servers.yml`, each with what is environment-specific: its transport (`stdio` with a command this process
56+
starts, or `http` with a streamable HTTP URL), its credential references (`${VAR}` placeholders resolved from the
57+
environment at boot, never logged; a stdio subprocess gets the SDK's default environment plus the variables listed) and
58+
its call timeout. Boot connects every server a function binds a tool of, before the host listens, lists its tools and
59+
refuses to start - by name - when a bound server is not configured, a bound tool is missing or its schema no longer
60+
matches the pinned digest, so a server-side change stops a deploy instead of reaching a model at run time; a configured
61+
server nobody binds is not connected. A function's body is the tool's arguments (a map, else a 400); its reply is the
62+
server's structured content, else the text of its content blocks; a result marked `isError` is a 400 carrying the
63+
server's text (the agent loop returns it to the model as that call's error), a slow call a 408, a protocol failure a 502,
64+
a server not connected a 503. `node mcp-binding.mjs describe [server]` prints each tool's digest, the `bind` line to
65+
paste and a catalog row for the graph, for the developer to review: the model reads the graph's descriptions, never the
66+
server's. `mcp.health` reports each connected server and how many tools its functions bind. Out of the box the default
67+
server file names the public Mermaid Chart MCP endpoint and the extension's `mermaid.render` binds its one tool, so the
68+
binding starts and serves a tool with no credential. The shared vector file `test/vectors/mcp-binding-vectors.json`
69+
(version 2; the Python twin runs the same bytes) pins the digest, the verification of declared bindings and the result
70+
mapping; the rest of the tests drive a fixture MCP server of this repository over both transports. The first shape of
71+
this binding (built 2026-11-14, before any release) read a `tools` allowlist under each server and registered each
72+
tool's route at boot as an alias of a private `mcp.tool` function; it is gone, and a leftover `tools` key is refused by
73+
name. **With it, `Platform` gains `onStartup(callback)`, `onCleanup(callback)` and `shutdown()`** - async callbacks run
74+
before the host listens and at shutdown (SIGINT and SIGTERM are handled only when a cleanup callback is registered), the
75+
place for an extension's asynchronous boot work; the routes a callback registers are announced with the others.
76+
**Upgrade note:** none - nothing changes for an application that registers no callback.
6877
4. **Route aliases: `preload` takes one route name or a comma-separated list** - in lockstep with the Python pack.
6978
`preload('hello.declarative, hello.world', { instances: 10 }, handler)` registers the same function under every name
7079
with the same `instances` and visibility - the Java engine's `@PreLoad(route = "a.b, c.d")` and the Rust port's

0 commit comments

Comments
 (0)