Skip to content

fix(adapters): mcp_tool_interceptor returns raw str for redacted output, breaking langchain-mcp-adapters #119

@gzak

Description

@gzak

Bug

When mcp_check_output returns redacted_data, the mcp_tool_interceptor in AxonFlowLangGraphAdapter returns the redacted string directly:

if output_check.redacted_data is not None:
    return output_check.redacted_data  # returns a raw str

langchain-mcp-adapters expects the interceptor to return an MCPToolCallResult (CallToolResult | ToolMessage | Command). When a plain str is returned instead, _convert_call_tool_result in langchain_mcp_adapters/tools.py attempts to access .content on the string, raising:

AttributeError: 'str' object has no attribute 'content'

Steps to Reproduce

  1. Run the langgraph-sample with a query that triggers PII redaction on an MCP tool output (e.g. "tell me everything about alice and bob" — Alice's record contains an SSN).
  2. The getUserInfo MCP tool returns "SSN: 123-54-8967. Favorite color: blue.".
  3. mcp_check_output redacts the SSN and sets redacted_data.
  4. The interceptor returns the redacted str, which langchain-mcp-adapters cannot process.

Expected Behavior

The interceptor should wrap the redacted string in a CallToolResult so the return type is always a valid MCPToolCallResult.

Fix

Wrap redacted_data in a CallToolResult:

from mcp.types import CallToolResult, TextContent

if output_check.redacted_data is not None:
    return CallToolResult(content=[TextContent(type="text", text=output_check.redacted_data)])

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions