Repository navigation
adapters: add FastMCP server middleware and client integration - #78
angelnicolasc wants to merge 3 commits into
Conversation
f1b31e7 to
0d89803
Compare
|
Thank you for this, and for the way it is framed. Acknowledging quickly so you are not waiting on silence, with the caveat that the OWASP relaunch call runs today and considered review will come after it. A few things worth saying plainly, because they are not generic praise. You answered an ask before it was made. The call later today asks for exactly this: the reference implementation runs on Bun, and Python was named as open and unclaimed. You got there first, from reading the repository. You targeted The fail-closed posture is the interesting part. The AGT reference implementation defaults to On your question, which was the right one to ask. The distinction the team has been drawing is that a reference implementation carries policy and demonstrates the contract end to end, while an adapter slots into an existing harness and emits the wire. A Guardian with a pluggable policy plus a client wrapper is the first shape, not the second, so One heads-up on review scope. The pull request adds Two things that would help while this waits. Say a word about what the conformance suite asserts and what it does not, since the project is trying to be careful about the difference between emission conformance and requirement-by-requirement conformance. And if you have run this against a real FastMCP client rather than only the tests, that is worth writing down. Labelled |
|
Cross-linking for visibility: the kick-off onramp issues are now filed, and #86 asks for exactly this work. It went up after your pull request, so this is a record that you got there first rather than a duplicate request. |
|
@angelnicolasc This was missing an issue to reference, so I filed #135 for it and accepted it. Could you add a line to the description saying |
|
Hi @angelnicolasc — I read through this PR and the sample Guardian it adds; nice work getting there first. I'd like to help take the Python side past the sample into a full port for #86, and wanted to coordinate before starting, as @rocklambros asked on #86. Is this still active on your end?
@rocklambros — one structural question while you're here: #86's note says the samples/ vs reference-implementations/ decision sits with the Spec workstream. Unless that's decided otherwise, I'd follow the agt-go precedent and build under |
|
Thanks for the Python Guardian sample! The conformance tests you built are exactly the kind of thing that catches real gaps. One process note: CONTRIBUTING.md says code contributions need to link to an accepted issue (one with a Two paths forward:
Your question about whether this belongs in No rush on this, and the work itself looks solid. Just needs the issue connection to move forward. |
Signed-off-by: angelnicolasc <angelnicolasc@users.noreply.github.com>
Signed-off-by: angelnicolasc <angelnicolasc@users.noreply.github.com>
0d89803 to
f328c6d
Compare
|
@rocklambros @dtduc-git Thanks for the thoughtful notes earlier — sorry for the delay picking this back up. Because Instead, I rebased
@rocklambros I added |
|
Thanks for this. It is queued rather than ignored until a lead reads it, and the lead may close it. No lead has reviewed this pull request, and it references no issue a lead assigned to you. Under Part 2 of the Code of Conduct, a pull request that changes behavior, normative text, or code starts from an issue labeled status:accepted that a lead assigned to you before you opened or reopened it. If a lead closes this one, you can reopen it once a lead assigns the work. An editorial fix needs no issue. If a check below fails, please fix it. |
…v.lock Signed-off-by: angelnicolasc <angelnicolasc@users.noreply.github.com>
|
This pull request's description says it closes #135, which is on the project roadmap. When it merges, GitHub closes that issue and the roadmap counts it as delivered. Please confirm the change delivers the whole issue before merging. |
|
Hi Nick, thanks for sticking with this. #135 is accepted and on the Language ports milestone, but nobody is assigned to it. CONTRIBUTING.md (D-041) only reviews a pull request whose issue is assigned to its author, and GitHub only lets us assign people who have access to the repository. Here is how we fix it:
Your issue section already says |
|
Thanks @rocklambros — just accepted the invitation. Ping me once #135 is assigned and I'll close and reopen the PR right away. |
Closes #135
What changed
Rebased onto current
integration(0.1.5) and moved from the earliersamples/python-guardian-fastmcp/sketch (and its.github/workflows/samples.yml) into a first-class FastMCP integration underadapters/src/acs/integrations/fastmcp/, followingadapters/README.md#contributing-a-new-adapter.Since #22 landed
acs.core,acs.client, andacs-example-guardianunderadapters/— and #118 settled the HKDF/HMAC-SHA256 wire parameters — carrying a second unsigned stdlib Guardian under a third top-levelsamples/tree would duplicateadapters/and re-introduce #70. Building directly onacs.coreandacs.clientgives FastMCP the full signed v0.1.0 wire contract out of the box against bothacs-example-guardianandagt-go, with zero.github/workflows/changes.Surfaces added
ACSFastMCPMiddleware(adapters/src/acs/integrations/fastmcp/adapter.py): attaches viamcp.add_middleware(...)and governs everytools/callinon_call_tool(pre-executionsteps/toolCallRequest, post-executionsteps/toolCallResultlinked viarequest_id_ref,steps/sessionStart/steps/sessionEnd).GovernedFastMCPClient: wrapsfastmcp.Client(async with GovernedFastMCPClient(client) as governed:) sharing the exact same_FastMCPSessioncore.fastmcp = ["fastmcp>=2.9,<5"]inadapters/pyproject.toml(withadapters/uv.lockupdated; zero dependency conflict withnatorpqc), registered under[project.entry-points."acs.integrations"]andadapters/run_conformance.py(run_conformance.py fastmcp).adapters/docs/fastmcp/README.md(with explicit Conformance Status table matching the Claude Code adapter format) andadapters/docs/fastmcp/mapping.md.Measured checks
Measured on
22ef253(Python 3.12,fastmcp 4.2.5,acs-adapters 0.1.5):handshake/hello, 1sessionStart, 3toolCallRequest, 3toolCallResult(request_id_refmatched), 1sessionEndasyncio.gathercalls (0.4sslow handshake)handshake/hello, event loop ticked continuously (asyncio.to_thread)ACS_DISABLED=1(with explicitguardian_url/default_denykwargs)Config.from_env+dataclasses.replace)ACS_STARTUP_POSTURE=proceedwith Guardian downGUARDIAN_REFUSAL_CODES(-32000..-32700) underACS_DEFAULT_DENY=0default_deny=FalseValueErrorValueError(never masked asACSGuardianDenied);toolCallResultemitsexit_status: "failure"MODIFY(parameter_overrides) + post-executionMODIFY(modified_content)ToolResult; §6.3 composition violations fail closed (modify_unsupported){1: "a", "1": "b"})envelope_not_signable) before sendingFastMCP+Client(mcp)+acs-example-guardianrm -rf /denied pre-execution (executed == ["echo hello"])CaptureGuardianemission conformance (advertised == emitted, independent HMAC)specification/v0.1.0/uv run lint-importsintegrations -> client -> core; noguardian/examples/testingimports)uv run python -m unittest discover -s tests/integrations/fastmcp -t .[fastmcp]extra (uv sync --locked --group test)test_emission,test_adapter,test_metadata,test_run_conformance)uv build --wheelacs_adapters-0.1.5-py3-none-any.whlcleanlyConformance boundaries (stated plainly)
test_emission.pyandtest_live.pyvalidate every emitted byte againstspecification/v0.1.0/viaCaptureGuardianand test live round-trip enforcement againstacs-example-guardian. They do not claim requirement-by-requirement certification.tools/call, not LLM prompt/response turns, souserMessageandagentResponseare neither emitted nor advertised (advertised == emitted).tools/callflows throughsteps/toolCallRequest/steps/toolCallResultand recordsprofile_claim_degradedonce per session viarecord_mcp_use. Non-tool MCP methods (resources/read,prompts/get) are not wrapped.askanddefersubstitute todenywith audit at the FastMCP boundary.Checklist
Signed-off-by(DCO)integration.github/workflows/modificationsuv run lint-importspasses (2 kept, 0 broken)fastmcpextra