Skip to content

Remove connector kind from remote connectors - #631

Merged
kentcdodds merged 4 commits into
mainfrom
cursor/remove-connector-kind-3316
Jul 6, 2026
Merged

kentcdodds merged 4 commits into
mainfrom
cursor/remove-connector-kind-3316

Conversation

@kentcdodds

@kentcdodds kentcdodds commented Jul 6, 2026 •

Copy link
Copy Markdown
Owner

Summary

Removes the kind dimension from remote connectors entirely. Connectors are now identified only by their user-chosen name (instanceId).

This is a hard break — no backward compatibility for old URLs, session keys, or stored settings shape.

Breaking changes

Before After
wss://…/@user/connectors/lights/home wss://…/@user/connectors/home
Session key [userId, kind, instanceId] [userId, instanceId]
MCP refs { kind, instanceId } { instanceId }
Settings UI "Kind" + "Connector name" "Connector name" only
meta_list_remote_connector_status.connector_kind removed; use connector_id

Migration

  • New D1 migration 0050-drop-remote-connector-kind.sql rebuilds remote_connector_settings without kind.
  • Dedupes on (user_id, lower(instance_id)), keeping the row with minimum rowid and lowercasing instance_id.
  • Manual cleanup/migration of connector processes and saved settings is expected on deploy.

Protocol note

connector.hello still accepts connectorKind from connector-kit clients, but Kody ignores it for routing and auth. connectorId is normalized (trim + lowercase) on hello.

Review follow-ups (addressed)

  • Simplified redundant name-conflict checks in settings-service.ts (CodeRabbit)
  • Fixed migration dedupe to use explicit MIN(rowid) join (Bugbot)
  • Normalized hello connectorId and migration instance_id casing (Bugbot)

Validation

  • npm run validate passes on latest commit
  • Cursor Bugbot, CodeRabbit, and CI all green on 3cdbd55c
Open in Web Open in Cursor 

Summary by CodeRabbit

  • New Features

    • Remote connectors now use a simpler URL/WebSocket addressing format based on the connector instance name only (no separate connector “kind” segment).
    • Connector labels, statuses, and capability metadata are streamlined to align with the single instance identifier.
  • Bug Fixes

    • Fixed remote connector routing/session handling to consistently key connections by instance name.
    • Updated connector settings, account export/deletion, shared-secret handling, and related status/search outputs to match the new format.
  • Documentation

    • Updated remote connector WebSocket/session-key documentation to reflect the new addressing scheme.

Drop the kind/type dimension from remote connectors so each connector is
identified only by its user-chosen name (instanceId).

Breaking changes:
- WebSocket URL: /@username/connectors/<name> (was .../kind/name)
- Session key: [userId, instanceId] (was [userId, kind, instanceId])
- MCP caller context refs: { instanceId } only
- D1 migration drops kind column; dedupes on (user_id, instance_id)
- connector.hello connectorKind is ignored (still accepted from protocol)

Updates account UI, settings API, capability metadata, status reporting,
and docs accordingly.
@coderabbitai

coderabbitai Bot commented Jul 6, 2026 •

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This PR removes connector kind from remote-connector identity and routing, switching shared schemas, worker storage, MCP capability output, account UI, and invocation payloads to instanceId only. It also adds a D1 migration to deduplicate and rekey persisted settings by (user_id, instance_id).

Changes

Remove connector kind

