# Connect MCP clients

Source: [Connect MCP clients](<https://docs.gptunnel.ru/en/mcp/connect/>)

<a id="_top"></a>
Use this server URL to connect a client manually.

```plaintext
https://gptunnel.ru/mcp
```

In most clients, the URL is all you need. The client opens a browser to [sign in with OAuth](<https://docs.gptunnel.ru/en/mcp/oauth/>) on the first request. If the client cannot sign in through a browser or the agent runs on a server, use an [MCP key](<https://docs.gptunnel.ru/en/mcp/keys/>) in the `Authorization: Bearer gtmcp_…` header.

<a id="tab-panel-0-0"></a>
**Claude**

Add the connector once to use it on both **claude.ai and Claude Desktop**.

1. Open **Customize → Connectors**.
2. Click **Add**, hover over **Custom** and select **Web**.
3. Enter `GPTunneL` as the name and `https://gptunnel.ru/mcp` as the server address. Click **Continue**.
4. Keep the sign-in settings Claude discovers and click **Continue**, then **Add**.
5. Sign in on the GPTunneL page and click **Allow**.
6. In a chat, click **+** or type `/`. Open **Connectors** and enable GPTunneL.

All Claude plans support custom connectors. The free plan allows one. Administrators on Team and Enterprise plans may restrict who can add them. If your menus differ, see [Claude Help](<https://support.claude.com/en/articles/11176164-use-connectors-to-extend-claude-s-capabilities>).

<a id="tab-panel-0-1"></a>
**Claude Code**

To sign in through a browser, add the server.

```bash
claude mcp add gptunnel --transport http https://gptunnel.ru/mcp
```

Then run `/mcp` in a Claude Code session, select `gptunnel` and sign in. To make the server available in all projects, add `--scope user` when registering it.

For browserless authentication, register the server with an MCP key.

```bash
claude mcp add gptunnel --transport http https://gptunnel.ru/mcp \
  --header "Authorization: Bearer gtmcp_..."
```

Run `claude mcp list` to verify the server was added.

<a id="tab-panel-0-2"></a>
**ChatGPT**

Use the ChatGPT web app to add a custom MCP server. Developer mode is optional for this setup.

1. Open **Plugins** ([chatgpt.com/plugins](<https://chatgpt.com/plugins>)).
2. Click **+** and select **Add custom MCP server**.
3. Enter `GPTunneL` as the name. Under **Connection**, use `https://gptunnel.ru/mcp` and select **OAuth** for authentication.
4. Select **I understand and want to continue** and click **Create as a plugin**.
5. Install the plugin, sign in to GPTunneL in the window that opens and click **Allow**.
6. In a new chat, type `@` and select GPTunneL. This applies to one message. Mention GPTunneL again in your next request.

Access depends on your plan and role.

- **Business, Enterprise and Edu** support generation, workflow runs and changes. Business workspace owners and admins can add custom servers. On Enterprise and Edu, admins can grant this permission to members.
- **Pro** supports read-only use. The agent can view models, workflows and the gallery.
- **Other plans** are not listed as supporting custom MCP servers in the ChatGPT documentation.

See [ChatGPT Help](<https://help.openai.com/en/articles/12584461-developer-mode-and-full-mcp-connectors-in-chatgpt-beta>).

<a id="tab-panel-0-3"></a>
**Cursor**

Register the server in `~/.cursor/mcp.json` for all projects or `.cursor/mcp.json` in your project root.

```json
{
  "mcpServers": {
    "gptunnel": {
      "url": "https://gptunnel.ru/mcp"
    }
  }
}
```

Open **Settings → MCP**, click **Login** or **Needs login** next to the server and sign in through your browser. To authenticate with an MCP key, add `"headers": { "Authorization": "Bearer gtmcp_..." }` to the server configuration.

<a id="tab-panel-0-4"></a>
**VS Code**

Add `.vscode/mcp.json` to your project or run **MCP: Add Server** and select **HTTP**.

```json
{
  "servers": {
    "gptunnel": {
      "type": "http",
      "url": "https://gptunnel.ru/mcp"
    }
  }
}
```

VS Code prompts you to sign in through your browser when you first start the server. Its tools appear in Copilot Chat in **Agent** mode.

<a id="tab-panel-0-5"></a>
**Codex**

```bash
codex mcp add gptunnel --url https://gptunnel.ru/mcp
codex mcp login gptunnel
```

You can also register the server in `~/.codex/config.toml`.

```toml
[mcp_servers.gptunnel]
url = "https://gptunnel.ru/mcp"
```

To authenticate with an MCP key, set the environment variable containing the token and reference it in the configuration.

```toml
[mcp_servers.gptunnel]
url = "https://gptunnel.ru/mcp"
bearer_token_env_var = "GPTUNNEL_MCP_KEY"
```

<a id="tab-panel-0-6"></a>
**Other clients**

Windsurf, Zed, Cline, LibreChat and other clients can connect if they support remote MCP over **Streamable HTTP**.

- Set the **URL** to `https://gptunnel.ru/mcp`.
- Select **Streamable HTTP** (`http`) as the transport.
- Use OAuth 2.1 with automatic discovery or set the `Authorization: Bearer gtmcp_...` header.

For clients that support only local `stdio` servers, use the proxy [`mcp-remote`](<https://www.npmjs.com/package/mcp-remote>):

```json
{
  "mcpServers": {
    "gptunnel": {
      "command": "npx",
      "args": ["-y", "mcp-remote", "https://gptunnel.ru/mcp"]
    }
  }
}
```

 <a id="own-agent"></a>
 
<a id="connect-your-own-agent"></a>
## Connect your own agent

For a server-side agent, keep an [MCP key](<https://docs.gptunnel.ru/en/mcp/keys/>) in an environment variable.

<a id="tab-panel-1-0"></a>
**Python**

```python
import asyncio, os
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client

async def main():
    headers = {"Authorization": f"Bearer {os.environ['GPTUNNEL_MCP_KEY']}"}
    async with streamablehttp_client("https://gptunnel.ru/mcp", headers=headers) as (read, write, _):
        async with ClientSession(read, write) as session:
            await session.initialize()
            tools = await session.list_tools()
            me = await session.call_tool("whoami", {})
            print(me.content[0].text)

asyncio.run(main())
```

<a id="tab-panel-1-1"></a>
**cURL**

```bash
curl -X POST https://gptunnel.ru/mcp \
  -H "Authorization: Bearer $GPTUNNEL_MCP_KEY" \
  -H "Content-Type: application/json" \
  -H "Accept: application/json, text/event-stream" \
  -d '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "tools/call",
    "params": { "name": "whoami", "arguments": {} }
  }'
```

The server handles each request independently. You can make this call without sending `initialize` first. The server sends an SSE event with the JSON-RPC response on its `data:` line.

<a id="tab-panel-1-2"></a>
**TypeScript (Node.js)**

```typescript
import { Client } from '@modelcontextprotocol/sdk/client/index.js'
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js'

const transport = new StreamableHTTPClientTransport(new URL('https://gptunnel.ru/mcp'), {
  requestInit: {
    headers: { Authorization: `Bearer ${process.env.GPTUNNEL_MCP_KEY}` },
  },
})

const client = new Client({ name: 'my-agent', version: '1.0.0' })
await client.connect(transport)

const { tools } = await client.listTools()
const me = await client.callTool({ name: 'whoami', arguments: {} })
```

> **Note: Claude API connection**
>
> If you use the Claude API, you can pass the server directly to the MCP connector in `mcp_servers` with `url` and `authorization_token`.

The Claude catalog’s media library uses `/mcp/claude`. To use `lab_quote` and `lab_generate`, add a connection to `https://gptunnel.ru/mcp` with the required permissions.

 <a id="checking-connection"></a>
 
<a id="verify-the-connection"></a>
## Verify the connection

Ask the agent “Check my GPTunneL connection and tell me which permissions it has.” It will call `whoami` and show the connection’s permissions. Listing your five latest generations and listing image models are also free.

 <a id="work-in-the-organization"></a>
 
<a id="use-an-organization-balance"></a>
## Use an organization balance

Tell the agent which organization should pay, for example “Use the Marketing organization’s balance.” The agent finds the organization with `list_orgs`. By default, GPTunneL charges the personal balance. A connection can use an organization balance only if its [spending settings](<https://docs.gptunnel.ru/en/mcp/billing/#balance-of-the-organization>) allow it.
