Files
PaperClipAI/scripts/ingest-app-definitions.mjs
T
DottaandPaperclip 889947c238 feat: add experimental native chat connectors (#13038)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work.
> - People also ask agents for work in their existing chat tools.
> - Each external conversation needs one task and a current authorized
source.
> - Retries, Stop, and provider failures must not duplicate work or
expose private data.
> - The first chat PR establishes the opt-in provider and data
contracts.
> - This PR adds experimental channel integration and its durable
control plane.
> - Users can request work from connected channels and inspect delivery
in Paperclip.

## Linked Issues or Issue Description

Refs #13100 and #13092. This is the second of exactly two chat PRs.
Foundation #13100 is merged and changed 143 files. Runner prerequisite
#13092 is also merged. This PR changes 400 files against master, below
the 500-file review limit. It contains no wireframe images or HTML
galleries.

## What Changed

- Add native Slack, GitHub, Microsoft Teams, Telegram, and Discord chat
connections. Keep chat disabled unless the operator enables experimental
chat connectors. Preserve the production GitHub tool connection and its
normal setup path.
- Bind each provider bot identity to one immutable Paperclip agent. Bind
each admitted external conversation to one task. Paperclip owns tasks,
runs, permissions, and audit records.
- Add durable admission, per-conversation queues, questions, task
controls, progress, final replies, images, files, and delivery receipts.
Board comments remain internal unless explicitly sent to the channel.
- Check current identity, provider reach, resource access, credentials,
runtime generation, and exact source before provider effects. Keep
private responses private. Never send raw reasoning, private logs,
credentials, or tool arguments.
- Hold uncertain sends for explicit audited resolution. Make Board
Send-to-channel atomic and idempotent. Keep reconnect and setup
credentials in Paperclip secret storage.
- Preserve current native-runner authority across retries, lost
acknowledgements, and recovery. Keep immutable input and completion
contracts separate from newer user input. Receipt reconciliation cannot
launch a provider.
- Reconcile chat close/new ordering and provider-effect lock order.
Audit resource access changes in the same transaction. Submit only the
selected resource from each UI toggle so stale pages cannot undo
unrelated access changes.
- Drain Codex stdout before certifying process exit. Bound the drain
with the existing shutdown grace. Preserve observed terminal authority
without treating an undrained process as successful or reusable.
- Incorporate master `018ca5da` with its ACP Stop, mobile task layout,
runner packaging, and official lock changes. Preserve dedicated
chat-answer continuations in both directions when ordinary queued
comments are adopted after Stop.
- Fence late adapter readiness behind an earlier Stop for the same run.
Preserve verified cleanup for registered adapters. Handle single Stop,
agent pause, duplicate Stops, and failure release without creating a
false cancellation receipt.
- Incorporate master's `6dd48cad4` wake-queue extraction. Preserve exact
failed-chat retry authorization and lineage, retired question-source
suppression, and the block on generic recovery that would discard the
admitted source. Fresh deferred input retains its separate promotion
path.
- Incorporate master `2a05b5ed3` and its queue-admission extraction,
simplified transaction ports, and separate runner CI job. Preserve exact
durable receipts, actor separation, and dedicated-answer isolation
through the new module. A failed receipt insert rolls back the
accompanying deferred-wake merge.

## Verification

Current head: `afe19299d06253cb628eb398e91d1200ea9f412a`, incorporating
master `2a05b5ed3457ea33efd6895520447d1d97fe98d8`. The conflicts are
resolved. This successor fixes two test-harness boundaries exposed by
CI: per-case route-module preparation and actual durable-save completion
before intentional runner termination. Production code and all existing
test/turn deadlines are unchanged. [Exact-head Greptile
review](https://github.com/paperclipai/paperclip/pull/13038#issuecomment-5587250594)
is **5/5**, completed September 10 at 13:20:55 UTC, with no actionable
findings or open review threads. [Fresh exact-head
CI](https://github.com/paperclipai/paperclip/actions/runs/34481724341)
passes **all 24 jobs**, including Build and both required aggregates.
Normal exact-head guarded merge was attempted and rejected by the
remaining branch approval policy: CODEOWNER review is required and no
human approval is present. Normal **squash auto-merge is enabled** as of
September 10 at 13:36:26 UTC. Requested CODEOWNERS have been notified;
no approval bypass or self-approval was used. Earlier-head results below
remain historical evidence, not qualification of this successor.

- Final exact-head Linux evidence: 995/995 chat integration cases; 36/36
agent-skills routes; 35/35 runner live-session cases, including real
process kill/resume; 1948 runner Vitest cases with three existing
benchmark/platform guards; 870/870 API-authority cases; and 104 browser
cases with four existing optional skips. Rust, conformance/replay, full
repository build, typecheck, canary, all server/workspace shards, and
both required aggregates pass with normal CI concurrency. Earlier failed
attempts remain recorded below.

- Latest test-only qualification: 141/141
route/permissions/authentication cases pass in separate cold forks, with
plain server types and independent review clear. The real-runner suite
passes 35/35, with plain runner types and independent review clear. A
controlled premature-save acknowledgement fails as expected; matching
ownership/effect/process evidence, rejected saves, real turn outcome,
test abort, and pre-kill liveness are covered. No local reproduction of
the original CI scheduling failure is claimed. The preceding [CI
run](https://github.com/paperclipai/paperclip/actions/runs/34479680858)
passes 21/24 jobs, including all 995 Linux chat cases and browser
aggregate (104 passed, four existing optional skips); only Build, the
skills serialized shard, and the required verification aggregate fail.
Its exact-head Greptile review was 5/5. Both failed job logs are
retained.

- Final fixture qualification: all eight focused Discord cases and all
995 chat integration cases pass. The exact modal statement/PID is
observed before taking the real connection lock; the test then proves
its actual blocking relationship before mutation. Original SQL
execution, provider behavior, negative assertions, and 1s/15s timeouts
remain unchanged. Independent review is clear and test/production hashes
remain frozen. The preceding [CI
attempt](https://github.com/paperclipai/paperclip/actions/runs/34477184777)
passed 22 jobs, including Build/runner, typecheck, canary, all other
test shards, and browser aggregate (104 passed, four existing optional
skips); the two fixture failures and failed verification aggregate
remain recorded, not relabeled as a pass.

- Current queue-module composition: 308/308 recovery/batching/queue/Stop
tests; 995/995 full chat integration; 89/89 module tests, including real
PostgreSQL receipt-insert rollback; 24/24 workflow/module-boundary
tests; plain server and UI types. All four actual local process/ACP
browser paths pass in 1.4 minutes. Fresh databases, no skips or retries,
stable reviewed source hashes. The initial boundary failure is retained;
its no-op service wrapper was removed without changing recovery context
or weakening the check. An exploratory standalone test-directory
typecheck fails because its new upstream transformation config is not a
standalone typechecking project; standard CI/build does not invoke it,
and no configuration was weakened to suppress those diagnostics.

- The preceding head `e02a63d462ce5d47433b0aeb632bb6fd20aab1ba` passed
[all 24 CI
jobs](https://github.com/paperclipai/paperclip/actions/runs/34436462958)
and exact-head Greptile review at 5/5. Required CODEOWNER review
prevented its normal merge before master advanced again.

- Final extracted-module composition: 307/307 recovery, batching, queue
and Stop-control tests; 995/995 full chat integration; 49/49 module
tests including eight PostgreSQL adapter cases; and 19/19 issue-update
tests. Plain server types pass. All four actual local process/ACP
browser paths pass in 1.3 minutes. Fresh databases, no skips or retries
in these cohorts, frozen source hashes, and independent review clear.

- The preceding head `3e4e1c1c` passes [all PR CI
jobs](https://github.com/paperclipai/paperclip/actions/runs/34415826820),
including Build and required `ci / verify` and `ci / e2e`. Both the
original Rust failure and the previously load-sensitive lineage fixture
pass with unchanged Linux concurrency. Master advanced afterward and
required this reconciliation.
- Final master composition: 448/448 focused UI tests, 186/186 adapter
tests, 24/24 queue/control tests, and 11/11 packaging tests. Plain UI,
server, shared, and adapter types pass. Token gates and diff checks
pass. Independent server and UI reviews are clear.
- Stop-registration regression: both real-service cases fail against
exact `a95` source and pass with the fix. The full corrected
recovery/control suite passes 265/265. Duplicate-owner and failed-Stop
controls also pass. Plain server types pass. The readiness barrier
prevents provider startup without adding an acknowledgment to an already
terminal run.
- Final qualification strengthens terminal-field equality and repeats
both affected cases successfully on a fresh database. All four actual
local process/ACP browser paths pass again in 1.3 minutes, without skips
or retries. The final screenshot shows Cancelled, a paused subtree,
retained input, and no error toast.
- Two new actual-service regressions fail before the merge fix. They
prove that queued-comment adoption could consume a dedicated chat answer
or add unrelated input to that answer. The fixed four-case cohort
passes, including ordinary upstream continuation and adapter Stop
controls. Full recovery passes 257/257. All four actual local
process/ACP Stop browser flows pass in 1.4 minutes, without skips or
retries, on a fresh database.
- The unchanged runner artifact was qualified with 171/171 transport
tests, 870/870 API-authority tests, conformance 1/1, and replay 11/11.
Six controlled reader tests prove the exit/drain repair. Its local
serial Rust workspace passed 546 top-level cases plus two invoked
helpers; the later passing Linux CI supplies default-concurrency
evidence.
- Prior exact-source full chat integration passes 995/995. Settings
regressions cover concurrent stale pages, 501 destinations, pending
state, rejected updates, and explicit retry. These deterministic tests
do not prove live provider behavior.
- Retained failed attempts and their causes are in the [qualification
log](https://github.com/paperclipai/paperclip/blob/afe19299d06253cb628eb398e91d1200ea9f412a/doc/plans/chat-adapters/2026-09-08-chat-queue-and-webhook-repair.md).
The first merge adapter run timed out while macOS slept for 290 seconds.
Its unchanged repeat passed with a temporary sleep guard. No assertion,
deadline, or CI gate was weakened.

Review commands include `pnpm --filter @paperclipai/server exec vitest
run src/__tests__/heartbeat-process-recovery.test.ts
src/__tests__/issue-queued-comments-routes.test.ts` and `pnpm exec
playwright test --config tests/e2e/playwright.config.ts
tests/e2e/acp-stop-continuation.spec.ts`. Database suites require fresh
disposable databases. See the [browser
runbook](https://github.com/paperclipai/paperclip/blob/afe19299d06253cb628eb398e91d1200ea9f412a/doc/plans/chat-adapters/2026-09-04-chat-adapters-browser-e2e-runbook.md)
for provider setup and separate live acceptance steps.

## Risks

- This remains experimental. Deterministic tests and bounded live
evidence do not establish every provider feature, tenant, permission
layout, or media shape. Teams work-tenant qualification is still open.
- Failed and uncertain provider effects remain visible and can require
operator action. A transport receipt does not prove recipient
visibility.
- Native controller and runner artifacts must remain compatible.
Preserve lease ownership, terminal authority, source binding, and
quarantine during future changes.
- Access and audit rows commit together, but activity notifications
remain best-effort. This is not a new durable event outbox.
- The PR operation does not deploy a live server, replace its runner, or
change provider permissions. Remaining live qualification is documented
in the [temporary
handoff](https://github.com/paperclipai/paperclip/blob/afe19299d06253cb628eb398e91d1200ea9f412a/doc/plans/chat-adapters/2026-09-08-open-qualification-followups.md).

## Model Used

OpenAI Codex assisted with implementation, tool execution, testing, and
review. The work records `gpt-6-astra` assistance. The environment does
not report a context-window size. No private reasoning traces are
included.

## 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
- [x] All Paperclip CI gates are green
- [x] 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-09-10 10:06:45 -05:00

1575 lines
49 KiB
JavaScript

import fs from "node:fs";
import path from "node:path";
const root = process.cwd();
const corpus =
process.env.PAPERCLIP_CONTENT_TEMPLATES ??
path.resolve(
root,
"../../paperclip-content/research/connections/vercel/templates",
);
const out = path.join(root, "packages/shared/src/app-definitions");
const brandingManifest = JSON.parse(
fs.readFileSync(
path.join(root, "ui/public/brands/apps/manifest.json"),
"utf8",
),
);
const brandingBySlug = new Map(
brandingManifest.providers.map((entry) => [entry.slug, entry]),
);
const brandingFor = (slug) => {
const entry = brandingBySlug.get(slug);
if (entry)
return {
logoUrl: entry.localAsset,
...(entry.darkAsset ? { darkLogoUrl: entry.darkAsset } : {}),
};
if (slug === "oauth-generic" || slug === "api-key-generic")
return { logoUrl: `/brands/apps/${slug}.svg` };
throw new Error(`${slug}: missing local branding provenance`);
};
const field = (key, label, placeholder) => ({
key,
label,
type: "password",
required: true,
placeholder,
secret: true,
});
const method = (
key,
transport,
auth,
defaults,
riskTier,
guidanceMd,
extra = {},
) => ({
key,
transport,
auth,
ownershipModes: auth === "oauth" ? ["customer", "dcr"] : ["customer"],
whenToUse:
transport === "mcp_remote"
? "Use the provider-hosted connection for the quickest setup."
: "Use credentials from your provider account.",
defaults,
guidanceMd,
riskTier,
...extra,
});
const chatProviderName = (provider) =>
({
discord: "Discord",
github: "GitHub",
"microsoft-teams": "Microsoft Teams",
slack: "Slack",
telegram: "Telegram",
})[provider];
const channelMethod = (
provider,
credentialFields,
requiredResourceFilters,
guidanceMd,
consoleLinks,
) => ({
key: "chat-agent",
label: "Chat with an agent",
purpose: "channel",
provider,
transport: "chat_sdk",
auth: "api_key",
ownershipModes: ["customer"],
whenToUse: `Let people in ${chatProviderName(provider)} start and continue work with one Paperclip agent.`,
credentialFields,
guidanceMd,
consoleLinks,
riskTier: "S3",
requiredResourceFilters,
});
const vercelConnect = (
serviceOrServices,
principalMode,
scopes,
header = { name: "Authorization", prefix: "Bearer " },
) => ({
credentialSources: {
vercelConnect: {
services: Array.isArray(serviceOrServices)
? serviceOrServices
: [serviceOrServices],
principalModes: [principalMode],
scopes,
header,
},
},
});
const posthogConfigFields = () => [
{
key: "projectId",
label: "Pin to project ID",
type: "text",
advanced: true,
placeholder: "Optional numeric project ID",
helperMd:
"Optional. Pin this connection to one project and remove PostHog's project-switching tool.",
validation: { pattern: "^[0-9]+$", maxLength: 32 },
transport: { location: "header", name: "x-posthog-project-id" },
},
{
key: "readOnly",
label: "Read-only mode",
type: "checkbox",
advanced: true,
defaultValue: false,
helperMd: "Turn on to hide tools that can change PostHog data.",
transport: {
location: "query",
name: "readonly",
format: "boolean",
omitFalse: true,
},
},
{
key: "features",
label: "Feature groups",
type: "textarea",
advanced: true,
placeholder: "Optional comma-separated feature groups",
helperMd:
"Leave blank to expose every feature group, or enter a comma-separated list to narrow access.",
validation: { maxLength: 500 },
transport: { location: "query", name: "features", format: "csv" },
},
{
key: "tools",
label: "Individual tools",
type: "textarea",
advanced: true,
placeholder: "Optional comma-separated tool names",
helperMd:
"Leave blank to expose all tools. Exact names here are combined with any feature groups.",
validation: { maxLength: 2000 },
transport: { location: "query", name: "tools", format: "csv" },
},
{
key: "mode",
label: "Tool response mode",
type: "select",
hidden: true,
required: true,
placeholder: "Individual tools",
defaultValue: "tools",
options: [{ value: "tools", label: "Individual tools" }],
helperMd:
"Paperclip uses individual tools so every action can be governed. CLI mode remains unavailable until nested execution is governed.",
transport: { location: "query", name: "mode" },
},
];
const posthogMethod = (key, auth, extra = {}) =>
method(
key,
"mcp_remote",
auth,
{ serverUrl: "https://mcp.posthog.com/mcp" },
"S3",
"Connect with PostHog's recommended defaults. Project pinning, read-only access, and catalog filters are optional advanced controls.",
{ tenantFields: posthogConfigFields(), ...extra },
);
const apps = [
[
"zapier",
"Zapier",
"Reach thousands of apps through your Zapier account.",
"productivity",
"zapier.com",
["https://mcp.zapier.com/*"],
method(
"generated-url",
"mcp_remote",
"none",
{},
"S3",
"Create a Zapier MCP server, then paste the complete generated connection URL. The token remains embedded in that URL.",
{
label: "Paste generated MCP URL",
whenToUse: "Use the complete provider-generated MCP URL from Zapier.",
},
),
],
[
"github",
"GitHub",
"Give agents repository tools or let people work with an agent from GitHub issues and pull requests.",
"developer",
"github.com",
["https://api.githubcopilot.com/mcp/*", "https://github.com/*"],
[
method(
"managed",
"mcp_remote",
"oauth",
{ serverUrl: "https://api.githubcopilot.com/mcp/" },
"S3",
"Authorize Paperclip, then choose selected repositories in GitHub. You can edit repository access later from GitHub's installation settings.",
{
label: "Use this connection as an agent tool",
purpose: "tool",
oauthStrategy: "paperclip_cloud_connector",
connectorProfile: "github.code",
grantKinds: ["user", "agent"],
ownershipModes: ["platform_shared"],
whenToUse:
"Connect your GitHub account for durable MCP, shell Git, gh, and repository access.",
warnings: [
"Shell Git and gh receive this identity for the run and are not constrained by per-tool Ask-first controls.",
],
requiredResourceFilters: ["organization", "repository"],
},
),
method(
"mcp-key",
"mcp_remote",
"api_key",
{ serverUrl: "https://api.githubcopilot.com/mcp/" },
"S3",
"Create a fine-grained token limited to the repositories agents should use.",
{
label: "Personal access token (advanced)",
purpose: "tool",
credentialFields: [
field("authorization", "GitHub token", "github_pat_..."),
],
keyPlacement: {
location: "header",
name: "Authorization",
prefix: "Bearer ",
},
requiredResourceFilters: ["organization", "repository"],
},
),
channelMethod(
"github",
[
{
...field("appId", "GitHub App ID", "123456"),
type: "text",
secret: false,
},
{
...field(
"privateKey",
"Private key (PEM)",
"-----BEGIN RSA PRIVATE KEY-----",
),
type: "textarea",
},
],
["organization", "repository"],
"Generate the webhook secret in Paperclip, then create one private GitHub App with active SSL-verified webhooks, Issues and Pull requests read/write permission, and the selectable issue_comment and pull_request_review_comment events. GitHub sends installation and installation_repositories automatically. Install the App only on repositories where people may mention the agent.",
{
register: "https://github.com/settings/apps/new",
docs: "https://docs.github.com/en/apps/creating-github-apps/registering-a-github-app/registering-a-github-app",
},
),
],
],
[
"slack",
"Slack",
"Give agents Slack tools or let people start and continue Paperclip work from Slack.",
"communication",
"slack.com",
["https://mcp.slack.com/*", "https://app.slack.com/client/*"],
[
method(
"mcp-oauth",
"mcp_remote",
"oauth",
{
serverUrl: "https://mcp.slack.com/mcp",
authorizationEndpoint: "https://slack.com/oauth/v2/authorize",
tokenEndpoint: "https://slack.com/api/oauth.v2.access",
scopesHint: ["channels:read", "chat:write", "search:read"],
},
"S3",
"Connect a Slack workspace and limit access to the channels agents need.",
{
label: "Use this connection as an agent tool",
purpose: "tool",
ownershipModes: ["customer"],
requiredResourceFilters: ["workspace", "channel"],
},
),
channelMethod(
"slack",
[
field("botToken", "Bot User OAuth Token", "xoxb-..."),
field(
"signingSecret",
"Signing Secret",
"Paste the Slack App signing secret",
),
],
["workspace", "channel"],
"Create and install one Slack App for this agent. Paperclip receives verified Events API requests and interactive callbacks, acknowledges with reactions, responds in direct messages, and starts one Paperclip task per new mentioned channel thread.",
{
register: "https://api.slack.com/apps",
docs: "https://api.slack.com/start/quickstart",
},
),
],
],
[
"microsoft-teams",
"Microsoft Teams",
"Let people start and continue Paperclip work with an agent from Microsoft Teams.",
"communication",
"teams.microsoft.com",
["https://teams.microsoft.com/*"],
channelMethod(
"microsoft-teams",
[
{
...field(
"clientId",
"Application / Client ID",
"00000000-0000-0000-0000-000000000000",
),
type: "text",
secret: false,
},
{
...field(
"tenantId",
"Directory / Tenant ID",
"00000000-0000-0000-0000-000000000000",
),
type: "text",
secret: false,
},
field("clientSecret", "Client secret", "Paste the client-secret value"),
],
["team", "channel", "chat"],
"Use a Microsoft 365 work or school organization where you can register an Entra app, create a single-tenant Azure Bot, and upload or install a Teams app. Personal or free Teams accounts at teams.live.com cannot complete this setup. Enable personal, team, and groupChat bot scopes and the ChannelMessage.Read.Group and ChatMessage.Read.Chat resource-specific application permissions. Those RSC grants let an installed app receive every message in a team or group chat without an @mention, so explain that access to installers. One team install covers its standard channels; private and shared channels require a separate installation and are not supported by this release.",
{
register: "https://dev.teams.microsoft.com/apps",
docs: "https://learn.microsoft.com/en-us/microsoftteams/platform/bots/how-to/create-a-bot-for-teams",
},
),
],
[
"telegram",
"Telegram",
"Let people start and continue Paperclip work with an agent from Telegram.",
"communication",
"telegram.org",
["https://t.me/*", "https://telegram.me/*", "https://api.telegram.org/*"],
channelMethod(
"telegram",
[field("botToken", "Bot token", "123456789:AA...")],
["chat", "group", "topic"],
"Create one dedicated bot with BotFather, then connect its token to the public Paperclip webhook endpoint.",
{
register: "https://t.me/BotFather",
docs: "https://core.telegram.org/bots/tutorial",
},
),
],
[
"discord",
"Discord",
"Let people start and continue Paperclip work with an agent from Discord.",
"communication",
"discord.com",
["https://discord.com/*"],
channelMethod(
"discord",
[
field("botToken", "Bot token", "Paste the Discord bot token"),
{
...field("applicationId", "Application ID", "123456789012345678"),
type: "text",
secret: false,
},
{
...field("guildId", "Server ID", "123456789012345678"),
type: "text",
secret: false,
},
],
["channel"],
"Create one dedicated Discord application and bot, enable the Message Content intent, install it in one server with the documented bot permissions, then connect its bot token, Application ID, and server ID. Paperclip starts one Discord thread per root bot mention and keeps the linked Paperclip task authoritative.",
{
register: "https://discord.com/developers/applications",
docs: "https://discord.com/developers/docs/quick-start/getting-started",
},
),
],
[
"notion",
"Notion",
"Read and update pages in your Notion workspace.",
"content",
"notion.so",
["https://mcp.notion.com/*"],
method(
"mcp-oauth",
"mcp_remote",
"oauth",
{ serverUrl: "https://mcp.notion.com/mcp" },
"S3",
"Connect Notion for workspace content. Share only the pages and databases agents should use.",
{
requiredResourceFilters: ["workspace", "page", "database"],
...vercelConnect("notion", "user", ["*"]),
},
),
{ redirectConstraints: "https-or-loopback-http" },
],
[
"posthog",
"PostHog",
"Analyze product usage, errors, feature flags, and experiments with PostHog's hosted MCP server.",
"analytics",
"posthog.com",
["https://mcp.posthog.com/*"],
[
posthogMethod("mcp-oauth", "oauth", {
label: "Sign in with PostHog",
ownershipModes: ["customer", "dcr"],
whenToUse:
"Sign in with PostHog in the browser. Recommended for hosted PostHog accounts.",
consoleLinks: {
docs: "https://posthog.com/docs/model-context-protocol",
},
...vercelConnect(["posthog", "mcp.posthog.com/mcp"], "user", ["*"]),
}),
posthogMethod("mcp-api-key", "api_key", {
label: "Use a personal API key",
whenToUse:
"Use a PostHog personal API key when browser sign-in is not suitable.",
credentialFields: [
field("authorization", "PostHog personal API key", "phx_..."),
],
keyPlacement: {
location: "header",
name: "Authorization",
prefix: "Bearer ",
},
consoleLinks: {
keys: "https://posthog.com/docs/model-context-protocol/faq",
docs: "https://posthog.com/docs/model-context-protocol/faq",
},
...vercelConnect(["posthog", "mcp.posthog.com/mcp"], "app", ["*"]),
}),
],
{ featured: true },
],
[
"linear",
"Linear",
"Create, update, and read Linear issues.",
"productivity",
"linear.app",
["https://mcp.linear.app/*"],
method(
"mcp-oauth",
"mcp_remote",
"oauth",
{
serverUrl: "https://mcp.linear.app/mcp",
authorizationEndpoint: "https://linear.app/oauth/authorize",
tokenEndpoint: "https://api.linear.app/oauth/token",
scopesHint: ["read", "write"],
},
"S2",
"Register a Linear OAuth app and add Paperclip's redirect URI before connecting.",
{
ownershipModes: ["customer"],
requiredResourceFilters: ["workspace", "team", "project"],
...vercelConnect("linear", "user", ["read", "write"]),
},
),
],
[
"google-sheets",
"Google Sheets",
"Read and update selected spreadsheets.",
"data",
"sheets.google.com",
["https://docs.google.com/spreadsheets/*", "https://sheets.google.com/*"],
method(
"local",
"local_stdio",
"none",
{ templateKey: "paperclip.google-sheets" },
"S3",
"Share each spreadsheet with the Paperclip robot email, then paste the sheet links.",
{ requiredResourceFilters: ["spreadsheet"] },
),
],
[
"context7",
"Context7",
"Look up current documentation for software libraries.",
"developer",
"context7.com",
["https://mcp.context7.com/*"],
method(
"mcp",
"mcp_remote",
"none",
{ serverUrl: "https://mcp.context7.com/mcp" },
"S1",
"Connect Context7 to give agents current library documentation.",
),
],
[
"shopify",
"Shopify",
"Search a store's products and policies, and manage shopping carts.",
"commerce",
"shopify.com",
["https://*.myshopify.com/api/ucp/mcp", "https://*.myshopify.com/api/mcp"],
[
method(
"ucp-commerce",
"mcp_remote",
"none",
{
serverUrlTemplate: "https://{storeDomain}/api/ucp/mcp",
toolArgumentDefaults: {
meta: {
"ucp-agent": {
profile:
"https://shopify.dev/ucp/agent-profiles/examples/2026-04-08/valid-with-capabilities.json",
},
},
},
},
"S3",
"Connect Shopify's current UCP server for shopper-facing catalog and commerce tools. Paperclip supplies the required agent profile automatically.",
{
label: "Shopify UCP commerce",
whenToUse:
"Recommended for Shopify's current UCP catalog, cart, and checkout tools.",
tenantFields: [
{
key: "storeDomain",
label: "Store domain",
type: "text",
required: true,
placeholder: "your-store.myshopify.com",
helperMd:
"Enter the permanent myshopify.com domain without https://. Custom storefront domains are not the MCP endpoint.",
validation: {
pattern: "^[A-Za-z0-9][A-Za-z0-9-]*\\.myshopify\\.com$",
maxLength: 255,
},
},
],
consoleLinks: {
docs: "https://shopify.dev/docs/agents/catalog/storefront-catalog",
},
warnings: [
"This is Shopify's shopper-facing UCP server, not Admin API access. It does not manage merchant products or customers.",
"The storefront must be public. A private or password-protected storefront returns HTTP 401 even when the merchant is signed in to Shopify Admin.",
"Paperclip currently uses Shopify's documented hosted agent-profile fixture while Paperclip's production UCP profile is being established.",
],
requiredResourceFilters: ["store"],
},
),
method(
"storefront-mcp",
"mcp_remote",
"none",
{ serverUrlTemplate: "https://{storeDomain}/api/mcp" },
"S3",
"Connect Shopify's official Storefront MCP server for shopper-facing catalog, policy, and cart tools.",
{
label: "Storefront policies and compatibility tools",
whenToUse:
"Use Shopify's compatibility server when agents need storefront policy and FAQ search.",
tenantFields: [
{
key: "storeDomain",
label: "Store domain",
type: "text",
required: true,
placeholder: "your-store.myshopify.com",
helperMd:
"Enter the permanent myshopify.com domain without https://. Custom storefront domains are not the MCP endpoint.",
validation: {
pattern: "^[A-Za-z0-9][A-Za-z0-9-]*\\.myshopify\\.com$",
maxLength: 255,
},
},
],
consoleLinks: {
docs: "https://shopify.dev/docs/apps/build/storefront-mcp/servers/storefront",
},
warnings: [
"This is Shopify's Storefront MCP, not Admin API access. It does not manage merchant products, orders, or customers.",
"The storefront must be public. A private or password-protected storefront returns HTTP 401 even when the merchant is signed in to Shopify Admin.",
],
requiredResourceFilters: ["store"],
},
),
],
{
docsUrl:
"https://shopify.dev/docs/apps/build/storefront-mcp/servers/storefront",
setupPrerequisite: {
title: "Launch the storefront before connecting",
description:
"Shopify's Storefront MCP is a public, no-auth endpoint. Paperclip cannot use the merchant's Shopify Admin session to bypass a private storefront.",
steps: [
"Select a Shopify plan; Shopify keeps trial storefronts private until a plan is selected.",
"In Shopify Admin, open Online Store → Preferences and set Storefront visibility to Public (remove password protection).",
"Use the permanent <store>.myshopify.com domain in Paperclip, even if the store also has a custom domain.",
],
actionLabel: "Open Shopify Admin",
actionUrl: "https://admin.shopify.com/",
},
},
],
[
"composio",
"Composio",
"Connect Composio so Paperclip can discover and manage the toolkits in your project.",
"productivity",
"composio.dev",
["https://backend.composio.dev/*"],
method(
"api-key",
"rest_api",
"api_key",
{ serviceHost: "backend.composio.dev" },
"S3",
"Create a scoped project API key in Composio. It needs read access to toolkits and auth configs; later service-connection phases also need connected-account and session access.",
{
whenToUse:
"Use a project API key from the Composio project that owns the toolkits and connected accounts.",
credentialFields: [
field(
"apiKey",
"Composio project API key",
"Paste the Composio API key",
),
],
keyPlacement: { location: "header", name: "x-api-key" },
consoleLinks: {
keys: "https://app.composio.dev/",
settings: "https://app.composio.dev/",
docs: "https://docs.composio.dev/reference/authenticating-to-composio/project-api-key-permissions",
},
},
),
{ featured: true },
],
[
"oauth-generic",
"OAuth app",
"Connect a provider using your own OAuth client.",
"other",
"oauth.net",
[],
method(
"oauth",
"rest_api",
"oauth",
{},
"S3",
"Register an OAuth client with the provider and add Paperclip's redirect URI.",
{
credentialFields: [
{
...field("clientId", "Client ID", "Paste the client ID"),
type: "text",
secret: false,
},
field("clientSecret", "Client secret", "Paste the client secret"),
],
},
),
],
[
"api-key-generic",
"API key app",
"Connect an API using a key from your provider.",
"other",
"openapis.org",
[],
method(
"api-key",
"rest_api",
"api_key",
{},
"S3",
"Create a restricted API key and paste it here.",
{
credentialFields: [field("apiKey", "API key", "Paste the API key")],
keyPlacement: {
location: "header",
name: "Authorization",
prefix: "Bearer ",
},
},
),
],
[
"sentry",
"Sentry",
"Investigate errors, releases, and production issues.",
"developer",
"sentry.io",
["https://mcp.sentry.dev/*"],
method(
"mcp-oauth",
"mcp_remote",
"oauth",
{
serverUrl: "https://mcp.sentry.dev/mcp",
discoveryUrl:
"https://sentry.io/.well-known/oauth-authorization-server",
},
"S2",
"Connect the Sentry organization and projects agents need for incident work.",
{ requiredResourceFilters: ["organization", "project", "environment"] },
),
],
[
"vercel",
"Vercel",
"Inspect projects, deployments, and runtime logs.",
"developer",
"vercel.com",
["https://mcp.vercel.com/*"],
method(
"mcp-oauth",
"mcp_remote",
"oauth",
{ serverUrl: "https://mcp.vercel.com/mcp" },
"S3",
"Connect the Vercel team and projects agents should operate.",
{ requiredResourceFilters: ["team", "project", "environment"] },
),
],
[
"anthropic",
"Anthropic",
"Use Anthropic APIs with a restricted key.",
"ai",
"anthropic.com",
["https://api.anthropic.com/*"],
method(
"api-key",
"rest_api",
"api_key",
{ serviceHost: "api.anthropic.com" },
"S3",
"Create a key in the Anthropic Console and rotate it if it has been exposed.",
{
credentialFields: [field("apiKey", "API key", "sk-ant-api03-...")],
keyPlacement: { location: "header", name: "x-api-key" },
},
),
],
].map(
([
slug,
name,
description,
category,
_domain,
urlPatterns,
m,
extra = {},
]) => ({
schemaVersion: 1,
slug,
name,
description,
categories: [category],
featured: [
"zapier",
"github",
"slack",
"notion",
"posthog",
"linear",
].includes(slug),
branding: brandingFor(slug),
urlPatterns,
methods: Array.isArray(m) ? m : [m],
...extra,
}),
);
apps.push({
schemaVersion: 1,
slug: "gmail",
name: "Gmail",
description:
"Search and read Gmail messages and create drafts without enabling mail sending.",
categories: ["communication", "productivity"],
featured: true,
branding: brandingFor("gmail"),
urlPatterns: ["https://gmailmcp.googleapis.com/*"],
docsUrl:
"https://developers.google.com/workspace/guides/configure-mcp-servers",
redirectConstraints: "https-or-loopback-http",
methods: [
{
key: "paperclip-id-oauth",
label: "Connect Gmail",
transport: "mcp_remote",
auth: "oauth",
oauthStrategy: "paperclip_id_connector",
grantKinds: ["user"],
ownershipModes: ["customer"],
whenToUse:
"Use Paperclip ID for a personal Gmail connection with centrally registered Google OAuth.",
defaults: {
serverUrl: "https://gmailmcp.googleapis.com/mcp/v1",
scopesHint: [
"https://www.googleapis.com/auth/gmail.readonly",
"https://www.googleapis.com/auth/gmail.compose",
],
},
guidanceMd:
"Connect your Gmail identity. Paperclip can search and read mail and create drafts. Sending mail is not enabled.",
warnings: [
"This connection is personal. Agents need an explicit install, profile, and delegation before they can use it.",
],
riskTier: "S3",
},
],
});
// The reviewed MCP program is a durable input, not another hand-maintained
// allowlist. Runtime definitions are generated from the same 46-row evidence
// ledger that the tests and implementation checklist validate.
const researchManifest = JSON.parse(
fs.readFileSync(
path.join(root, "packages/shared/src/self-serve-mcp-research.json"),
"utf8",
),
);
const categoryBySlug = {
airtable: "data",
asana: "productivity",
beehiiv: "content",
bitly: "analytics",
box: "content",
brex: "commerce",
candid: "data",
clickhouse: "data",
cloudflare: "developer",
cloudinary: "content",
coda: "productivity",
egnyte: "content",
embat: "commerce",
"hugging-face": "ai",
jira: "productivity",
kernel: "developer",
"local-falcon": "analytics",
make: "productivity",
manufact: "productivity",
mem0: "ai",
miro: "productivity",
mixpanel: "analytics",
netlify: "developer",
notion: "content",
oreilly: "content",
pagerduty: "developer",
planetscale: "data",
posthog: "analytics",
postman: "developer",
razorpay: "commerce",
resend: "communication",
sanity: "content",
sentry: "developer",
similarweb: "analytics",
stripe: "commerce",
supabase: "data",
"ticket-tailor": "commerce",
ticktick: "productivity",
todoist: "productivity",
webflow: "content",
wix: "content",
xero: "commerce",
zapier: "productivity",
};
const oauthMethodFor = (
entry,
key = "mcp-oauth",
serverUrl = entry.serverUrl,
extra = {},
) =>
method(
key,
"mcp_remote",
"oauth",
{ serverUrl },
entry.riskTier,
`Connect ${entry.name} in the browser. ${entry.prerequisite}`,
{
label: `Sign in with ${entry.name}`,
ownershipModes: ["dcr"],
whenToUse: "Use browser sign-in for the provider-hosted MCP server.",
consoleLinks: { docs: entry.docsUrl },
warnings: [entry.prerequisite],
...extra,
},
);
const customerOAuthMethodFor = (entry) =>
oauthMethodFor(entry, "mcp-own-oauth", entry.serverUrl, {
label: "Use your own OAuth app",
ownershipModes: ["customer"],
whenToUse: `Register an OAuth app with ${entry.name}, then enter its client ID and secret.`,
consoleLinks: { register: entry.docsUrl, docs: entry.docsUrl },
});
const apiKeySpec = {
bitly: {
name: "Authorization",
prefix: "Bearer ",
placeholder: "Paste your Bitly API token",
},
cloudflare: {
name: "Authorization",
prefix: "Bearer ",
placeholder: "Paste your Cloudflare API token",
},
coda: {
name: "Authorization",
prefix: "Bearer ",
placeholder: "Paste your Coda API token",
},
kernel: {
name: "X-API-Key",
prefix: null,
placeholder: "Paste your Kernel API key",
},
mem0: { name: "Authorization", prefix: "Bearer ", placeholder: "m0sk_..." },
oreilly: {
name: "Authorization",
prefix: "Bearer ",
placeholder: "Paste your O'Reilly API token",
},
pagerduty: {
name: "Authorization",
prefix: "Token token=",
placeholder: "Paste your PagerDuty user API token",
},
// Postman's general REST API examples use X-API-Key, but its hosted MCP
// server explicitly expects the key as an Authorization bearer token.
postman: {
name: "Authorization",
prefix: "Bearer ",
placeholder: "PMAK-...",
},
razorpay: {
name: "Authorization",
prefix: "Basic ",
placeholder: "Paste the base64-encoded key ID and secret",
},
sanity: { name: "Authorization", prefix: "Bearer ", placeholder: "sk..." },
similarweb: {
name: "api-key",
prefix: null,
placeholder: "Paste your Similarweb API key",
},
stripe: { name: "Authorization", prefix: "Bearer ", placeholder: "sk_..." },
supabase: {
name: "Authorization",
prefix: "Bearer ",
placeholder: "sbp_...",
},
};
const apiKeyMethodFor = (
entry,
key = "mcp-api-key",
serverUrl = entry.serverUrl,
extra = {},
) => {
const spec = apiKeySpec[entry.slug] ?? {
name: "Authorization",
prefix: "Bearer ",
placeholder: `Paste your ${entry.name} API key`,
};
return method(
key,
"mcp_remote",
"api_key",
{ serverUrl },
entry.riskTier,
`Use a customer-created ${entry.name} key. ${entry.prerequisite}`,
{
label: "Use an API key",
whenToUse:
"Use a restricted customer-owned key when browser sign-in is not suitable.",
credentialFields: [
field("authorization", `${entry.name} API key`, spec.placeholder),
],
keyPlacement: {
location: "header",
name: spec.name,
prefix: spec.prefix,
},
consoleLinks: { keys: entry.docsUrl, docs: entry.docsUrl },
warnings: [entry.prerequisite],
...extra,
},
);
};
const specialMethodsFor = (entry) => {
// Atlassian's /authv2 rollout only issues GA-tool-compatible tokens when the
// authorization request includes this reviewed protected-resource scope set.
// Omitting scope currently yields agent-interface scopes that its own Jira
// tools reject with HTTP 401. Users can still deselect write toolsets in the
// provider consent screen; never replace this allowlist with live discovery.
if (entry.slug === "jira")
return [
oauthMethodFor(entry, "mcp-oauth", entry.serverUrl, {
defaults: {
serverUrl: entry.serverUrl,
scopesHint: [
"read:me",
"read:account",
"offline_access",
"email",
"read:jira-work",
"write:jira-work",
"search:confluence",
"read:confluence-user",
"read:page:confluence",
"write:page:confluence",
"read:comment:confluence",
"write:comment:confluence",
"read:space:confluence",
"read:hierarchical-content:confluence",
"write:component:compass",
"read:component:compass",
"read:scorecard:compass",
"write:scorecard:compass",
"read:event:compass",
"read:metric:compass",
"read:all:twg",
"write:all:twg",
],
},
}),
];
if (entry.slug === "hugging-face")
return [
oauthMethodFor(entry, "mcp-oauth", entry.serverUrl, {
defaults: { serverUrl: entry.serverUrl, scopesHint: ["read-mcp"] },
}),
];
if (entry.slug === "xero")
return [
oauthMethodFor(entry, "mcp-own-oauth", entry.serverUrl, {
label: "Use your own OAuth app",
ownershipModes: ["customer"],
whenToUse: `Register an OAuth app with ${entry.name}, then enter its client ID and secret.`,
consoleLinks: { register: entry.docsUrl, docs: entry.docsUrl },
defaults: {
serverUrl: entry.serverUrl,
scopesHint: [
"openid",
"profile",
"email",
"offline_access",
"accounting.settings",
"accounting.invoices.read",
"accounting.reports.aged.read",
"accounting.reports.balancesheet.read",
"accounting.reports.profitandloss.read",
],
},
}),
];
if (entry.slug === "clickhouse")
return [
oauthMethodFor(entry, "mcp-oauth", entry.serverUrl, {
tenantFields: [
{
key: "serviceId",
label: "ClickHouse Cloud service ID",
type: "text",
required: true,
placeholder: "11e1031f-9a13-4cac-9bc7-d4ec9286ec17",
helperMd:
"Copy the service ID from ClickStack → Team Settings → API & Agents.",
transport: { location: "header", name: "x-service-id" },
},
],
requiredResourceFilters: ["service"],
}),
];
if (entry.slug === "planetscale")
return [
oauthMethodFor(entry, "mcp-oauth", entry.serverUrl, {
label: "Database access",
tenantFields: [
{
key: "project",
label: "Project or database",
type: "text",
advanced: true,
placeholder: "Optional project or database name",
helperMd:
"Records the intended database boundary; final access is selected during PlanetScale authorization.",
},
{
key: "branch",
label: "Branch",
type: "text",
advanced: true,
placeholder: "Optional branch name",
helperMd:
"Records the intended branch boundary; final access is selected during PlanetScale authorization.",
},
],
requiredResourceFilters: ["organization", "database", "branch"],
}),
oauthMethodFor(
entry,
"mcp-insights-only",
"https://mcp.pscale.dev/mcp/planetscale-insights-only",
{
label: "Insights only",
whenToUse:
"Use query insights and schema recommendations without query execution tools.",
requiredResourceFilters: ["organization", "database", "branch"],
},
),
];
if (entry.slug === "postman")
return [
oauthMethodFor(
entry,
"mcp-oauth-minimal",
"https://mcp.postman.com/minimal",
{
label: "US · Browser sign-in",
capabilityProfile: {
key: "minimal",
label: "Minimal",
description:
"Essential workspace, collection, and environment tools with the smallest tool catalog.",
},
},
),
oauthMethodFor(entry, "mcp-oauth-code", "https://mcp.postman.com/code", {
label: "US · Browser sign-in",
capabilityProfile: {
key: "code",
label: "Code",
description: "Tools for generating client code from API definitions.",
},
}),
oauthMethodFor(entry, "mcp-oauth-full", "https://mcp.postman.com/mcp", {
label: "US · Browser sign-in",
capabilityProfile: {
key: "write",
label: "Full",
description:
"All Postman API tools, including write-capable collaboration and advanced features.",
},
}),
apiKeyMethodFor(
entry,
"mcp-eu-key-minimal",
"https://mcp.eu.postman.com/minimal",
{
label: "EU · API key",
capabilityProfile: {
key: "minimal",
label: "Minimal",
description:
"Essential workspace, collection, and environment tools with the smallest tool catalog.",
},
},
),
apiKeyMethodFor(
entry,
"mcp-eu-key-code",
"https://mcp.eu.postman.com/code",
{
label: "EU · API key",
capabilityProfile: {
key: "code",
label: "Code",
description:
"Tools for generating client code from API definitions.",
},
},
),
apiKeyMethodFor(
entry,
"mcp-eu-key-full",
"https://mcp.eu.postman.com/mcp",
{
label: "EU · API key",
capabilityProfile: {
key: "write",
label: "Full",
description:
"All Postman API tools, including write-capable collaboration and advanced features.",
},
},
),
];
if (entry.slug === "pagerduty")
return [
apiKeyMethodFor(
entry,
"mcp-api-key-us",
"https://mcp.pagerduty.com/mcp",
{ label: "US service region" },
),
apiKeyMethodFor(
entry,
"mcp-api-key-eu",
"https://mcp.eu.pagerduty.com/mcp",
{ label: "EU service region" },
),
];
if (entry.slug === "supabase") {
const tenantFields = [
{
key: "projectRef",
label: "Project reference",
type: "text",
required: true,
placeholder: "abcdefghijklmnopqrst",
helperMd: "Scope the connection to one development project.",
transport: { location: "query", name: "project_ref" },
},
{
key: "readOnly",
label: "Read-only mode",
type: "checkbox",
defaultValue: false,
helperMd:
"Enable this to prevent the connection from changing the database.",
transport: { location: "query", name: "read_only", format: "boolean" },
},
{
key: "features",
label: "Feature groups",
type: "textarea",
advanced: true,
placeholder: "database,docs",
helperMd: "Optional comma-separated feature groups.",
transport: { location: "query", name: "features", format: "csv" },
},
];
const warning =
"Do not connect production data unless you have reviewed Supabase's MCP security guidance.";
return [
oauthMethodFor(entry, "mcp-oauth", entry.serverUrl, {
guidanceMd:
"Connect Supabase in the browser and scope the connection to one development project. Write tools start enabled and remain governed by Paperclip's action policies.",
tenantFields,
warnings: [entry.prerequisite, warning],
requiredResourceFilters: ["project"],
}),
apiKeyMethodFor(entry, "mcp-api-key", entry.serverUrl, {
guidanceMd:
"Use a customer-created Supabase key scoped to one development project. Write tools start enabled and remain governed by Paperclip's action policies.",
tenantFields,
warnings: [entry.prerequisite, warning],
requiredResourceFilters: ["project"],
}),
];
}
return null;
};
for (const entry of researchManifest.entries) {
const existing = apps.find((app) => app.slug === entry.slug);
if (entry.status === "blocked") {
if (existing)
existing.availability = { available: false, reason: entry.prerequisite };
continue;
}
if (existing) {
existing.docsUrl = entry.docsUrl;
existing.redirectConstraints = existing.methods.some(
(entryMethod) => entryMethod.auth === "oauth",
)
? "https-or-loopback-http"
: existing.redirectConstraints;
if (entry.slug !== "zapier")
for (const entryMethod of existing.methods)
if (
entryMethod.transport === "mcp_remote" &&
entryMethod.defaults?.serverUrl
)
entryMethod.defaults.serverUrl = entry.serverUrl;
continue;
}
let methods = specialMethodsFor(entry);
if (!methods) {
if (entry.authMode === "customer_oauth")
methods = [customerOAuthMethodFor(entry)];
else if (entry.authMode === "api_key") methods = [apiKeyMethodFor(entry)];
else {
methods = [oauthMethodFor(entry)];
if (entry.authMode === "dcr_or_api_key")
methods.push(apiKeyMethodFor(entry));
}
}
const warnings = [];
if (["coda", "mixpanel"].includes(entry.slug))
warnings.push(
"This provider's hosted MCP server is currently beta or preview.",
);
if (["brex", "razorpay", "stripe"].includes(entry.slug))
warnings.push(
"Financial or destructive actions must be explicitly approved before execution.",
);
apps.push({
schemaVersion: 1,
slug: entry.slug,
name: entry.name,
description: `Connect ${entry.name}'s provider-hosted MCP server.`,
categories: [categoryBySlug[entry.slug] ?? "other"],
featured: entry.slug === "jira",
branding: brandingFor(entry.slug),
urlPatterns: [`${new URL(entry.serverUrl).origin}/*`],
docsUrl: entry.docsUrl,
redirectConstraints: methods.some(
(entryMethod) => entryMethod.auth === "oauth",
)
? "https-or-loopback-http"
: undefined,
methods: methods.map((entryMethod) =>
warnings.length > 0
? {
...entryMethod,
warnings: [...(entryMethod.warnings ?? []), ...warnings],
}
: entryMethod,
),
});
}
// Google Workspace definitions are reviewed, first-class app entries rather
// than rows synthesized from the generic connection corpus. Keep each product
// independent in the generated manifest while sharing only backend OAuth
// infrastructure.
const reviewedGoogleSlugs = [
"gmail",
"google-drive",
"google-docs",
"google-sheets",
"google-slides",
"google-calendar",
"google-chat",
"google-people",
"google-workspace-search",
];
for (const slug of reviewedGoogleSlugs) {
const existingIndex = apps.findIndex((app) => app.slug === slug);
if (existingIndex >= 0) apps.splice(existingIndex, 1);
apps.push(
JSON.parse(fs.readFileSync(path.join(out, `${slug}.json`), "utf8")),
);
}
const parseTableRow = (line) =>
line
.slice(1, -1)
.split("|")
.map((cell) => cell.trim());
const parseCapture = (fileName) => {
const markdown = fs.readFileSync(path.join(corpus, fileName), "utf8");
const stateMatches = [...markdown.matchAll(/^## State: (.+)$/gm)];
if (stateMatches.length === 0)
throw new Error(`${fileName}: no captured states`);
return stateMatches.map((match, index) => {
const body = markdown.slice(
match.index + match[0].length,
stateMatches[index + 1]?.index ?? markdown.length,
);
const inputsBlock =
body.match(/### Inputs\n([\s\S]*?)(?=\n### |$)/)?.[1] ?? "";
const inputRows = inputsBlock
.split("\n")
.filter((line) => line.startsWith("|"))
.slice(2)
.map(parseTableRow);
const fields = inputRows.map(
([label, tagType, required, placeholder, prefilledValue, checked]) => ({
label,
tagType,
required: required.toLowerCase() === "yes",
placeholder: placeholder || null,
prefilledValue: prefilledValue || null,
checked: checked.toLowerCase() === "true",
}),
);
const linksBlock =
body.match(/### Links\n([\s\S]*?)(?=\n## |$)/)?.[1] ?? "";
const links = linksBlock
.split("\n")
.map((line) => line.match(/^(.+?) → (https?:\/\/\S+)$/))
.filter(Boolean)
.map((link) => ({ label: link[1].trim(), href: link[2] }));
return { label: match[1].trim(), fields, links };
});
};
const inferState = (slug, state) => {
const label = state.label.toLowerCase();
const fieldText = state.fields
.map((field) => field.label.toLowerCase())
.join(" ");
const transport =
slug === "oauth-generic" ||
slug === "api-key-generic" ||
label.includes("path: api") ||
label.includes("api key form")
? "rest_api"
: "mcp_remote";
const auth =
slug === "oauth-generic" ||
label.includes("oauth") ||
fieldText.includes("client id")
? "oauth"
: slug === "api-key-generic" ||
label.includes("api key") ||
fieldText.includes("api key")
? "api_key"
: null;
const ownershipModes = [];
// A "Managed" state in Vercel describes credential custody, not ownership of
// a Paperclip connection. Keep those concepts separate: importing this review
// evidence must never silently turn an operator-owned connector into
// `platform_shared`.
const externalCredentialCustody =
label.includes("managed") && !label.includes("no managed")
? "vercel_connect"
: null;
if (
label.includes("your own credentials") ||
label.includes("manual") ||
label.includes("api key")
)
ownershipModes.push("customer");
if (slug === "oauth-generic" && !label.includes("manually"))
ownershipModes.push("dcr");
return {
label: state.label,
transport,
auth,
ownershipModes: [...new Set(ownershipModes)],
externalCredentialCustody,
fieldCount: state.fields.length,
linkCount: state.links.length,
};
};
const validateApp = (app) => {
if (
app.schemaVersion !== 1 ||
!app.slug ||
!app.name ||
!Array.isArray(app.methods) ||
app.methods.length === 0
)
throw new Error(`${app.slug || "unknown"}: invalid AppDefinition`);
for (const connectionMethod of app.methods) {
if (
connectionMethod.auth === "api_key" &&
!connectionMethod.keyPlacement &&
(connectionMethod.purpose ?? "tool") !== "channel"
)
throw new Error(
`${app.slug}/${connectionMethod.key}: tool api_key requires keyPlacement`,
);
if (
connectionMethod.auth === "oauth" &&
connectionMethod.ownershipModes.length === 0
)
throw new Error(
`${app.slug}/${connectionMethod.key}: oauth requires ownershipModes`,
);
for (const connectionField of [
...(connectionMethod.tenantFields ?? []),
...(connectionMethod.extensionFields ?? []),
...(connectionMethod.credentialFields ?? []),
])
if (
connectionField.required &&
connectionField.type !== "checkbox" &&
!connectionField.placeholder
)
throw new Error(
`${app.slug}/${connectionMethod.key}/${connectionField.key}: required field needs placeholder`,
);
}
};
const captureFiles = fs
.readdirSync(corpus)
.filter((fileName) => fileName.endsWith(".md") && fileName !== "INDEX.md")
.sort();
if (captureFiles.length !== 99)
throw new Error(`Expected 99 captures, found ${captureFiles.length}`);
const parsedCaptures = Object.fromEntries(
captureFiles.map((fileName) => [
path.basename(fileName, ".md"),
parseCapture(fileName),
]),
);
const reviewReport = {
schemaVersion: 1,
corpusSize: captureFiles.length,
providers: captureFiles.map((fileName) => {
const slug = path.basename(fileName, ".md");
const states = parsedCaptures[slug].map((state) => inferState(slug, state));
return {
slug,
stateCount: states.length,
states,
ambiguities: states
.filter((state) => !state.auth)
.map(
(state) => `Auth is not explicit in capture state: ${state.label}`,
),
};
}),
};
for (const app of apps) {
validateApp(app);
if (parsedCaptures[app.slug] && parsedCaptures[app.slug].length === 0)
throw new Error(`${app.slug}: capture has no states`);
}
fs.mkdirSync(out, { recursive: true });
for (const app of apps)
fs.writeFileSync(
path.join(out, `${app.slug}.json`),
JSON.stringify(app, null, 2) + "\n",
);
fs.writeFileSync(
path.join(root, "packages/shared/src/app-definitions.ingestion-report.json"),
JSON.stringify(reviewReport, null, 2) + "\n",
);
const imports = apps
.map(
(a, i) =>
`import a${i} from "./app-definitions/${a.slug}.json" with { type: "json" };`,
)
.join("\n");
fs.writeFileSync(
path.join(root, "packages/shared/src/app-definitions.generated.ts"),
`${imports}\nimport type { AppDefinition } from "./types/app-definition.js";\nexport const APP_DEFINITIONS=[${apps.map((_, i) => `a${i}`).join(",")}] as AppDefinition[];\n`,
);
const ambiguityCount = reviewReport.providers.reduce(
(total, provider) => total + provider.ambiguities.length,
0,
);
console.log(
`Parsed ${captureFiles.length} captures and ${reviewReport.providers.reduce((total, provider) => total + provider.stateCount, 0)} states; emitted ${apps.length} Wave 1 definitions and flagged ${ambiguityCount} states for review.`,
);