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

# LiteLLM MCP Gateway

> Add the Consensus MCP server to LiteLLM's config.yaml with a bearer token or per-user OAuth with Dynamic Client Registration.

LiteLLM's MCP Gateway exposes upstream MCP servers on its `/mcp` endpoint and scopes them by key and team. Register Consensus in the UI under **MCP Servers › Add New MCP Server**, or in `config.yaml`.

<Warning>
  LiteLLM's `transport` defaults to `"sse"`. Set it to `"http"` or the connection will fail; Consensus has no SSE endpoint.
</Warning>

## Shared API key

```yaml theme={null}
mcp_servers:
  consensus:
    url: "https://mcp.consensus.app/mcp"
    transport: "http"
    auth_type: "bearer_token"
    auth_value: os.environ/CONSENSUS_API_KEY
    description: "Search 220M+ peer-reviewed papers"
```

`bearer_token` sends the value as `Authorization: Bearer <auth_value>`. If you'd rather set the header explicitly:

```yaml theme={null}
mcp_servers:
  consensus:
    url: "https://mcp.consensus.app/mcp"
    transport: "http"
    static_headers:
      Authorization: "Bearer ak_live_..."
```

## Per-user OAuth

Consensus supports Dynamic Client Registration, so point LiteLLM at the registration endpoint and it registers itself:

```yaml theme={null}
mcp_servers:
  consensus:
    url: "https://mcp.consensus.app/mcp"
    transport: "http"
    auth_type: oauth2
    oauth2_flow: authorization_code
    authorization_url: "https://consensus.app/oauth/authorize/"
    token_url: "https://consensus.app/oauth/token/"
    registration_url: "https://consensus.app/oauth/register/"
    scopes: ["search"]
```

LiteLLM's callback is `https://<PROXY_BASE_URL>/ui/mcp/oauth/callback`; set `PROXY_BASE_URL` when running behind an ingress. `oauth2_flow` is required on every `oauth2` entry.

If your clients already hold a Consensus-issued token, `auth_type: true_passthrough` forwards it unchanged.

## Notes

* Changing `server_id` after keys and teams have been granted access breaks those permissions.
* On aggregate endpoints, per-server credentials go in `x-mcp-consensus-authorization`.

LiteLLM docs: [MCP](https://docs.litellm.ai/docs/mcp) · [MCP OAuth](https://docs.litellm.ai/docs/mcp_oauth)
