Fix MCP tool/prompt calls failing with non-serializable framework arguments#3483
Closed
Fix MCP tool/prompt calls failing with non-serializable framework arguments#3483
Conversation
Co-authored-by: markwallace-microsoft <127216156+markwallace-microsoft@users.noreply.github.com>
…et_prompt Co-authored-by: markwallace-microsoft <127216156+markwallace-microsoft@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix MCP tool call failure due to non-serializable arguments
Fix MCP tool/prompt calls failing with non-serializable framework arguments
Jan 28, 2026
4 tasks
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.
Motivation and Context
MCP
call_tool()andget_prompt()methods were attempting to serialize framework-internal arguments likeresponse_format(a Python type), causing serialization failures when these parameters were passed through the function invocation pipeline.Description
Added filtering to exclude non-serializable framework kwargs before passing to MCP SDK:
call_toolmethod: Addedresponse_formatto existing exclusion set and improved formatting for readabilityget_promptmethod: Added same filtering logic (previously missing)Framework kwargs now filtered:
{"chat_options", "tools", "tool_choice", "thread", "conversation_id", "options", "response_format"}Tests added:
test_mcp_tool_filters_framework_kwargs()- validates tool call filteringtest_mcp_prompt_filters_framework_kwargs()- validates prompt call filteringBoth tests verify that only actual tool/prompt parameters are passed to MCP session, while framework kwargs are stripped.
Contribution Checklist
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
astral.sh/usr/bin/curl curl -LsSf REDACTED(dns block)If you need me to access, download, or install something from one of these locations, you can either:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.