Skip to content

refactor(mcp): store source config once per namespace, not per binding#223

Merged
RhysSullivan merged 1 commit intomainfrom
rs/fix-mcp-per-tool-config
Apr 13, 2026
Merged

refactor(mcp): store source config once per namespace, not per binding#223
RhysSullivan merged 1 commit intomainfrom
rs/fix-mcp-per-tool-config

Conversation

@RhysSullivan
Copy link
Copy Markdown
Owner

Summary

Follow-up to #222 applying the same fix to the MCP plugin.

Per-tool binding rows were duplicating the full McpStoredSourceData (remote endpoint, headers, query params, auth config including OAuth refresh-token secret IDs) on every entry. A source with N tools stored N copies of the same blob, and every `updateSource` call — or token rotation — rewrote every binding row (`O(N)` writes per edit).

  • Drop `sourceData` from per-binding rows. They now store only `{ namespace, binding }`.
  • Invoker resolves runtime config via `bindingStore.getSourceConfig(namespace)` on the hot path.
  • `updateSource` becomes a single `putSource` — `O(1)` writes instead of `O(N)`.
  • Source row persistence switched from raw `JSON.stringify`/`JSON.parse` to the existing `McpStoredSourceSchema`, removing the two `preferSchemaOverJson` linter suppressions.

Migration

No explicit migration required. Legacy binding rows carry an extra `sourceData` field; Effect Schema strips unknown fields on decode, so old rows load fine and the next write drops the duplication naturally. Source rows haven't changed shape — the schema-based encoder produces the same JSON layout the old `JSON.stringify` path did.

This is simpler than the #222 story (which needed a decode-optional `invocationConfig` + self-heal) because for MCP the `config` field on the source row already contains everything the invoker needs — there's no separate "resolved" view to reconstruct.

Test plan

  • `bun run typecheck` — full workspace, clean
  • `bun run --filter '@executor/plugin-mcp' test` — 19/19 passing
  • Manually exercise an MCP add + edit-source flow end-to-end
  • Verify OAuth token rotation path still writes correctly

Per-tool binding rows were duplicating the full McpStoredSourceData
(remote endpoint, headers, query params, auth config including OAuth
refresh-token secretIds) on every entry. A source with N tools stored
N copies, and every updateSource (or token rotation) rewrote every row.

Drop sourceData from the per-binding schema and resolve it via
getSourceConfig(namespace) on the invoke hot path. updateSource is
now a single putSource — O(1) writes instead of O(N).

Also switch source row persistence from raw JSON.stringify/JSON.parse
to the existing McpStoredSourceSchema, removing the preferSchemaOverJson
linter suppressions.

Legacy binding rows have an extra sourceData field; Effect Schema
strips unknown fields on decode, so old rows load fine and the next
write drops the duplication naturally — no explicit migration needed.
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
🔵 In progress
View logs
executor-cloud 4f5ee73 Apr 13 2026, 07:13 AM

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Apr 13, 2026

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
executor-marketing 4f5ee73 Commit Preview URL

Branch Preview URL
Apr 13 2026, 07:14 AM

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Apr 13, 2026

Open in StackBlitz

@executor/sdk

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/sdk@223

@executor/plugin-file-secrets

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-file-secrets@223

@executor/plugin-google-discovery

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-google-discovery@223

@executor/plugin-graphql

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-graphql@223

@executor/plugin-keychain

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-keychain@223

@executor/plugin-mcp

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-mcp@223

@executor/plugin-onepassword

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-onepassword@223

@executor/plugin-openapi

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-openapi@223

@executor/plugin-workos-vault

npm i https://pkg.pr.new/RhysSullivan/executor/@executor/plugin-workos-vault@223

commit: 4f5ee73

@RhysSullivan RhysSullivan merged commit 7337765 into main Apr 13, 2026
7 checks passed
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.

1 participant