feat: add support for structured content for MCP#318
Open
hallvictoria wants to merge 8 commits intodevfrom
Open
feat: add support for structured content for MCP#318hallvictoria wants to merge 8 commits intodevfrom
hallvictoria wants to merge 8 commits intodevfrom
Conversation
…-library into hallvictoria/structured-content
gavin-aguiar
reviewed
Apr 6, 2026
| try: | ||
| if isinstance(arg, type): | ||
| if issubclass(arg, (ContentBlock, CallToolResult)): | ||
| is_content_block = True |
Contributor
There was a problem hiding this comment.
Here if arg is CallToolResult, you're setting is_content_block = True instead of is_call_tool_result = True..
Lets break this into 2 if conditions
if issubclass(arg, ContentBlock):
...
elif issubclass(arg, CallToolResult):
...
| result = await result | ||
|
|
||
| if result is None: | ||
| return str(result) |
Contributor
There was a problem hiding this comment.
This will return "None" . Maybe return ""
| auto_use_result_schema = use_result_schema | ||
| return_annotation = sig.return_annotation | ||
| if return_annotation != inspect.Signature.empty and not auto_use_result_schema: | ||
| from azure.functions.mcp import ContentBlock, CallToolResult |
Contributor
There was a problem hiding this comment.
These imports will happen at every call. Can we move this to the top?
| return False | ||
|
|
||
| # Primitive types don't generate structured content unless explicitly marked | ||
| if isinstance(obj, (str, int, float, bool)): |
Contributor
There was a problem hiding this comment.
NIT: bool is a subclass of int so its just a redundant check. (str, int, float) should be enough
| Returns True if: | ||
| - The object's class is decorated with a marker that sets __mcp_content__ = True | ||
| - The object is not a primitive type (str, int, float, bool, None) | ||
| - The object is not a dict or list (unless explicitly marked) |
Contributor
There was a problem hiding this comment.
Should we add a check for this ?
if isinstance(obj, (dict, list)):
return False
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes: Azure/azure-functions-python-worker#1825, Azure/azure-functions-python-worker#1836, Azure-Samples/remote-mcp-functions-python#38
Examples: