microsoft/semantic-kernel · error · FunctionExecutionException
Unsupported content type: {type(content)}
Error message
Unsupported content type: {type(content)} What it means
Thrown by _kernel_content_to_mcp_content_types (mcp.py:184) as a FunctionExecutionException when the content argument is not one of TextContent, ImageContent, AudioContent, BinaryContent, or ChatMessageContent. The MCP connector can only serialize these kernel content types into MCP message types; anything else is rejected. Note: unsupported items inside a ChatMessageContent are silently skipped (debug-logged) rather than raising.
Source
Thrown at python/semantic_kernel/connectors/mcp.py:184
if isinstance(content, BinaryContent):
return [
types.EmbeddedResource(
type="resource",
resource=types.BlobResourceContents(
blob=content.data_string, mimeType=content.mime_type, uri=content.uri or "sk://binary"
),
)
]
if isinstance(content, ChatMessageContent):
messages: list[types.TextContent | types.ImageContent | types.AudioContent | types.EmbeddedResource] = []
for item in content.items:
if isinstance(item, (TextContent, ImageContent, BinaryContent, AudioContent)):
messages.extend(_kernel_content_to_mcp_content_types(item))
else:
logger.debug("Unsupported content type: %s", type(item))
return messages
raise FunctionExecutionException(f"Unsupported content type: {type(content)}")
@experimental
def _get_parameter_dict_from_mcp_prompt(prompt: types.Prompt) -> list[dict[str, Any]]:
"""Creates a MCPFunction instance from a prompt."""
# Check if 'properties' is missing or not a dictionary
if not prompt.arguments:
return []
return [
{
"name": prompt_argument.name,
"description": prompt_argument.description,
"is_required": True,
"type_object": str,
}
for prompt_argument in prompt.arguments
]
View on GitHub (pinned to c028a0c7dc)
Solutions
- Return one of the supported content types (TextContent/ImageContent/AudioContent/BinaryContent) or a ChatMessageContent composed of them.
- If you have a custom type, convert it to TextContent(str(value)) before returning from the MCP-exposed tool.
- Upgrade semantic-kernel: newer content types may have been added to the mapping.
- For ChatMessageContent, ensure every item is one of the four supported leaf types; unsupported items are dropped silently.
Example fix
# before return [FunctionResultContent(id=..., result=my_obj)] # after return [TextContent(text=str(my_obj))]
Defensive patterns
Strategy: type-guard
Validate before calling
from semantic_kernel.contents import TextContent, ImageContent, AudioContent, BinaryContent, ChatMessageContent
SUPPORTED = (TextContent, ImageContent, AudioContent, BinaryContent, ChatMessageContent)
def contents_are_mcp_supported(value) -> bool:
items = value if isinstance(value, list) else [value]
return all(isinstance(i, SUPPORTED) for i in items) Type guard
from semantic_kernel.contents import TextContent, ImageContent, AudioContent, BinaryContent, ChatMessageContent
def is_supported_content(content) -> bool:
return isinstance(content, (TextContent, ImageContent, AudioContent, BinaryContent, ChatMessageContent)) Try / catch
from semantic_kernel.exceptions.function_exceptions import FunctionExecutionException
try:
result = await plugin.call_tool("foo")
except FunctionExecutionException as ex:
if "Unsupported content type" in str(ex):
# coerce the tool's return value to TextContent and retry
... Prevention
- Return only TextContent/ImageContent/AudioContent/BinaryContent (or ChatMessageContent of those) from MCP-exposed tools.
- Convert custom or unknown values with TextContent(text=str(value)).
- Keep semantic-kernel updated so newly added content types are mapped.
- Avoid passing FunctionCallContent/FunctionResultContent at the top level to MCP.
When it happens
Trigger: A kernel tool returns a content type the connector cannot map, e.g. a FunctionResultContent or FunctionCallContent passed at the top level, a custom KernelContent subclass, or a raw Python object wrapped incorrectly. The final raise at mcp.py:184 is reached only when none of the isinstance branches match.
Common situations: Returning a custom content subclass from a tool invoked over MCP; passing a FunctionResultContent directly instead of its inner value; version mismatch where a newer content type isn't handled; building tool results manually.
Related errors
- Failed to call tool '{tool_name}'.
- Failed to call prompt '{prompt_name}'.
- Plugin creation failed for {pluginName}
- Prompt name is required.
- No handler found for the prompt '{promptName}'.
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/c55bda86fff125a7.
Report an issue: GitHub.