> ## Documentation Index
> Fetch the complete documentation index at: https://build.practicehub.io/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP Server

> Let Claude, ChatGPT or your own agent work inside a clinic

PracticeHub exposes a [Model Context Protocol](https://modelcontextprotocol.io) server on every clinic domain. An AI client connects once, discovers the tools, and can then look things up, book and reschedule appointments, and create or update records — through the same API and the same rules as everything else on this site.

```
https://{clinic}.{region}.practicehub.io/v3/api/mcp
```

<CardGroup cols={3}>
  <Card title="Discovers itself" icon="radar">
    `list_entity_types` describes every resource; the generic tools then read and write any of them. New resources appear automatically.
  </Card>

  <Card title="Two ways in" icon="key">
    An API key for headless agents, or OAuth for AI apps acting for a signed-in team member.
  </Card>

  <Card title="Same rules" icon="shield-check">
    Tools call the API's services, so an agent cannot do anything a person could not, and every action is on the audit trail.
  </Card>
</CardGroup>

## Authentication

| Client                                                   | Credential                                                                                                                                                                                                                               | Runs as                                          |
| -------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------ |
| Claude, ChatGPT and other AI apps a team member connects | OAuth 2.1 with dynamic client registration and PKCE — the client discovers `/.well-known/oauth-authorization-server`, registers itself, and the team member approves on a PracticeHub consent screen. See [Connectors](/mcp/connectors). | That team member — their name is on every action |
| Your own agent or automation                             | An API key as `Authorization: Bearer {key}` — the same key as the REST API                                                                                                                                                               | The integration the key belongs to               |

## Protocol

Streamable HTTP: JSON-RPC 2.0 over `POST`, with `Accept: application/json, text/event-stream`. The usual sequence is `initialize` → `tools/list` → `tools/call`.

```bash theme={null}
curl -X POST https://your-clinic.your-region.practicehub.io/v3/api/mcp \
  -H "Authorization: Bearer $KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{
        "protocolVersion":"2025-06-18","capabilities":{},
        "clientInfo":{"name":"my-agent","version":"1.0"}}}'
```

## What an agent can do

* **Understand the clinic's data** — `list_entity_types` returns every resource with its attributes, what is filterable and sortable, and which write operations it accepts.
* **Find anything** — `query_entities` with the API's [filter syntax](/guides/querying#filters), or the friendlier `patient-lookup-tool` for name / phone / email searches.
* **Change anything the API allows** — `write_entity` for create / update / delete on any writable resource, plus curated `appointment-book-tool` and `appointment-reschedule-tool` for the common flows.

The [Tools reference](/mcp/tools) lists each tool with its parameters. Reads and writes are logged on the account's **Developers → API Logs** page like any API request.

<Tip>
  Tools return the API's `422` / `409` messages as tool errors, so an agent that tries to book a deleted patient or double-process a visit is told exactly why and can correct itself.
</Tip>
