# Install Page Systems in a CrewAI agent

Give a CrewAI agent the Page Systems MCP server with `mcps`.

Tested with `crewai` 1.15.27.

## 1. Set your API key

Create a key in the [dashboard](https://app.pagesystems.ai/dashboard/keys) (it starts with `ap_live_` and is shown once) and set it where your agent runs. Never commit it.

```bash
export PAGE_SYSTEMS_API_KEY=ap_live_...
```

## 2. Install

```bash
pip install crewai "pydantic[email]"
```

`pydantic[email]` is required: some page types have email fields, and without it CrewAI cannot build `create_page`'s input schema. It then logs a warning and calls `create_page` with no arguments, so every page fails with "expected string, received undefined".

## 3. Add the server to your agent

```python
import os
import urllib.request

from crewai import Agent, Crew, Task
from crewai.mcp import MCPServerHTTP

skill = urllib.request.urlopen("https://pagesystems.ai/v1/skill").read().decode()  # once, at startup

assistant = Agent(
    role="Assistant",
    goal="Get answers from people by sending them a page instead of a long chat question.",
    backstory=your_backstory + "\n\n" + skill,
    llm=llm,
    mcps=[
        MCPServerHTTP(
            url="https://pagesystems.ai/mcp",
            headers={"Authorization": f"Bearer {os.environ['PAGE_SYSTEMS_API_KEY']}"},
            cache_tools_list=True,
        )
    ],
)

task = Task(description="Ask Sam which of 9:00, 11:00 or 14:00 next Tuesday works for a call. Send a page.", expected_output="The page link and its id.", agent=assistant)
print(Crew(agents=[assistant], tasks=[task]).kickoff().raw)
```

## 4. Read the answer later

A crew run ends when its task is done, and the person answers after that. Keep the page id from the first run, and give a later task the id: "Sam answered page `<id>`. Read the answer." The agent calls `get_page_result` with it.

## 5. Check it works

Ask your agent something a page answers better than chat, for example "Ask Sam which of 9:00, 11:00 or 14:00 next Tuesday works for a call." It should send a link. Open it, pick a time, submit, then ask the agent what Sam picked: it reads the answer with `get_page_result`.
