Skip to main content

Connect a workflow to a remote MCP server

Point your workflow at an MCP server.

Written by Jamie Gaynor

Model Context Protocol (MCP) is a standard way for tools to expose their capabilities to an AI as a set of callable "tools." In Tines 3B, you can point a workflow at any remote MCP server, then call its tools from your own step code. This article walks you through connecting to a server and calling its tools.

Before you start, gather a few things:

  • A remote MCP server URL. Tines 3B connects to any server that speaks streamable HTTP, e.g., https://mcp.example.com/mcp

  • A way to authenticate. Either OAuth (recommended) or a bearer token, depending on what the server supports.

  • A workflow to build in. You can use an existing workflow or create a new one.

Step 1: Create the MCP server connector

Connectors hold your credentials and inject authentication into requests, so you never handle tokens in your step code. To create one:

  1. Create a new connector and choose the MCP server connector type.

  1. Give it a name, e.g., "My MCP server."

  2. Enter the Server URL — the endpoint that accepts MCP JSON-RPC requests.

  3. Choose an Authentication method:

    • OAuth (the default). Tines 3B discovers the server's OAuth endpoints and registers a client automatically. You can leave Client ID and Client secret blank unless the server doesn't support automatic registration.

    • Bearer token. Paste a token or API key, and Tines 3B sends it as Authorization: Bearer <token> on every request.

When you save, Tines 3B runs a connection test by sending an initialize request to confirm the server responds.

Step 2: Attach the connector to a step

Add the connector to the step where you'll call the MCP server. Once it's attached, Tines 3B injects authentication on any request that matches the connector's URL pattern. This means two things for your code:

  • Never set the Authorization header yourself. Tines 3B adds it for you.

  • Never print or store tokens. They're handled at the platform boundary.

Step 3: Call the server's tools

An MCP server is a JSON-RPC 2.0 API behind a single HTTP endpoint. You talk to it with a plain fetch from your step. Every request is a POST to the server URL with these headers:

  • Content-Type: application/json

  • Accept: application/json, text/event-stream

The response comes back as either plain JSON or a server-sent events (SSE) stream, so your code needs to handle both. For SSE, parse each data: line as JSON and take the message whose id matches your request.

Open a session

A session follows a short lifecycle:

  1. Send an initialize request with protocolVersion: "2025-06-18", empty capabilities, and your clientInfo. If the server rejects that version, retry with the version it names in the error.

  2. If the response includes an Mcp-Session-Id header, echo it on every later request.

  3. Send a notifications/initialized notification, which has no id and expects no response.

await mcp(
SERVER_URL,
"initialize",
{
protocolVersion: "2025-06-18",
capabilities: {},
clientInfo: { name: "3B", version: "1.0" },
},
1
);
await mcp(SERVER_URL, "notifications/initialized");

List and call tools

With the session open, you can discover what the server offers and invoke it:

  • tools/list returns each tool's name, description, and JSON Schema input. If the result has a nextCursor, page through with cursor.

  • tools/call takes { name, arguments } and returns content blocks — usually { type: "text", text }. Always check isError before trusting the output.

const { tools } = await mcp(SERVER_URL, "tools/list", {}, 2);
const result = await mcp(
SERVER_URL,
"tools/call",
{
name: "some_tool",
arguments: { query: "example" },
},
3
);
if (result.isError) throw new Error(result.content?.[0]?.text);

The same request shape works for prompts and resources: prompts/list, prompts/get, resources/list, and resources/read.

Prefer one short-lived session per task. When you're done, you can send a DELETE to the endpoint with the session header, and ignore a 405 if the server doesn't support it.

Handling authentication errors

If a request comes back with a 401 or 403, it means the connector needs to be reconnected. Don't try to run an authentication flow from your code, instead, tell the person running the workflow to reconnect the MCP server connector.

A shortcut: load the mcp-client skill

Tines 3B ships a built-in skill called mcp-client that packages the handshake, SSE parsing, and tool-calling protocol into a ready-to-use helper. When you're building with the Tines 3B AI, it can load this skill automatically for a step that has an MCP server connector attached, so you don't have to write the plumbing by hand.

Did this answer your question?