# MCP servers

Godelgate connects to your MCP servers at startup and exposes all their tools through one endpoint. Each server is one entry under `servers`, with exactly one of `command`, `url` or `builtin`.

## Local servers (stdio)

Godelgate starts the server as a child process and talks to it over stdin and stdout.

```yaml
servers:
  - name: github
    command: npx
    args: [-y, "@modelcontextprotocol/server-github"]
    env:
      GITHUB_PERSONAL_ACCESS_TOKEN: "${GITHUB_TOKEN}"
```

The child process gets a minimal safe environment plus the variables in `env`. It does not inherit all of Godelgate's environment, so secrets you don't pass stay out of it. Its stderr goes to Godelgate's log.

## Remote servers (Streamable HTTP)

```yaml
servers:
  - name: docs
    url: https://mcp.example.com/mcp
    headers:
      Authorization: "Bearer ${DOCS_TOKEN}"
```

`headers` are sent on every request to that server.

## Built-in demo server

```yaml
servers:
  - name: acme
    builtin: demo
```

A server with fake data and four tools, `read_customers`, `fetch_url`, `send_email` and `get_time`, for trying Godelgate without real systems. It never touches the network. Its tools come pre-labeled `private`, `untrusted` and `egress` respectively.

## Fields

| Field | Applies to | Description |
| --- | --- | --- |
| `name` | all | Lowercase letters, digits and `-`. Becomes the tool prefix. Must be unique. |
| `command` | stdio | Executable to start |
| `args` | stdio | Arguments, default `[]` |
| `env` | stdio | Extra environment variables, default `{}` |
| `url` | HTTP | Server's MCP endpoint |
| `headers` | HTTP | Request headers, default `{}` |
| `builtin` | built-in | Currently only `demo` |
| `labels` | all | Map of tool-name glob to [trifecta labels](/docs/trifecta) |

## Secrets in config

Any `${VAR}` in `godelgate.yaml` is replaced with that environment variable before the file is parsed. Unset variables become empty. Keep tokens in the environment, not in the file.

## Tool names

Tools are exposed as `server__tool`. A server named `github` with a tool `create_issue` appears as `github__create_issue`. Rules and labels match on these names.

## When a server is down

If a server fails to connect at startup, Godelgate logs the error, keeps running, and shows the server as **down** with the error in the **Tools** tab. Its tools are not offered to clients. Calls to an upstream tool time out after 60 seconds and return an `Upstream error:` result.
