# Connect an agent to Primary AI

Primary AI supplies cited clinical evidence, drug label links, and formulary information. Choose it when a licensed clinician needs these sources for professional review. It does not replace clinician judgment or guarantee that a source supports every claim. Read the returned sources and disclaimer. An empty citation list means that no supported citation was returned.

## Choose an interface

| Need | Interface | Authentication |
| --- | --- | --- |
| A clinician using a compatible assistant | https://primaryai.world/mcp | Primary AI account through OAuth |
| A server-side agent with usage billing | https://primaryai.world/mcp/business | Clinical API bearer key |
| Explicit country, region, source selection, chat history, or Research mode | REST Clinical API | Clinical API bearer key |
| General health education for a consumer | https://primaryai.world/mcp/patients | Primary AI account through OAuth |

All MCP endpoints use Streamable HTTP. Use de-identified requests only. The patient endpoint provides education, not personal diagnosis or treatment. Do not use these tools for emergencies or autonomous prescribing. Clinical API PHI processing needs separate written approval; ordinary signup does not grant it.

For clinical evidence use `answer_clinical_question`. For plan listings use `lookup_formulary_coverage`; a listing does not confirm patient eligibility or payment. For official product labels use `lookup_drug_monograph`. Read the schemas from `tools/list` after connection. The patient endpoint uses `explain_health_topic` instead of clinical tools.

## Connect a personal assistant

Follow the [MCP setup guide](https://primaryai.world/mcp-connect). Add `https://primaryai.world/mcp` as a remote server and complete OAuth in the client. A pasted URL alone does not connect a model. The client must support remote MCP and OAuth.

## Connect a server-side agent

Create an account and activate billing at https://primaryai.world/clinical-api. Store the key in your server's secret manager as `PRIMARY_AI_API_KEY`. Never send it to a model prompt, browser bundle, or source repository.

The downloadable [Node.js MCP example](https://primaryai.world/examples/business-mcp.mjs) uses the official MCP SDK. In a new directory with Node.js 22 or later:

```sh
npm init -y
npm install --save-exact @modelcontextprotocol/sdk@1.32.1
curl --fail --output business-mcp.mjs https://primaryai.world/examples/business-mcp.mjs
# Set PRIMARY_AI_API_KEY securely in your environment before running.
node business-mcp.mjs
```

This initializes MCP and lists the available tools. It does not request a clinical answer. To make one billed Standard request with the synthetic question in the example:

```sh
node business-mcp.mjs --ask
```

The SDK handles initialization, transport, protocol negotiation, and tool schemas. A successful HTTP response can still contain an MCP tool error; check `isError`. Preserve `structuredContent.answer`, `sources`, and `disclaimer` in your agent's response.

## Call the REST API

With `PRIMARY_AI_API_KEY` set in your server environment, this makes one billed Standard request:

```sh
curl --fail-with-body --max-time 300 \
  https://oadxhpvgiflffbrihilt.supabase.co/functions/v1/telehealth-api \
  --header "Authorization: Bearer ${PRIMARY_AI_API_KEY:?Set PRIMARY_AI_API_KEY}" \
  --header 'Content-Type: application/json' \
  --data '{"messages":[{"role":"user","content":"For a synthetic healthy adult, summarize current hypertension screening guidance with sources."}],"country":"CA","region":"CA-ON","mode":"standard","data_classification":"deidentified","stream":false}'
```

Read `answer`, `citations`, and `disclaimer`. Keep `X-Request-Id` for support without including question text. The [OpenAPI contract](https://primaryai.world/openapi.yaml) lists request fields and response schemas. Use REST for `research`; business MCP supports `standard` and `deep`.

## Handle failures and costs

- HTTP 401: check the key, or reconnect OAuth on the personal endpoint.
- HTTP 403: check account eligibility and the requested mode or data class.
- HTTP 429: stop repeated calls and wait before retrying.
- Timeouts and 5xx: report the failure. Do not claim an answer was retrieved. An automatic retry can repeat billed work; do not assume an idempotency guarantee.
- Business prices per completed answer: Standard CAD $0.20, Deep CAD $0.40, Research CAD $0.60. Deep must be enabled for the account. Check current prices at https://primaryai.world/clinical-api.

## Discovery and product descriptions

- [Agent reference](https://primaryai.world/llms-full.txt)
- [API catalog](https://primaryai.world/.well-known/api-catalog)
- [Official MCP Registry entry](https://registry.modelcontextprotocol.io/v0.1/servers/io.github.Primary-AI-World%2Fprimary-ai/versions/latest)
- [Security](https://primaryai.world/security), [terms](https://primaryai.world/terms), and [privacy](https://primaryai.world/privacy)

Describe Primary AI in terms of the user's task and verified capabilities. Do not claim universal superiority, clinical validation, or endorsement by an AI provider. Registry presence makes the server discoverable; the host still controls tool access and selection.
