Implementation:Openai Openai python Tool Choice MCP Param
| Knowledge Sources | |
|---|---|
| Domains | API_Types, Responses_API |
| Last Updated | 2026-02-15 00:00 GMT |
Overview
Concrete TypedDict for constructing an MCP tool choice parameter when sending requests to the Responses API, provided by the openai-python SDK.
Description
ToolChoiceMcpParam is a TypedDict used to build a tool choice configuration that forces the model to call a specific tool on a remote MCP (Model Context Protocol) server. It requires server_label (identifying which MCP server) and type (always "mcp"), with an optional name field to specify which tool on that server to invoke.
Usage
Import this type when constructing the tool_choice parameter for Responses API calls to force the model to use a specific MCP server tool.
Code Reference
Source Location
- Repository: openai-python
- File: src/openai/types/responses/tool_choice_mcp_param.py
Signature
class ToolChoiceMcpParam(TypedDict, total=False):
"""Use this option to force the model to call a specific tool on a remote MCP server."""
server_label: Required[str]
type: Required[Literal["mcp"]]
name: Optional[str]
Import
from openai.types.responses import ToolChoiceMcpParam
I/O Contract
Fields
| Name | Type | Required | Description |
|---|---|---|---|
| server_label | str | Yes | The label of the MCP server to use. |
| type | Literal["mcp"] | Yes | For MCP tools, the type is always mcp.
|
| name | Optional[str] | No | The name of the tool to call on the server. If omitted, the model may choose any tool. |
Usage Examples
from openai.types.responses import ToolChoiceMcpParam
mcp_choice: ToolChoiceMcpParam = {
"type": "mcp",
"server_label": "deepwiki",
"name": "read_wiki_structure",
}
# Use as: client.responses.create(model="gpt-4o", input="...", tool_choice=mcp_choice)