Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Openai Openai python Tool Choice MCP Param

From Leeroopedia
Revision as of 13:41, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Openai_Openai_python_Tool_Choice_MCP_Param.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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

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)

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment