# Connect to the MCP server

> One URL gives any MCP app the Invariant Earth tools: point facts, parcels, geocoding and drive times, every value with its source.

Source: https://docs.invariant-ai.com/mcp/installation

The Invariant Earth MCP server lets an AI app look up U.S. parcels and addresses, check mapped flood zones and infrastructure, and calculate drive times. Ask for the source and retrieval date alongside each field when the response provides them.

Nothing to install. Add this URL to your app:

```text
https://api.invariant-ai.com/mcp
```

Then sign in with your API key. Chat apps open a sign-in page where you paste the key, or create one with your email and a 6-digit code. Coding agents can send the key as a header instead.

## Before you start

- You need an Invariant API key (it starts with `ief_`). [Get one free](https://docs.invariant-ai.com/get-api-key), or create it on the sign-in page.
- The server speaks Streamable HTTP. There's no local process, no `npx` and no Docker image.
- The tools only read data. They never write files or change anything on your machine.

## Where does your agent run?

| Your agent runs in | Go to |
| --- | --- |
| Claude (web, desktop, mobile) or ChatGPT | [Chat apps](https://docs.invariant-ai.com/mcp/installation#chat-apps) |
| Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI | [Apps on your computer](https://docs.invariant-ai.com/mcp/installation#apps-on-your-computer) |
| Your own code (Anthropic API, OpenAI API, an agent framework) | [An agent on a server](https://docs.invariant-ai.com/mcp/installation#an-agent-on-a-server) |

## Chat apps

### Claude

1. Open **Settings**, then **Connectors**, then **Add custom connector**.
2. Name it `Invariant Earth` and paste `https://api.invariant-ai.com/mcp` as the URL. Leave the OAuth fields empty.
3. Click **Add**, then **Connect**. A sign-in page opens: paste your API key, or enter your email and the 6-digit code we send you to create one.
4. In a chat, turn the connector on from the tools menu.

On Team and Enterprise plans an owner adds the connector once for the workspace, then each member connects.

### ChatGPT

1. Turn on developer mode: **Settings**, **Apps and connectors**, **Advanced settings**.
2. Click **Create**. Name it `Invariant Earth`, paste `https://api.invariant-ai.com/mcp` as the MCP server URL and choose **OAuth** authentication.
3. Tick the box that you trust the app, click **Create**, and sign in with your key on the page that opens.

Business and Enterprise workspaces need an admin to allow custom connectors.

## Apps on your computer

### Claude Code

With your key in an environment variable (no browser step):

```bash
claude mcp add --transport http --scope user invariant-earth https://api.invariant-ai.com/mcp \
  --header "Authorization: Bearer $INVARIANT_API_KEY"
```

Or with the browser sign-in: add the server without the header, then run `/mcp` inside Claude Code and choose **Authenticate**.

```bash
claude mcp add --transport http --scope user invariant-earth https://api.invariant-ai.com/mcp
```

Parcel enrichment and driving screens can run past a minute. Raise the tool timeout if you see timeouts: `MCP_TOOL_TIMEOUT=180000 claude`.

### Codex

```bash
codex mcp add invariant-earth --url https://api.invariant-ai.com/mcp --bearer-token-env-var INVARIANT_API_KEY
```

Or sign in through the browser instead of the environment variable:

```bash
codex mcp add invariant-earth --url https://api.invariant-ai.com/mcp
codex mcp login invariant-earth
```

Codex stops a tool call after 60 seconds by default. For long parcel or drive-time calls, add `tool_timeout_sec = 180` under `[mcp_servers.invariant-earth]` in `~/.codex/config.toml`.

### Cursor

Add this to `~/.cursor/mcp.json` (or `.cursor/mcp.json` in a project):

```json
{
  "mcpServers": {
    "invariant-earth": {
      "url": "https://api.invariant-ai.com/mcp",
      "headers": { "Authorization": "Bearer ${env:INVARIANT_API_KEY}" }
    }
  }
}
```

Leave out `headers` to sign in from **Cursor Settings**, **MCP**, next to `invariant-earth`.

### VS Code

Run **MCP: Add Server** from the Command Palette, choose **HTTP**, paste `https://api.invariant-ai.com/mcp` and name it `invariant-earth`. VS Code opens the sign-in page on first use. To use a header instead, put this in `.vscode/mcp.json`:

```json
{
  "inputs": [{ "type": "promptString", "id": "invariant-key", "description": "Invariant API key", "password": true }],
  "servers": {
    "invariant-earth": {
      "type": "http",
      "url": "https://api.invariant-ai.com/mcp",
      "headers": { "Authorization": "Bearer ${input:invariant-key}" }
    }
  }
}
```

### Windsurf

In `~/.codeium/windsurf/mcp_config.json`, under `mcpServers` (Windsurf calls the URL `serverUrl`):

```json
"invariant-earth": {
  "serverUrl": "https://api.invariant-ai.com/mcp",
  "headers": { "Authorization": "Bearer ${env:INVARIANT_API_KEY}" }
}
```

### Gemini CLI

```bash
gemini mcp add --transport http invariant-earth https://api.invariant-ai.com/mcp \
  --header "Authorization: Bearer $INVARIANT_API_KEY"
```

### Other MCP apps

Add a server of type HTTP (some apps say Streamable HTTP), paste `https://api.invariant-ai.com/mcp`, and either sign in when asked or set the header `Authorization: Bearer <your key>`. `X-API-Key: <your key>` works too.

## An agent on a server

### Anthropic Messages API

The MCP connector takes the URL and your key as the token:

```python
import anthropic, os

client = anthropic.Anthropic()
reply = client.beta.messages.create(
    model="claude-sonnet-5-5",
    max_tokens=2000,
    betas=["mcp-client-2025-11-20"],
    mcp_servers=[{
        "type": "url",
        "url": "https://api.invariant-ai.com/mcp",
        "name": "invariant-earth",
        "authorization_token": os.environ["INVARIANT_API_KEY"],
    }],
    tools=[{"type": "mcp_toolset", "mcp_server_name": "invariant-earth"}],
    messages=[{"role": "user", "content": "How far is 39.0438,-77.4874 from the nearest 230 kV substation? Cite sources."}],
)
```

### OpenAI Responses API

```python
from openai import OpenAI
import os

resp = OpenAI().responses.create(
    model="gpt-5",
    tools=[{
        "type": "mcp",
        "server_label": "invariant-earth",
        "server_url": "https://api.invariant-ai.com/mcp",
        "authorization": os.environ["INVARIANT_API_KEY"],
        "require_approval": "never",
    }],
    input="Is 39.0438,-77.4874 in a FEMA floodplain? Cite the source.",
)
```

### Your own tools

Prefer plain HTTP? Each MCP tool is a route of the HTTP API with the same JSON: `invariant_fetch` is [`POST /v1/fetch`](https://docs.invariant-ai.com/api/fetch), `invariant_enrich` is [`POST /v1/enrich`](https://docs.invariant-ai.com/api/enrich), `invariant_geocode` is [`POST /v1/geocode`](https://docs.invariant-ai.com/api/geocode) and `invariant_proximity` is [`POST /v1/proximity`](https://docs.invariant-ai.com/api/proximity). Copy-paste tool definitions are on [Use with AI agents](https://docs.invariant-ai.com/agents).

## Check that it works

Ask your agent:

> Use Invariant Earth: what is the elevation at 39.0438, -77.4874, and what's the nearest substation? Give the sources.

You should see a call to `invariant_fetch` and an answer near 90 m with a USGS source URL. Next, a parcel question:

> Who owns the parcel at 39.0438, -77.4874 and how many acres is it?

That one calls `invariant_enrich` with the `parcel` preset.

## Try a parcel, flood or site-screening question

| What you want to know | What to ask the agent |
| --- | --- |
| Which parcel matches an address? | “Find the assessor parcel number for 200 Larkin Street, San Francisco. Show the normalized address, match type and parcel source. Preserve any leading zeros.” |
| Does a mapped flood zone intersect a property? | “Check whether the address point at 214 3rd Street, Brooklyn, is in a FEMA flood zone. Report any flood zone overlap across the parcel separately.” |
| What infrastructure is mapped near a site? | “For 39.0438, -77.4874, show the serving utility territory, nearest mapped substation and distance. Cite each field and show missing values.” |

For the parcel and flood examples, compare the response with the [dated city and FEMA reference records](https://invariant-ai.com/blog/best-gis-apis-for-site-selection#gis-api-trial-requests). For a site power decision, [check which utility to contact](https://docs.invariant-ai.com/find-electric-utility-by-address) and ask it to confirm capacity, required upgrades and the service date. See [how to screen a site](https://docs.invariant-ai.com/screen-a-site) and [how to check flood zones by address](https://docs.invariant-ai.com/check-flood-zone-by-address).

## Server details

|  |  |
| --- | --- |
| URL | `https://api.invariant-ai.com/mcp` |
| Server configuration | [server.json](https://docs.invariant-ai.com/mcp/server.json) |
| Transport | Streamable HTTP, stateless, JSON responses (no SSE stream, no session id) |
| Protocol versions | `2025-11-25`, `2025-06-18`, `2025-03-26`, `2024-11-05` |
| Auth | `Authorization: Bearer <API key>` or `X-API-Key`, or OAuth 2.1 with PKCE (scope `mcp:tools`) |
| OAuth discovery | `https://api.invariant-ai.com/.well-known/oauth-protected-resource/mcp` and `https://api.invariant-ai.com/.well-known/oauth-authorization-server` |
| Tools | [5 read-only tools](https://docs.invariant-ai.com/mcp/tools), 3 resources, 3 prompts |
| Hosts | `api.invariant-ai.com` only, for both the tools and the sign-in page |

The OAuth access token is your API key. Revoke the key with [`DELETE /v1/keys/me`](https://docs.invariant-ai.com/api/key-revoke) and every app using it is signed out within a minute. Problems? See [Troubleshooting](https://docs.invariant-ai.com/mcp/troubleshooting).
