Skip to content

Comments

fix: pass through unknown MCP content block types#590

Open
dotuananh0712 wants to merge 2 commits intoanthropics:mainfrom
dotuananh0712:fix/574-search-result-dropped
Open

fix: pass through unknown MCP content block types#590
dotuananh0712 wants to merge 2 commits intoanthropics:mainfrom
dotuananh0712:fix/574-search-result-dropped

Conversation

@dotuananh0712
Copy link

Summary

The MCP tool result handler in query.py only handled text and image content blocks, silently dropping other block types like search_result. This prevented using native citations with custom RAG tools.

Problem

When a custom @tool returns a search_result content block, the SDK silently dropped it because the handler only checked for:

  • hasattr(item, "text") → text blocks
  • hasattr(item, "data") and hasattr(item, "mimeType") → image blocks

The search_result block has neither, so it fell through both checks.

Solution

Add a fallback using model_dump() to pass through unknown block types, enabling:

  • search_result blocks for RAG citations
  • Any future content block types the MCP SDK adds

Changes

In _internal/query.py, added:

elif hasattr(item, "model_dump"):
    content.append(item.model_dump())

Fixes

Fixes #574


This PR was contributed by an AI assistant (OpenCode).

Add RateLimitEvent dataclass and parser support for rate_limit_event
messages from Claude Code CLI. This prevents MessageParseError from
crashing the receive_messages() generator when rate limit events occur.

The fix adds:
1. RateLimitEvent type to types.py
2. Handler for 'rate_limit_event' case in message_parser.py

Fixes anthropics#583
The MCP tool result handler in query.py only handled 'text' and 'image'
content blocks, silently dropping other block types like 'search_result'.

This fix adds a fallback that uses model_dump() to pass through unknown
block types, enabling RAG applications to use search_result blocks for
structured citations.

Fixes anthropics#574
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.

search_result content blocks silently dropped by MCP tool result handler

1 participant