Files
PaperClipAI/doc/connections/tracks/remote-mcp.md
T
DottaandPaperclip 8403e1c4ce docs(connections): modularize connector playbook and add create-connector skill (#23384)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - App connectors let agents interact with external tools, suites, REST
APIs, and chat channels under instance governance
> - `doc/connections/CONNECTOR-PLAYBOOK.md` grew to 2,968 lines (171 KB)
and accumulated stale guidance on `rest_api` adapters and setup UX, with
no upfront research-and-interview gate to aim new connectors at user
expectations
> - An autonomous agent cannot reliably build a new connector in one
command when the playbook mixes every track together and defaults
blindly to remote MCP
> - This pull request splits the playbook into a concise router plus six
load-on-demand track guides and adds the
`.agents/skills/create-connector` skill
> - The benefit is that agents and contributors audit official vendor
docs up front, recommend the right architecture track, and load only the
guidance needed for that connector

## Linked Issues or Issue Description

**Issue type**
Outdated (no longer matches behavior)

**Where is the issue?**
`doc/connections/CONNECTOR-PLAYBOOK.md`, `doc/connections/README.md`,
`.agents/skills/create-connector/`

**What's wrong?**
`doc/connections/CONNECTOR-PLAYBOOK.md` was a 2,968-line monolith that
still claimed `rest_api` is not exposed through the gateway (despite
`rest-registry.ts`, `browser-use-cloud`, and
`google-workspace-rest-tools`), contradicted itself on one-screen setup
vs. a two-step Access → Connect flow, and jumped straight into MCP
endpoint probing without an official-docs feasibility audit or product
alignment interview.

**Suggested fix**
Refactor `CONNECTOR-PLAYBOOK.md` into a short canonical router +
universal invariants contract, move track-specific details into
`doc/connections/tracks/`, and add `.agents/skills/create-connector/`
with a mandatory Research-First → Proactive Recommendation & Interview
gate.

## What Changed

- Refactored `doc/connections/CONNECTOR-PLAYBOOK.md` from 2,968 lines to
184 lines (Phase 0 official-docs feasibility audit & interview, 6-track
selection matrix, universal invariants, canonical one-screen setup UX,
production validation matrix, preserved inbound anchors).
- Created six focused track guides and one deep reference under
`doc/connections/tracks/`:
  - `remote-mcp.md` (Track A)
  - `rest-adapter.md` (Track B)
  - `managed-oauth-suite.md` (Track C)
  - `connector-skills.md` (Track D)
  - `chat-channel.md` (Track E)
  - `local-and-aggregators.md` (Track F)
- `app-definition-reference.md` (field reference, troubleshooting,
provider attribution, proposal template)
- Added `.agents/skills/create-connector/SKILL.md` and
`.agents/skills/create-connector/brief-template.md` implementing the
one-command connector workflow with three explicit human Stop Gates.
- Updated `doc/connections/README.md` to link the modular playbook,
track guides, and `create-connector` skill.

## Verification

- Verified all relative markdown links across all 11 created/modified
files resolve to existing files with zero broken links.
- Verified `git diff --check` passes cleanly on all modified and added
files.
- Confirmed all existing inbound anchors to `CONNECTOR-PLAYBOOK.md`
(`#step-9-align-with-production-validation`, `#chat-channel-connectors`,
`#question-experience-inventory`,
`#retain-inspectable-per-format-evidence`) remain intact.

## Risks

- Low risk: documentation and agent-skill changes only; no runtime,
schema, or UI code is modified.

## Model Used

- Google Gemini (Antigravity agentic coding assistant, tool use and code
execution enabled)

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

---------

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-12-01 16:33:39 +00:00

11 KiB
Raw Blame History

Track A: Curated Remote MCP Connector

Use this track when the provider publishes an official, Cloud-reachable remote HTTP MCP server whose tool surface and read/write capabilities match what Paperclip users expect — and whose auth/fields can be represented by the common AppDefinition contract with zero or minimal runtime code.

Baseline: An operator can already connect any standards-compliant remote HTTP MCP server through Connect your own MCP server or Paste a config with no code change (see GENERIC-REMOTE-MCP.md). A curated catalog entry adds branding, tailored fields, validation, reviewed scope defaults, and support copy — nothing else. It converges on the exact same connection, gateway, and review pipeline.

When NOT to use Track A alone

Five Independent Axes

Never describe a connection as merely "an OAuth connection" or "an MCP connection." Every method chooses all five axes:

Axis Values Question
Transport mcp_remote (default), local_stdio (approved templates only), rest_api (reviewed adapters only) How does Paperclip reach actions?
Authentication oauth, api_key, none How does the provider authorize requests?
OAuth client ownership dcr, customer, platform_shared, platform_provisioned Who supplies and controls the OAuth client registration?
Credential source paperclip_vault, reviewed vercel_connect Where does durable provider credential material live?
Grant identity organization, user, agent Does the credential act for the company, one person, or one dedicated agent?

Authentication Support Matrix

Pattern Definition shape What the user sees What Paperclip stores
Automatic OAuth auth: "oauth", ownershipModes: ["dcr"] Browser sign-in DCR/CIMD client binding + token secret refs
Automatic OAuth + own-app escape hatch ownershipModes: ["customer", "dcr"] Recommended browser sign-in; own client under Advanced Same as automatic, or supplied client ID + encrypted client secret
Customer OAuth only ownershipModes: ["customer"] Required client ID (+ secret), then browser sign-in Client ID in redacted config; client secret & tokens as secret refs
Paperclip-managed OAuth oauthStrategy: "paperclip_cloud_connector", connectorProfile, platform_shared Browser sign-in through Paperclip Cloud Tokens land in instance vault on a user grant; Cloud never persists plaintext tokens
API key / PAT auth: "api_key", credentialFields, keyPlacement Write-only credential field Encrypted secret version + placement-only refs
Generated URL auth: "none", no fixed URL/default template Paste provider-generated MCP URL Public URL shape in config; full secret-bearing URL in vault
No auth auth: "none", fixed serverUrl or validated serverUrlTemplate Zero fields or only required tenant/resource fields No provider credential

For mcp_remote, header credentials and secret-bearing generated URLs have the complete generic runtime path. Do not ship query, body_json, or env key placements on mcp_remote without tracing the invocation path and adding an end-to-end fixture.

OAuth Discovery & Client Resolution

For standard OAuth methods, Paperclip resolves endpoints in oauthEndpointsForConnection (server/src/services/tool-access.ts):

  1. defaults.discoveryUrl is authoritative when set (must describe the MCP resource or its authorization server, not a separate web/API OAuth service).
  2. A complete manifest pair (authorizationEndpoint + tokenEndpoint) replaces discovery when DCR is not supported or when using an operator-entered client.
  3. Otherwise, for mcp_remote, discoverOAuthEndpoints checks stored/hinted endpoints, then runs RFC 9728 (GET <serverUrl> → 401 + WWW-Authenticate → /.well-known/oauth-protected-resource) → RFC 8414 (/.well-known/oauth-authorization-server, trying both insertion and OIDC suffix forms). Authorization, token, and refresh requests carry RFC 8707 resource and validate RFC 9207 iss.

Client resolution order:

  1. Deployment-preconfigured client (PAPERCLIP_TOOL_OAUTH_<PROVIDER>_CLIENT_ID/_SECRET).
  2. Client ID Metadata Document (CIMD), when advertised and the instance has a public HTTPS URL.
  3. Dynamic Client Registration (DCR / RFC 7591), when advertised and dcr is in ownershipModes.
  4. Customer-supplied client ID and secret.
  • Set oauthClientRegistration: "dcr" when live evidence proves CIMD fails while DCR works (requires dcr in ownershipModes).
  • Record probed redirect-URI rules in redirectConstraints (e.g., https-or-loopback-http).
  • DCR needs neither Paperclip ID nor Paperclip Connect. Each instance registers its own public client (token_endpoint_auth_method: "none" + PKCE S256) and uses its own /api/tools/oauth/callback. Cloud and self-hosted use the exact same path.

Files You Normally Touch

ui/public/brands/apps/<slug>.svg                  # official, sanitized mark
ui/public/brands/apps/manifest.json               # runtime branding paths
doc/connections/tool-method-permission-reviews.json # reviewed scopes & actions
scripts/ingest-app-definitions.mjs                # or scripts/app-definition-overrides/<slug>.json
packages/shared/src/app-definitions/<slug>.json   # generated (+ app-owned agentInstructions if any)
packages/shared/src/app-definitions.generated.ts  # generated registry
packages/shared/src/self-serve-mcp-research.json  # when part of self-serve MCP research
packages/shared/src/app-definitions.test.ts       # manifest/provider assertions

Method Design Rules

  • Create separate methods only for real user choices (e.g., US vs. EU endpoint, materially different OAuth vs. API-key path, distinct provider toolsets).
  • Do not create separate methods for DCR vs. CIMD, DCR vs. own OAuth app on the same endpoint (fold own-app under Advanced), or optional filters/read-only switches (make them advanced: true fields with safe defaults).
  • Prefer a write/draft-capable method as default; put read-only switches under Advanced.
  • Use grantKinds: ["user"] for providers that only support personal delegated identity or private personal data (e.g., personal meeting notes, email).
  • Use setupPrerequisite for steps required before consent (preview enrollment, public storefront); put plan/admin caveats in warnings and guidanceMd.
  • Use defaults.toolArgumentDefaults only for required, provider-documented protocol metadata that Paperclip owns (hidden from agent/Test schemas and authoritative on collision).

Minimal Method Recipes

Automatic OAuth (DCR / CIMD)

{
  "key": "mcp-oauth",
  "label": "Sign in with Example",
  "transport": "mcp_remote",
  "auth": "oauth",
  "ownershipModes": ["dcr"],
  "whenToUse": "Use browser sign-in for the hosted MCP server.",
  "defaults": {
    "serverUrl": "https://mcp.example.com/mcp",
    "scopesHint": ["example.read", "example.write"]
  },
  "guidanceMd": "Connect the workspace agents should use.",
  "consoleLinks": { "docs": "https://docs.example.com/mcp" },
  "riskTier": "S3"
}

Customer OAuth Only

{
  "key": "mcp-own-oauth",
  "label": "Use your own OAuth app",
  "transport": "mcp_remote",
  "auth": "oauth",
  "ownershipModes": ["customer"],
  "whenToUse": "Register an OAuth app, then enter its client ID and secret.",
  "defaults": { "serverUrl": "https://mcp.example.com/mcp" },
  "guidanceMd": "Register Paperclip's callback URI in the provider console.",
  "consoleLinks": {
    "register": "https://example.com/developers/apps",
    "docs": "https://docs.example.com/mcp/oauth"
  },
  "riskTier": "S3"
}

API Key / PAT

{
  "key": "mcp-api-key",
  "label": "Use an API key",
  "transport": "mcp_remote",
  "auth": "api_key",
  "ownershipModes": ["customer"],
  "whenToUse": "Use a restricted key from the provider console.",
  "defaults": { "serverUrl": "https://mcp.example.com/mcp" },
  "credentialFields": [
    {
      "key": "authorization",
      "label": "Example API key",
      "type": "password",
      "required": true,
      "placeholder": "ex_...",
      "secret": true
    }
  ],
  "keyPlacement": { "location": "header", "name": "Authorization", "prefix": "Bearer " },
  "guidanceMd": "Create a key limited to the resources agents need.",
  "riskTier": "S3"
}

Provider-Generated URL / No-Auth Tenant Template

  • Generated URL: auth: "none", ownershipModes: ["customer"], defaults: {}, narrow urlPatterns.
  • No-auth tenant template: auth: "none", defaults: { "serverUrlTemplate": "https://{tenantDomain}/api/mcp" }, validated tenantFields with pattern + maxLength.

Step-by-Step Authoring Sequence

  1. Brand first: Follow CONNECTOR-ICONS.md. Add the official SVG (or ≥128×128 PNG) to ui/public/brands/apps/ and register in ui/public/brands/apps/manifest.json. Ingestion fails closed if branding is missing.
  2. Permission review: Add the method's reviewed scopes, supported actions, provider restrictions, and official evidence URL to tool-method-permission-reviews.json. Never request all advertised scopes automatically.
  3. Author durable source & regenerate: Edit scripts/ingest-app-definitions.mjs or scripts/app-definition-overrides/<slug>.json, then regenerate definitions:
    # With a local paperclip-content checkout (or PAPERCLIP_CONTENT_TEMPLATES set):
    pnpm connections:ingest-app-definitions
    
    # Without the external research corpus (regenerates definitions and preserves the checked-in report):
    pnpm connections:ingest-app-definitions --definitions-only
    
    Inspect git diff to ensure no unrelated provider churn.
  4. Add generic runtime support only if needed: Check packages/shared/src/types/app-definition.ts, validators/app-definition.ts, normalizeConnectionMethodConfig, projectedConnectionHeaders, tool-access.ts, tool-gateway.ts, and classifyRisk. Never add a provider-name branch when a reusable field solves the problem.
  5. Deterministic tests: Run and extend:
    node scripts/check-app-brand-assets.mjs
    pnpm exec vitest run \
      packages/shared/src/app-definitions.test.ts \
      server/src/__tests__/tool-access-service.test.ts \
      server/src/__tests__/generic-mcp-connection.test.ts \
      server/src/__tests__/tool-connection-removal.test.ts \
      ui/src/pages/apps/AppsConnect.test.tsx \
      ui/src/pages/apps/Browse.test.tsx
    
  6. Isolated UI & live proof: Follow the Production Validation lifecycle in the main playbook.

For full field definitions, troubleshooting, and worked dry-run examples, see app-definition-reference.md.