Skip to content

fix(adapters): use JSON serialization in MCP interceptor#112

Merged
saurabhjain1592 merged 4 commits intomainfrom
fix/mcp-interceptor-serialization
Mar 7, 2026
Merged

fix(adapters): use JSON serialization in MCP interceptor#112
saurabhjain1592 merged 4 commits intomainfrom
fix/mcp-interceptor-serialization

Conversation

@saurabhjain1592
Copy link
Member

Summary

Fixes two serialization issues in AxonFlowLangGraphAdapter.mcp_tool_interceptor() introduced in #109:

  • Input statement: was using Python repr() (connector({'key': 'value'})), now uses json.dumps (connector({"key": "value"})). The old format could trigger false positives in SQLi detection when args contain SQL-like content.
  • Output message: was using ad-hoc format ({result: <repr>}, not valid JSON), now uses json.dumps of the raw result. Gives static policy checks (PII scanning, exfiltration detection) clean JSON to work with.

Both changes use default=str fallback for non-serializable types.

Test plan

  • Existing 15 interceptor tests pass
  • 2 new tests: test_connector_type_derived_from_request now asserts JSON statement format, test_output_message_uses_json_serialization verifies JSON output
  • ruff check passes
  • Full test suite passes (592+ tests)

The mcp_tool_interceptor was using Python repr() for statement and
output message construction, producing non-standard formats like
connector({"key": "value"}) and {result: 'data'}. This could cause
false positives in SQLi detection and reduces policy scan quality.

Changed to json.dumps(default=str) for both:
- Input statement: connector_type(json_args) instead of repr
- Output message: JSON-serialized result instead of ad-hoc format

Added tests for statement and output message serialization format.
The operation default was changed before any release shipped with "query",
so it is not a user-visible change. The Added section already documents
the default as "execute".
…default

mcp_check_input() shipped in v3.7.0 with default "query". PR #106 changed
it to "execute" after v3.8.0 was tagged. Users on v3.7.0/v3.8.0 saw
"query" as the default, so this is a real behavioral change in v3.9.0.
@saurabhjain1592 saurabhjain1592 merged commit 5f5fcf8 into main Mar 7, 2026
13 checks passed
@saurabhjain1592 saurabhjain1592 deleted the fix/mcp-interceptor-serialization branch March 7, 2026 19:21
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.

1 participant