# pip install openai
#
# OpenAI's Responses API supports remote MCP servers as a built-in tool type,
# so you can point it at the same StashGamma MCP endpoint used by Claude —
# no separate integration, no glue code, same free API key and rate-limit
# bucket as the REST API. See https://www.stashgamma.com/mcp-stock-data-api
#
# require_approval="never" skips the human-in-the-loop confirmation OpenAI
# normally asks for before an MCP tool call — reasonable here since
# get_eod_data is a read-only, no-side-effects call. Remove it (or set it to
# "always") if you want to review each call before it runs.

from openai import OpenAI

client = OpenAI()

response = client.responses.create(
    model="gpt-4.1",
    tools=[
        {
            "type": "mcp",
            "server_label": "stashgamma",
            "server_url": "https://www.stashgamma.com/api/dataapi/mcp",
            "headers": {"X-Api-Key": "YOUR_API_KEY"},
            "require_approval": "never",
        }
    ],
    input="Get QQQ's daily EOD bars for the last month and summarize the trend.",
)

print(response.output_text)
