# Connect an AI agent

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

LongevityGraph runs three MCP (Model Context Protocol) servers. Pick the ones that match who you are and what you do, add them 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, clinical work** (charts, labs, orders, scheduling, messages, panels, favorites):
  `https://longevitygraph.ai/mcp/emr`
- **Practice staff, practice setup** (the Knowledge Hub, protocols, biomarker cards and aliases, ranges and targets, program stages):
  `https://longevitygraph.ai/mcp/emr/setup`

Staff who do both kinds of work add both staff servers. You sign in once; each connection asks for its own approval. Turn on the one a chat needs, or both when a task needs both.

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

The servers share a sign-in service, but a connection to one does not grant access to another. Your AI client should open a LongevityGraph browser window for sign-in and approval.

## Practice staff: before you connect

- A practice admin turns on agent access once, in the EMR under **Settings → Clinical → MCP Agents**. Until then the sign-in window says agent access is off.
- You sign in with your EMR account. When LongevityGraph asks, you choose the practice, an access level and how long the connection lasts:
  - **View only**: read charts, labs and the clinical summary.
  - **Prepare for review**: also prepare proposals and message drafts for a person to review, approve, sign or send in LongevityGraph.
  - **Take routine actions**: also complete routine workflow tasks that you confirm in your AI client, such as booking a visit, closing a patient request with a note to the patient, or sending the practice's standard onboarding reminder. For staff, an admin must allow this level first.
- At every level the agent cannot sign, prescribe or release results. Replies to a patient's message, and new conversations with a patient, are drafts that a person sends. Clinical proposals wait in LongevityGraph for a clinician.

## 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` for clinical work and `https://longevitygraph.ai/mcp/emr/setup` for practice setup; when it is unclear which, add both.
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 servers instead, the clinical one and, for practice setup, the setup one:

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

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, Claude Desktop and Cowork)

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.

Claude Cowork uses the connectors you add here, so once LongevityGraph is connected it is available in Cowork too.

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**.

## 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) and, for practice setup, [Add the LongevityGraph EMR Setup server to Cursor](cursor://anysphere.cursor-deeplink/mcp/install?name=longevitygraph-emr-setup&config=eyJ1cmwiOiJodHRwczovL2xvbmdldml0eWdyYXBoLmFpL21jcC9lbXIvc2V0dXAifQ%3D%3D)

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

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

Cursor can connect by registering its OAuth client during sign-in or by using its published client identity. Either route uses the same patient or EMR server URL above. For a hosted Cursor agent such as Grok Bot, use the corresponding server URL in that agent's MCP settings; a desktop-only OAuth setting may not apply to the hosted agent.

## VS Code

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

Practice staff add the clinical server, the setup server, or both:

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

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

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

## Other clients and hosted agents

Choose **remote HTTP MCP** and paste the patient, EMR clinical or EMR setup URL above. A client that supports browser OAuth sign-in should discover LongevityGraph's sign-in service automatically. Published client identity and dynamic client registration are both supported. If the client offers a manually supplied public OAuth client ID, its developer can register one in advance and configure that ID; no client secret is needed for a public client.

Some API-hosted agent tools accept an access token but do not open a sign-in window. Their host application must obtain and refresh a user-approved LongevityGraph token before calling MCP. Pasting the server URL into such a tool alone cannot start sign-in. Never paste a token into an agent conversation.

If sign-in never opens, check that the client supports OAuth for remote HTTP MCP and that you used the exact server URL above. An `invalid_client_metadata` error means client registration failed; an `invalid_redirect_uri` error means its callback was refused. Share the client name and error code with support, without sending passwords, cookies or tokens. For staff, the practice must also have agent access enabled before consent can complete.

## 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).
