---
docId: doc_28b122b8d3814a74805ce72cb0893e26
title: Connect an MCP server
description: "Save an MCP server and test it when its credentials are ready."
api:
  group: herramientas/servidores-mcp
  auth: bearer
  operations:
    - operationId: connectMcpServer
      method: POST
      path: /v1/tools/mcp
      postmanName: Connect an MCP server
---

<script>
  import { Ways, Note } from '$lib/components';
</script>

# Connect an MCP server

Save an MCP server connection. Platica also tests it to discover its tools when all credentials are ready:


- The server is public (`auth.type: "none"`), or
- you sent in `secrets` the secret for each slot.

If a credential is missing, the connection is saved and `nextStep` says what comes next.

## Example

<Ways tabs="api,sdk">
<Ways.Way name="api">

```bash
curl https://api.platic.ai/v1/tools/mcp \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Docs", "url": "https://mcp.example.com/mcp" }'
```

</Ways.Way>
<Ways.Way name="sdk">

```ts
await platic.tools.mcp.create({ name: "Docs", url: "https://mcp.example.com/mcp" });
```

</Ways.Way>
</Ways>

## Request body

| Field | Type | Description | Required |
|-------|------|-------------|----------|
| `name` | string | Name of the server inside Platica, 1 to 120 characters | ✓ |
| `url` | string | URL of the MCP server | ✓ |
| `description` | string | Up to 500 characters | — |
| `auth` | object | How it authenticates, without the credential. See [authentication](#authentication). Defaults to `{ "type": "none" }` | — |
| `headers` | object | Fixed headers, as `name: value` pairs. A header that carries a credential goes with an empty value and is bound as `header:<name>` | — |
| `secrets` | object | Map of slot to secret id, to bind in this same call | — |
| `tools` | string[] | Original names of the tools to install as soon as the connection is verified. Up to 100. If you omit it, none is installed | — |

```json
{
  "name": "Linear",
  "description": "Support team issues",
  "url": "https://mcp.linear.app/mcp",
  "auth": { "type": "bearer" },
  "secrets": {
    "auth.token": "5d0c7a1e9b3f4a6c8e2d1f0b7a9c3e5d6f8a0b2c4d6e8f1a3b5c7d9e0f2a4b6c"
  }
}
```

### Authentication

| `auth` | Slot it exposes |
|--------|-----------------|
| `{ "type": "none" }` | None |
| `{ "type": "bearer" }` | `auth.token`: the server's token |
| `{ "type": "apikey-header", "headerName": "X-Api-Key", "headerPrefix": "" }` | `auth.token`: the key, sent in the `headerName` header after the `headerPrefix` text. `headerName` is required |
| `{ "type": "oauth2", "scope": "read write", "clientId": "…" }` | None you have to bind: a person authorizes it. `scope` and `clientId` are optional |

## Response

`201 Created`. `data` has the full server, with the fields in [get an MCP server](/api-reference/mcp-servers/get#response-fields).

```json
{
  "status": "success",
  "message": "MCP server saved — see nextStep",
  "data": {
    "id": "QZPHpckDPC58JIVLQA3Z",
    "name": "Linear",
    "description": "Support team issues",
    "url": "https://mcp.linear.app/mcp",
    "transport": "streamable-http",
    "slug": "a1b2c3",
    "authType": "bearer",
    "auth": { "type": "bearer" },
    "status": "pending_config",
    "lastError": null,
    "serverInfo": { "name": "linear-mcp", "version": "1.4.0" },
    "customHeaderNames": [],
    "discoveredToolsCount": 2,
    "installedToolsCount": 0,
    "lastSyncAt": null,
    "createdAt": "2026-10-28T12:02:11.410Z",
    "updatedAt": "2026-10-28T12:02:14.900Z",
    "version": 1,
    "verified": true,
    "secrets": [
      {
        "slot": "auth.token",
        "state": "authorized",
        "secretId": "5d0c7a1e9b3f4a6c8e2d1f0b7a9c3e5d6f8a0b2c4d6e8f1a3b5c7d9e0f2a4b6c"
      }
    ],
    "discoveredTools": [
      {
        "name": "create_issue",
        "description": "Create a new issue in Linear",
        "inputSchema": {
          "type": "object",
          "properties": {
            "title": { "type": "string" },
            "teamId": { "type": "string" }
          },
          "required": ["title", "teamId"]
        },
        "installed": false
      },
      {
        "name": "search_issues",
        "description": "Search issues by text query",
        "inputSchema": {
          "type": "object",
          "properties": { "query": { "type": "string" } }
        },
        "installed": false
      }
    ],
    "installedTools": [],
    "verification": { "confirmed": true },
    "nextStep": "Verified. Choose which tools to install with POST /v1/tools/mcp/QZPHpckDPC58JIVLQA3Z/tools/sync: create_issue, search_issues."
  }
}
```

`message` is `MCP server connected successfully` when the call left tools installed, and `MCP server saved — see nextStep` in every other case.

## What happens depending on what you send

| You sent | Result |
|----------|--------|
| A public server, or a complete `secrets` | It is saved and tested. `discoveredTools` has what it offers |
| The above, plus `tools` | It also installs those tools and the server ends up `connected` |
| `bearer` or `apikey-header` without `secrets` | It is saved without testing. The `auth.token` slot stays `missing` |
| `oauth2` | It is saved as `pending_auth`. Continue with [start OAuth](/api-reference/mcp-servers/start-oauth) |

<Note type="important">

The connection is saved even if the first test fails or a secret cannot be bound. The response is still `201` and carries the reason in `data.testError` or `data.secretsError`, both as `{ code, message }`. Do not connect it again: fix the problem and use [test an MCP server](/api-reference/mcp-servers/test).

</Note>

## Errors

| Status | `details.code` | When it happens |
|--------|----------------|-----------------|
| `400` | `INVALID_REQUEST` | `name` or `url` is missing, or a field fails validation. `details.issues` has the list of problems |
| `400` | `SECRET_REFERENCE_REQUIRED` | You sent a credential inside the connection: `auth.token`, `auth.clientSecret`, or a header with a credential name and a value. When it applies, `details.slot` names the slot |
| `400` | `INVALID_CONFIG` | The name, URL, or authentication is not valid, or the headers have repeated or disallowed names |
| `403` | `FORBIDDEN` | The person behind the token does not have access to Integrations |

## Notes

- Follow what `nextStep` says: [bind a secret](/api-reference/mcp-servers/bind-secret), [start OAuth](/api-reference/mcp-servers/start-oauth), [test](/api-reference/mcp-servers/test), or [choose tools](/api-reference/mcp-servers/select-tools).
- The names in `tools` are the ones in `discoveredTools[].name`. If you do not know them yet, connect without `tools` and choose them later.
- After installing a tool, use [connect a tool](/api-reference/agents/tools/connect) to assign it to an agent.
- The call can take a while: the test waits for the server for up to 90 seconds.
