Repository navigation
Serve the pinned Foundations as read-only MCP tools for one bot - #84
Merged
Merged
Conversation
tools/foundations_mcp.py launches an MCP stdio server (adapters/foundations_mcp.py) for one bot's AOR on this device. It lists <foundation>.<tool> for each Foundation the host names with --foundation, with input schemas from the pinned tool inventories, and runs every call through the bot's AOR session: a standing POODO goal per Foundation, host-authored checkpoints, a precommitted decision on the read-only ToolFace grant, and execution through the existing pinned adapter (manifest, live inventory and, for the shared adapter, the receipt input digest). The Foundation's structuredContent is returned unchanged; the POODO record goes in _meta["cstack/poodo"]. Why this shape: - Reuse, not a second composition: build_aor_session gains a foundations subset, so cores, grants, witnessed ledgers, approvals and shields are the ones the existing MCP server uses. The server subclasses McpServer for framing and strict parsing; McpServer.INSTRUCTIONS became a class attribute. - Arguments are validated against the exact pinned input schema before any decision, so malformed input never spends budget or writes the ledger. - A top-level allOf/oneOf/anyOf (math.exact_scalar, robotics.mechanism_check) is projected into one object schema in tools/list, because some clients reject top-level combinators; the server still validates the exact schema. - An Engine result that is not an object is returned as text only, because MCP structuredContent must be an object. - No core change. - Requirement CS-REQ-091 and design component SDD-C31, chosen above the ids other in-flight branches use. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Akilleez-QA
marked this pull request as ready for review
November 17, 2026 05:18
Akilleez-QA
pushed a commit
that referenced
this pull request
Nov 17, 2026
#84 (now on main) imported tailnet_hostname from tools/cstack_mcp.py, which this branch replaces with adapters.local_setup.resolve_device and require_durable. Use the same flow in tools/foundations_mcp.py: refuse to start without the durable ledger unless --allow-memory-ledger is given, and take the device from --device, the recorded name, or the tailnet. Its launcher tests pass --allow-memory-ledger, and a new test checks the refusal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Akilleez-QA
added a commit
that referenced
this pull request
Nov 17, 2026
…e; Tailscale optional (#85) * Add cstack init; refuse the memory ledger in agent mode; make Tailscale optional One command (python -B tools/cstack_init.py) sets up a private state folder and a durable, signed witnessed ledger (per-bot signing keys, two local witness keys, roster, per-bot anchors, ledger.json written last). It is idempotent, never replaces a mismatched or exposed key, and --check verifies every ledger file without changing anything. tools/cstack_mcp.py now exits 2 before creating any state when Cstack is not set up, naming the init command; --allow-memory-ledger keeps the memory ledger for tests and throwaway development. A test fails if the generated bot profiles ever emit that flag. The device name comes from --device, the name init recorded, or the tailnet name, so Tailscale is optional. cryptography moves into requirements.txt because the witnessed ledger is now the default. Requirements CS-REQ-084, CS-REQ-085, CS-REQ-086; design SDD-C28 (and SDD-C15 for CS-REQ-085). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * Start the Foundations MCP launcher through cstack init's checks #84 (now on main) imported tailnet_hostname from tools/cstack_mcp.py, which this branch replaces with adapters.local_setup.resolve_device and require_durable. Use the same flow in tools/foundations_mcp.py: refuse to start without the durable ledger unless --allow-memory-ledger is given, and take the device from --device, the recorded name, or the tailnet. Its launcher tests pass --allow-memory-ledger, and a new test checks the refusal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Cstack <cstack@Cstacks-Mac-Mini.local> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Akilleez-QA
pushed a commit
that referenced
this pull request
Nov 17, 2026
Brings in #84 (Foundations MCP server) and #85 (cstack init, durable ledger required in agent mode). Conflicts in CHANGELOG.md, docs/architecture/architecture.md and docs/guides/how-to/define-bots.md resolved by keeping both sides' entries; EXPORT-MANIFEST.json regenerated with tools/build_export_manifest.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Akilleez-QA
pushed a commit
that referenced
this pull request
Nov 17, 2026
Brings in #84 (Foundations MCP server), #85 (cstack init) and #86 (starter agents). Conflicts in docs/architecture/architecture.md and docs/requirements/requirements.md resolved by keeping both sides: component rows in SDD order (C26, C28, C29, C31) and requirements CS-REQ-084 to CS-REQ-086 before CS-REQ-087. EXPORT-MANIFEST.json regenerated with tools/build_export_manifest.py; data dictionary --check passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Akilleez-QA
pushed a commit
that referenced
this pull request
Nov 17, 2026
Brings in #84 to #87. Conflicts resolved by keeping both sides: CHANGELOG.md entries; requirements and verification-matrix revision rows renumbered so main's 2.2 (cstack init) stays and this PR's CS-REQ-088 row becomes 2.3, with each document's Version set to 2.3. EXPORT-MANIFEST.json regenerated with tools/build_export_manifest.py; data dictionary --check passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Change
Wave 1C: serve the pinned Foundations as read-only MCP tools for an agent ("Sage" or any other) in one bot's AOR, so domain answers come with their receipts and every call is a witnessed POODO decision.
tools/foundations_mcp.py --aor <slug> --foundation <name> ...launchesadapters/foundations_mcp.py, an MCP stdio server that:<foundation>.<tool>(for examplerefrigeration.saturation_pressure) for each Foundation the host named at launch that the bot's AOR does not deny, with input schemas from the pinned tool inventories. A request cannot add a Foundation; an unregistered name, a runtime such ascstack_forge, a repeat or an empty choice stops the launch;AorSession: a standing POODO goal per Foundation, host-authored checkpoints, a precommitted decision on the read-only ToolFace grant, then execution through the existing pinned adapter (manifest verified, live inventory pinned and, for the shared adapter, receipt input digest recomputed);isErrorandstructuredContent(receipt, evidence, boundary flags) unchanged, with the POODO record in_meta["cstack/poodo"]. CHECK values and the evidence ceiling are never rewritten. A refused, tampered, unadmitted, pending or over-budget call is a tool error; nothing is retried.Rationale.
build_aor_sessiongains an optionalfoundationssubset, so cores, grants, witnessed ledgers, approvals and shields are the onestools/cstack_mcp.pyalready uses. The server subclassesMcpServerfor framing and strict parsing; the only change there is thatMcpServer.INSTRUCTIONSbecame a class attribute (same text).allOf/oneOf/anyOf(math.exact_scalar,robotics.mechanism_check) is merged into one object schema intools/list, because some clients reject top-level combinators; the server still validates against the exact schema.structuredContentmust be an object.Requirements, design and interface impact
docs/icd/icd-foundations.md; pointer incontracts/INTERFACES.md.contracts/ADAPTERS.json: two rows (foundations-mcp-server,foundations-mcp-launcher), checked bytests/test_adapter_inventory.py.tests/test_foundations_mcp.py.bootstrap.py,adapters/mcp_stdio_server.py,ADAPTERS.json, requirements/verification docs), becausefeat/handoff-channelandfeat/cstack-initedit the same files.Verification
These ran on the head commit
54e2a9don macOS with Python 3.15 in a throwaway venv (ci/requirements.txtinstalled). No model calls were made and no credentials were set.python -B -m unittest discover -s tests: Ran 746, failures=76, errors=4, skipped=8. main at0a9703b, same machine: Ran 734, failures=76, errors=4, skipped=8. The failing tests are identical on both (diffed). They are the known macOS workcell/EndoForge failures (workcell_not_executed) plus the tests that neednpm cifor the workcell toolchain, which was not run. All 12 new tests pass. Linux CI is the authority.bash ci/run-local.sh python links trace: suite results as above;check_links1442 paths, 0 broken;check_trace78 requirements, 77/77 test files traced, 0 failures.New tests (
tests/test_foundations_mcp.py): the tool list matches the pinned schemas; each vendored Foundation's representative tool is called over the real pinned bridges and its receipt comes back unchanged; unknown tool returns invalid params; malformed input never reaches the core; an out-of-profile number is refused before dispatch; the host chooses the Foundations; unknown, empty or repeated choices are refused; a denied domain lists nothing; an ask-class call waits for the owner; a tampered manifest is refused; the stdio launcher lists and calls; an unregistered Foundation stops the launch.Not done
tools/cstack_mcp.pycannot both hold the same bot and domain at once (the existing lifetime store claim).Peer review record
Checklist
# noqa: E402markers follow the existing launcher pattern intools/cstack_mcp.py.🤖 Generated with Claude Code