# Connect your own agent

> Connect any MCP client to Control Health over streamable HTTP with OAuth 2.1, or call the agents.v1 REST API directly.

Any MCP client that speaks streamable HTTP and OAuth 2.1 can connect to Control Health. If you would rather not use MCP, the same rails are a JSON REST API.

## Endpoints

- MCP server (streamable HTTP): `https://api.controlhealth.ai/mcp`
- Protected resource metadata (RFC 9728): `https://api.controlhealth.ai/.well-known/oauth-protected-resource/mcp`
- Authorization server metadata (RFC 8414): `https://api.controlhealth.ai/.well-known/oauth-authorization-server`
- Dynamic client registration (RFC 7591): `https://api.controlhealth.ai/oauth2/register`

## Connect over MCP

1. Call the MCP server without a token. It answers 401, and its `WWW-Authenticate` header names the protected resource metadata.
2. Read the protected resource metadata. Its `authorization_servers` is the api, and `scopes_supported` lists `profile`, `catalog`, `recommend`, `orders`, `results`, `import`.
3. Read the authorization server metadata for the authorize, token, revocation and registration endpoints. Only the authorization code grant with PKCE `S256` is accepted, plus refresh tokens.
4. Register your client with dynamic client registration, or use a client ID metadata document URL as your `client_id`. A public client needs no secret.
5. Send the person to authorize with PKCE, the scopes you need and `resource=https://api.controlhealth.ai/mcp`. They sign in, see what you asked for and choose Allow or Don't allow.
6. Exchange the code for tokens. Access tokens last an hour; refresh tokens rotate on every use, so keep the newest one.
7. Call the MCP server with `Authorization: Bearer <token>`. `tools/list` shows only the tools the person's grant allows.

The tools, by the scope they need:

- **See your profile summary and which data sources you've connected** (`profile`): `get_profile`.
- **Search lab tests and panels and get prices** (`catalog`): `search_catalog`, `get_test` and `estimate_order`.
- **Ask you intake questions and build a personalized panel** (`recommend`): `intake_questions` and `recommend_panel`.
- **See your orders and appointments, and start an order you confirm** (`orders`): `create_order`, `list_orders`, `get_order`, `list_slots`, `book_appointment`, `reschedule_appointment`, `cancel_appointment`, `choose_walk_in`, `get_prep_guide` and `request_order_cancel`.
- **Read your lab results** (`results`): `get_results`.
- **Send you health summaries, health conversations with AI assistants and records exports to review; nothing is saved until you keep it** (`import`): `import_health_summary` and `import_health_conversation`.

Limits, per person: every call, 120 calls a minute; intake_questions and recommend_panel, 30 calls an hour; create_order, 10 calls an hour; book_appointment, reschedule_appointment, cancel_appointment and choose_walk_in, 20 calls an hour.

## Or call the REST API

`agents.v1` is the same rails as JSON over HTTPS at `https://api.controlhealth.ai`. The catalog and quotes need no login; results and orders take the same OAuth token, issued for `https://api.controlhealth.ai` (its metadata is at `https://api.controlhealth.ai/.well-known/oauth-protected-resource`). `agents.v1` is versioned: a breaking change ships as `agents.v2`. Every endpoint, with its auth and limit, is in [llms.txt](https://controlhealth.ai/llms.txt).

```bash
curl -s -X POST https://api.controlhealth.ai/agents/v1/quotes \
  -H 'Content-Type: application/json' \
  -d '{"products": ["<product id or slug>"]}'
```

## Discovery files

- [llms.txt](https://controlhealth.ai/llms.txt): every endpoint, tool, scope and limit, and these guides.
- [MCP server card](https://controlhealth.ai/.well-known/mcp/server-card.json): the server, its authorization and its tools, as JSON.
- [Agent skills](https://controlhealth.ai/.well-known/agent-skills/index.json): build a personalized panel, estimate a price, start an order and get results, each as a SKILL.md.

Then run the [golden-path test](https://controlhealth.ai/agents/golden-path) with your agent.

## Important

Educational information and lab-ordering support only. Not medical advice, diagnosis or treatment: the person should review their results with a clinician. In an emergency, call 911. Nothing is ordered or paid without the person: an agent builds an order, and the person confirms and pays for it in Control Health. Book, move or cancel a lab visit only after the person agrees, and a cancellation is always confirmed by the person.

Web page: https://controlhealth.ai/agents/custom
