Skip to content
Documentation
On this page

Import MCP, OpenAPI, and GraphQL

Wrap a remote MCP server, OpenAPI specification, or GraphQL endpoint inside an Executor app with mcpRouter, liveOpenapiRouter, and graphqlRouter.

Executor turns remote MCP servers, OpenAPI documents, and GraphQL endpoints into app routers with mcpRouter (apps/mcp), liveOpenapiRouter (apps/openapi), and graphqlRouter (apps/graphql). All three mount inside tools, compose with withApprovals, and cache with ctx.cache on Local, Self-host, and Cloud.

The step that matters most: call the router helper inside defineApp(requirements, async (ctx) => ({ tools: ... })), pass cache: ctx.cache and signal: ctx.signal, and declare required peer packages in package.json.

Prerequisites and permissions: an app pinned to executor apps framework (Build an app), edit/deploy permission (Local owner, or app creator, admin, or owner on Cloud and Self-host), plus @modelcontextprotocol/sdk for MCP or graphql for GraphQL.

You’ll know it worked when… after deploying and linking any required account, upstream operations appear on the Tools tab and run through tools.search.

How to use it

The code is the same across Local, Self-host, and Cloud. For authenticated services, declare a provider as in Accounts and providers and pass { account, headers } (or { account, credentials } for OpenAPI) so Executor caches each account’s discovered catalog separately.

Remote MCP server (apps/mcp)

  1. Add "@modelcontextprotocol/sdk": "1.32.1" (peer range ^1.31.0) to dependencies in package.json.
  2. Call mcpRouter({ url, account?, headers?, cache: ctx.cache, signal: ctx.signal }, kinds?) inside your defineApp factory.
  3. For authenticated MCP servers, add health: (check) => mcpHealth(check, { url, headers: check.account.request.headers() }) to your provider. mcpHealth verifies both that the server accepts the account and that it refuses an unauthenticated request without running any tools.
  4. Override upstream read-only guesses with the optional kinds map ({ toolName: "query" | "mutation" }), and attach approvals with withApprovals.

OpenAPI specification (apps/openapi)

No extra peer dependency is needed beyond apps.

  1. Call liveOpenapiRouter({ source, baseUrl?, account?, credentials?, headers?, cache: ctx.cache, signal: ctx.signal }, kinds?).
  2. Pass source: { url: "https://..." } for a public OpenAPI document, or source: { document } for an inline or imported JSON/YAML object.
  3. GET, HEAD, OPTIONS, and QUERY operations become queries; other HTTP methods become mutations unless overridden in kinds (keyed by operationId or tool name).
  4. Use openapiOperationNames(document) or openapiToolNames(options) when inspecting how operations map to tool names, and renameTools to adjust generated names.

GraphQL endpoint (apps/graphql)

  1. Add "graphql": "16.11.0" (peer range ^16.11.0) to dependencies in package.json.
  2. Call graphqlRouter({ url, account?, headers?, cache: ctx.cache, signal: ctx.signal }, kinds?).
  3. GraphQL queries map to Executor queries and GraphQL mutations map to Executor mutations via introspection.

Combining multiple sources or accounts

  • Mount multiple imported sources under named keys in router({ docs: ..., api: ... }). If one upstream server is unreachable, only that router fails to load; the app’s other routers keep working.
  • Override an imported router’s title, description, or instructions with router(imported, { title, description, instructions }).
  • For provider.many() user requirements, wrap the import inside accountRouter(ctx.user?.accounts.service ?? [], async (account) => ...) so each linked account gets its own sub-router and cached catalog.

Example

This app wraps a public MCP server and adds an approval rule for any tool the server marks destructive:

{
  "name": "deepwiki-mcp-app",
  "private": true,
  "dependencies": {
    "apps": "0.0.1-beta.148",
    "@modelcontextprotocol/sdk": "1.32.1"
  }
}
import { defineApp, toolAnnotations, withApprovals } from "apps";
import { mcpRouter } from "apps/mcp";
import { always } from "apps/operations/approval";

export default defineApp({}, async ({ cache, signal }) => {
  const server = await mcpRouter({
    url: "https://mcp.deepwiki.com/mcp",
    cache,
    signal,
  });

  return {
    tools: withApprovals(server, (tool) =>
      toolAnnotations(tool)?.destructiveHint === true ? always() : undefined,
    ),
  };
});

Limits

  • Peer dependencies must be declared: importing apps/mcp without @modelcontextprotocol/sdk (^1.31.0) or apps/graphql without graphql (^16.11.0) in package.json fails the deploy and names the missing package.
  • OpenAPI document and response bounds: public source: { url } OpenAPI definitions are limited to 40 MB. OpenAPI HTTP responses are read with a 16 MiB / 30-second bound; streaming endpoints (such as live SSE) appear in metadata with streaming: true but cannot run through a single-result tool call.
  • Binary payloads in OpenAPI: binary request bodies and multipart binary fields take base64 strings; binary responses return { base64, contentType }.
  • MCP token scoping: an OAuth token issued for an MCP server often works only against that MCP endpoint, not against a separate REST or GraphQL API on the same service.
  • Cache entry size: each cached catalog entry is bounded to 2 MB. Always pass cache: ctx.cache so listing tools reuses metadata without re-introspecting on every call; reconnecting an account starts an empty cache scope.

Was this page helpful?