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

# Install the MCP server

> Bring MergeGuide governance into your AI coding assistant with the MCP server.

The MergeGuide **MCP server** lets AI coding assistants check changes against your
policies as part of their loop — so AI-written code is governed at the moment it's
produced, not just at review time. It is published as the npm package
`@mergeguide/mcp-server` and exposes a `mergeguide-mcp` command.

<Note>
  **Requires Node.js 18 or newer.** The MCP server connects an
  [MCP](https://modelcontextprotocol.io)-capable client (such as Claude Code) to
  your MergeGuide policies.
</Note>

## Run it

The simplest way to run the server is with `npx`, which fetches and runs the
published package without a global install:

```bash theme={null}
npx @mergeguide/mcp-server
```

<Tip>
  If you ran [`mergeguide init`](/get-started/quickstart), the MCP server was already
  installed via `npx` and registered in your project's `.mcp.json` for you. You can
  skip the manual configuration below.
</Tip>

## Configure your client

Add the server to your client's `.mcp.json` so it launches automatically. Most
MCP clients use this shape:

```json .mcp.json theme={null}
{
  "mcpServers": {
    "mergeguide": {
      "type": "stdio",
      "command": "npx",
      "args": ["@mergeguide/mcp-server"]
    }
  }
}
```

Reload your client; "mergeguide" should appear among its available MCP servers.

## Optional environment variables

You can tune the server's behavior through environment variables in the `env`
block of your `.mcp.json` entry:

| Variable               | Default      | Description                                           |
| ---------------------- | ------------ | ----------------------------------------------------- |
| `MERGEGUIDE_MODE`      | `local-only` | Operating mode: `online`, `offline`, or `local-only`. |
| `MERGEGUIDE_LOG_LEVEL` | `info`       | Log level: `debug`, `info`, `warn`, or `error`.       |
| `MERGEGUIDE_CACHE_TTL` | `300000`     | Result cache lifetime in milliseconds.                |

```json .mcp.json theme={null}
{
  "mcpServers": {
    "mergeguide": {
      "type": "stdio",
      "command": "npx",
      "args": ["@mergeguide/mcp-server"],
      "env": {
        "MERGEGUIDE_MODE": "online",
        "MERGEGUIDE_LOG_LEVEL": "info"
      }
    }
  }
}
```

## Next steps

<CardGroup cols={2}>
  <Card title="Install the CLI" icon="terminal" href="/install/cli">
    The CLI powers local checks and git hooks.
  </Card>

  <Card title="Enforcement layers" icon="layer-group" href="/operation/enforcement-layers">
    How the MCP server fits with the IDE, hooks, and PR gate.
  </Card>
</CardGroup>
