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

# Connect an MCP server

> Authenticate an MCP server, discover its tools, and attach one to an agent.

Connect an existing Model Context Protocol (MCP) server to discover the tools it
exposes. You can then attach selected tools to agents without copying their
implementations into SLNG.

## Prerequisites

* An MCP server reachable over Streamable HTTP or server-sent events (SSE).
* Its URL and authentication requirements.
* Permission to manage organization MCP servers, tools, and Vault secrets.

<Steps>
  <Step title="Add the server">
    <Tabs>
      <Tab title="Dashboard" icon="monitor">
        Open **Global Tools**, select the **MCPs** tab, and choose **Add MCP
        server**.

        <Frame caption="Open the MCPs tab and add a server">
          <img src="https://mintcdn.com/slng-new-docs/_MURdOw87SJsfVag/heroshots/mcp-servers.png?fit=max&auto=format&n=_MURdOw87SJsfVag&q=85&s=ce1b25e7995bd4146908cb80166f1cdf" alt="The MCPs tab with Add MCP server highlighted" width="2560" height="1600" data-path="heroshots/mcp-servers.png" />
        </Frame>

        Enter a name, server URL template, and optional description. Select
        **HTTP streaming** unless the server requires SSE.

        <Frame caption="Configure the MCP server endpoint and transport">
          <img src="https://mintcdn.com/slng-new-docs/_MURdOw87SJsfVag/heroshots/mcp-add-server.png?fit=max&auto=format&n=_MURdOw87SJsfVag&q=85&s=68eb2f4d08374d1d4268a7ab440501e8" alt="The Add MCP server form with Server URL template highlighted" width="2560" height="1600" data-path="heroshots/mcp-add-server.png" />
        </Frame>
      </Tab>

      <Tab title="API" icon="code">
        Create the connection configuration. This example creates the bearer
        secret in the Vault with the same request. Replace
        `<MCP_BEARER_TOKEN>` before sending it.

        ```json server.json theme={null}
        {
          "name": "Wayne inventory",
          "description": "Inventory tools for Wayne Enterprises support agents.",
          "url_template": "https://mcp.wayne.example/mcp",
          "transport": "streamable_http",
          "auth": {
            "type": "bearer",
            "secret_name": "WAYNE_MCP_TOKEN"
          },
          "headers": [],
          "credentials": [
            {
              "mode": "create",
              "secret_name": "WAYNE_MCP_TOKEN",
              "value": "<MCP_BEARER_TOKEN>"
            }
          ]
        }
        ```

        ```bash Request theme={null}
        curl -X POST https://api.agents.slng.ai/v1/agents/mcp-servers \
          -H "Authorization: Bearer $SLNG_API_KEY" \
          -H "Content-Type: application/json" \
          -d @server.json
        ```
      </Tab>
    </Tabs>
  </Step>

  <Step title="Configure authentication">
    Choose no authentication, bearer authentication, or a custom authentication
    header. Secret names use `SCREAMING_SNAKE_CASE` and refer to Vault values.

    You can also add literal or Vault-backed custom headers. Do not duplicate
    the configured authentication header or transport-managed headers.
  </Step>

  <Step title="Verify the connection">
    <Tabs>
      <Tab title="Dashboard" icon="monitor">
        Choose **Connect**. Confirm that the server status is **ready** and
        review the discovered tool names, descriptions, and schemas.
      </Tab>

      <Tab title="API" icon="code">
        Use the server `id` returned by the create request.

        ```bash Request theme={null}
        curl -X POST \
          https://api.agents.slng.ai/v1/agents/mcp-servers/$SERVER_ID/connect \
          -H "Authorization: Bearer $SLNG_API_KEY"
        ```

        A successful response has `status: "connected"` and lists discovered
        tools in `capabilities.tools`.
      </Tab>
    </Tabs>
  </Step>

  <Step title="Attach an exposed tool">
    Select a discovered tool and attach it to an agent. The attachment stores
    the server ID, tool name, and observed schema hash. MCP tools are
    model-invoked.

    See [Attach a tool to an agent](/guides/agents/tools-and-mcp/attach-to-an-agent).
  </Step>
</Steps>

## Handle unavailable servers

The connection status can be `unknown`, `healthy`, `unavailable`, `invalid`, or
`circuit_open`. If discovery fails, verify the transport, URL, credentials, and
server response before reconnecting.

An attached tool remains tied to the schema hash observed during discovery. If
the server changes that schema, reconnect and review the attachment before
using the new contract. During a call, an unavailable server returns a tool
failure to the agent; it does not silently substitute another tool.

See [MCP servers API reference](/api-reference/agents-resources/mcp-servers) for
the full connection and discovery fields.
