fix(adapters): wrap redacted MCP output in CallToolResult#120
fix(adapters): wrap redacted MCP output in CallToolResult#120
Conversation
e3446dc to
edb3e4e
Compare
saurabhjain1592
left a comment
There was a problem hiding this comment.
Good fix — the CallToolResult wrapping is correct and the Optional → X | None modernization is a nice cleanup.
CI is red because the test matrix in .github/workflows/ci.yml still includes 3.9:
python-version: ['3.9', '3.10', '3.11', '3.12']The 3.9 job fails on requires-python >= 3.10, which triggers fail-fast and cancels the other jobs. Drop 3.9 from the matrix and it should go green.
Also check if release.yml has a similar matrix or 3.9 reference that needs updating.
saurabhjain1592
left a comment
There was a problem hiding this comment.
Two blocking issues before this can merge. The redaction fix itself is correct.
[P1] Top-level mcp import makes the LangGraph adapter unusable without the extra
from mcp.types import CallToolResult, TextContent is now at module level in langgraph.py. This means from axonflow.adapters import AxonFlowLangGraphAdapter fails with ImportError unless mcp is installed, even for users who only use the workflow-gating parts of the adapter and never call mcp_tool_interceptor().
This is a regression from the current optional-dependency model and contradicts the PR description ("Uses a lazy import with a clear ImportError message if mcp is not installed").
Fix: move the mcp import inside mcp_tool_interceptor() or the redaction branch, and raise a helpful ImportError there instead.
[P1] Bugfix PR quietly drops advertised Python 3.9 support
pyproject.toml now sets requires-python = ">=3.10" and masfeat.py rewrites all types to X | None (3.10+ syntax), but the rest of the repo still advertises and tests 3.9. The PR's own test (3.9) job is already failing at install time: Package 'axonflow' requires a different Python: 3.9.25 not in '>=3.10'.
Dropping 3.9 is fine (it's EOL), but it should be an explicit, separate change with:
- CI matrix updated (
.github/workflows/ci.ymlandrelease.yml) to remove3.9 - README compatibility section updated
- Release notes calling out the compatibility break
Recommendation: split this PR into two:
- The
CallToolResultbugfix (with lazy import) — can ship as a patch release - The Python 3.9 drop +
Optionalmodernization — ships as a minor or major version bump
That way the bugfix isn't blocked on the compatibility discussion and users on 3.9 still get the fix.
saurabhjain1592
left a comment
There was a problem hiding this comment.
Two issues I'd strongly recommend fixing before merging. The redaction fix itself is correct.
[P1] Top-level mcp import breaks LangGraph adapter for users who don't have mcp installed
from mcp.types import CallToolResult, TextContent is now at module level in langgraph.py. This means from axonflow.adapters import AxonFlowLangGraphAdapter fails with ImportError unless mcp is installed, even for users who only use the workflow-gating parts of the adapter and never call mcp_tool_interceptor().
This is a regression from the current optional-dependency model and contradicts the PR description ("Uses a lazy import with a clear ImportError message if mcp is not installed").
Fix: move the mcp import inside mcp_tool_interceptor() or the redaction branch, and raise a helpful ImportError there instead.
[P1] Bugfix PR quietly drops advertised Python 3.9 support
pyproject.toml now sets requires-python = ">=3.10" and masfeat.py rewrites all types to X | None (3.10+ syntax), but the rest of the repo still advertises and tests 3.9. The PR's own test (3.9) job is already failing at install time: Package 'axonflow' requires a different Python: 3.9.25 not in '>=3.10'.
Dropping 3.9 is fine (it's EOL), but it should be an explicit, separate change with:
- CI matrix updated (
.github/workflows/ci.ymlandrelease.yml) to remove3.9 - README compatibility section updated
- Release notes calling out the compatibility break
Recommendation: split this PR into two:
- The
CallToolResultbugfix (with lazy import) — can ship as a patch release - The Python 3.9 drop +
Optionalmodernization — ships as a minor or major version bump
That way the bugfix isn't blocked on the compatibility discussion and users on 3.9 still get the fix.
ffbecd5 to
f069e61
Compare
When mcp_check_output returns redacted_data, the interceptor was returning a plain str. langchain-mcp-adapters expects MCPToolCallResult (CallToolResult | ToolMessage | Command) and calls .content on the return value, causing AttributeError at runtime. Now wraps the redacted string in a CallToolResult with a single TextContent block, which is the correct return type for the interceptor protocol. Also adds mcp>=1.0.0 as a new 'langgraph' optional extra and to dev dependencies, with a lazy import that surfaces a clear error message if mcp is not installed. Fixes #119
f069e61 to
2b0e967
Compare
Summary
mcp_tool_interceptorwas returningoutput_check.redacted_data(a plainstr) when a redaction policy applied to an MCP tool resultlangchain-mcp-adaptersexpects the interceptor to returnMCPToolCallResult(CallToolResult | ToolMessage | Command) and unconditionally accesses.contenton the return value, causingAttributeError: 'str' object has no attribute 'content'CallToolResult(content=[TextContent(type="text", text=...)]), which is the correct type for the interceptor contractmcp>=1.0.0as a newlanggraphoptional extra (pip install 'axonflow[langgraph]') and to dev dependenciesImportErrormessage ifmcpis not installedFixes #119
Test plan
test_returns_redacted_data_when_presentupdated to assert the return is aCallToolResultwith the correctTextContentTestMCPToolInterceptortests pass