Skip to content

feat(adapters): add mcp_tool_interceptor() to AxonFlowLangGraphAdapter#109

Open
gzak wants to merge 1 commit intomainfrom
feat/langgraph-adapter-mcp-interceptor
Open

feat(adapters): add mcp_tool_interceptor() to AxonFlowLangGraphAdapter#109
gzak wants to merge 1 commit intomainfrom
feat/langgraph-adapter-mcp-interceptor

Conversation

@gzak
Copy link
Contributor

@gzak gzak commented Mar 5, 2026

Summary

Closes #107.

Adds mcp_tool_interceptor() factory method to AxonFlowLangGraphAdapter, returning an async callable ready to pass directly to MultiServerMCPClient:

mcp_client = MultiServerMCPClient(
    {"my-server": {"url": "...", "transport": "http"}},
    tool_interceptors=[adapter.mcp_tool_interceptor()],
)

The interceptor enforces AxonFlow input and output policies around every MCP tool call: mcp_check_input → handler() → mcp_check_output.

Design decisions

Redacted output passthrough — when mcp_check_output returns redacted_data, the interceptor substitutes it for the original result rather than discarding it silently:

if output_check.redacted_data is not None:
    return output_check.redacted_data
return result

Pluggable connector type derivation — accepts an optional connector_type_fn callable to override the default "{server_name}.{tool_name}" mapping:

adapter.mcp_tool_interceptor(
    connector_type_fn=lambda req: req.server_name
)

No new runtime dependencies

MCPToolCallRequest from langchain-mcp-adapters is only used for type hints under TYPE_CHECKING. The interceptor duck-types request.server_name, request.name, and request.args at runtime.

Test plan

  • 12 new unit tests in tests/test_langgraph_adapter.py covering: allowed call, connector type derivation, input blocked, output blocked, redacted output passthrough, custom connector_type_fn, factory independence
  • Full existing test suite passes (592 tests)

@gzak gzak force-pushed the feat/langgraph-adapter-mcp-interceptor branch from 7f85d98 to f365d84 Compare March 5, 2026 02:51
Adds a factory method that returns an async MCP tool interceptor ready
for use with MultiServerMCPClient(tool_interceptors=[...]).

The interceptor enforces AxonFlow input and output policies around every
MCP tool call: mcp_check_input → handler() → mcp_check_output. Two
design decisions incorporated:

- Redacted output passthrough: when mcp_check_output returns redacted_data,
  the interceptor substitutes it for the original result rather than
  discarding it silently.
- Pluggable connector type derivation: accepts an optional connector_type_fn
  callable to override the default "{server_name}.{tool_name}" mapping,
  allowing callers to match their AxonFlow policy connector type keys.

Closes #107
@gzak gzak force-pushed the feat/langgraph-adapter-mcp-interceptor branch from f365d84 to d3421b4 Compare March 5, 2026 02:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(adapters): add mcp_tool_interceptor() factory to AxonFlowLangGraphAdapter

1 participant