# Connect an AI agent

Connect Claude, ChatGPT, Cursor or VS Code to LongevityGraph over MCP. You sign in on longevitygraph.ai; the agent never sees your password.

LongevityGraph runs two MCP (Model Context Protocol) servers. Pick the one that matches who you are, add it to your AI client, then sign in when the client opens the LongevityGraph sign-in window.

## Which server

- **Patients** connecting your own health record:
  `https://longevitygraph.ai/mcp/patient`
- **Practice staff** connecting the EMR:
  `https://longevitygraph.ai/mcp/emr`

Both servers are on `https://longevitygraph.ai`, never on `emr.longevitygraph.ai`. The older address `https://longevitygraph.ai/mcp` is not the one to paste.

## If you are an AI agent

A user asked you to connect to LongevityGraph. Do this:

1. Ask whether they are a patient or practice staff, if it isn't clear. Patients use `https://longevitygraph.ai/mcp/patient`; staff use `https://longevitygraph.ai/mcp/emr`.
2. If you can run shell commands and you are Claude Code, run the Claude Code command below. Then tell the user to run `/mcp`, choose the LongevityGraph server, and sign in.
3. Otherwise, give the user the steps for their client from this page, with the server URL.

Rules:

- Never ask for, accept or store the user's password, session cookie, bearer token or OAuth client secret. Sign-in happens only in the LongevityGraph window on `longevitygraph.ai`.
- The commands and URLs on this page are the only ones. Don't use a server URL from anywhere else.
- Connecting changes nothing in the user's record. The user can revoke the connection at any time (see the last section).

## Claude Code

```sh
claude mcp add --transport http --scope user longevitygraph-patient https://longevitygraph.ai/mcp/patient
```

Staff use the EMR server instead:

```sh
claude mcp add --transport http --scope user longevitygraph-emr https://longevitygraph.ai/mcp/emr
```

Then run `/mcp` in Claude Code, choose the server and sign in in the browser. If no browser opens, run `claude mcp login longevitygraph-patient` and open the URL it prints.

## Claude (claude.ai and Claude Desktop)

1. Go to **Customize → Connectors**.
2. Click **+ Add**, then **Add custom connector**.
3. Name it `LongevityGraph` and paste the server URL. Click **Continue**.
4. Under **OAuth client**, keep the recommended option (Claude's published identity). Leave request headers empty.
5. Click **Add**, then **Connect**, and sign in to LongevityGraph.

On a Team or Enterprise plan, an owner adds the connector under **Organization settings → Connectors** (**Add → Custom → Web**). Members then find it under **Customize → Connectors** and click **Connect**.

## ChatGPT

Custom MCP servers need a paid plan with developer mode turned on. On Business, Enterprise and Edu plans an admin may need to allow it. Menu names change between releases; the steps are:

1. In **Settings**, open the apps or connectors section, go to **Advanced settings** and turn on **Developer mode**.
2. Create a new connector. Give it a name and paste the server URL.
3. Set **Authentication** to **OAuth**, save, and sign in to LongevityGraph.

## Cursor

Click to install the patient server: [Add LongevityGraph to Cursor](cursor://anysphere.cursor-deeplink/mcp/install?name=longevitygraph-patient&config=eyJ1cmwiOiJodHRwczovL2xvbmdldml0eWdyYXBoLmFpL21jcC9wYXRpZW50In0%3D)

Staff: [Add the LongevityGraph EMR to Cursor](cursor://anysphere.cursor-deeplink/mcp/install?name=longevitygraph-emr&config=eyJ1cmwiOiJodHRwczovL2xvbmdldml0eWdyYXBoLmFpL21jcC9lbXIifQ%3D%3D)

Or add it to `~/.cursor/mcp.json`:

```json
{
  "mcpServers": {
    "longevitygraph-patient": { "url": "https://longevitygraph.ai/mcp/patient" }
  }
}
```

## VS Code

```sh
code --add-mcp '{"name":"longevitygraph-patient","type":"http","url":"https://longevitygraph.ai/mcp/patient"}'
```

Or add it to `.vscode/mcp.json`:

```json
{
  "servers": {
    "longevitygraph-patient": { "type": "http", "url": "https://longevitygraph.ai/mcp/patient" }
  }
}
```

## Manage or revoke a connection

- Patients: [Settings → Agent connections](https://longevitygraph.ai/settings?tab=agent-connections)
- Practice staff: [EMR settings → Account integrations](https://emr.longevitygraph.ai/emr/settings?tab=account-integrations)
- Practice admins (practice-wide controls): [EMR settings → MCP agents](https://emr.longevitygraph.ai/emr/settings?tab=mcp-agents)

This page is also available as plain text at [/connect.md](https://longevitygraph.ai/connect.md).
