Back to Blog

GPT MCP Integration Guide: Using MCP with OpenAI

Ultrion TeamJuly 18, 202612 min read

GPT MCP Integration Guide: Using MCP with OpenAI

How to use Model Context Protocol tools with GPT models and the OpenAI platform.


While Claude has native MCP support, OpenAI's GPT models can also use MCP through adapters and integrations. This guide covers every way to connect MCP tools to GPT-powered applications.


MCP Support Options for GPT

Option 1: OpenAI MCP Adapter

OpenAI provides an MCP adapter for GPT models:

from openai import OpenAI
from mcp_adapter import MCPAdapter

client = OpenAI()

# Create MCP adapter β€” bridges MCP tools to GPT function calling
adapter = MCPAdapter(client)

# Connect to MCP servers
adapter.connect_server(
    name="database",
    command="node",
    args=["./mcp-servers/db-server.js"],
)

adapter.connect_server(
    name="web-tools",
    url="https://web-tools-mcp.example.com/sse",
)

# Use GPT with MCP tools
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "What's in our database?"}],
    tools=adapter.get_tools(),  # Automatically converts MCP tools to GPT format
)

# Handle tool calls
if response.choices[0].message.tool_calls:
    results = await adapter.execute_tool_calls(
        response.choices[0].message.tool_calls
    )
    # Continue conversation with results
    messages = [
        {"role": "user", "content": "What's in our database?"},
        response.choices[0].message,
        *results,
    ]
    response = client.chat.completions.create(
        model="gpt-4o",
        messages=messages,
        tools=adapter.get_tools(),
    )

Option 2: LangChain MCP Bridge

LangChain provides MCP integration that works with GPT:

from langchain.agents import AgentExecutor, create_openai_tools_agent
from langchain_openai import ChatOpenAI
from langchain_mcp import MCPToolkit

# Initialize MCP toolkit
toolkit = MCPToolkit(
    servers=[
        {"command": "node", "args": ["./db-server.js"]},
        {"url": "https://tools-mcp.example.com/sse"},
    ]
)

# Get tools as LangChain tools
tools = await toolkit.get_tools()

# Create GPT agent with MCP tools
llm = ChatOpenAI(model="gpt-4o")
agent = create_openai_tools_agent(llm, tools, prompt)
executor = AgentExecutor(agent=agent, tools=tools)

result = await executor.ainvoke({
    "input": "Query the database for recent orders"
})

Option 3: Manual Tool Translation

Convert MCP tool schemas to OpenAI function calling format:

async def mcp_to_openai_tools(mcp_server_url):
    """Fetch MCP tools and convert to OpenAI format."""
    client = MCPClient(mcp_server_url)
    mcp_tools = await client.list_tools()

    openai_tools = []
    for tool in mcp_tools:
        openai_tools.append({
            "type": "function",
            "function": {
                "name": tool["name"],
                "description": tool["description"],
                "parameters": tool["inputSchema"],
            },
        })

    return openai_tools, client


async def execute_mcp_tool(client, tool_name, arguments):
    """Execute an MCP tool and return the result."""
    result = await client.call_tool(tool_name, arguments)
    return result["content"][0]["text"]

Option 4: Custom Agent with MCP

Build a custom agent loop that bridges GPT and MCP:

class GPTMCPAgent:
    def __init__(self, model="gpt-4o"):
        self.client = OpenAI()
        self.model = model
        self.mcp_servers = {}
        self.mcp_tools = []

    async def add_server(self, name, url):
        client = MCPClient(url)
        await client.connect()
        self.mcp_servers[name] = client

        tools = await client.list_tools()
        for tool in tools:
            self.mcp_tools.append({
                "server": name,
                "name": tool["name"],
                "schema": tool,
            })

    def get_openai_tools(self):
        return [{
            "type": "function",
            "function": {
                "name": t["name"],
                "description": t["schema"]["description"],
                "parameters": t["schema"].get("inputSchema", {}),
            },
        } for t in self.mcp_tools]

    async def run(self, user_message):
        messages = [
            {"role": "system", "content": self.system_prompt},
            {"role": "user", "content": user_message},
        ]

        while True:
            response = self.client.chat.completions.create(
                model=self.model,
                messages=messages,
                tools=self.get_openai_tools(),
            )

            msg = response.choices[0].message

            if not msg.tool_calls:
                return msg.content

            messages.append(msg)

            for tool_call in msg.tool_calls:
                # Find the MCP server for this tool
                tool_info = next(
                    t for t in self.mcp_tools if t["name"] == tool_call.function.name
                )
                server = self.mcp_servers[tool_info["server"]]

                # Execute via MCP
                import json
                args = json.loads(tool_call.function.arguments)
                result = await server.call_tool(tool_call.function.name, args)

                messages.append({
                    "role": "tool",
                    "tool_call_id": tool_call.id,
                    "content": result["content"][0]["text"],
                })

