Claude
Connect Claude Desktop and Claude Code to agentgateway
Configure Anthropic’s Claude Desktop app or Claude Code CLI to use agentgateway as an MCP server.
Note
This page covers connecting Claude as an MCP client. To proxy Claude Code’s LLM traffic (prompts and responses) through agentgateway, see the Claude Code LLM client guide.
Before you begin
- Install and run agentgateway.
- Confirm agentgateway is up by opening the agentgateway UI.
- Use the MCP endpoint
http://localhost:3000/mcpto connect your client to agentgateway. If you run agentgateway on a different host or port, replacelocalhost:3000in the examples accordingly.
Claude Desktop
Claude Desktop reads claude_desktop_config.json for local MCP servers that run as a command (stdio). The file does not accept a remote url. Choose one of the following options to connect to agentgateway.
Option 1: Local gateway with mcp-remote
Use the mcp-remote package as a stdio bridge. Claude Desktop starts mcp-remote, and mcp-remote connects to agentgateway over streamable HTTP. This option works with a gateway on localhost or a port-forwarded gateway.
Install Node.js 18 or later. Claude Desktop uses
npxto runmcp-remote.Open the Claude Desktop configuration file. In Claude Desktop, go to Settings > Developer > Edit Config. If you do not see Developer, go to Settings > Desktop app.
The file is at~/Library/Application Support/Claude/claude_desktop_config.json.Add agentgateway to the
mcpServerssection.{ "mcpServers": { "agentgateway": { "command": "npx", "args": ["-y", "mcp-remote", "http://localhost:3000/mcp"] } } }The
mcp-remotebridge allows plainhttp://URLs forlocalhost. For any other host, use anhttps://URL or add"--allow-http"toargs.Fully quit Claude Desktop, and open it again. On macOS, press
Cmd+Q. Closing the window is not enough.In a new chat, open the tools menu, and verify that
agentgatewayis listed with its tools.
If the server shows as failed, check the log at ~/Library/Logs/Claude/mcp-server-agentgateway.log on macOS or in %APPDATA%\Claude\logs\ on Windows.
To send a token to a gateway that requires authentication, see Authentication.
Option 2: Gateway on public HTTPS
If your gateway is reachable on a public HTTPS URL, add it as a custom connector instead. Claude connects to custom connectors from Anthropic’s cloud, not from your device. Therefore, the following requirements apply.
- The URL must be reachable on the public internet over HTTPS on port 443. A
localhostURL and a URL with another port do not work. - Sending a custom request header, such as an
Authorizationtoken, is not available to every organization. For the current status and the steps, see Add custom connectors and Getting started with custom connectors in the Claude docs.
- In Claude Desktop, go to Settings > Connectors, and click Add custom connector.
- Enter your MCP URL, such as
https://mcp.example.com/mcp. - If the gateway uses MCP authentication, complete the OAuth sign-in. Otherwise, select No sign in.
Claude Code CLI
Configure Claude Code to connect to agentgateway.
claude mcp add --transport http agentgateway http://localhost:3000/mcpOr, add to your project’s .mcp.json.
{
"mcpServers": {
"agentgateway": {
"type": "http",
"url": "http://localhost:3000/mcp"
}
}
}Warning
The SSE transport (/sse) is deprecated. Use the streamable HTTP transport (/mcp) for all new setups.
Authentication
If agentgateway requires authentication, send the token in the Authorization header. Do not put the token in the URL.
Use the --header flag.
claude mcp add --transport http agentgateway http://localhost:3000/mcp \
--header "Authorization: Bearer <token>"Or, set headers in your project’s .mcp.json.
{
"mcpServers": {
"agentgateway": {
"type": "http",
"url": "http://localhost:3000/mcp",
"headers": {
"Authorization": "Bearer <token>"
}
}
}
}