Call APIStack from the OpenAI Responses API with a remote MCP tool

With a remote MCP tool, OpenAI connects to the APIStack server, lists its tools and calls them during the response. Your code sends one request and gets the final answer.

Prefer video? · 1:34

Give your AI agent 100+ tools with one MCP URL

Connect APIStack to Claude Code, Cursor, VS Code or your own agent, with a real agent run.

Set it up

pip install openai

Create a free APIStack account and set your key as APISTACK_API_KEY.

import os
from openai import OpenAI

client = OpenAI()
response = client.responses.create(
    model="gpt-5-mini",
    tools=[{
        "type": "mcp",
        "server_label": "apistack",
        "server_url": "https://apistack.online/api/mcp/connect",
        "headers": {"x-api-key": os.environ["APISTACK_API_KEY"]},
        "require_approval": "never",
    }],
    input="What is Microsoft's latest stock price and today's trading range?",
)
print([item.type for item in response.output])
print(response.output_text)

Output from a real run (openai 2.x Python SDK, gpt-5-mini):

['mcp_list_tools', 'reasoning', 'mcp_call', 'reasoning', 'mcp_call', 'reasoning', 'mcp_call', 'reasoning', 'message']
Microsoft (MSFT)
- Latest price: $516.17 USD
- Today's trading range: $497.25 – $519.40 USD
- Note: quote is delayed ~15–20 minutes.

Approvals

"require_approval": "never" lets the model call tools without a round trip to your code. Use the default approval flow if you want to review each call before it runs.

Your key goes to OpenAI

OpenAI sends the headers you set to the MCP server on your behalf. Use a dedicated APIStack key for this so you can rotate it on its own.

Related guides