# List mailbox folders with Strands Agents and Pear MCP

Use the Strands Python MCP client to inspect the folders in a connected mailbox before an agent searches it. No model call is needed for this check.

[Canonical walkthrough](https://pearmcp.com/use-cases/strands-agents-mail-folders)

## Before you start

- Install strands-agents in a private Python environment with the MCPClient HTTP transport available.
- Connect one mailbox with folder-read access in Pear. Choose an iCloud or Outlook mailbox whose folders you recognise.
- Create a project API key in Pear Settings and provide it as PEAR_API_KEY in your local environment.

## 1. Ask Pear which mail folders exist

Strands can invoke a named MCP tool directly. This example reads the folders on your default mail account without passing them to a model. The context manager closes the connection when the call finishes.

```python
import os
from uuid import uuid4
from strands.tools.mcp import MCPClient

pear = MCPClient(
    url="https://pearmcp.com/api/mcp",
    headers={"Authorization": f"Bearer {os.environ['PEAR_API_KEY']}"},
)
with pear:
    result = pear.call_tool_sync(
        tool_use_id=str(uuid4()),
        name="pear_list_mail_folders",
        arguments={},
    )
    if result["status"] != "success":
        raise RuntimeError("Folder lookup failed. Check the account and key.")
    print(result["content"])
```

> Which exact folder path does Pear return for the project folder I use in Mail or Outlook?

Compare a custom folder name and its parent with your mailbox app. Keep the returned provider identifiers alongside the display names.

## 2. Choose a folder for a later search

If your Strands application also has a model, give its mail search only the read tools it needs. Use the discovered folder and bound the first search to one familiar message. The Python check above ends after listing folders.

> Search the selected project folder for the subject I give you. Return up to three matches with sender and date. Leave the messages as they are.

Open one match in the same folder and compare its sender and date. A similarly named folder in another account can contain different mail.

## Troubleshooting

**Strands rejects the url argument** — Check the installed strands-agents version against the transport reference. The example uses the documented MCPClient constructor with url and headers.

**Pear asks you to choose an account** — Call pear_provider_status to identify the connected mailbox, then use the account selector from the live folder tool schema. A send-only connection cannot enumerate folders.

The Strands SDK documents the transport and direct tool call. A live Pear account test with Strands is pending. Folder names can contain client or project information. Keep terminal output private and revoke the project key in Pear when finished.

[How Pear handles your data](https://pearmcp.com/data-handling)

- [Strands MCP HTTP transport](https://strandsagents.com/docs/user-guide/sdk/tools/mcp-transports/)
- [Strands Python MCPClient reference](https://strandsagents.com/docs/api/python/strands.tools.mcp.mcp_client/)
- [Connect an agent SDK](https://pearmcp.com/guides/developer-sdks)
- [Triage messages in a selected folder](https://pearmcp.com/use-cases/inbox-triage)
