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)
- Add
"@modelcontextprotocol/sdk": "1.32.1"(peer range^1.31.0) todependenciesinpackage.json. - Call
mcpRouter({ url, account?, headers?, cache: ctx.cache, signal: ctx.signal }, kinds?)inside yourdefineAppfactory. - For authenticated MCP servers, add
health: (check) => mcpHealth(check, { url, headers: check.account.request.headers() })to your provider.mcpHealthverifies both that the server accepts the account and that it refuses an unauthenticated request without running any tools. - Override upstream read-only guesses with the optional
kindsmap ({ toolName: "query" | "mutation" }), and attach approvals withwithApprovals.
OpenAPI specification (apps/openapi)
No extra peer dependency is needed beyond apps.
- Call
liveOpenapiRouter({ source, baseUrl?, account?, credentials?, headers?, cache: ctx.cache, signal: ctx.signal }, kinds?). - Pass
source: { url: "https://..." }for a public OpenAPI document, orsource: { document }for an inline or imported JSON/YAML object. GET,HEAD,OPTIONS, andQUERYoperations become queries; other HTTP methods become mutations unless overridden inkinds(keyed byoperationIdor tool name).- Use
openapiOperationNames(document)oropenapiToolNames(options)when inspecting how operations map to tool names, andrenameToolsto adjust generated names.
GraphQL endpoint (apps/graphql)
- Add
"graphql": "16.11.0"(peer range^16.11.0) todependenciesinpackage.json. - Call
graphqlRouter({ url, account?, headers?, cache: ctx.cache, signal: ctx.signal }, kinds?). - 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 insideaccountRouter(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/mcpwithout@modelcontextprotocol/sdk(^1.31.0) orapps/graphqlwithoutgraphql(^16.11.0) inpackage.jsonfails 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 withstreaming: truebut 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.cacheso listing tools reuses metadata without re-introspecting on every call; reconnecting an account starts an empty cache scope.