---
layout: article
title: Pi
description: Learn how you can add the Appwrite MCP server to Pi to interact with both the Appwrite API and documentation, and to react to events in your project.
---

## 1. Quick start prompts

Get started quickly with these pre-built prompts for common Appwrite integrations:

- [TanStack Start](/docs/tooling/ai/quickstart-prompts/tanstack-start)
- [Next.js](/docs/tooling/ai/quickstart-prompts/nextjs)

[Browse all quick start prompts](/docs/tooling/ai/quickstart-prompts)

## 2. Add the MCP server

Connect the Appwrite MCP server to [Pi](https://pi.dev), a terminal coding agent, for deeper integration with the Appwrite API and documentation. It is a remote HTTP server, so you don't run a server on your machine.

If you don't have Pi yet, install it from your terminal on macOS or Linux. On Windows, or to install with npm, see [pi.dev](https://pi.dev).

```bash
curl -fsSL https://pi.dev/install.sh | sh
```

Pi connects to the server through [pi-mcp-adapter](https://github.com/nicobailon/pi-mcp-adapter), a Pi extension that adds MCP servers to your sessions. Install it:

```bash
pi install npm:pi-mcp-adapter
```

Add the Appwrite MCP server to `~/.pi/agent/mcp-adapter.json`. Create the file if it doesn't exist, or merge this into it:

```json
{
  "mcpServers": {
    "appwrite": {
      "url": "https://mcp.appwrite.io/",
      "auth": "oauth"
    }
  }
}
```

The server uses OAuth for authentication. Start Pi by running `pi` in your terminal, then run `/mcp-auth appwrite`. Your browser opens so you can sign in to your Appwrite account and authorize access. You don't need an API key. The adapter keeps the sign-in in your operating system's credential store.

**Pi's built-in MCP support**

Pi also has built-in MCP support, which you set up with `pi mcp add`. The events extension in [Step 4](#step-4) needs pi-mcp-adapter, so this guide uses the adapter. The adapter turns off the built-in support in Pi's settings and reads the servers you added with `pi mcp add`, so those keep working.

## 3. Test the integration

Run `/mcp` in Pi to check that **appwrite** is listed with its tools. Then try out the following example prompts:

**Example prompts:**

- `Create a new user in my Appwrite project`
- `List all databases in my project`
- `Show me the tables in my database`
- `How do I set up real-time subscriptions in Appwrite?`
- `Show me how to authenticate users with OAuth`
- `How do I implement file uploads with Appwrite Storage?`

The following screenshot shows Pi answering `List the users in my Appwrite project pi-guide` for a test project.

![Pi lists the users in an Appwrite project](/images/docs/mcp/pi/list-users-light.avif)

## 4. React to project events

The Appwrite MCP server supports [MCP Events](/docs/tooling/ai/mcp-servers#events), an MCP extension that lets an agent subscribe to changes in your project. Pi can subscribe to an event, such as a new user, finish its turn, and wake up when the event happens. The server pushes each event over the connection Pi already has open, so you don't need a public URL.

Pi receives events through [pi-mcp-events](https://github.com/mikekelly/pi-mcp-events), an extension that adds an `mcp_events` tool on top of pi-mcp-adapter. Install it, then restart Pi to load it:

```bash
pi install npm:@realmikekelly/pi-mcp-events
```

Ask Pi to subscribe to `users.user.created`. Replace `<PROJECT_ID>` with your project ID:

```
Subscribe with mcp_events to users.user.created on the appwrite server for project_id <PROJECT_ID>, then finish your turn and wait. Whenever an event arrives, look up that user and tell me their name and email.
```

Pi opens the subscription and goes idle. When a user signs up or you create one in the Appwrite Console, Pi wakes up without a new prompt, looks up the user, and replies with their name and email.

When you no longer need the events, ask Pi to unsubscribe:

```
Unsubscribe from users.user.created
```

The following recording shows the whole flow in a test project. Pi subscribes, wakes up when a user is created, reports the user, and then unsubscribes.

![Pi subscribes to users.user.created, wakes up when a user is created, and unsubscribes](/images/docs/mcp/pi/events-light.gif)

Subscriptions last as long as the Pi session. After you restart Pi or run `/reload`, ask it to subscribe again. To see every event you can subscribe to and how delivery works, read [Events](/docs/tooling/ai/mcp-servers#events).
