---
docId: doc_59198d1657ad4609a895eadd326476b2
title: Connect an MCP server
description: "Connect an MCP server, choose its tools and assign them to your agent."
---

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

# Connect an MCP server

<span id="what-youll-build"></span>

Connect an MCP server so your agent can use its tools. With Linear, for example, you can give it tools to search and create issues.

To manage Platica from an assistant such as Claude, use the [Platica MCP server](/mcp).

## Before you start

You need an [agent](/guides/create-an-agent), its id in `AGENT_ID` and the MCP server's URL.

- If the server needs no credentials, start at step 2.
- If it uses OAuth, follow [If the server uses OAuth](#if-the-server-uses-oauth).
- If it uses a token, store it as a secret in step 1.

To use the platform, see [Connect an MCP server](/help/integrations/functions/mcp-servers/connect).

<Steps>
<Steps.Step>

**Store the credential as a secret**

Send the token when you create the secret. Later reads don't return its value. ([Create a secret](/api-reference/secrets/create))

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

```bash
curl https://api.platic.ai/v1/secrets \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "name": "Linear · token", "kind": "bearer", "value": "<Linear token>" }'
```

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

```ts
import { Platic } from "platic-sdk";

const platic = new Platic({ apiKey: process.env.PLATIC_API_KEY! });
const agentId = process.env.AGENT_ID!;

const secret = await platic.secrets.create({
  name: "Linear · token",
  kind: "bearer",
  value: process.env.LINEAR_TOKEN!,
});
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

Store the Linear token as a secret.

</Ways.Say>

Tool: [`create_secret`](/mcp/tools#create_secret). To keep the token out of the chat, store it yourself in **Integrations → Functions → Secrets** and ask it to use that one.

</Ways.Way>
</Ways>

Keep the secret's `id` in `SECRET_ID`.

</Steps.Step>
<Steps.Step>

**Connect the server**

Platica tests it in the same call and tells you which tools it offers. ([Connect an MCP server](/api-reference/mcp-servers/connect))

<Ways tabs="api,sdk,asistente">
<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": "Linear",
    "url": "https://mcp.linear.app/mcp",
    "auth": { "type": "bearer" },
    "secrets": { "auth.token": "'$SECRET_ID'" }
  }'
```

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

```ts
const server = await platic.tools.mcp.create({
  name: "Linear",
  url: "https://mcp.linear.app/mcp",
  auth: { type: "bearer" },
  secrets: { "auth.token": secret.id },
});
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

Connect the Linear MCP server, https://mcp.linear.app/mcp, with the Linear token secret, and tell me which tools it offers.

</Ways.Say>

Tool: [`connect_mcp_server`](/mcp/tools#connect_mcp_server).

</Ways.Way>
</Ways>

Save the server's `id` in `MCP_ID`. Check `discoveredTools` to choose the tools you need. If `verified` is `false`, follow `nextStep`.

</Steps.Step>
<Steps.Step>

**Choose which tools to install**

Select the tools the agent needs. This example installs `search_issues` and `create_issue`. ([Choose tools](/api-reference/mcp-servers/select-tools))

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

```bash
curl https://api.platic.ai/v1/tools/mcp/$MCP_ID/tools/sync \
  -H "Authorization: Bearer $PLATIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{ "tools": ["search_issues", "create_issue"] }'
```

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

```ts
const synced = await platic.tools.mcp.syncTools(server.id, {
  tools: ["search_issues", "create_issue"],
});
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

From the Linear server, install only search_issues and create_issue.

</Ways.Say>

Tool: [`sync_mcp_server_tools`](/mcp/tools#sync_mcp_server_tools).

</Ways.Way>
</Ways>

Send the complete list of tools you want to keep. Omitted tools are uninstalled. The response includes their ids in `installedTools`, in each tool's `id` field.

</Steps.Step>
<Steps.Step>

**Connect them to the agent**

Each tool is connected separately, with its `id`. It applies right away, without publishing the agent. ([Connect a tool](/api-reference/agents/tools/connect))

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

```bash
curl -X PUT https://api.platic.ai/v1/agents/$AGENT_ID/tools/$TOOL_ID \
  -H "Authorization: Bearer $PLATIC_API_KEY"
```

Repeat the call with the `id` of each tool.

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

```ts
for (const tool of synced.installedTools) {
  await platic.agents.tools.connect(agentId, tool.id);
}
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

Give the Support agent the Linear tools you installed.

</Ways.Say>

Tool: [`connect_agent_tool`](/mcp/tools#connect_agent_tool), once per tool.

</Ways.Way>
</Ways>

</Steps.Step>
</Steps>

## Check it worked

Use [List the agent's tools](/api-reference/agents/tools/list) to check that both Linear tools are assigned. Ask the agent to find a known issue and check the result.

If you change the connection later, the server goes back to `pending_config`: bind the secret again, test it and choose the tools again. The connections to your agents are kept. See [Update an MCP server](/api-reference/mcp-servers/update).

## If the server uses OAuth

Some servers don't accept a fixed token: a person has to sign in and authorize. Skip step 1 and, in step 2, connect the server with `"auth": { "type": "oauth2" }` and no `secrets`. Then ask for the authorization page. ([Start OAuth](/api-reference/mcp-servers/start-oauth))

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

```bash
curl -X POST https://api.platic.ai/v1/tools/mcp/$MCP_ID/oauth/start \
  -H "Authorization: Bearer $PLATIC_API_KEY"

# When the person authorizes:
curl -X POST https://api.platic.ai/v1/tools/mcp/$MCP_ID/test \
  -H "Authorization: Bearer $PLATIC_API_KEY"
```

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

```ts
const { authorizeIn } = await platic.tools.mcp.startOAuth(server.id);

// When the person authorizes:
await platic.tools.mcp.test(server.id);
```

</Ways.Way>
<Ways.Way name="asistente">
<Ways.Say>

Give me the link to authorize the Linear server.

</Ways.Say>

Tool: [`start_mcp_server_oauth`](/mcp/tools#start_mcp_server_oauth). When you authorize, ask it to test the server: it uses [`test_mcp_server`](/mcp/tools#test_mcp_server).

</Ways.Way>
</Ways>

Open `authorizeIn` with an account that has access to the workspace and complete authorization. You don't need to send or receive OAuth tokens through the API. Then continue with step 3.

## Next steps

- [Give it files](/guides/add-knowledge) so it knows your business.
- [Test it before you publish](/guides/evals): a scenario can require the agent to use one of these tools.
- [MCP servers](/api-reference/mcp-servers): secrets, states and connection changes.
