From 0b87e469dadda319fe0e7613c551e1d34bbf339c Mon Sep 17 00:00:00 2001 From: Eric Law <39393654+acn-ericlaw@users.noreply.github.com> Date: Wed, 18 Nov 2026 17:08:40 +0800 Subject: [PATCH 1/3] feat(mcp-binding): recipes for tools from existing MCP servers - mcp-recipes.yml, the shared digest vector and the gated live test (RFC-0013 step 5) Co-Authored-By: Claude Fable 5.1 --- CHANGELOG.md | 11 ++ extensions/mcp-binding/README.md | 13 ++ .../mcp-binding/resources/mcp-recipes.yml | 85 ++++++++++ .../thread-bp-agent-tools-python.md | 10 +- memory/sessions/2026-11-18-090840.md | 38 +++++ tests/test_mcp_recipes.py | 151 ++++++++++++++++++ tests/vectors/mcp-recipes.json | 93 +++++++++++ 7 files changed, 398 insertions(+), 3 deletions(-) create mode 100644 extensions/mcp-binding/resources/mcp-recipes.yml create mode 100644 memory/sessions/2026-11-18-090840.md create mode 100644 tests/test_mcp_recipes.py create mode 100644 tests/vectors/mcp-recipes.json diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d97509..b17e803 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -70,6 +70,17 @@ `dev/graph-up.sh` and `graph-down.sh` run Neo4j Community on Colima for development; the live test runs against it when `TOOLS_GRAPH_TEST_URI` is set. The five new catalog rows join the `catalog/` folder and `describe`. +4. **Recipes for tools from existing MCP servers (RFC-0013 in mercury-composable, step 5).** + `extensions/mcp-binding/resources/mcp-recipes.yml` holds one ready server-file entry for each server of the engines' + page *Tools from MCP Servers* - the reference servers Git, Time, Fetch and Filesystem (`uvx` and `npx`, versions + pinned), Neo4j's Cypher server, GitHub's hosted server and Playwright's browser - with every environment-specific + value a `${NAME:default}` reference and every credential a reference without a default. The binding does not load + the file; an entry is copied into `mcp-servers.yml` and its tools declared with `bind` as before. + `tests/vectors/mcp-recipes.json`, shared byte for byte with the Node.js pack, pins the input-schema digests of the + six servers that list their tools without a credential (56 tools, read 2026-11-18 through both packs' `describe`, + identical), and `tests/test_mcp_recipes.py` loads the recipes file on every run and, with `MCP_RECIPES_LIVE=1`, + starts each server through the binding's own probe and compares the digests, so a recipe that rots fails by name. + ### Fixed 1. **A direct `python extensions/mcp-binding/mcp_binding.py` now connects its servers.** The binding attached its boot diff --git a/extensions/mcp-binding/README.md b/extensions/mcp-binding/README.md index dd741f7..3a18794 100644 --- a/extensions/mcp-binding/README.md +++ b/extensions/mcp-binding/README.md @@ -122,6 +122,18 @@ catalog row (name your function's route; review the description before the graph A tool the server offers but no function binds is shown as `not bound` and is never served. +## Recipes + +`resources/mcp-recipes.yml` holds one ready entry for each server of the engines' page +[Tools from MCP Servers](https://accenture.github.io/mercury-composable/guides/tools-from-mcp-servers/): the reference +servers Git, Time, Fetch and Filesystem (started with `uvx` and `npx`, versions pinned), Neo4j's Cypher server, GitHub's +hosted server and Playwright's browser. Every environment-specific value is a `${NAME:default}` reference and every +credential a reference without a default. The binding does not read the file: copy an entry into `mcp-servers.yml`, +set the references it names, run `describe` on it and declare the tools you want with `bind` and a function, as above. +The page carries the digests of the six servers that list their tools without a credential, read on 2026-11-18 from +the pinned versions, and `tests/test_mcp_recipes.py` re-reads them live when `MCP_RECIPES_LIVE=1` is set (the Neo4j +server also wants `NEO4J_PASSWORD` and a database): a recipe that rots fails at the digest, as the boot would. + ## The function contract | | | @@ -182,6 +194,7 @@ server's `tools/call` is inside that `exec_time`, not a span of its own. Driven ```bash pip install -e '.[dev]' pytest tests/test_mcp_binding.py +MCP_RECIPES_LIVE=1 pytest tests/test_mcp_recipes.py # starts the recipe servers with uvx and npx ``` The shared vector file pins the pure half (the digest, the verification of declared bindings, the result mapping) in diff --git a/extensions/mcp-binding/resources/mcp-recipes.yml b/extensions/mcp-binding/resources/mcp-recipes.yml new file mode 100644 index 0000000..3d580f6 --- /dev/null +++ b/extensions/mcp-binding/resources/mcp-recipes.yml @@ -0,0 +1,85 @@ +# Recipes - the MCP servers of the engines' page "Tools from MCP servers" (RFC-0013, step 5), one +# entry per server, ready to copy into mcp-servers.yml. The binding does not read this file by +# default, and nothing here is served until a function binds a tool of it: a bind line in +# mcp_binding.py (or in an application that imports it), a preload function on a route of your own, +# a catalog row on the graph and an Event-over-HTTP entry on the engine. +# +# Everything environment-specific is a ${NAME:default} reference, resolved from this process's +# environment at boot. A credential has no default, so a missing one stops the boot by name, and a +# resolved value is never logged. The package versions are the ones the page's digests were read +# from (2026-11-18): bump one, run describe, review the schema and re-pin the digest next to the +# function that binds the tool. +# +# The gated test tests/test_mcp_recipes.py loads this file on every run and, with MCP_RECIPES_LIVE=1, +# starts each server with uvx or npx through the binding's own probe and checks the digests pinned +# in tests/vectors/mcp-recipes.json (the Neo4j server also wants NEO4J_PASSWORD and a database, for +# example the one extensions/agent-tools/dev/graph-up.sh starts). +servers: + # Git (reference server, Python). The history and state of one repository; --repository confines + # every tool to it, and the function that binds a tool adds repo_path from configuration, so no + # graph names a path. The reads are git_status, git_diff_unstaged, git_diff_staged, git_diff, + # git_log, git_show, git_branch and git_remote; git_add, git_commit, git_reset, git_create_branch, + # git_checkout and git_merge are write: true on the graph. + git: + transport: stdio + command: uvx + args: ['mcp-server-git==2026.11.11', '--repository', '${MCP_GIT_REPOSITORY:/srv/repository}'] + # Time (reference server, Python). The alternative to the built-in time.now when a use case + # converts between zones or reasons about relative times; --local-timezone fixes the server's + # default zone. All three tools read. + time: + transport: stdio + command: uvx + args: ['mcp-server-time==2026.11.11', '--local-timezone', '${MCP_TIME_ZONE:UTC}'] + # Fetch (reference server, Python). The alternative to the built-in web.fetch: one tool, Markdown + # out, robots.txt honoured, private addresses refused by default, and --allowed-hosts as the + # allowlist (repeat the option for more hosts). The built-in web.crawl has no counterpart here. + fetch: + transport: stdio + command: uvx + args: ['mcp-server-fetch==2026.11.11', '--allowed-hosts', '${MCP_FETCH_ALLOWED_HOST:docs.example.com}'] + # Filesystem (reference server, Node.js). The alternative to the built-in file.* tools, started in + # read-only mode: the ten tools that read and list. Without --read-only the server also offers + # write_file, edit_file, create_directory, move_file and copy_file, each write: true on the graph. + # The directories named are the sandbox; a path outside them is refused by the server. + filesystem: + transport: stdio + command: npx + args: ['-y', '@modelcontextprotocol/server-filesystem@2.3.0', '--read-only', '${MCP_FILESYSTEM_ROOT:/srv/documents}'] + # Neo4j's Cypher server (vendor server, Python). The alternative to graph.schema, graph.query and + # graph.write over the vendor's own server: get_neo4j_schema (needs the APOC plugin in the + # database), read_neo4j_cypher and write_neo4j_cypher (write: true on the graph; add --read-only to + # leave it out of the listing). graph.ingest has no counterpart - the model would write the MERGE + # statements itself. + neo4j: + transport: stdio + command: uvx + args: ['mcp-neo4j-cypher==0.6.0'] + env: + NEO4J_URI: '${NEO4J_URI:bolt://127.0.0.1:7687}' + NEO4J_USERNAME: '${NEO4J_USERNAME:neo4j}' + NEO4J_PASSWORD: '${NEO4J_PASSWORD}' + NEO4J_DATABASE: '${NEO4J_DATABASE:neo4j}' + # GitHub's server (vendor server). The hosted endpoint over streamable HTTP with a fine-grained + # personal access token of least privilege (or the deployment's GitHub App token); the toolsets + # header selects the tool families, the read-only header hides every write. The listing needs the + # credential, so its digests are not pinned on the page: run describe with the token and pin what it + # prints. A self-hosted alternative is the vendor's container image over stdio. + github: + transport: http + url: 'https://api.githubcopilot.com/mcp/' + headers: + Authorization: 'Bearer ${GITHUB_MCP_TOKEN}' + X-MCP-Toolsets: '${GITHUB_MCP_TOOLSETS:repos,issues,pull_requests}' + X-MCP-Readonly: '${GITHUB_MCP_READONLY:true}' + timeout_ms: 30000 + # Playwright's server (vendor server, Node.js). A headless browser with an in-memory profile; + # --allowed-origins is the allowlist of sites the browser may request. The reads are the snapshot, + # the screenshot, find, the console and network listings and navigation; the actions (click, type, + # fill_form, select_option, press_key, drag, file_upload, handle_dialog) are write: true on the + # graph; browser_evaluate and browser_run_code_unsafe are never bound. + playwright: + transport: stdio + command: npx + args: ['-y', '@playwright/mcp@0.0.85', '--headless', '--isolated', '--allowed-origins', '${MCP_PLAYWRIGHT_ORIGINS:https://docs.example.com}'] + timeout_ms: 60000 diff --git a/memory/open-threads/thread-bp-agent-tools-python.md b/memory/open-threads/thread-bp-agent-tools-python.md index be1f544..587faa1 100644 --- a/memory/open-threads/thread-bp-agent-tools-python.md +++ b/memory/open-threads/thread-bp-agent-tools-python.md @@ -13,8 +13,12 @@ `graph-down.sh`, 161 tests and a live round trip on the development Neo4j; eight defaults set without a ruling in the session log. The Node twin landed as mercury-nodejs #130; the Playground's three graphs as mercury-composable #647 (step 4), driven live through both packs 2026-11-17 - the drive taught a relative `include` - (PR #65, merge `30cbb0d`, MERGED 2026-11-17, with the README's Event-over-HTTP snippet corrected to one route per entry). Next: nothing - here until the recipes page (step 5, the engine's). The plan as settled - step 1: `extensions/agent-tools/agent_tools.py` (the layout of `extensions/mcp-binding`: a module docstring, a + (PR #65, merge `30cbb0d`, MERGED 2026-11-17, with the README's Event-over-HTTP snippet corrected to one route per entry). **Step 5, the pack's half, BUILT 2026-11-18:** `extensions/mcp-binding/resources/mcp-recipes.yml` (seven server + entries - git, time, fetch, filesystem, neo4j, github, playwright - with `${NAME:default}` references and pinned + versions, not loaded by default), the shared digest vector `tests/vectors/mcp-recipes.json` (56 tools of the six + servers that list without a credential, read through `describe`, identical from both packs) and + `tests/test_mcp_recipes.py` (five tests on every run, six gated live on `MCP_RECIPES_LIVE=1`; 11 passed live); the + page is the engine's `docs/guides/tools-from-mcp-servers.md`. Next: nothing until Eric rules on RFC-0013's promotion. The plan as settled - step 1: `extensions/agent-tools/agent_tools.py` (the layout of `extensions/mcp-binding`: a module docstring, a `README.md`, `resources/application.yml`, a `describe` command printing every catalog row, `platform.on_startup` for the gated registration) with the file tools inside `tools.file.root` (`file.read`, `file.write` marked `write: true` with `create` the default, `file.list`, `file.search`; paths resolved with symlinks followed and refused outside the root; @@ -34,4 +38,4 @@ plus its skill inventory `files.list`), the Node twin (step 3), the Playground graphs and the recipes (steps 4-5, in the engine repo). RFC-0012 is done and promoted (ADR-0035, mercury-composable #643). → serves: vision-mercury-python - + diff --git a/memory/sessions/2026-11-18-090840.md b/memory/sessions/2026-11-18-090840.md new file mode 100644 index 0000000..387fa75 --- /dev/null +++ b/memory/sessions/2026-11-18-090840.md @@ -0,0 +1,38 @@ +# Session (2026-11-18T09:08:40.000Z) + +**Agent:** Claude Code +**Title:** RFC-0013 step 5, the pack's half - the MCP recipes file, the shared digest vector and the gated live test +**User:** Eric - "both npx and uvx are available in this dev machine. please continue with step 5." + +## What We Did + +- **`extensions/mcp-binding/resources/mcp-recipes.yml`:** one ready server-file entry per recipe of the engines' page + "Tools from MCP Servers" - the reference servers Git, Time, Fetch (`uvx`, 2026.11.11) and Filesystem (`npx`, 2.3.0, + `--read-only`), Neo4j's Cypher server (`uvx`, 0.6.0, the connection from `NEO4J_*` variables), GitHub's hosted server + (streamable HTTP, a token reference, the toolsets and read-only headers) and Playwright's browser (`npx`, 0.0.85, + `--headless --isolated --allowed-origins`). Every environment-specific value is a `${NAME:default}` reference, every + credential a reference without a default; the binding does not load the file. +- **`tests/vectors/mcp-recipes.json`:** the input-schema digests of 56 tools of the six servers that list their tools + without a credential, read on 2026-11-18 through `describe` from the pinned versions; the Node.js binding printed the + same digests line for line. Shared byte for byte with the Node pack, pinned by SHA in both tests. +- **`tests/test_mcp_recipes.py`:** on every run the vector pin, the seven servers with their transports and commands, + the references resolved from the environment, every pinned server with a recipe and tools, the rot helper; gated on + `MCP_RECIPES_LIVE=1`, each credential-free server started through the binding's own probe and its digests compared + (the Neo4j one also wants `NEO4J_PASSWORD`): 11 passed live in about twenty seconds against the development Neo4j. +- README (a Recipes section, the live command), CHANGELOG Unreleased/Added 4. +- **What the build taught:** `args` are resolved through `${}` like `env` and `headers`, so a path placeholder works in + an argument list; the Neo4j server reads `NEO4J_URI`, `NEO4J_USERNAME`, `NEO4J_PASSWORD` and `NEO4J_DATABASE` from + its environment and `--read-only` lists two tools of three; the Filesystem server's `--read-only` lists ten of + fifteen; the Fetch server's own description addresses a chat assistant, which is why the graph's row is rewritten; + the engine's loop refuses `$schema` and `anyOf`, so a row is never a copy of `describe`'s output; a credential + reference without a default fails `load_servers` for the whole file, so the test sets placeholders for the + credentials it never sends. +- Gates: ruff OK, basedpyright OK, pytest 603 passed (the live Mermaid test failed once in the full run and passed + alone - the public endpoint). Diff scanned for [[conv-compartment-downstream-secrets]]: fictional hosts only. + +## Memory References + +- Referenced: bp-agent-tools-python (edited: step 5's pack half), mcp-binding-function-per-tool (the bind shape the + recipes apply), conv-compartment-downstream-secrets (the diff scanned) +- Created: (none) +- Superseded: (none) diff --git a/tests/test_mcp_recipes.py b/tests/test_mcp_recipes.py new file mode 100644 index 0000000..e383964 --- /dev/null +++ b/tests/test_mcp_recipes.py @@ -0,0 +1,151 @@ +"""The MCP recipes (extensions/mcp-binding/resources/mcp-recipes.yml) and the digests they pin. + +The engines' page "Tools from MCP servers" (RFC-0013, step 5) gives a recipe for each of seven MCP +servers - the server-file entry, the ``bind`` lines and the catalog rows. The entries live in +``mcp-recipes.yml``, which the binding does not load by default, and the input-schema digests of +the six servers that list their tools without a credential are pinned in +``tests/vectors/mcp-recipes.json``, shared byte for byte with the Node.js twin. The tests here load +the recipes file on every run and, when ``MCP_RECIPES_LIVE`` is set, start each server with ``uvx`` +or ``npx`` through the binding's own probe and compare the digests, so a recipe that rots is caught +at the digest, as the binding's boot would catch it. +""" + +from __future__ import annotations + +import hashlib +import importlib.util +import json +import os +import sys +from pathlib import Path +from typing import Any + +import pytest + +_TESTS = Path(__file__).resolve().parent +_BINDING = _TESTS.parent / "extensions" / "mcp-binding" / "mcp_binding.py" +_RECIPES = _BINDING.parent / "resources" / "mcp-recipes.yml" +_DIGESTS = _TESTS / "vectors" / "mcp-recipes.json" +# the Node.js twin pins the same digest: change the file in both packs or in neither +_DIGESTS_SHA256 = "10c70fe179d315cb0932d56cf0bc1e11290eb7c922ff439e5b9e7944df437d53" + +_spec = importlib.util.spec_from_file_location("mcp_binding_recipes_under_test", _BINDING) +assert _spec is not None +assert _spec.loader is not None +# typed Any: the module is loaded dynamically from a file path, so its attributes are +# unknowable statically - Any tells every analyzer to trust the runtime +binding: Any = importlib.util.module_from_spec(_spec) +sys.modules.setdefault("mcp_binding_recipes_under_test", binding) +_spec.loader.exec_module(binding) + +DIGESTS: dict[str, Any] = json.loads(_DIGESTS.read_text(encoding="utf-8")) +LIVE = bool(os.environ.get("MCP_RECIPES_LIVE")) +RECIPE_SERVERS = ["fetch", "filesystem", "git", "github", "neo4j", "playwright", "time"] +# the servers that list their tools without a credential - the ones the page pins +CREDENTIAL_FREE = ["git", "time", "fetch", "filesystem", "playwright"] +# a credential the file references but these tests never send gets a placeholder, so the file +# loads; a real value already in the environment (the Neo4j run) is kept +PLACEHOLDERS = { + "GITHUB_MCP_TOKEN": "not-used-by-this-test", + "NEO4J_PASSWORD": "not-used-by-this-test", +} + + +@pytest.fixture +def recipes(monkeypatch: pytest.MonkeyPatch, tmp_path: Path) -> dict[str, Any]: + for name, placeholder in PLACEHOLDERS.items(): + monkeypatch.setenv(name, os.environ.get(name) or placeholder) + monkeypatch.setenv("MCP_GIT_REPOSITORY", str(_TESTS.parent)) + monkeypatch.setenv("MCP_FILESYSTEM_ROOT", str(tmp_path)) + return {spec.name: spec for spec in binding.load_servers(str(_RECIPES))} + + +def rot(actual: dict[str, str], pinned: dict[str, str]) -> tuple[list[str], list[str]]: + """The pinned tools a server no longer offers, and the ones whose schema changed.""" + missing = sorted(set(pinned) - set(actual)) + changed = sorted( + name for name, digest in pinned.items() if name in actual and actual[name] != digest + ) + return missing, changed + + +# --- the files, on every run ---------------------------------------------------------------- + + +def test_the_digest_file_is_the_one_the_node_twin_runs() -> None: + digest = hashlib.sha256(_DIGESTS.read_bytes()).hexdigest() + assert digest == _DIGESTS_SHA256, "update both packs' pins when the shared file changes" + + +def test_the_recipes_file_names_the_seven_servers(recipes: dict[str, Any]) -> None: + assert sorted(recipes) == RECIPE_SERVERS + for name in ("git", "time", "fetch", "neo4j"): + assert recipes[name].transport == "stdio" and recipes[name].command == "uvx", name + for name in ("filesystem", "playwright"): + assert recipes[name].transport == "stdio" and recipes[name].command == "npx", name + github = recipes["github"] + assert github.transport == "http" and github.url.startswith("https://") + assert github.headers["Authorization"].startswith("Bearer ") + assert github.headers["X-MCP-Readonly"] == "true" + + +def test_the_references_resolve_from_the_environment(recipes: dict[str, Any]) -> None: + # the repository and the root this test set; the defaults where it set nothing + assert str(_TESTS.parent) in recipes["git"].args + assert "--read-only" in recipes["filesystem"].args + assert recipes["time"].args[-1] == "UTC" + assert recipes["neo4j"].env["NEO4J_URI"] == os.environ.get("NEO4J_URI", "bolt://127.0.0.1:7687") + assert recipes["neo4j"].env["NEO4J_USERNAME"] == os.environ.get("NEO4J_USERNAME", "neo4j") + + +def test_every_pinned_server_has_a_recipe_and_tools(recipes: dict[str, Any]) -> None: + pinned = DIGESTS["servers"] + assert sorted(pinned) == sorted(CREDENTIAL_FREE + ["neo4j"]) + assert set(pinned) <= set(recipes) + for name, server in pinned.items(): + assert server["tools"], name + for tool, digest in server["tools"].items(): + assert len(digest) == 64 and int(digest, 16) >= 0, f"{name}.{tool}" + + +def test_rot_names_what_is_missing_and_what_changed() -> None: + pinned = {"a": "1", "b": "2", "c": "3"} + assert rot({"a": "1", "b": "9", "d": "4"}, pinned) == (["c"], ["b"]) + assert rot(dict(pinned), pinned) == ([], []) + + +# --- the servers, live (gated) --------------------------------------------------------------- + + +async def offered_digests(spec: Any) -> dict[str, str]: + offered = await binding.offered_tools(spec) + return {tool["name"]: binding.schema_digest(tool["input_schema"]) for tool in offered} + + +@pytest.mark.skipif( + not LIVE, + reason="set MCP_RECIPES_LIVE=1 to start the recipe servers with uvx and npx and check their digests", +) +@pytest.mark.parametrize("name", CREDENTIAL_FREE) +@pytest.mark.asyncio +async def test_live_recipe_digests(name: str, recipes: dict[str, Any]) -> None: + actual = await offered_digests(recipes[name]) + missing, changed = rot(actual, DIGESTS["servers"][name]["tools"]) + assert not missing and not changed, ( + f"the {name} recipe rotted - missing {missing}, changed {changed}: run describe on it, review " + "the schema, then re-pin the digest in both packs' vector file and on the page" + ) + + +@pytest.mark.skipif( + not (LIVE and os.environ.get("NEO4J_PASSWORD")), + reason="set MCP_RECIPES_LIVE=1 and NEO4J_PASSWORD, with a database at NEO4J_URI " + "(e.g. the one extensions/agent-tools/dev/graph-up.sh starts)", +) +@pytest.mark.asyncio +async def test_live_neo4j_recipe_digests(recipes: dict[str, Any]) -> None: + actual = await offered_digests(recipes["neo4j"]) + missing, changed = rot(actual, DIGESTS["servers"]["neo4j"]["tools"]) + assert not missing and not changed, ( + f"the neo4j recipe rotted - missing {missing}, changed {changed}" + ) diff --git a/tests/vectors/mcp-recipes.json b/tests/vectors/mcp-recipes.json new file mode 100644 index 0000000..6c501cf --- /dev/null +++ b/tests/vectors/mcp-recipes.json @@ -0,0 +1,93 @@ +{ + "version": 1, + "read_on": "2026-11-18", + "note": "The SHA-256 input-schema digests of the MCP servers the engines' page 'Tools from MCP servers' gives recipes for, read with the binding's describe command from the servers mcp-recipes.yml starts. Shared byte for byte by mercury-python and mercury-nodejs. The gated recipes test starts each server and compares; a missing tool or a changed digest is the recipe rotting - run describe, review the schema, re-pin here and on the page.", + "servers": { + "git": { + "started_with": "uvx mcp-server-git==2026.11.11", + "tools": { + "git_add": "fe607783e69161974a5f7a4ccd35c37a74701420facc8f99a153e9e1bd268a00", + "git_branch": "268f353022c7efb49a6e61f3bd3c81522910358facafa35c16fca0a5a305f693", + "git_checkout": "b655a056a01c07675207106a974e3c18649ad97cfe5049bbc68b5f033a8ce4d6", + "git_commit": "c5cd9087b800e226a17190a2b110c7d9fe5a1131288faeb0f21478403293b967", + "git_create_branch": "9118849f78270629cb79f009849443a991834e4e6a1a6767671d8efd5306d7b8", + "git_diff": "32ee0e282fb126d18d4a4c6615b17defcaab9535409999d8625718408f57a8c4", + "git_diff_staged": "a34503e2686d88a396e63b81ab6bff39b2ab9dbdca5de355ceab4e6b4a74399e", + "git_diff_unstaged": "b5f28e179d77d1f8132248f474d5d7e689ff385ac68eb29cacd14e0b3c93e593", + "git_log": "c4e5907dca6fbbbb7ba130e7ab57445f91d7c1df0d67f01a610940176b3c708e", + "git_merge": "c26790c6086e8573806324d6f22714afb77481979c1bda9bc9295148b4cd96b9", + "git_remote": "53800ff477e1de5e8a838b9eaa6b03f2d0b118320bdeae3d2d16e93b3ad20e79", + "git_reset": "eea611c41ac2f0dac25fa3cc39a6b9692425bd6bc1de10c91e3ec81846c9707e", + "git_show": "fa979031e75d98d89ad67bda75bdebe7069fbad3f5907c50cb0aafd8fc4c9ad1", + "git_status": "7bd4de8036937dec083fd66e127b8e7ba67ec8e38453a3d20872e5eefafd6a48" + } + }, + "time": { + "started_with": "uvx mcp-server-time==2026.11.11", + "tools": { + "convert_time": "d4b3b9657b706c76a75371dccba7d10c119e8000c2edc03068c3676d7dc066cb", + "get_current_time": "0fad5d2bdd1e327fb88f14add9d4052c3bbccf1f661cc78cd4261ac1f41788a4", + "get_time_ago": "5e938ffeb16607ee3cf0f6d1e4c9df7de60b37f372f6449e330647267f1fe6dc" + } + }, + "fetch": { + "started_with": "uvx mcp-server-fetch==2026.11.11", + "tools": { + "fetch": "16fdd8e4c71db0b8693474bca52a6a1d81f6d862bb842ccead7287a220e1ef98" + } + }, + "filesystem": { + "started_with": "npx -y @modelcontextprotocol/server-filesystem@2.3.0 --read-only", + "tools": { + "directory_tree": "69bdec6a46d6ec8303f47749ba940e28f0bf859ef07aa6a842cf3ac86c14a7cd", + "get_file_info": "341692883b0120e165caa3d5736d66b11710a7ff8a5f4dfbef0dbb822b1138b4", + "list_allowed_directories": "93ab7499dc3c616f8db8780fed0d9f69270803cda913882ad2ef3943db8d7225", + "list_directory": "b82677a25149a3481a3c05f4b769b1c6496911bac868335e54170e09c24d1e66", + "list_directory_with_sizes": "c4e7d1e4396f0d78e5506c159a12b540e513da82dd8814ff3f7ae724fc86870d", + "read_file": "3c51bad3f48b697f48fd24a1f310baf60fe906021ef15b38cd179ec856b635c6", + "read_media_file": "0bf785608c87d1c51b81eb946f9e7801fff5c59647b4806820eeaa2419e698a3", + "read_multiple_files": "e33001b8d3c59a392539941ea3ce0fb40beba8cbbe687f40d850eeee50515aa8", + "read_text_file": "3c51bad3f48b697f48fd24a1f310baf60fe906021ef15b38cd179ec856b635c6", + "search_files": "ad17e78560702ac5a0cbf3caf5ce0ff09ba13de8e0053642778e138b1bd3b444" + } + }, + "neo4j": { + "started_with": "uvx mcp-neo4j-cypher==0.6.0", + "tools": { + "get_neo4j_schema": "51d2e5525a9bb54a5a06451a19eea2832e868b6c9c44637f29294e52c35b70ce", + "read_neo4j_cypher": "9631746823a32739ed4fa1dd5bd2bd04c93780ade4ba3b48aa9f3915b4069562", + "write_neo4j_cypher": "9631746823a32739ed4fa1dd5bd2bd04c93780ade4ba3b48aa9f3915b4069562" + } + }, + "playwright": { + "started_with": "npx -y @playwright/mcp@0.0.85", + "tools": { + "browser_click": "7fed82f52ae7018670d967e4429b63501948c80de2df2e9279ce4c103694d0d3", + "browser_close": "71fc596a20f27da3dec80050e5d1f553eba34aea24c2853b853488a811e6b892", + "browser_console_messages": "0d6cacf9f20123a6a4559c2bb05816020528d6529e6c1cb14520ea00fb9e23ef", + "browser_drag": "3dcca018f0b0e9341fee3c91b5420f82557a59a9d9763699e90970b2bd3ed1cb", + "browser_drop": "2f2a2c904744c935fc66547031c43b43466e86043f6c306624b536867b18d8e8", + "browser_emulate_media": "3b4bcf539a7e561f0e7e233035d5e616d295c9fe0bd5d3c165120b305d2edaeb", + "browser_evaluate": "04a3962dec15576f5ad84707db0251b84868e4d7dd4a5cf5e5e0ded786fc7d03", + "browser_file_upload": "c76aede191ef1e3bdd09ff177419a1e77a0e1f3f676bdd7c8053ac78e6a80086", + "browser_fill_form": "c991223a68247bd517c0fa1b61db444178ff6ad546e7214936d29b8de4c2f2ee", + "browser_find": "d060308e6e1797f03317b2368c4d658b0013b0eb00c5ae7534db13b4528f0c3e", + "browser_handle_dialog": "2d4cacf71e9fd7f902bebbc84f106614b891c2654de32b71b1f0d629a10d8b5c", + "browser_hover": "3b0a5a3333d051dba9f6b023c341eef00f0e5264bef37bc0a11f83156937e803", + "browser_navigate": "2165538e098634780eec628947d795a2619b4d2e3cef0e36d3084ac46abb94f7", + "browser_navigate_back": "71fc596a20f27da3dec80050e5d1f553eba34aea24c2853b853488a811e6b892", + "browser_network_request": "f0dbfd6ba87b3b7739e5b0aa6fa8c0d981aa214128eb3c1a8891caa46bd60b30", + "browser_network_requests": "e943ec891442cf3a071a3d090af243ca4e3db8924c7e95650672e47917d5da56", + "browser_press_key": "57a7f701ebf865e5a7a759c15e8d04bca12cb756c2e3f4ae7280070bb6e310e2", + "browser_resize": "4a80d1f511092cf5e94b689f81afd36ec42b0ac74a510f7220a7c9987af00b84", + "browser_run_code_unsafe": "6a9943c16c5666a93c77010063b536f864936fc22606c48e7bb3a36b5b7fd444", + "browser_select_option": "03b097752bdb41817ec0a6a259062598e5c85c1a8c7106d0f2fde506321096bd", + "browser_snapshot": "1d7650f3b9f3612bbb4f1511c77944e7b9ed6e98c9e012926a243c58f016df6f", + "browser_tabs": "fc3f534e7428342371db86b438fad5f52abbe45d43b6e18fd79fb3d23de782c8", + "browser_take_screenshot": "78dcb99cc226d741aa8c11a11ee0df62e15a9f9ab9db1a1ce4fdc5512d323d96", + "browser_type": "ed892740ebc14bb2a49467c08b8bb02717d50f1f3ef8ed06d51abf5ebb3249da", + "browser_wait_for": "cee58694f677034e21fc68446200888eb28469696b4ca9259047e15084fb22ff" + } + } + } +} From 8d95c6a66e352c6330bd196758b7edb6c3555753 Mon Sep 17 00:00:00 2001 From: Eric Law <39393654+acn-ericlaw@users.noreply.github.com> Date: Wed, 18 Nov 2026 17:10:21 +0800 Subject: [PATCH 2/3] memory: RFC-0013 step 5's pack half opened as PR #66 Co-Authored-By: Claude Fable 5.1 --- memory/open-threads/thread-bp-agent-tools-python.md | 2 +- memory/sessions/2026-11-18-090840.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/memory/open-threads/thread-bp-agent-tools-python.md b/memory/open-threads/thread-bp-agent-tools-python.md index 587faa1..043396c 100644 --- a/memory/open-threads/thread-bp-agent-tools-python.md +++ b/memory/open-threads/thread-bp-agent-tools-python.md @@ -17,7 +17,7 @@ entries - git, time, fetch, filesystem, neo4j, github, playwright - with `${NAME:default}` references and pinned versions, not loaded by default), the shared digest vector `tests/vectors/mcp-recipes.json` (56 tools of the six servers that list without a credential, read through `describe`, identical from both packs) and - `tests/test_mcp_recipes.py` (five tests on every run, six gated live on `MCP_RECIPES_LIVE=1`; 11 passed live); the + `tests/test_mcp_recipes.py` (five tests on every run, six gated live on `MCP_RECIPES_LIVE=1`; 11 passed live; PR #66); the page is the engine's `docs/guides/tools-from-mcp-servers.md`. Next: nothing until Eric rules on RFC-0013's promotion. The plan as settled - step 1: `extensions/agent-tools/agent_tools.py` (the layout of `extensions/mcp-binding`: a module docstring, a `README.md`, `resources/application.yml`, a `describe` command printing every catalog row, `platform.on_startup` for the gated registration) with the file tools inside `tools.file.root` (`file.read`, `file.write` marked `write: true` with diff --git a/memory/sessions/2026-11-18-090840.md b/memory/sessions/2026-11-18-090840.md index 387fa75..345426d 100644 --- a/memory/sessions/2026-11-18-090840.md +++ b/memory/sessions/2026-11-18-090840.md @@ -30,6 +30,8 @@ - Gates: ruff OK, basedpyright OK, pytest 603 passed (the live Mermaid test failed once in the full run and passed alone - the public endpoint). Diff scanned for [[conv-compartment-downstream-secrets]]: fictional hosts only. +Opened as PR #66. + ## Memory References - Referenced: bp-agent-tools-python (edited: step 5's pack half), mcp-binding-function-per-tool (the bind shape the From 978a338380d839e5fe3d342918610b7671d18f4c Mon Sep 17 00:00:00 2001 From: Eric Law <39393654+acn-ericlaw@users.noreply.github.com> Date: Wed, 18 Nov 2026 17:21:40 +0800 Subject: [PATCH 3/3] fix(tests): the recipes test loads the binding module once per process, under the name the binding test uses A second execution of mcp_binding.py registered mermaid.render again with a second function object and broke the binding test's identity check whenever both files ran in one process (CI on #66). Co-Authored-By: Claude Fable 5.1 --- memory/sessions/2026-11-18-090840.md | 9 +++++++-- tests/test_mcp_recipes.py | 30 ++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/memory/sessions/2026-11-18-090840.md b/memory/sessions/2026-11-18-090840.md index 345426d..e046c10 100644 --- a/memory/sessions/2026-11-18-090840.md +++ b/memory/sessions/2026-11-18-090840.md @@ -27,8 +27,13 @@ the engine's loop refuses `$schema` and `anyOf`, so a row is never a copy of `describe`'s output; a credential reference without a default fails `load_servers` for the whole file, so the test sets placeholders for the credentials it never sends. -- Gates: ruff OK, basedpyright OK, pytest 603 passed (the live Mermaid test failed once in the full run and passed - alone - the public endpoint). Diff scanned for [[conv-compartment-downstream-secrets]]: fictional hosts only. +- Gates: ruff OK, basedpyright OK, pytest 603 passed and one failed - first read as the public Mermaid endpoint, and + wrong: the new test module loaded `mcp_binding.py` a second time under its own module name, so its `@preload` + registered `mermaid.render` again with a second function object and the binding test's identity check failed + whenever both files ran in one process (CI on #66 failed the same way). The recipes test now reuses the module + `test_mcp_binding.py` loads, by its name in `sys.modules`, and executes the file only when it is first; the full + suite is green. **Lesson:** a file-loaded module with `@preload` registrations is loaded once per process - + share the module name across test files, never load it twice. Diff scanned for [[conv-compartment-downstream-secrets]]: fictional hosts only. Opened as PR #66. diff --git a/tests/test_mcp_recipes.py b/tests/test_mcp_recipes.py index e383964..68a9a6c 100644 --- a/tests/test_mcp_recipes.py +++ b/tests/test_mcp_recipes.py @@ -29,14 +29,28 @@ # the Node.js twin pins the same digest: change the file in both packs or in neither _DIGESTS_SHA256 = "10c70fe179d315cb0932d56cf0bc1e11290eb7c922ff439e5b9e7944df437d53" -_spec = importlib.util.spec_from_file_location("mcp_binding_recipes_under_test", _BINDING) -assert _spec is not None -assert _spec.loader is not None -# typed Any: the module is loaded dynamically from a file path, so its attributes are -# unknowable statically - Any tells every analyzer to trust the runtime -binding: Any = importlib.util.module_from_spec(_spec) -sys.modules.setdefault("mcp_binding_recipes_under_test", binding) -_spec.loader.exec_module(binding) +# the module name tests/test_mcp_binding.py loads the binding under: one process executes the +# module once, because a second execution would register mermaid.render again with a second function +# object and break that test's identity check (the preload registry is shared) +_MODULE = "mcp_binding_under_test" + + +def _load_binding() -> Any: + # typed Any: the module is loaded dynamically from a file path, so its attributes are + # unknowable statically - Any tells every analyzer to trust the runtime + loaded = sys.modules.get(_MODULE) + if loaded is not None: + return loaded + spec = importlib.util.spec_from_file_location(_MODULE, _BINDING) + assert spec is not None + assert spec.loader is not None + module: Any = importlib.util.module_from_spec(spec) + sys.modules[_MODULE] = module + spec.loader.exec_module(module) + return module + + +binding: Any = _load_binding() DIGESTS: dict[str, Any] = json.loads(_DIGESTS.read_text(encoding="utf-8")) LIVE = bool(os.environ.get("MCP_RECIPES_LIVE"))