# Install Page Systems in a Claude Agent SDK agent

Add the Page Systems MCP server to the agent's options and allow its tools.

Tested with `@anthropic-ai/claude-agent-sdk` 0.3.296 (TypeScript) and `claude-agent-sdk` 0.2.165 (Python).

## 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. TypeScript

```bash
npm install @anthropic-ai/claude-agent-sdk
```

```ts
import { query } from '@anthropic-ai/claude-agent-sdk';

const skill = await fetch('https://pagesystems.ai/v1/skill').then((r) => r.text()); // once, at startup

for await (const message of query({
  prompt: userMessage,
  options: {
    systemPrompt: [yourInstructions, skill].join('\n\n'),
    mcpServers: {
      'page-systems': {
        type: 'http',
        url: 'https://pagesystems.ai/mcp',
        headers: { Authorization: `Bearer ${process.env.PAGE_SYSTEMS_API_KEY}` },
      },
    },
    allowedTools: ['mcp__page-systems__*'],
  },
})) {
  if (message.type === 'result') console.log(message.subtype === 'success' ? message.result : message.errors);
}
```

## 3. Python

```bash
pip install claude-agent-sdk
```

```python
import os
import urllib.request

from claude_agent_sdk import ClaudeAgentOptions, ResultMessage, query

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

options = ClaudeAgentOptions(
    system_prompt=your_instructions + "\n\n" + skill,
    mcp_servers={
        "page-systems": {
            "type": "http",
            "url": "https://pagesystems.ai/mcp",
            "headers": {"Authorization": f"Bearer {os.environ['PAGE_SYSTEMS_API_KEY']}"},
        }
    },
    allowed_tools=["mcp__page-systems__*"],
)

async for message in query(prompt=user_message, options=options):
    if isinstance(message, ResultMessage):
        print(message.result)
```

`allowedTools` / `allowed_tools` lets the agent call the Page Systems tools without asking for permission each time.

## 4. Keep the conversation

The answer arrives in a later turn. Keep the `session_id` from the result message and pass it as `resume` on the next `query`; the model then calls `get_page_result` with the page id it already has.

## 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`.
