MCP servers

Connect your own Model Context Protocol (MCP) server to give your VableAI agent tools that run on your backend, such as looking up a customer's orders or booking an appointment.

The agent calls these tools from VableAI's servers, not from the user's browser. When a signed-in user talks to the agent, each call carries that user's access token, so your MCP server knows who is asking and can answer for that user only.

MCP servers are different from intents. Intents run in the user's browser and act on your web app. MCP tools run on your server and work the same on every platform, including voice.

How it works

sequenceDiagram
  participant User
  participant Vable as VableAI
  participant MCP as Your MCP server
  Note over Vable,MCP: When you add or refresh the server
  Vable->>MCP: List tools (static headers only)
  MCP-->>Vable: Tools and their inputs
  Note over User,MCP: During a conversation
  User->>Vable: "Where's my last order?"
  Vable->>MCP: Call list_orders with Authorization: Bearer <user's token>
  MCP->>MCP: Verify the token with your public key
  MCP-->>Vable: The user's orders
  Vable-->>User: "Your order A100 has shipped."
  • Listing tools: VableAI lists your server's tools when you add it in the dashboard and each time you select Refresh tools. These requests carry your static headers but no user token.
  • Calling tools: each call carries your static headers. For a signed-in user it also carries Authorization: Bearer <token>, the same access token you passed to the SDK.
  • Guests: visitors without a valid access token can't use MCP tools, unless you make a tool available to guests.

Before you start

You need:

  • A signing key and access tokens. Follow Authentication to create a signing key, upload its public key and pass access tokens to the SDK. Your MCP server checks the same tokens with the same public key.
  • An MCP server reachable over HTTPS that uses the Streamable HTTP transport. VableAI can't reach servers on private networks such as localhost or 10.x.x.x.

1. Build your MCP server

Any MCP server that supports Streamable HTTP works. This example uses Node.js with Express, the official MCP TypeScript SDK and jsonwebtoken:

npm install @modelcontextprotocol/sdk express jsonwebtoken zod

Find the signed-in user

Check the Authorization header with the public key from your signing key pair. A request without a valid token is a guest.

import express from "express";
import jwt from "jsonwebtoken";

// The public key you uploaded to VableAI, from the key pair you sign
// access tokens with.
const publicKey = process.env.VABLE_SIGNING_PUBLIC_KEY!;

type User = { id: string; email?: string };

// Returns the signed-in user, or null for a guest or an invalid token.
function userFromRequest(req: express.Request): User | null {
  const header = req.headers.authorization;
  if (!header?.startsWith("Bearer ")) return null;
  try {
    const claims = jwt.verify(header.slice("Bearer ".length), publicKey, {
      algorithms: ["RS256"],
    }) as jwt.JwtPayload;
    return claims.sub ? { id: claims.sub, email: claims.email } : null;
  } catch {
    return null;
  }
}

Register your tools

Register every tool whether or not there's a user, because VableAI lists tools without a token. Check the user inside each tool instead.

import { z } from "zod";
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";

function createServer(user: User | null) {
  const server = new McpServer({ name: "shop", version: "1.0.0" });

  server.registerTool(
    "list_orders",
    {
      title: "List orders",
      description: "Lists the signed-in customer's most recent orders.",
      inputSchema: {
        limit: z
          .number()
          .int()
          .min(1)
          .max(20)
          .optional()
          .describe("How many orders to return. Defaults to 5."),
      },
    },
    async ({ limit = 5 }) => {
      if (!user) {
        return {
          isError: true,
          content: [{ type: "text", text: "The customer isn't signed in." }],
        };
      }
      const orders = await findOrdersForCustomer(user.id, limit);
      return { content: [{ type: "text", text: JSON.stringify(orders) }] };
    },
  );

  return server;
}

The agent decides when to use a tool from its title, description and input descriptions, so write them for someone who has never seen your API. Return isError: true with a short explanation when a call fails: the agent reads it and can tell the user what went wrong.

Serve it over HTTP

This creates a server for each request, so each call only sees its own user:

import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";

const app = express();
app.use(express.json());

app.post("/mcp", async (req, res) => {
  const server = createServer(userFromRequest(req));
  const transport = new StreamableHTTPServerTransport({
    sessionIdGenerator: undefined,
  });
  res.on("close", () => {
    transport.close();
    server.close();
  });
  await server.connect(transport);
  await transport.handleRequest(req, res, req.body);
});

app.listen(3000);

Optional: require an API key

The access token tells you who the user is, not that the request came from VableAI. To only accept requests from VableAI, check a secret header that you also set in the dashboard:

app.use("/mcp", (req, res, next) => {
  if (req.header("X-Api-Key") !== process.env.MCP_API_KEY) {
    res.status(401).json({ error: "Invalid API key" });
    return;
  }
  next();
});

