Skip to content

Fix MCP tool calls with gpt 5.2#1696

Merged
dgageot merged 1 commit intodocker:mainfrom
dgageot:gpt-5.2
Feb 11, 2026
Merged

Fix MCP tool calls with gpt 5.2#1696
dgageot merged 1 commit intodocker:mainfrom
dgageot:gpt-5.2

Conversation

@dgageot
Copy link
Member

@dgageot dgageot commented Feb 11, 2026

Some models (e.g. OpenAI gpt-5.2-pro) send explicit null for optional parameters, but MCP servers like gopls reject them because null is not a valid value for the declared parameter type (e.g. string). Strip nil values from the arguments map before forwarding to the MCP server, since omitting the key is semantically equivalent for optional params.

Assisted-By: cagent

Some models (e.g. OpenAI gpt-5.2-pro) send explicit null for optional
parameters, but MCP servers like gopls reject them because null is not a
valid value for the declared parameter type (e.g. string). Strip nil
values from the arguments map before forwarding to the MCP server, since
omitting the key is semantically equivalent for optional params.

Assisted-By: cagent
@dgageot dgageot requested a review from a team as a code owner February 11, 2026 13:40
Copy link

@docker-agent docker-agent bot left a comment

Choose a reason for hiding this comment

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

Review Summary

No bugs found in the changed code.

This PR correctly addresses the issue where some LLM models (like gpt-5.2-pro) send explicit null values for optional parameters that MCP servers reject.

Key Changes Reviewed:

  1. Null-stripping logic (mcp.go:224-230): The code safely removes null values from the arguments map before forwarding to the MCP server. Deleting from a map during iteration is explicitly safe in Go.

  2. Test coverage (mcp_test.go): Comprehensive test cases verify that:

    • All null values are stripped
    • Only null values are stripped (non-null values preserved)
    • Empty arguments remain empty

The implementation is sound, well-tested, and follows Go idioms correctly.

@dgageot dgageot merged commit 859a975 into docker:main Feb 11, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants