Skip to content

Fix/mcp tool missing parameters #478

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

andreas-bergstrom
Copy link

The ToolParamOfMcp function was missing critical parameters (allowed_tools and require_approval) that are required for proper MCP integration according to OpenAI's documentation.

This is a breaking change that adds two new required parameters:

  • allowedTools []string: List of specific tools that can be called
  • requireApproval string: Controls tool approval behavior (never/always/auto)

Without these parameters, MCP integration fails even though tool discovery works. The function now properly populates the ToolMcpParam struct fields that were already available but not being set.

Breaking Change: Function signature changed from:
ToolParamOfMcp(serverLabel, serverURL string)
To:
ToolParamOfMcp(serverLabel, serverURL string, allowedTools []string, requireApproval string)

Fixes MCP tool execution issues where requests would fail with 500 errors or never reach the MCP server despite successful tool discovery.

Without this fix MCP calls through Responses API will freeze at this stage (awaiting approval I guess) and OpenAI response to client will be empty:
Skärmavbild 2025-08-11 kl  21 10 54

With this fix applied, everything works as it should:
Skärmavbild 2025-08-11 kl  21 11 20

…lParamOfMcp

The ToolParamOfMcp function was missing critical parameters (allowed_tools and
require_approval) that are required for proper MCP integration according to
OpenAI's documentation.

This is a breaking change that adds two new required parameters:
- allowedTools []string: List of specific tools that can be called
- requireApproval string: Controls tool approval behavior (never/always/auto)

Without these parameters, MCP integration fails even though tool discovery works.
The function now properly populates the ToolMcpParam struct fields that were
already available but not being set.

Breaking Change: Function signature changed from:
  ToolParamOfMcp(serverLabel, serverURL string)
To:
  ToolParamOfMcp(serverLabel, serverURL string, allowedTools []string, requireApproval string)

Fixes MCP tool execution issues where requests would fail with 500 errors
or never reach the MCP server despite successful tool discovery.
Tests verify that the function correctly handles:
- All parameters provided (serverLabel, serverURL, allowedTools, requireApproval)
- Empty allowedTools slice (should be omitted)
- Nil allowedTools slice (should be omitted)
- Empty requireApproval string (should be omitted)
- Minimal parameters (both optional fields empty)

Ensures the function properly sets AllowedTools and RequireApproval fields
only when non-empty values are provided, using the param.Opt pattern correctly.
@andreas-bergstrom andreas-bergstrom requested a review from a team as a code owner August 11, 2025 19:24
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.

1 participant