Skip to content
Documentation
On this page

Services and API imports · Check an MCP account

Services and API imports · Check an MCP account from the built-in skills in Executor 2.0.0-beta.79.

This page covers Check an MCP account from the built-in skills shipped with Executor 2.0.0-beta.79. It contains app-authoring/integrations.md.

Previous: Services and API imports · Next: Services and API imports · OpenAPI APIs

Check an MCP account

Give an authenticated MCP provider mcpHealth from apps/mcp as its health check. It connects to the server with the account’s headers, initializes, and reads the first page of tools. Then it does the same without any headers, to show that the server needs the credentials. No tool runs. Do not check MCP accounts with the vendor’s REST or GraphQL API: an MCP OAuth token is often valid only for the MCP server it was issued for. Do not import @modelcontextprotocol/sdk to write your own check.

import { defineProvider, oauth2 } from "apps";
import { mcpHealth } from "apps/mcp";

export const url = "https://mcp.example.com/mcp";
export const headers = (account: { fields: { access_token: string } }) => ({
  Authorization: "Bearer " + account.fields.access_token,
});

export const provider = defineProvider({
  name: "Example",
  hosts: ["mcp.example.com"],
  auth: { oauth: oauth2({ discover: url }) },
  health: (check) => mcpHealth(check, { url, headers: headers(check.account) }),
});

Pass the check context health receives as the first argument. mcpHealth reads the account, signal and deadline from it: both checks share the time Executor gives the account check and stop early enough to report a server that did not answer in time. Use the same url and headers in mcpRouter. Send credentials only in headers: the check without them uses the same url. Do not set timeoutMs for a longer wait: it can only shorten that time.

With the account’s headers, a refused token reports rejected credentials, an insufficient_scope challenge a missing permission, and 429 or 5xx an unavailable service. The check stops there. A server that cannot be reached, or answers in a way Executor cannot use, means the check could not verify the account. The account form shows why.

When the server accepts the account, the check passes only if the server refuses the same requests without credentials (401 or 403, while initializing or listing tools). Some servers answer without credentials, so a wrong key would pass as well. The check then could not verify the account, and the form says: “This MCP server answers without credentials, so Executor can’t check this account. A refused key will show up when a tool is called.” It also could not verify the account if the requests without credentials time out or fail in any other way, such as 429 or 5xx; the form names that failure. MCP has no standard current-user request, so the check reports no account name. Quick-add OAuth apps are generated with this check.

Streamable HTTP and legacy SSE are supported. Every discovery/call owns and closes its connection. Session-local workflows do not survive separate tool calls. Results retain MCP content, structuredContent, isError, and _meta, except a text block that only repeats structuredContent as JSON, which is dropped; remote tool failures are results, while transport failures reject the call. A tool’s output type describes that whole result, with the server’s output schema under structuredContent, and every result is checked against it. Read typed fields from result.structuredContent after checking result.isError. Calls are never automatically retried. Upstream form elicitation automatically uses the running tool context; preserve that context when wrapping generated tools. Request and response metadata, including approval persistence choices, pass through. Show approval terms from request metadata to the user. Return a persistence choice only when the user explicitly selects it; accepting once must not add a saved grant. Input waits pause the active upstream timeout; the server can impose its own deadline. Discovery cannot prompt. Remote prompts/resources, sampling and URL-mode elicitation are not exposed.

The helper returns a router. Its title, description and icons come from the server’s serverInfo, and its instructions become a skill agents can read. To keep several servers in one app, mount each under a key; tools become <key>.<tool> and a server that cannot be reached is reported without hiding the others. Here accounts is ctx.app.accounts of an app with a plain app requirement for each server:

const bearer = (account) => ({ Authorization: "Bearer " + account.fields.access_token });

tools: router({
  linear: await mcpRouter({
    url: "https://mcp.linear.app/mcp",
    account: accounts.linear,
    headers: bearer(accounts.linear),
    cache,
    signal,
  }),
  sentry: router(
    await mcpRouter({
      url: "https://mcp.sentry.dev/mcp",
      account: accounts.sentry,
      headers: bearer(accounts.sentry),
      cache,
      signal,
    }),
    { description: "Errors and releases for the web app" },
  ),
}),

Was this page helpful?