Comparison: GPT MCP vs Claude MCP

Aspect Claude MCP GPT MCP
Integration Native Via adapter
Setup Config file Code-based
Tool discovery Automatic Manual or adapter
Multi-server Built-in Requires management
Performance Optimized Similar
Streaming Native Via adapter
Best for Pure MCP apps GPT-centric apps

Use Cases

Data Analysis Assistant

agent = GPTMCPAgent(model="gpt-4o")
await agent.add_server("database", "https://db-mcp.example.com/sse")
await agent.add_server("analytics", "https://analytics-mcp.example.com/sse")

# GPT can now query databases and run analytics
result = await agent.run("Analyze Q2 sales data and create a summary report")

Development Assistant

agent = GPTMCPAgent(model="gpt-4o")
await agent.add_server("github", "https://github-mcp.example.com/sse")
await agent.add_server("filesystem", command="node", args=["./fs-server.js"])

# GPT can read code, check issues, and suggest changes
result = await agent.run("Review the latest PR and suggest improvements")

Research Assistant

agent = GPTMCPAgent(model="gpt-4o")
await agent.add_server("search", "https://search-mcp.example.com/sse")
await agent.add_server("library", "https://library-mcp.example.com/sse")

result = await agent.run("Research the latest AI agent frameworks and compare them")

Deploying MCP Servers for GPT

When building MCP servers for GPT users:

Design Considerations

  1. Clear descriptions β€” GPT needs clear descriptions to select tools
  2. Simple schemas β€” GPT works best with straightforward JSON schemas
  3. Error messages β€” Provide helpful error messages when tool calls fail
  4. Response format β€” Return text that GPT can understand and relay

Example: GPT-Optimized MCP Server

const server = new McpServer({ name: "gpt-friendly-tools" });

server.tool(
  "search_products",
  "Search for products by name, category, or price range. Returns matching products with details.",
  // ^ Clear, detailed description helps GPT select this tool
  {
    query: z.string().describe("Product name or keyword to search for"),
    category: z.string().optional().describe("Product category (e.g., 'electronics', 'books')"),
    min_price: z.number().optional().describe("Minimum price in EUR"),
    max_price: z.number().optional().describe("Maximum price in EUR"),
  },
  async (args) => {
    const results = await searchProducts(args);

    // Return text that GPT can easily process
    const formatted = results.map(p =>
      `${p.name} (€${p.price}) β€” ${p.description}`
    ).join("\n");

    return {
      content: [{
        type: "text",
        text: `Found ${results.length} products:\n\n${formatted}`,
      }],
    };
  }
);

Publishing MCP Servers for GPT Users

When publishing on SkillExchange:

  1. Mark compatibility β€” Tag with "GPT-compatible" and "Claude-compatible"
  2. Provide examples β€” Show GPT-specific usage
  3. Document any limitations β€” Note features that work differently with GPT
  4. Test with both β€” Verify your server works with Claude and GPT

Future of GPT + MCP

OpenAI is reportedly working on deeper MCP integration:

  • Native MCP support β€” Eliminating the need for adapters
  • MCP in the Assistants API β€” Direct MCP server connections
  • MCP marketplace β€” Integration with tool marketplaces
  • Streaming improvements β€” Better support for long-running operations

Conclusion

While Claude has the most mature MCP integration, GPT users aren't left behind. With adapters, LangChain bridges, or custom agent loops, you can use any MCP server with GPT models. As MCP adoption grows, expect native support to improve across all platforms.


Learn More

Browse GPT-compatible MCP tools on SkillExchange.

Newsletter

Enjoying this article?

Get weekly insights on building and selling AI skills, MCP tools, and creator economics. Join 2,000+ AI builders and creators.

No spam. Unsubscribe anytime.

Related Articles

Ready to try AI skills?

Browse the marketplace and discover skills for your AI agents.

Browse Skills