{"record":{"id":"c55bda86fff125a7","repo":"microsoft/semantic-kernel","slug":"unsupported-content-type-type-content","errorCode":null,"errorMessage":"Unsupported content type: {type(content)}","messagePattern":"Unsupported content type: (.+?)","errorType":"exception","errorClass":"FunctionExecutionException","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/mcp.py","lineNumber":184,"sourceCode":"    if isinstance(content, BinaryContent):\n        return [\n            types.EmbeddedResource(\n                type=\"resource\",\n                resource=types.BlobResourceContents(\n                    blob=content.data_string, mimeType=content.mime_type, uri=content.uri or \"sk://binary\"\n                ),\n            )\n        ]\n    if isinstance(content, ChatMessageContent):\n        messages: list[types.TextContent | types.ImageContent | types.AudioContent | types.EmbeddedResource] = []\n        for item in content.items:\n            if isinstance(item, (TextContent, ImageContent, BinaryContent, AudioContent)):\n                messages.extend(_kernel_content_to_mcp_content_types(item))\n            else:\n                logger.debug(\"Unsupported content type: %s\", type(item))\n        return messages\n\n    raise FunctionExecutionException(f\"Unsupported content type: {type(content)}\")\n\n\n@experimental\ndef _get_parameter_dict_from_mcp_prompt(prompt: types.Prompt) -> list[dict[str, Any]]:\n    \"\"\"Creates a MCPFunction instance from a prompt.\"\"\"\n    # Check if 'properties' is missing or not a dictionary\n    if not prompt.arguments:\n        return []\n    return [\n        {\n            \"name\": prompt_argument.name,\n            \"description\": prompt_argument.description,\n            \"is_required\": True,\n            \"type_object\": str,\n        }\n        for prompt_argument in prompt.arguments\n    ]\n","sourceCodeStart":166,"sourceCodeEnd":202,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/mcp.py#L166-L202","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nreturn [FunctionResultContent(id=..., result=my_obj)]\n\n# after\nreturn [TextContent(text=str(my_obj))]","handlingStrategy":"type-guard","validationCode":"from semantic_kernel.contents import TextContent, ImageContent, AudioContent, BinaryContent, ChatMessageContent\n\nSUPPORTED = (TextContent, ImageContent, AudioContent, BinaryContent, ChatMessageContent)\n\ndef contents_are_mcp_supported(value) -> bool:\n    items = value if isinstance(value, list) else [value]\n    return all(isinstance(i, SUPPORTED) for i in items)","typeGuard":"from semantic_kernel.contents import TextContent, ImageContent, AudioContent, BinaryContent, ChatMessageContent\n\ndef is_supported_content(content) -> bool:\n    return isinstance(content, (TextContent, ImageContent, AudioContent, BinaryContent, ChatMessageContent))","tryCatchPattern":"from semantic_kernel.exceptions.function_exceptions import FunctionExecutionException\n\ntry:\n    result = await plugin.call_tool(\"foo\")\nexcept FunctionExecutionException as ex:\n    if \"Unsupported content type\" in str(ex):\n        # coerce the tool's return value to TextContent and retry\n        ...","preventionTips":["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."],"tags":["mcp","content-conversion","serialization","function-execution"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}