> For the complete documentation index, see [llms.txt](https://docs.nexos.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nexos.ai/gateway-api/connect-to-the-mcp-gateway.md).

# Connect to the MCP Gateway

The MCP Gateway gives your coding agent access to the integrations connected to your nexos.ai workspace: chat, issue trackers, documents, and any MCP server added to the gateway. Connect your client once and it can search for and run tools across all of them, without installing one server per integration.

```
https://mcp.nexos.ai
Authenticate with Authorization: Bearer <your-user-api-key> on every request.
```

{% hint style="info" %}
Availability. The MCP Gateway is enabled per company. If requests fail with `503` and `the integrations MCP gateway is not enabled for your company`, it is not enabled for yours yet.
{% endhint %}

### Before you start

**You need two things:**

* **A user API key**. Create one in nexos.ai; these are the same keys you use with the nexos.ai API. Team API keys do not work: an integration is always used on behalf of a person, and a team key does not identify one.
* **At least one connected integration**. The gateway serves the integrations you have connected, enabled and hold valid credentials for.

There is no OAuth flow: your client does not need to open a browser, and `codex mcp login` and similar commands do not apply.

Keep the key out of files you commit. Export it in the shell that launches your client, and let the client read it from there:

```bash
export NEXOS_API_KEY="your-user-api-key"
```

### Connect your client

Pick your client below. Every client authenticates with the same key and the same URL.

#### Claude Code (remote http)

```
claude mcp add · scope local, user or project
```

```bash
claude mcp add --transport http mcp-gateway https://mcp.nexos.ai \
  --header 'Authorization: Bearer ${NEXOS_API_KEY}'
```

The default scope is `local` (this project, your user only). Add `--scope user` to make it available in every project, or `--scope project` to write `.mcp.json` in the repository so your team shares it.

If you prefer editing the file, an entry needs `"type": "http"`:

```json
{
  "mcpServers": {
    "mcp-gateway": {
      "type": "http",
      "url": "https://mcp.nexos.ai",
      "headers": { "Authorization": "Bearer ${NEXOS_API_KEY}" }
    }
  }
}
```

***

#### Cursor (remote http)

```
.cursor/mcp.json · ~/.cursor/mcp.json
```

Add the server to `.cursor/mcp.json` in the project, or `~/.cursor/mcp.json` to make it global:

```json

{
  "mcpServers": {
    "mcp-gateway": {
      "url": "https://mcp.nexos.ai",
      "headers": {
        "Authorization": "Bearer ${env:NEXOS_API_KEY}"
      }
    }
  }
}
```

Cursor reads `${env:NAME}` from the environment it was started with.

***

#### VS Code and GitHub Copilot (remote http)

```
.vscode/mcp.json · user profile
```

Add the server to `.vscode/mcp.json` in the workspace, or open the user-level file with MCP: Open User Configuration from the command palette:

```json
{
  "servers": {
    "mcp-gateway": {
      "type": "http",
      "url": "https://mcp.nexos.ai",
      "headers": {
        "Authorization": "Bearer ${input:nexos-api-key}"
      }
    }
  },
  "inputs": [
    {
      "type": "promptString",
      "id": "nexos-api-key",
      "description": "nexos.ai user API key",
      "password": true
    }
  ]
}
```

VS Code prompts for the key on first start and stores it securely. If you use the Copilot portable format instead (`.mcp.json` in the workspace root, or `~/.copilot/mcp-config.json`), the top-level key is `mcpServers` and interpolation is `${NAME}`. Do not mix the two formats in one file.

***

#### Codex CLI (remote http)

```
~/.codex/config.toml
```

Add a table to `~/.codex/config.toml`:

```toml
[mcp_servers.nexos]
url = "https://mcp.nexos.ai"
bearer_token_env_var = "NEXOS_API_KEY"
```

Codex reads the token from that environment variable, so export it in the shell that launches Codex. `codex mcp list` shows the server. There is no flag for a bearer token on `codex mcp add`; editing the file is the supported way to use an API key.

***

#### Claude Desktop (custom connector)

```
settings UI, not claude_desktop_config.json
```

Remote servers are added as custom connectors, not in `claude_desktop_config.json`:

1. Open Customize → Connectors → Add custom connector.
2. Enter the name MCP Gatway and the URL `https://mcp.nexos.ai`.
3. Under Request headers, add `Authorization` with the value `Bearer <your-user-api-key>`.
4. Choose No sign in when asked how to authenticate.

On Team and Enterprise plans, an owner adds the connector under Organization settings → Connectors before members can connect. Connectors are brokered through Anthropic's cloud, so the server must be reachable from the public internet.

***

#### Gemini CLI (remote http)

```
~/.gemini/settings.json · .gemini/settings.json
```

```bash
gemini mcp add --transport http --scope user \
  -H 'Authorization: Bearer ${NEXOS_API_KEY}' \
  mcp-gateway https://mcp.nexos.ai
```

This writes `~/.gemini/settings.json`; `--scope project` writes `.gemini/settings.json` instead. If you edit the file by hand, the key is `httpUrl`, not `url`: Gemini reads a plain `url` as the older SSE transport, and the connection fails.

***

#### Cline (streamable http)

```
cline_mcp_settings.json
```

Use the Remote Servers tab in Cline's MCP Servers view, or add this to the settings file that Configure MCP Servers opens:

```json
{
  "mcpServers": {
    "mcp-gateway": {
      "type": "streamableHttp",
      "url": "https://mcp.nexos.ai",
      "headers": {
        "Authorization": "Bearer YOUR_USER_API_KEY"
      },
      "disabled": false,
      "autoApprove": []
    }
  }
}
```

Set `type` explicitly. Without it, Cline assumes SSE and the connection fails.

***

#### Windsurf (remote http)

```
open from Cascade's MCP panel
```

Open Cascade's MCP panel and choose Open MCP config file, then add:

```json
{
  "mcpServers": {
    "mcp-gateway": {
      "serverUrl": "https://mcp.nexos.ai",
      "headers": {
        "Authorization": "Bearer ${env:NEXOS_API_KEY}"
      }
    }
  }
}
```

Windsurf moved its config under the `devin` path, and older instructions still point at `~/.codeium/...`. Opening the file from the UI avoids depending on the path.

***

#### Zed (remote http)

```
settings.json
```

Add the server under `context_servers` in your settings file (zed: open settings file from the command palette):

```json
{
  "context_servers": {
    "mcp-gateway": {
      "url": "https://mcp.nexos.ai",
      "headers": {
        "Authorization": "Bearer YOUR_USER_API_KEY"
      }
    }
  }
}
```

Zed asks for OAuth only when no `Authorization` header is set, so the static token is used as is.

***

#### Any other client (streamable http)

```
url + headers, or mcp-remote
```

The gateway is a remote, stateless Streamable HTTP server, so any client that accepts a URL and a static header works. It does not serve SSE, and it has no local stdio mode.

Clients that use the common `mcpServers` shape take the same entry as the Cursor example above. The key that holds the URL differs, so use the client's own spelling:

| Client            | URL key     | Transport key            |
| ----------------- | ----------- | ------------------------ |
| Claude Code       | `url`       | `type: "http"`           |
| Cursor            | `url`       | none                     |
| VS Code / Copilot | `url`       | `type: "http"`           |
| Codex             | `url`       | none (config.toml)       |
| Gemini CLI        | `httpUrl`   | none                     |
| Cline             | `url`       | `type: "streamableHttp"` |
| Windsurf          | `serverUrl` | none                     |
| Zed               | `url`       | none                     |
| Antigravity       | `serverUrl` | none                     |

If a client only supports local stdio servers, bridge it with `mcp-remote`:

```bash
npx -y mcp-remote https://mcp.nexos.ai --transport http-only \
  --header 'Authorization: Bearer ${NEXOS_API_KEY}'
```

Add `--header-file /path/to/headers` if you would rather keep the key out of the process list. If your client is one that mangles spaces in arguments, write the header without a space after the colon (`Authorization:${NEXOS_AUTH_HEADER}`) and put `Bearer <key>` in the variable.

If a client only supports OAuth and cannot send a header, it cannot authenticate against the gateway yet.

### Finding and calling tools

You will not see every tool from every integration listed. On the aggregate endpoint, `tools/list` returns three discovery tools, which keeps the tool list small however many integrations are connected:

| Tool                          | What it does                                                                                                                                                              |
| ----------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `list_available_integrations` | Lists your integrations. One with `"usable": false` needs reconnecting and comes with a `reconnect_url`.                                                                  |
| `search_tools`                | Finds tools by describing what you need, for example `send a message to a slack channel`, and returns their full definitions. `limit` defaults to 10 and is capped at 50. |
| `call_tool`                   | Runs a tool that `search_tools` returned, by name and integration.                                                                                                        |

So a request normally takes two steps: the agent calls `search_tools`, then `call_tool` with the best match. Explain this in your first prompt, or your agent may look for tool names it was never shown.

To have one integration's tools listed and called directly, use its own endpoint, `https://mcp.nexos.ai/<integration-id>`. `GET /servers` lists your integrations and their IDs.

#### Try it

Some prompts that exercise the discovery tools:

* Which of my integrations can I use, and are any of them disconnected? <button type="button" class="button secondary medium" data-action="select" data-slug="which-of-my-integrations-can-i-use-and-are-any-of-them-disconnec">Copy</button>
* Find the tool for creating a Jira issue, then create one in project ABC for the login&#x20;

&#x20;     timeout bug. <button type="button" class="button secondary medium" data-action="select" data-slug="find-the-tool-for-creating-a-jira-issue-then-create-one-in-proje">Copy</button>

* Search my integrations for sending a Slack message, and send "deploy finished"&#x20;

&#x20;     to #releases. <button type="button" class="button secondary medium" data-action="select" data-slug="search-my-integrations-for-sending-a-slack-message-and-send-depl">Copy</button>

#### Narrow what the agent sees

Add query parameters to the server URL to limit the integrations in scope:

| Parameter             | Effect                                                   |
| --------------------- | -------------------------------------------------------- |
| `agent=<uuid>`        | Only the integrations attached to that agent.            |
| `apps=slack,jira`     | Only integrations of those applications.                 |
| `instances=<id>,<id>` | Only those integrations, by the IDs from `GET /servers`. |

The filters narrow what you can already use; they never widen it. For example, `https://mcp.nexos.ai?apps=slack,jira`.

### Reconnecting an integration

If a tool needs an integration whose connection expired or was never completed, the gateway asks you to reconnect it:

**Clients that accept event streams**

With `Accept: application/json, text/event-stream`, you get a prompt to open the reconnect page. Once you finish, the original call continues and returns its result. The gateway waits up to about five minutes.

**Clients that accept only JSON**

You get a tool result with `isError: true` naming the integration and where to reconnect it.

### Security

* Enable per-tool approval in your client where it offers one. Integrations can read and write data on your behalf, and tool output is untrusted input to the model.
* Grant the integration's own account only the access you want the agent to have.
* Revoke a leaked key in nexos.ai; there is no per-session token to expire.
* A company or network that restricts outbound traffic must allowlist `mcp.nexos.ai`.

### Troubleshooting

| What you see                 | What it means                                                                                                                                                                                                    |
| ---------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| 401                          | The API key is missing or invalid. Check that you exported `NEXOS_API_KEY` in the shell that launched the client.                                                                                                |
| 403 or -32600                | You used a team API key. `GET /servers` returns `403`; a tool call returns JSON-RPC `-32600` with `this endpoint needs a user API key`. Create a user API key instead.                                           |
| 503                          | `the integrations MCP gateway is not enabled for your company`. The gateway is not enabled for your company, or is switched off in this environment.                                                             |
| -32601                       | The method is not supported. The gateway implements `initialize`, `ping`, `tools/list` and `tools/call`.                                                                                                         |
| -32602                       | Invalid parameters: no tool name, an unknown tool, or an unknown `agent`.                                                                                                                                        |
| -32002                       | `app instance not available`. The integration does not exist for you, is disabled, belongs to another company, or you hold no valid credentials for it. Run `list_available_integrations` to see what is usable. |
| -32603                       | Internal error. Retry, and contact support if it persists.                                                                                                                                                       |
| `search_tools` finds nothing | Describe the capability differently, or call `list_available_integrations` to check that the integration is connected and usable.                                                                                |
| 405 when connecting          | The client tried to open an SSE stream with `GET`. Choose the streamable HTTP transport.                                                                                                                         |
| Connection times out         | A proxy is probably blocking `mcp.nexos.ai`, or the client is on SSE.                                                                                                                                            |

### Limits

* Requests are limited to 4 MiB.
* Only user API keys are accepted; team keys are rejected.
* `search_tools` returns 10 results by default and at most 50.
* Sessions are stateless: there is no session to resume, and neither `initialize` nor `DELETE` changes any state.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.nexos.ai/gateway-api/connect-to-the-mcp-gateway.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
