> ## Documentation Index
> Fetch the complete documentation index at: https://hyperbrowser.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP Integration

> Connect HyperAgent to MCP servers for extended capabilities

HyperAgent functions as a fully functional MCP (Model Context Protocol) client. Connect to MCP servers to extend capabilities with tools like Google Sheets, Notion, Slack, and more.

## What is MCP?

MCP (Model Context Protocol) is a standard for connecting AI models to external tools and data sources. HyperAgent can connect to any MCP-compatible server.

## Setting Up MCP

Initialize the MCP client with your server configuration:

```typescript theme={null}
import { HyperAgent } from "@hyperbrowser/agent";

const agent = new HyperAgent({
  llm: {
    provider: "openai",
    model: "gpt-4o", // Recommended for MCP
  },
});

await agent.initializeMCPClient({
  servers: [
    {
      command: "npx",
      args: [
        "@composio/mcp@latest",
        "start",
        "--url",
        "https://mcp.composio.dev/googlesheets/your-connection-id",
      ],
      env: {
        npm_config_yes: "true",
      },
    },
  ],
});
```

## Example: Web Data to Google Sheets

Scrape data from a website and write it to Google Sheets:

```typescript theme={null}
const agent = new HyperAgent({
  llm: {
    provider: "openai",
    model: "gpt-4o",
  },
  debug: true,
});

await agent.initializeMCPClient({
  servers: [
    {
      command: "npx",
      args: [
        "@composio/mcp@latest",
        "start",
        "--url",
        "https://mcp.composio.dev/googlesheets/...",
      ],
      env: {
        npm_config_yes: "true",
      },
    },
  ],
});

const response = await agent.executeTask(
  "Go to https://en.wikipedia.org/wiki/List_of_U.S._states_and_territories_by_population " +
  "and get the data on the top 5 most populous states from the table. " +
  "Then insert that data into a Google Sheet."
);

console.log(response);
await agent.closeAgent();
```

## Available MCP Servers

Popular MCP servers you can connect to:

| Server        | Use Case                        |
| ------------- | ------------------------------- |
| Google Sheets | Read/write spreadsheet data     |
| Notion        | Create and update pages         |
| Slack         | Send messages and notifications |
| GitHub        | Create issues, PRs              |
| Airtable      | Database operations             |

Find more at [Composio MCP](https://composio.dev/mcp) or build your own.

## Multiple Servers

Connect to multiple MCP servers simultaneously:

```typescript theme={null}
await agent.initializeMCPClient({
  servers: [
    {
      command: "npx",
      args: ["@composio/mcp@latest", "start", "--url", "sheets-url"],
      env: { npm_config_yes: "true" },
    },
    {
      command: "npx",
      args: ["@composio/mcp@latest", "start", "--url", "slack-url"],
      env: { npm_config_yes: "true" },
    },
  ],
});

await agent.executeTask(
  "Scrape the pricing from competitor.com, save to Google Sheets, and notify #sales on Slack"
);
```
