> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fcontext.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP Server

> Connect AI assistants to fcontext market data with OAuth 2.1

# MCP Server

Access the official remote MCP server for fcontext market data.

## Overview

Your AI assistant can use the fcontext MCP server to access authenticated, metered market data through your fcontext account. The first version exposes tools for realtime quotes, static instrument data, calculated quote indexes, candlesticks, market news, finance calendars, and top movers.

The remote MCP endpoint is:

```text theme={null}
https://mcp.fcontext.com/mcp
```

## Authentication

The MCP server uses OAuth 2.1. When an interactive MCP client connects for the first time, it redirects you to sign in and approve market-data access. No API key is needed for MCP clients.

The authorization server is:

```text theme={null}
https://openapi.fcontext.com/api/auth
```

MCP access tokens are JWTs bound to the MCP resource audience:

```text theme={null}
https://mcp.fcontext.com/mcp
```

Tokens must include the `market_data` scope.

<Note>
  API keys are for the HTTP Market Data API at `https://openapi.fcontext.com/api/market-data`. MCP clients should use OAuth unless you are building your own server-side integration.
</Note>

## Getting Started

Choose a client that supports remote MCP servers and add the fcontext endpoint:

<Tabs>
  <Tab title="Codex Desktop">
    Add a remote MCP server with this URL:

    ```text theme={null}
    https://mcp.fcontext.com/mcp
    ```

    Complete the OAuth sign-in flow when Codex prompts you, then enable the server for chats that need market data.
  </Tab>

  <Tab title="Claude / Claude Code">
    Add a custom remote MCP connector with this URL:

    ```text theme={null}
    https://mcp.fcontext.com/mcp
    ```

    Complete OAuth authentication in the browser window opened by your client.
  </Tab>

  <Tab title="Cursor">
    Add a remote MCP server with this URL:

    ```text theme={null}
    https://mcp.fcontext.com/mcp
    ```

    When Cursor asks for authorization, sign in with your fcontext account and approve market-data access.
  </Tab>
</Tabs>

## MCP Tools

Once connected, your AI assistant can call these tools:

| Tool                        | Description                                                                                     |
| --------------------------- | ----------------------------------------------------------------------------------------------- |
| `fcontext_get`              | Call a permitted fcontext market-data `GET` endpoint by relative path after `/api/market-data`. |
| `fcontext_quote`            | Fetch realtime quotes for one or more symbols.                                                  |
| `fcontext_static_info`      | Fetch static instrument information.                                                            |
| `fcontext_calc_index`       | Fetch calculated quote indexes.                                                                 |
| `fcontext_candlestick`      | Fetch historical candlestick data for a symbol.                                                 |
| `fcontext_news`             | Fetch market news.                                                                              |
| `fcontext_finance_calendar` | Fetch financial calendar events.                                                                |
| `fcontext_top_movers`       | Fetch top market movers.                                                                        |

All tools reuse the same account billing, usage analytics, and upstream credential isolation as the HTTP Market Data API. Caller bearer tokens, cookies, and API keys are never forwarded to the market-data provider.

## Example Usage

After connecting, try asking your AI assistant:

* “What is Apple’s latest quote?”
* “Show me one month of daily candlesticks for Nvidia.”
* “What are today’s top US market movers?”
* “Find recent news for Tesla.”
* “Check upcoming finance calendar events for this week.”
* “Compare static information for AAPL.US and MSFT.US.”

## Troubleshooting

| Problem                                       | What to check                                                                                                                                                                          |
| --------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Client cannot discover authorization metadata | Confirm it can reach `https://openapi.fcontext.com/api/auth/.well-known/oauth-authorization-server` or `https://openapi.fcontext.com/.well-known/oauth-authorization-server/api/auth`. |
| MCP request returns `401`                     | Reconnect the MCP server and complete OAuth again. The response includes `WWW-Authenticate` with the protected resource metadata URL.                                                  |
| MCP request returns `403`                     | The token is valid but does not include the `market_data` scope. Re-authorize the client.                                                                                              |
| Tool call fails with a path error             | Use relative paths with `fcontext_get`, such as `quote` or `content/news`; absolute URLs and path traversal are rejected.                                                              |
