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

# MCP Servers

> The tools Mains gives agents, and how to connect your own

MCP (Model Context Protocol) is an open standard for connecting AI agents to external tools and data sources. Mains uses it in two directions: it **exposes its own tools** to every agent runtime, and it lets you **register external servers** that agents can call.

## **Built-in Mains Tools**

Mains runs an in-process MCP server and attaches it to every session, so agents can reach into the app itself -- no setup, nothing to install.

| **Tool**           | **What it does**                                                                              | **Available to**        |
| ------------------ | --------------------------------------------------------------------------------------------- | ----------------------- |
| `GetWorkspaceDiff` | Read the workspace's captured git [diff](/diff-viewer), for the current run or a specific one | Claude, Copilot, Cursor |
| `SaveReview`       | Open a [review](/reviews) record against the workspace                                        | Claude, Copilot, Cursor |
| `SaveFinding`      | Record one review finding                                                                     | Claude, Copilot, Cursor |
| `SaveFindings`     | Record several findings at once                                                               | Claude, Copilot, Cursor |
| `CommitChanges`    | Stage and commit -- the same path the [git actions panel](/git-actions) uses                  | All four                |
| `CreatePR`         | Open a pull request with `gh`                                                                 | All four                |
| `CheckPackage`     | Score a package against the [dependency guard](/dependency-guards) before installing it       | Codex, Cursor           |

<Note>
  The review tools are withheld from Codex, whose flow in Mains is code-writing rather than review. `CheckPackage` is the mirror image: Claude and Copilot guard packages through a pre-tool hook on `Bash`, so they never need to call it explicitly -- Codex and Cursor can't hook that path, so they get the tool instead.
</Note>

`CommitChanges` and `CreatePR` pick up your [commit and PR instructions](/settings#git) automatically. When instructions are configured and the agent calls the tool without a message or body, the tool returns those instructions first so the agent can follow them before committing.

## **Adding an MCP Server**

MCP servers are added through the terminal using the Claude Code CLI. Once registered, the server is available to use inside Mains immediately.

```javascript theme={null}
# Add a stdio server (local process)
claude mcp add slack -- npx -y @anthropic-ai/mcp-server-slack
# Add with environment variables
claude mcp add github -- npx -y @modelcontextprotocol/server-github \
  -e GITHUB_TOKEN=ghp_xxxxx
# Add an HTTP server (remote)
claude mcp add remote-api --transport http --url https://mcp.example.com/sse
```

After adding, restart your workspace session — Mains picks up the new server and its tools become available to the agent.

## **Agent Support**

Both agent runtimes in Mains can use MCP servers, with some differences in how they discover and invoke tools.

### **Claude Code**

Claude Code loads MCP servers from multiple sources, merged by priority:

| **Source**       | **Path**                              |
| ---------------- | ------------------------------------- |
| User (global)    | `~/.claude/settings.json`             |
| Project (shared) | `.{your_project}/settings.json`       |
| Local (personal) | `.{your_project}/settings.local.json` |

### **GitHub Copilot**

Copilot discovers MCP servers registered through the same CLI. Tools are subject to the tool permission rules in [**<u>Copilot configuration</u>**](/copilot/configuration). You can allow or deny specific tools before they execute.

## **Popular Servers**

| **Server** | **Install Command**                                                               | **Description**    |
| ---------- | --------------------------------------------------------------------------------- | ------------------ |
| GitHub     | `claude mcp add github -- npx -y @modelcontextprotocol/server-github`             | Issues, PRs, repos |
| Slack      | `claude mcp add slack -- npx -y @anthropic-ai/mcp-server-slack`                   | Channels, messages |
| Linear     | `claude mcp add linear -- npx -y @linear/mcp-server`                              | Issues, projects   |
| Filesystem | `claude mcp add fs -- npx -y @modelcontextprotocol/server-filesystem /path`       | Local file access  |
| Postgres   | `claude mcp add db -- npx -y @modelcontextprotocol/server-postgres $DATABASE_URL` | Database queries   |

<Note>
  If a server is disconnected when a session starts, its tools won't be available for that run. Check `claude mcp list` to verify server status.
</Note>
