Skip to content

Connectors: how Jarvis authenticates to external services ​

How the worker reaches Notion, Google Docs and other sources (CTX-02, CTX-03), and how that works on a headless server (ADR-0016) with secrets in Infisical (ADR-0015). Status: decision taken 2026-11-08, implementation planned in ../plans/server-readiness.md (Task 2.6).

Two ways in ​

  1. The owner's claude.ai connectors (ADR-0027) — Notion, Slack, Google Docs, Google Drive. No token, no servers.json entry: see "claude.ai connectors" below. This is what the server uses.
  2. A server in servers.json with a credential from Infisical — everything else, and the way to narrow a service to less than the owner's whole account. The rest of this document.

claude.ai connectors (ADR-0027) ​

The claude login on the machine is the owner's claude.ai account, and the account's connectors come with it. To let runs read one:

  1. Connect the service once at https://claude.ai/settings/connectors (any device).
  2. On the machine, as the engine's user, check it is there: claude mcp list shows claude.ai Notion … ✔ Connected.
  3. List it in ~/.jarvis/jarvis.config.json and restart the engine:
    json
    "connectors": { "claudeAi": ["notion", "slack", "google_docs", "google_drive"] }

Dispatcher and worker runs then have the connector's read tools without asking, and are denied every other tool of it and every other connector of the account. A ui_check run gets none. The Connections page shows claude.ai connector, read-only; like every connector, it is proven only when a run reads a source.

What to know before turning one on: a read tool sees the owner's whole account in that service (private Slack channels included), a run with connectors also reads the user settings source, and the grant expires with the claude.ai login. The ADR lists all of it.

How a servers.json connector is wired ​

The engine writes a mcp.json for every run from ~/.jarvis/mcp/servers.json, substituting ${VAR} with the engine's environment, and starts claude with --mcp-config <run>/mcp.json --strict-mcp-config (engine/src/infrastructure/claude/run-files.ts). Consequences:

  • Claude Code's own MCP store and the OAuth tokens it keeps after /mcp are not used. Only servers listed in servers.json load.
  • A connector's credential is whatever its variable holds. If the credential can be a secret in Infisical, the connector needs no interactive step on any machine.
  • The engine cannot test a connector without a model run; /api/connections only reports whether the variables are set (connector-probe.ts). A bad credential surfaces when a worker reads the source (CTX-05: Blocked).

Rule: one interactive login per machine, and it is claude ​

The only thing the owner does over SSH on the server is claude → /login. Every other service must be reachable with a credential that lives in Infisical. Pick the authentication type in this order:

OrderTypeExamplesServer work
1Static token or service accountNotion internal integration token; Google service account key; GitHub PATnone
2OAuth done once on the laptop, refresh token stored in Infisical (way 1)a Google MCP server that reads the token from envnone
3OAuth done once on the server over an SSH tunnel, token on the server's disk (way 2, fallback)a server that only stores its token in its own fileone SSH session
—Remote MCP with OAuth through Claude Code (/mcp)hosted Notion / Google MCP, claude.ai connectorsnot used on the server

Way 1 (chosen): authorise on the laptop, keep the refresh token in Infisical ​

Preconditions: the MCP server accepts the refresh token (or the path of a token file) from an environment variable, and the OAuth app is In production in Google Cloud. A Google OAuth app left in Testing invalidates refresh tokens after 7 days, so the server would silently lose access weekly.

  1. Create the OAuth client (type Desktop app) in the owner's Google Cloud project; publish the consent screen (internal use, no verification needed when only the owner's account uses it).
  2. Run the server's authorisation once on the laptop; it opens the browser, the owner grants access, the server writes its token file. For Google Docs, run it read-only, never with the server's defaults (they grant write access to Drive, Docs, Sheets, Slides and Calendar, and the scopes cannot be narrowed later). First export GOOGLE_DRIVE_MCP_CLIENT_ID and GOOGLE_DRIVE_MCP_CLIENT_SECRET from the OAuth client of step 1, then run the exact command in "Google Docs" under "Per connector" below, with GOOGLE_DRIVE_MCP_SCOPES set.
  3. Copy the refresh token (and client id/secret) into Infisical dev and prod; delete the local token file if the server can read the values from env; otherwise keep it under ~/.jarvis on the laptop only.
  4. Reference the variables in ~/.jarvis/mcp/servers.json as ${VAR} for each variable the server reads (for Google Docs: see "Per connector" below).

The laptop and the server share one refresh token; Google allows that. Rotation: revoke the token in the Google account, repeat steps 2–3, systemctl restart jarvis-engine.

Preferred over OAuth entirely, when the server can read it from a variable: a service account. Its JSON key goes to Infisical (GOOGLE_SERVICE_ACCOUNT_JSON, base64), the Drive folder is shared with the service account's e-mail as Viewer; no browser, no expiry, revoked by deleting the key. The chosen Google Docs server cannot read it from a variable (see "Per connector"), so Google Docs uses way 1.

Way 2 (fallback): authorise on the server through an SSH tunnel ​