Add this before the app.post("/mcp", ...) handler. VableAI sends static headers on every request, including when it lists tools.


2. Add the server in the dashboard

  1. Open the VableAI dashboard and go to Actions > MCP servers.
  2. Select Add MCP server.
  3. Fill in:
    • Name: lowercase letters, digits and single underscores, up to 32 characters, such as shop. The agent sees your tools as <name>__<tool>, such as shop__list_orders.
    • MCP server URL: the full HTTPS URL of your endpoint, such as https://api.example.com/mcp.
    • Static headers: any headers to send on every request, such as X-Api-Key. You can't set Authorization, which carries the user's token. Saved values are never shown again; leave a value blank when editing to keep it.
  4. Select Connect and list tools. VableAI connects to your server and lists its tools. If it can't, the panel shows why.
  5. Choose which tools the agent can use, then select Save.

New tools are on for signed-in users and off for guests.

When your tools change

VableAI keeps the list of tools from the last time it checked. After you add, remove or change tools on your server, open the ⋯ menu on the server's row and select Refresh tools, or select Refresh tools in the server's panel. Tools you turned off stay off.


3. Test it

  1. Sign in to your app so the SDK has an access token.
  2. Ask the agent something one of your tools answers, such as "What are my recent orders?".
  3. Check your MCP server's logs for the call and the user's sub.

Guest access

By default, only signed-in users can use MCP tools. You can make a tool available to guests, visitors who aren't signed in, for things like checking an order's status from its order number and email address.

Guest calls carry only your static headers, with no user token. Before a tool is opened to guests, the dashboard asks you to confirm these risks:

  • Anyone who can open a chat or call on your site, without signing in, can make the agent use the tool.
  • Your MCP server can't tell who is asking, so it can't limit answers to that person's own data.
  • The agent fills in the tool's inputs from what the visitor says, so a visitor can ask about any order number, email address or record.
  • Visitors can try to talk the agent into using the tool in ways you didn't intend.

Only open read-only tools to guests, and make the tool's own inputs prove ownership, such as an order number together with the email address it was placed with. Never open tools that change data, take payments or return personal data.

To make a tool available to guests:

  1. Open the server in Actions > MCP servers.
  2. Turn on Available to guests for the tool.
  3. Read the warning, tick I understand the risks, then select Allow guests.
  4. Select Save.

A guest tool should check its inputs itself, like this one:

server.registerTool(
  "order_status",
  {
    title: "Order status",
    description:
      "Gets the status of an order. Needs the order number and the email address the order was placed with.",
    inputSchema: {
      orderNumber: z.string().describe("The order number, such as A100"),
      email: z
        .string()
        .email()
        .describe("The email address the order was placed with"),
    },
    annotations: { readOnlyHint: true },
  },
  async ({ orderNumber, email }) => {
    const order = await findOrder(orderNumber);
    // Answer only when the email matches, so nobody can look up an order
    // from its number alone.
    if (!order || order.email.toLowerCase() !== email.toLowerCase()) {
      return {
        isError: true,
        content: [
          { type: "text", text: "No order matches that number and email." },
        ],
      };
    }
    return {
      content: [
        { type: "text", text: `Order ${order.number} is ${order.status}.` },
      ],
    };
  },
);

If a guest tool changes: when a refresh finds that a guest tool's description or inputs changed, VableAI turns guest access off for it, and the dashboard shows "Guest access removed". Review the tool, then turn guest access on again if it's still safe.


Limits

LimitValue
URLHTTPS only. No redirects, and no private or local addresses
Tools per server100
Time for a tool call15 seconds
Time to list tools10 seconds
Size of a response1 MB
Text the agent reads from one call16,000 characters. Longer results are cut short

Token expiry

VableAI checks the access token when a conversation starts or resumes, then sends the same token with each tool call. If the token expires during a long conversation, your server rejects the call and the agent tells the user the tool failed.

To avoid this, give access tokens a lifetime longer than your longest conversations, or renew them as described in Token expiry and sign-out.


Troubleshooting

ProblemLikely cause
"URL must use https"The URL starts with http://. Serve your MCP server over HTTPS
"the MCP server's address is on a private network"The URL points at localhost or a private IP address, or its domain resolves to one. Use a public address
"the MCP server redirected to …"Your server answered with a redirect. Use the final URL, including any trailing slash it redirects to
"couldn't get the MCP server's tools: … Unauthorized"Your server needs a header you didn't set, or rejected the request because it had no user token. Listing tools must work with static headers alone
A tool you added doesn't appearVableAI hasn't checked since you added it. Select Refresh tools
The agent doesn't use a toolThe tool is turned off, the server is disabled, or the user isn't signed in and the tool isn't available to guests. Also check that the tool's description says when to use it
Your server receives calls without AuthorizationThe user isn't signed in, and the tool is available to guests
"the tool took too long to answer"The call took longer than 15 seconds