Skip to content

fix: support structuredContent in MCP tool responses#494

Closed
layer4down wants to merge 2 commits intojundot:mainfrom
layer4down:fix/mcp-websearch-empty-output
Closed

fix: support structuredContent in MCP tool responses#494
layer4down wants to merge 2 commits intojundot:mainfrom
layer4down:fix/mcp-websearch-empty-output

Conversation

@layer4down
Copy link
Copy Markdown
Contributor

Summary

Fixes issue #469 where MCP web search tools (e.g., victor/websearch HuggingFace Space) returned empty output despite successful tool execution.

Problem

MCP web search servers return results in the structuredContent field of CallToolResult, but the _extract_content method only checked the content field, resulting in empty responses.

Solution

Modified _extract_content in omlx/mcp/client.py to fall back to structuredContent when content is empty or not present.

Changes

  • omlx/mcp/client.py: Added structuredContent fallback in _extract_content method (lines 359-361)
  • tests/test_mcp_client.py: Added test case test_call_tool_structured_content to verify the fix

Testing

All 36 MCP client tests pass, including the new test:

tests/test_mcp_client.py: 36/36 passed (including test_call_tool_structured_content)

Related

Closes #469

Hunter Br added 2 commits March 31, 2026 04:21
- Add fallback to structuredContent when content is empty
- Web search MCP servers return results in structuredContent field
- Fixes issue jundot#469 where web search tools returned empty output
- Add test case for structuredContent support
@jundot
Copy link
Copy Markdown
Owner

jundot commented Apr 14, 2026

thanks for the contribution! the core idea — falling back to structuredContent when content is empty — is solid and aligns with the MCP spec.

i cherry-picked the key logic change (structuredContent fallback in _extract_content) and the formatting fixes into main directly at 3171bd3, with you as co-author.

a couple notes on why i didn't merge the PR as-is:

  • issue [MCP] Web search returns no output #469 was actually a client-side problem (Open WebUI not executing tools via /v1/mcp/execute), not a missing structuredContent issue. the PR description links to it but the fix doesn't address the original report
  • tests/test_structured_content.py duplicated tests already in test_mcp_client.py and had inline imports (project convention requires top-level imports)

your contribution is credited in the commit. appreciate the PR!

@jundot jundot closed this Apr 14, 2026
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.

[MCP] Web search returns no output

2 participants