Layer / File(s) Summary
Shared schemas and docs
packages/shared/src/chat.ts, packages/shared/src/remote-connectors.ts, docs/contributing/architecture/remote-connectors.md, packages/worker/src/remote-connector/types.ts, packages/worker/src/mcp/capabilities/types.ts, packages/worker/src/mcp/kody-remote-types.ts, packages/worker/src/remote-connector/settings-types.ts
Removes kind from shared connector reference/type shapes and updates the remote connector architecture docs to describe the instanceId-only URL and session-key flow.
Routing, session keys, and secret resolution
packages/worker/src/remote-connector/connector-session-key.ts, .../client.ts, .../snapshot-cache.ts, .../resolve-remote-connector-secret.ts, and related tests
Reworks user-scoped route parsing, session-key construction, snapshot cache keys, MCP client creation, and shared-secret resolution to use instanceId only.
Settings storage and connector sessions
packages/worker/migrations/0050-drop-remote-connector-kind.sql, packages/worker/src/remote-connector/settings-repo.ts, settings-service.ts, session.ts, and related tests
Rekeys settings persistence by (user_id, instance_id), updates shared-secret lookups and row mapping, and removes persisted connector-kind state from the remote connector session durable object.
Worker account flows and route hardening
packages/worker/src/index.ts, app/account-deletion.ts, app/account-export.ts, app/handlers/account-remote-connectors.ts, app/account-remote-connectors-data.ts, client/routes/account-remote-connectors.tsx, security/public-route-hardening.workers.test.ts, and related tests
Updates account deletion/export, account remote-connector editing, and public route hardening checks to use instanceId-only connector data and URLs.
MCP capability synthesis and search output
packages/worker/src/mcp/capabilities/**, mcp/run-kody-registry.ts, mcp/index.ts, mcp/tools/search*.ts, and tests
Removes connector kind from capability metadata, registry cache keys, kody registry status, and search/status serialization.
Package invocation and workflow propagation
packages/worker/src/package-invocations/*, packages/worker/src/package-runtime/package-workflows.node.test.ts
Propagates remoteConnectors as { instanceId } through package invocation and workflow code paths.

Estimated code review effort: 4 (Complex) | ~75 minutes

Sequence Diagram(s)

sequenceDiagram
  participant WorkerIndex
  participant ConnectorSessionKey
  participant RemoteConnectorClient
  participant SnapshotCache
  WorkerIndex->>ConnectorSessionKey: parseUserScopedConnectorRoutePath
  ConnectorSessionKey-->>WorkerIndex: userId, instanceId
  WorkerIndex->>RemoteConnectorClient: createRemoteConnectorMcpClient(instanceId)
  RemoteConnectorClient->>SnapshotCache: getCachedRemoteConnectorSnapshot(userId, instanceId)
Loading

Possibly related PRs

  • kentcdodds/kody#155: Both PRs touch the same remote-connector identity and routing code, but with opposite connector key shapes.
  • kentcdodds/kody#418: Both PRs modify the remote-connector session-key and URL/addressing paths.
  • kentcdodds/kody#605: Both PRs touch remote-connector snapshot caching and its key inputs.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main breaking change: removing connector kind from remote connectors.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/remove-connector-kind-3316

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@kentcdodds
kentcdodds marked this pull request as ready for review July 6, 2026 00:18
@github-actions

github-actions Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

🔎 Preview deployed: https://kody-pr-631.kentcdodds.workers.dev

Worker: kody-pr-631
D1: kody-pr-631-db
KV: kody-pr-631-oauth-kv

Mocks:

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
packages/worker/src/remote-connector/settings-service.ts (1)

104-138: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Redundant conflict detection / extra DB round-trip.

The nameConflict check (Lines 104-112) already rejects any row whose instance_id === instanceId and id !== input.id, which fully covers the uniqueness rule for both create and update. In the update branch existing.id === input.id, so the refConflict block (Lines 129-138) re-queries by instanceId and re-checks the exact same condition, adding a redundant DB call and dead code. Similarly, in the create path nameConflict throws before existing is used, so the getRemoteConnectorSettingRowByInstanceId branch always resolves to null.

♻️ Proposed simplification
 	const existing = input.id
 		? await getRemoteConnectorSettingRowById({
 				db: input.env.APP_DB,
 				userId: input.userId,
 				id: input.id,
 			})
-		: await getRemoteConnectorSettingRowByInstanceId({
-				db: input.env.APP_DB,
-				userId: input.userId,
-				instanceId,
-			})
+		: null
 	if (input.id && !existing) {
 		throw new Error('Remote connector setting not found.')
 	}
-
-	if (input.id) {
-		const refConflict = await getRemoteConnectorSettingRowByInstanceId({
-			db: input.env.APP_DB,
-			userId: input.userId,
-			instanceId,
-		})
-		if (refConflict && refConflict.id !== existing?.id) {
-			throw new Error('A remote connector with this name already exists.')
-		}
-	}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/worker/src/remote-connector/settings-service.ts` around lines 104 -
138, The conflict detection in settings-service’s update/create flow is
duplicated: the initial nameConflict check already covers any row with the same
instanceId and a different id, so the later refConflict block and its extra
getRemoteConnectorSettingRowByInstanceId lookup are redundant. Remove the
refConflict branch from the existing input.id path and rely on the existing
nameConflict plus the existing row lookup to keep the uniqueness check in one
place.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@packages/worker/src/remote-connector/settings-service.ts`:
- Around line 104-138: The conflict detection in settings-service’s
update/create flow is duplicated: the initial nameConflict check already covers
any row with the same instanceId and a different id, so the later refConflict
block and its extra getRemoteConnectorSettingRowByInstanceId lookup are
redundant. Remove the refConflict branch from the existing input.id path and
rely on the existing nameConflict plus the existing row lookup to keep the
uniqueness check in one place.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3fc6e598-4121-4d2d-8d60-2d02b9901ea1

📥 Commits

Reviewing files that changed from the base of the PR and between de3b3fb and 5e02fe7.

📒 Files selected for processing (53)
  • docs/contributing/architecture/remote-connectors.md
  • packages/shared/src/chat.ts
  • packages/shared/src/remote-connectors.ts
  • packages/worker/client/routes/account-remote-connectors.tsx
  • packages/worker/migrations/0050-drop-remote-connector-kind.sql
  • packages/worker/src/app/account-deletion.node.test.ts
  • packages/worker/src/app/account-deletion.ts
  • packages/worker/src/app/account-export.node.test.ts
  • packages/worker/src/app/account-export.ts
  • packages/worker/src/app/account-remote-connectors-data.ts
  • packages/worker/src/app/handlers/account-remote-connectors.node.test.ts
  • packages/worker/src/app/handlers/account-remote-connectors.ts
  • packages/worker/src/app/loader-data.ts
  • packages/worker/src/index.ts
  • packages/worker/src/mcp-auth.workers.test.ts
  • packages/worker/src/mcp/capabilities/meta/meta-list-capabilities.node.test.ts
  • packages/worker/src/mcp/capabilities/meta/meta-list-capabilities.ts
  • packages/worker/src/mcp/capabilities/meta/meta-list-remote-connector-status.ts
  • packages/worker/src/mcp/capabilities/meta/search.ts
  • packages/worker/src/mcp/capabilities/registry.ts
  • packages/worker/src/mcp/capabilities/remote-connector/index.ts
  • packages/worker/src/mcp/capabilities/types.ts
  • packages/worker/src/mcp/executor.node.test.ts
  • packages/worker/src/mcp/index.ts
  • packages/worker/src/mcp/kody-remote-types.ts
  • packages/worker/src/mcp/run-kody-registry.node.test.ts
  • packages/worker/src/mcp/run-kody-registry.ts
  • packages/worker/src/mcp/tools/search-format.node.test.ts
  • packages/worker/src/mcp/tools/search-format.ts
  • packages/worker/src/mcp/tools/search-handler.node.test.ts
  • packages/worker/src/mcp/tools/search.node.test.ts
  • packages/worker/src/mcp/tools/search.ts
  • packages/worker/src/package-invocations/http.workers.test.ts
  • packages/worker/src/package-invocations/service.node.test.ts
  • packages/worker/src/package-runtime/package-workflows.node.test.ts
  • packages/worker/src/remote-connector/client.ts
  • packages/worker/src/remote-connector/connector-session-key.node.test.ts
  • packages/worker/src/remote-connector/connector-session-key.ts
  • packages/worker/src/remote-connector/remote-connectors-shared.node.test.ts
  • packages/worker/src/remote-connector/remote-domain-id.node.test.ts
  • packages/worker/src/remote-connector/resolve-remote-connector-secret.node.test.ts
  • packages/worker/src/remote-connector/resolve-remote-connector-secret.ts
  • packages/worker/src/remote-connector/session.node.test.ts
  • packages/worker/src/remote-connector/session.ts
  • packages/worker/src/remote-connector/settings-repo.ts
  • packages/worker/src/remote-connector/settings-service.node.test.ts
  • packages/worker/src/remote-connector/settings-service.ts
  • packages/worker/src/remote-connector/settings-types.ts
  • packages/worker/src/remote-connector/snapshot-cache.node.test.ts
  • packages/worker/src/remote-connector/snapshot-cache.ts
  • packages/worker/src/remote-connector/status.ts
  • packages/worker/src/remote-connector/types.ts
  • packages/worker/src/security/public-route-hardening.workers.test.ts
💤 Files with no reviewable changes (20)
  • packages/worker/src/remote-connector/types.ts
  • packages/worker/src/mcp/kody-remote-types.ts
  • packages/worker/src/remote-connector/settings-types.ts
  • packages/worker/src/mcp/capabilities/meta/meta-list-capabilities.ts
  • packages/worker/src/mcp/capabilities/types.ts
  • packages/worker/src/remote-connector/resolve-remote-connector-secret.node.test.ts
  • packages/worker/src/app/account-remote-connectors-data.ts
  • packages/worker/src/app/handlers/account-remote-connectors.ts
  • packages/worker/src/remote-connector/client.ts
  • packages/worker/src/mcp/tools/search-format.ts
  • packages/worker/src/index.ts
  • packages/worker/src/mcp/tools/search.ts
  • packages/worker/src/remote-connector/snapshot-cache.node.test.ts
  • packages/worker/src/mcp/tools/search-format.node.test.ts
  • packages/worker/src/app/loader-data.ts
  • packages/shared/src/chat.ts
  • packages/worker/src/app/account-export.node.test.ts
  • packages/worker/src/remote-connector/snapshot-cache.ts
  • packages/worker/src/remote-connector/session.node.test.ts
  • packages/worker/src/mcp/capabilities/meta/search.ts

The initial nameConflict scan already enforces per-user instanceId
uniqueness for both create and update paths, so drop the redundant
refConflict lookup and create-path instanceId fetch.
Comment thread packages/worker/migrations/0050-drop-remote-connector-kind.sql Outdated
Comment thread packages/worker/src/remote-connector/session.ts
Use an explicit MIN(rowid) join when collapsing duplicate connector
settings so the surviving row's secret/metadata is deterministic.

Normalize connector.hello connectorId with
normalizeRemoteConnectorInstanceId so persisted IDs match routing,
session keys, and saved settings.

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit af399ab. Configure here.

Comment thread packages/worker/migrations/0050-drop-remote-connector-kind.sql
Normalize instance_id to lowercase when rebuilding
remote_connector_settings so migrated rows match runtime routing
and auth, and dedupe on (user_id, lower(instance_id)).
@kentcdodds
kentcdodds merged commit 50a3109 into main Jul 6, 2026
5 checks passed
@kentcdodds
kentcdodds deleted the cursor/remove-connector-kind-3316 branch July 6, 2026 01:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants