---
title: "Services and API imports"
description: "Services and API imports from the built-in skills in Executor 2.0.0-beta.79."
---

This page covers Connect a service from the [built-in skills](/docs/reference/skills) shipped with Executor `2.0.0-beta.79`. It contains `app-authoring/integrations.md`.

Next: [Services and API imports · Check an MCP account](/docs/reference/skills/app-authoring/integrations-2)

## Connect a service

Use this when the user asks you to add a service, often from a setup prompt
copied from the dashboard. Pick the helper below, read the service's
authentication docs, and ask the user how they sign in when it is unclear. Put
that method in `provider.ts` ([accounts.md](/docs/reference/skills/app-authoring/accounts#use-a-provider-account)); never put a
credential in source. When the service has a safe current-user or account read,
give the provider a `health` check that calls it ([accounts.md](/docs/reference/skills/app-authoring/accounts-2#check-an-account)),
so users can validate credentials before saving and see which account they connected. For an
MCP server, use [`mcpHealth`](/docs/reference/skills/app-authoring/integrations-2#check-an-mcp-account). Look up exact helper options with `framework.describe`.

| Interface                   | Helper                                                    |
| --------------------------- | --------------------------------------------------------- |
| Remote MCP server           | `mcpRouter` from `apps/mcp`                               |
| OpenAPI or Swagger document | `liveOpenapiRouter` from `apps/openapi`                   |
| GraphQL endpoint            | `graphqlRouter` from `apps/graphql`                       |
| Anything else               | Queries and mutations with `fetch` ([tools.md](/docs/reference/skills/app-authoring/tools#a-runnable-first-app)) |

Reach MCP servers over HTTP with `mcpRouter`. Apps cannot start local processes,
so a stdio-only server needs an HTTP endpoint first.

## OAuth apps the user registers

Every `oauth2` method needs an OAuth client. Before telling the user to register
one, request the connection and call `accounts.oauthSetup` with its
`provider.id` and the method name (Cloud and self-host). `mode: "automatic"`
means Executor can supply a client itself, registering one at sign-in if it
needs to, and the user only signs in;
`firstParty: { label }`, such as "Executor for Google", names the host's own
client. `client-required` means the user supplies one.

Executor looks for a client in this order: one the user already saved, the
host's first-party client, a client ID metadata document, then dynamic
registration. Executor Cloud has first-party clients for Google and GitHub;
self-host has them only when its operator sets their credentials. One applies
only when the method's authorization and token URLs are exactly its own and
every requested scope is one it allows, so the same issuer with other endpoints
or scopes can still need the user's client.

Executor gets a client itself when the authorization server advertises a
`registration_endpoint`, or accepts client ID metadata documents and the host
publishes one: Executor Cloud does, and self-host does when its operator turns
it on. Otherwise the method needs a client from the user: the connect page asks
them to create an OAuth app in the service's developer settings, add
Executor's redirect URI to it, and enter its client ID and client secret.
Public PKCE clients, declared with `tokenEndpointAuthMethod: "none"`, have no
secret. Executor saves the
client after a successful connection and reuses it. Give the user the connect
link as usual; never ask for a client ID or secret in chat.

The redirect URI belongs to the host. The connect page shows it. On Cloud and
self-host, `appAccounts.userConnect`, `appAccounts.appConnect` and
`accounts.connection` also return it as `redirectUri`, so you can tell the user
what to register before they open the link. The local server uses
`/api/oauth/callback` on its own origin.

Without a first-party client, expect to need the user's for Google, GitHub and
Slack, which offer no registration, and for services such as Fastmail that
accept only clients and redirect URIs registered in advance. When a service
advertises registration but refuses it, the first connect attempt fails and the
page opens the same client form. Client-credentials methods always take the
user's client ([accounts.md](/docs/reference/skills/app-authoring/accounts-3#oauth-sign-in)).

## Approvals for imported tools

Helpers attach no approval. Wrap the router with `withApprovals` from `apps`
and choose each tool's policy in app code. Ask before every OpenAPI and
GraphQL mutation (non-`GET`/`HEAD` methods and GraphQL mutation fields), and
before MCP tools whose server sets `destructiveHint: true`:

```ts
import { toolAnnotations, withApprovals } from "apps";
import { always } from "apps/operations/approval";

// OpenAPI and GraphQL. liveOpenapiRouter returns the router; the other helpers return a Promise.
withApprovals(liveOpenapiRouter(options), (tool) =>
  tool.kind === "mutation" ? always() : undefined,
);
// MCP
withApprovals(await mcpRouter(options), (tool) =>
  toolAnnotations(tool)?.destructiveHint === true ? always() : undefined,
);
```

To ask before every MCP tool the server does not mark read-only, including tools
with no hints, invert the rule:

```ts
withApprovals(await mcpRouter(options), (tool) =>
  toolAnnotations(tool)?.readOnlyHint === true ? undefined : always(),
);
```

To classify an MCP tool yourself, pass `kinds` as `mcpRouter`'s second argument, such as
`{ get_live_context: "query", run_script: "mutation" }`. Rules see its `readOnlyHint` from that
classification, not the server's. Mark a tool a query only when you have checked that it reads.

The callback also receives the tool's name relative to the router. Returning
`undefined` keeps the tool's own approval. With accounts, wrap each account's
router inside the `accountRouter` callback, so each account keeps its own
tools' hints. Quick-add MCP apps are generated with the MCP rule above.

## Remote MCP tools

Import `mcpRouter` from `apps/mcp`. Add `@modelcontextprotocol/sdk` (currently
`1.32.1`) to the app's `package.json` dependencies. The dashboard's quick add
generates this for public and OAuth servers. A public server needs no account:

```ts
import { defineApp } from "apps";
import { mcpRouter } from "apps/mcp";

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

A tool the server marks `readOnlyHint: true` is a query, but that is the
server's claim, so Executor still treats a failed call to it as one that may
have written: the agent is told not to repeat it. A second argument, `kinds`,
keyed by tool name, is the app's own classification: `{ search: "query" }`
confirms a tool that only reads and keeps a read's retry advice, and
`"mutation"` corrects a wrong hint. Confirm only tools you know do not write.

Authenticated apps declare `user: { accounts: { service: provider.many() } }`,
so each member links their own accounts, and combine discovery with
`tools: await accountRouter(ctx.user?.accounts.service ?? [], account => mcpRouter({ ... }), { signal })`
from `apps`. Each tool takes `{ accountId, input }`: the chosen account ID and the
original upstream input. Same-name tools keep one name with an input schema for
each account. No linked accounts expose no tools; the factory also runs without a
caller for the app's background work, where `ctx.user` is undefined. The callback
may return the router or a Promise of it, and may return a `router` of your own
queries and mutations; `defineApp` checks their handler contexts as for any
router.

For one service account the whole team shares, declare it as the app's own,
`app: { accounts: { service: provider } }`, and pass `ctx.app.accounts.service`
to `mcpRouter` directly. Someone who can edit the app links the account for
everyone; every caller uses it, and tools take the server's own input. Quick add generates the per-member
form.

Pass that callback's `account` with headers derived from it. Headers are only
accepted together with the account they belong to.
OAuth uses `oauth2({ discover: "https://example.com/mcp" })`
and `Authorization: "Bearer " + account.fields.access_token`.
API-key methods use a `secrets` field and the header the server documents,
for example `headers: { "X-API-Key": account.fields.token }`.

When quick add refuses a server, its reason names what the server answered
without credentials. A 401 with a Bearer challenge and no OAuth metadata means
a key sent as `Authorization: "Bearer " + ...`; confirm the header in the
service's documentation. A 403 web page means a firewall refused Executor's
check, not that a key is needed. A public server that also offers OAuth is
added without an account; its `provider.ts` keeps the discovered OAuth.
The factory runs with the caller's linked accounts, so different accounts can
expose different catalogs. Do not keep a global authenticated catalog.