For a server that stores its token only in its own file and cannot take it from env.

sh
ssh -L <port>:127.0.0.1:<port> jarvis@<host>     # <port> = the callback port the MCP server prints
# on the server, as jarvis:
<mcp server's auth command>                      # prints an https://accounts.google.com/... URL
# open that URL in the laptop's browser, grant access; the redirect to localhost:<port> goes through the tunnel
chmod 600 <token file>

Security of this way, and why it is only the fallback:

  • The callback listens on the server's 127.0.0.1; only the one-time authorisation code crosses the SSH tunnel. The refresh token is fetched by the server over HTTPS. Nothing is exposed on a public interface.
  • The token sits in plaintext on the server disk, like the claude login in ~/.claude. Anyone with SSH as jarvis can use it: SSH stays key-only over Tailscale (ADR-0016).
  • Hetzner snapshots include the file. Keep 2FA on the Hetzner account; after a suspected leak, revoke the app's access in the Google account, not just the file.
  • Rotation means repeating the procedure instead of changing a value in Infisical. Record the exact commands in deploy/README.md when a connector uses this way.

Not used: remote MCP servers authorised with /mcp ​

A remote server added with claude mcp add and authorised with /mcp keeps its token in ~/.claude (Keychain on macOS, a file on Linux) and is not given to runs: a strict run does not load it, and a run with claude.ai connectors (ADR-0027) has no allow rule for its tools. Do not copy ~/.claude between machines for this. The account's own connectors are the exception, and they need no /mcp.

Per connector ​

ConnectorTypeVariablesScope control
Notioninternal integration tokenNOTION_TOKENshare only the root page (connectors.notionRoot) with the integration
Google Docsway 1: OAuth refresh token from env (see below)GOOGLE_DRIVE_MCP_REFRESH_TOKEN, GOOGLE_DRIVE_MCP_CLIENT_ID, GOOGLE_DRIVE_MCP_CLIENT_SECRETread-only scopes at authorisation; connectors.googleFolder points the worker at the folder
GitHubfine-grained PAT of the bot accountGITHUB_TOKENthe allow-listed repositories (ADR-0012)
Claude Designmanual handoff in iteration 1——

Google Docs: @piotr-agier/google-drive-mcp@2.13.0 ​

MIT, one maintainer, npm provenance and registry signatures, no install scripts. Its tools cover reading a Doc, search and listing a folder. The servers.json fragment is in agent/README.md.

Why way 1 and not a service account. The server supports a service account only through GOOGLE_APPLICATION_CREDENTIALS, a file path (it does readFileSync); it cannot take the key from a variable, so the credential would not come from Infisical through the environment. A service account would need the deploy to write a 0600 file; that is not what we wire. The server picks a mode in this order: service account, external token, browser OAuth. Never set GOOGLE_APPLICATION_CREDENTIALS on the server, or it silently wins over the refresh token.

Variables (external-token mode; the presence of the refresh token selects it): GOOGLE_DRIVE_MCP_REFRESH_TOKEN, GOOGLE_DRIVE_MCP_CLIENT_ID, GOOGLE_DRIVE_MCP_CLIENT_SECRET.

Scopes are fixed at consent time. In external-token mode GOOGLE_DRIVE_MCP_SCOPES does nothing: the client is built with the refresh token and no scopes. The server's default scopes are broad (full drive, documents, spreadsheets, presentations and calendar, with write), so authorise on the laptop with the scopes set, or Jarvis holds a token that can write to the owner's whole Drive and Calendar:

sh
GOOGLE_DRIVE_MCP_SCOPES=https://www.googleapis.com/auth/drive.readonly,https://www.googleapis.com/auth/documents.readonly \
  npx -y @piotr-agier/google-drive-mcp@2.13.0 auth

Export the client id and secret first (see the open item below). The refresh token lands in ~/.config/google-drive-mcp/tokens.json. Copy it by hand into Infisical dev and prod (the project documents no export command), together with the client id and secret.

The version is pinned deliberately. This process holds a Google refresh token, and npx -y without a version resolves the latest release on every run. Bump it by hand after reading the release.

What /api/connections shows. It reports ok when the three variables and connectors.googleFolder are set, and names whichever are missing. That does not prove access: a bad or revoked token surfaces when a worker reads the source and the task goes to Blocked (CTX-05).

Verify at first setup (the research could not confirm these):

  • whether a service account can read a personal (non-Workspace) account's Doc after sharing;
  • whether drive.readonly alone suffices for the Docs API, or documents.readonly is also required;
  • whether publishing the consent screen to "In production" needs verification for these scopes;
  • whether the server needs a writable home directory in external-token mode.
  • how auth obtains the OAuth client id and secret: the steps say to export GOOGLE_DRIVE_MCP_CLIENT_ID and GOOGLE_DRIVE_MCP_CLIENT_SECRET first, which is the plausible reading and is not confirmed; if auth prompts for them or wants a downloaded client-secret JSON instead, fix the steps.