# StashGamma MCP integration examples

The same EOD data API, exposed as a [Model Context Protocol](https://modelcontextprotocol.io)
server so agents can call it directly instead of you writing REST glue code.

- Endpoint: `https://www.stashgamma.com/api/dataapi/mcp`
- Transport: Streamable HTTP, stateless (no SSE, no session to keep alive)
- Auth: same `X-Api-Key` header as the REST API, sent alongside the JSON-RPC POST body —
  shares the same hour/day/week rate-limit bucket as REST calls on that key
- One tool: `get_eod_data(symbol, from?, to?)` → same OHLCV bar shape as the REST endpoint
- Errors (bad symbol, rate-limited, no data) come back as a tool result with `isError: true`
  and a human-readable reason, not an opaque protocol error — your agent can see and react
  to "retry in Ns" directly.

## Ways to use it

**1. Point a chat client at it (no code)** — see [`claude_desktop_config.json`](claude_desktop_config.json)
and [`claude_code_mcp.json`](claude_code_mcp.json). Drop the `stashgamma` entry into your
client's MCP server config, restart the client, and ask it about a symbol.

**2. OpenAI (Responses API)** — see [`../openai/responses_mcp_example.py`](../openai/responses_mcp_example.py).
OpenAI's Responses API supports remote MCP servers as a built-in tool type — point it at
this same endpoint, same key.

**3. ChatGPT (Custom GPT Actions)** — ChatGPT's consumer app doesn't take an MCP server
directly; a Custom GPT calls tools via an OpenAPI schema instead. See
[`../openapi/stashgamma-eod.openapi.yaml`](../openapi/stashgamma-eod.openapi.yaml) — paste it
into GPT Builder → Configure → Actions, then set Authentication to a custom `X-Api-Key`
header.

**4. Call it programmatically** — see [`python_client.py`](python_client.py) and
[`node_client.mjs`](node_client.mjs) if you're building your own agent/script and want to
call the tool directly via an MCP SDK, without a chat UI in the loop.

Full protocol-level reference: https://www.stashgamma.com/developer-docs#mcp
