Skip to content

Python: Decode base64 image, audio and blob content from MCP servers - #14675

Open
Jae Bird (jaeminbird) wants to merge 1 commit into
microsoft:mainfrom
jaeminbird:fix-mcp-base64-content
Open

Jae Bird (jaeminbird) wants to merge 1 commit into
microsoft:mainfrom
jaeminbird:fix-mcp-base64-content

Conversation

@jaeminbird

Copy link
Copy Markdown

Motivation and Context

MCP sends image/audio data and blob blob as base64, but the MCP connector builds ImageContent/AudioContent/BinaryContent without data_format="base64". So .data holds the base64 text, data_uri becomes data:image/png;,iVBOR... (no ;base64), and blob resources lose their mimeType (text/plain). Tool results, prompts and sampling messages with images reach the model broken; the Google AI connector sends the base64 text as image bytes.

Description

Pass data_format="base64" for the three types, and the resource mimeType for blobs.

  • New test covers image, audio and a blob resource via call_tool and get_prompt; fails before, passes after.
  • urllib.request.urlopen(content.data_uri) now returns the original bytes (before: the base64 text).
  • tests/unit/connectors/mcp and tests/unit/contents pass; ruff and mypy clean.

Contribution Checklist

Copilot AI balanced review requested due to automatic review settings October 29, 2026 06:19
@jaeminbird
Jae Bird (jaeminbird) requested a review from a team as a code owner October 29, 2026 06:19

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

@semantic-kernel-automation semantic-kernel-automation Bot added the python Pull requests for the Python Semantic Kernel label Oct 29, 2026
@jaeminbird

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

This branch was successfully deployed

1 active deployment
github-app-auth — 75810508 Deployed Oct 29, 2026 by jaeminbird via add_label #29480
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

python Pull requests for the Python Semantic Kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants