# Use Pear MCP from the Claude Agent SDK, OpenAI and Vercel AI SDK

<!-- MCP_HOST_IDS: claude-agent-sdk, openai-responses-api, vercel-ai-sdk -->
<!-- MCP_HOST_COMPATIBILITY:START -->
## Connection and authentication

Use the authentication method shown for each client surface.

| Client surface | Authentication | Setup guide |
| --- | --- | --- |
| Claude Agent SDK | API key via environment | Setup guide available |
| OpenAI Responses API | API key via environment | Setup guide available |
| Vercel AI SDK | API key via environment | Setup guide available |
<!-- MCP_HOST_COMPATIBILITY:END -->

Give an agent you build access to your connected iCloud or Microsoft 365 account
through Pear's hosted MCP endpoint.

## 1. Prepare a key for your code

[Sign in to Pear](https://pearmcp.com/login), connect iCloud or Microsoft 365, and
create an API key in Settings for this project. Load it from the environment as
`PEAR_API_KEY`; never commit it or send it to a browser. A Pear key belongs to one
Pear account, so do not run an app for other people with your key.

None of these SDKs signs a user in to Pear for you. The Claude Agent SDK and OpenAI
Responses API run no interactive OAuth flow, and Pear has no OAuth client registered
for your application, so these examples use the API key.

## 2. Claude Agent SDK

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

for await (const message of query({
  prompt: 'Call pear_provider_status and list my ready accounts. Do not change anything.',
  options: {
    mcpServers: {
      pear: {
        type: 'http',
        url: 'https://pearmcp.com/api/mcp',
        headers: { Authorization: `Bearer ${process.env.PEAR_API_KEY}` },
      },
    },
    allowedTools: [
      'mcp__pear__pear_provider_status',
      'mcp__pear__pear_list_calendars',
      'mcp__pear__pear_list_events',
    ],
  },
})) {
  if (message.type === 'result' && message.subtype === 'success') {
    console.log(message.result);
  }
}
```

Tools in `allowedTools` run without asking, so list only reads at first. The `system`
init message should show Pear as `connected`.

## 3. OpenAI Responses API

```ts
import OpenAI from 'openai';

const client = new OpenAI();

const response = await client.responses.create({
  model: process.env.OPENAI_MODEL,
  tools: [
    {
      type: 'mcp',
      server_label: 'pear',
      server_url: 'https://pearmcp.com/api/mcp',
      authorization: process.env.PEAR_API_KEY,
      allowed_tools: ['pear_provider_status', 'pear_list_calendars', 'pear_list_events'],
      require_approval: 'always',
    },
  ],
  input: 'Call pear_provider_status and list my ready accounts. Do not change anything.',
});

console.log(response.output);
```

OpenAI calls Pear on your behalf, so tool arguments and results pass through OpenAI's
API and its retention settings. Send `authorization` with every request; Pear accepts
the key with or without a `Bearer ` prefix. With approvals on, answer each
`mcp_approval_request` with an `mcp_approval_response`.

## 4. Vercel AI SDK

```ts
import { createMCPClient } from '@ai-sdk/mcp';
import { generateText, stepCountIs } from 'ai';

const pear = await createMCPClient({
  transport: {
    type: 'http',
    url: 'https://pearmcp.com/api/mcp',
    headers: { Authorization: `Bearer ${process.env.PEAR_API_KEY}` },
  },
});

try {
  const { pear_provider_status, pear_list_events } = await pear.tools();
  const { text } = await generateText({
    model: process.env.AI_MODEL,
    tools: { pear_provider_status, pear_list_events },
    stopWhen: stepCountIs(5),
    prompt: 'Call pear_provider_status and list my ready accounts. Do not change anything.',
  });
  console.log(text);
} finally {
  await pear.close();
}
```

The AI SDK does not turn MCP tool annotations into an approval policy; add your own
approval step before any Pear write tool runs.

## 5. Check one real result

Confirm the output lists ready accounts from `pear_provider_status`, then read one day
of a named calendar with an explicit timezone and compare with your calendar app.

## Writes from code

Pear writes use `pear_draft_write` to prepare an exact change and
`pear_execute_approved_write` to run it once. Show a person the draft before execution,
and reuse an idempotency key only when retrying the identical action.

## Troubleshooting and revocation

A 401 means the key is missing, inactive or sent in a header other than Authorization.
Pear uses Streamable HTTP. Revoke the key in Pear; give each project its own key.

## Provider limits and next steps

Tools depend on your connected provider, account permissions, and client settings. Start with a read, then inspect a preview before approving writes.

- [iCloud setup](https://pearmcp.com/icloud-mcp-server)
- [iCloud Mail](https://pearmcp.com/ai-icloud-mail)
- [Microsoft 365 setup](https://pearmcp.com/microsoft-365-mcp-server)
- [Outlook Mail](https://pearmcp.com/outlook-mail-mcp)
- [Microsoft To Do](https://pearmcp.com/microsoft-to-do-mcp)
- [Data handling](https://pearmcp.com/data-handling)
- [Plans](https://pearmcp.com/pricing)

Pear's hosted CalDAV connection cannot access Apple's upgraded Reminders store. Only legacy reminder data still exposed through CalDAV is available; reconnecting cannot change this limit. Microsoft To Do is unaffected. Gmail works with a Google app password. Google sign-in for Calendar, Tasks and Contacts is coming soon.

## Sources and compatibility status

Documentation checked on 25 November 2026. Setup guide available; a complete Pear
authentication, tool-list, read, and approved-write test with each SDK is still pending.

- [Claude Agent SDK: MCP](https://code.claude.com/docs/en/agent-sdk/mcp)
- [OpenAI: remote MCP servers](https://developers.openai.com/api/docs/guides/tools-connectors-mcp)
- [AI SDK: MCP tools](https://ai-sdk.dev/docs/ai-sdk-core/mcp-tools)
- [HTML setup guide](https://pearmcp.com/guides/developer-sdks)
- [Read a calendar with Pydantic AI and Pear MCP](https://pearmcp.com/use-cases/pydantic-ai-calendar)
- [List mailbox folders with Strands Agents and Pear MCP](https://pearmcp.com/use-cases/strands-agents-mail-folders)
