Skip to content

Feature Request: Native Support for MCP Server Integration in OpenAI Python SDK #2320

@iceriny

Description

@iceriny

Confirm this is a feature request for the Python library and not the underlying OpenAI API.

  • This is a feature request for the Python library

Describe the feature or improvement you're requesting

Description
I propose adding native support to the OpenAI Python SDK for interacting with local or remote Model Context Protocol (MCP) servers. This integration would enable OpenAI SDK users to seamlessly leverage MCP-provided resources (prompts, tools, models, etc.) while retaining compatibility with OpenAI’s existing interfaces.

Proposed Functionality

  1. MCP Server Configuration: Allow users to configure an MCP server endpoint or local process (via parameters like StdioServerParameters in the example) directly within the OpenAI client initialization.
  2. Protocol Bridging: Automatically translate OpenAI SDK requests (e.g., chat.completions.create) into MCP protocol calls (e.g., prompt resolution, resource loading, tool execution) when an MCP server is configured.
  3. Backend Agnosticism: Retain the default OpenAI API behavior unless an MCP server is explicitly specified, ensuring backward compatibility.

Use Case Example
A developer could initialize the OpenAI client with either:

# Default OpenAI behavior  
client = openai.OpenAI(api_key="...")  

# MCP-integrated behavior  
client = openai.OpenAI(  
    mcp_server=StdioServerParameters(command="python", args=["mcp_server.py"])  
)  

Subsequent client calls would then utilize MCP-managed resources (prompts, tools), enabling dynamic model orchestration while maintaining familiar OpenAI SDK semantics.

Benefits

  1. Simplifies integration workflows for users operating in hybrid OpenAI/MCP environments.
  2. Enables use cases like runtime prompt templating, resource management, and tool execution via MCP.
  3. Strengthens interoperability between OpenAI’s ecosystem and the MCP protocol’s extensibility.

References

This feature would empower developers to flexibly combine OpenAI’s capabilities with MCP-managed infrastructure while maintaining a unified coding interface.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions