Skip to content

feat(helm): wire the Google Calendar hosted-MCP client through api-keys - #2111

Merged
lilyshen0722 merged 2 commits into
mainfrom
fix/google-calendar-client-wiring
Oct 9, 2026
Merged

lilyshen0722 merged 2 commits into
mainfrom
fix/google-calendar-client-wiring

Conversation

@lilyshen0722

Copy link
Copy Markdown
Contributor

Wires the Google Calendar hosted-MCP client through api-keys so the entry built in #2066 can leave not_configured.

Why now: the entry is client: 'pre-registered' and reads GOOGLE_CALENDAR_CLIENT_ID / GOOGLE_CALENDAR_CLIENT_SECRET, the names hostedMcpClientConfigKeys('google-calendar') derives. Nothing mapped them into the backend. The OAuth client now exists in its own Google Cloud project (Web application; one redirect URI, https://api.commonly.me/api/integrations/connect/hosted-mcp/google-calendar/callback; scopes openid plus the three Calendar read scopes the entry pins; Testing mode). Both Secret Manager keys exist with an enabled version, commonly-dev-google-calendar-client-id and -secret, created 2026-10-09 and verified by name and version only. They carry the same project-level access as the secrets ESO already reads. The ordering rule was "secret values first, wiring second", because ESO rejects all of api-keys when one referenced remote key is missing. That order held.

What changes (the same shape as Slack's OAuth block):

  • values.yaml: hostedMcp.googleCalendar.enabled, default false, with the create-before-enable note, so a self-hosted chart with ESO on but no such secrets keeps syncing.
  • values-dev.yaml: enabled.
  • templates/secrets/api-keys.yaml: the two remoteRefs, inside {{- if .Values.hostedMcp.googleCalendar.enabled }}.
  • templates/core/backend-deployment.yaml: both env vars from api-keys, optional: true, so an instance with the flag off still starts and the entry reads not_configured.

Rendered both ways (helm template … -f values-dev.yaml --set externalSecrets.enabled=true): with the flag off, the backend has the two optional refs and the ExternalSecret has no Google Calendar entries. With it on, the ExternalSecret gains both secretKey/remoteRef pairs. helm lint is clean with the default values and with values-dev.

Test (backend/__tests__/unit/integrations/hostedMcpClientWiring.test.js, 3): for every pre-registered entry in HOSTED_MCP_ENTRIES, each derived env name must be mapped in the Deployment from an api-keys key with optional: true, and the ExternalSecret must reference that key as commonly-dev-<key>. A positive control asserts the entry list includes google-calendar, so the loop cannot pass empty. This is review-checklist rule 7's shape: three layers held together only by a naming convention, now pinned.

  • Mutation A, optional: true dropped from the secret's env ref: exactly that arm fails, 2 pass.
  • Mutation B, the ExternalSecret pointed at a wrong remote key for the id: exactly that arm fails, 2 pass.
  • Run under Node 22, matching CI.

After merge: Deploy Dev, then confirm api-keys synced (SecretSynced) and that the backend carries both names (names only). The catalogue then flips google-calendar to available, and the live walk (C0–C10) follows on Sam's account. One open dependency is outside this PR. Google's Calendar MCP server is Developer Preview, and the Preview Program application needs a Workspace-domain address, which is being sorted with Sam. Until then the Connect flow may stop at Google even with the client wired.

Gate: Vera.

🤖 Generated with Claude Code

https://claude.ai/code/session_013geJsV4RJMujdvpf3JV2Cv

The Google Calendar entry (#2066) uses a pre-registered OAuth client and
reads GOOGLE_CALENDAR_CLIENT_ID / GOOGLE_CALENDAR_CLIENT_SECRET, but nothing
mapped those names into the backend, so the entry read not_configured. Both
Secret Manager keys now exist with a version (commonly-dev-google-calendar-
client-id / -secret, created 2026-10-09), so the wiring can land:

- values.yaml: hostedMcp.googleCalendar.enabled, default false, with the
  same create-before-enable rule as Slack's OAuth block.
- values-dev.yaml: enabled for the dev instance.
- api-keys ExternalSecret: the two remoteRefs, gated by the flag, because a
  missing remote key stops ESO syncing all of api-keys.
- backend Deployment: both env vars from api-keys, optional, so an instance
  with the flag off keeps starting.

A new test pins the chain for every pre-registered entry: each env name
hostedMcpClientConfigKeys derives is mapped (optional) from an api-keys key
that the ExternalSecret references as commonly-dev-<key>.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013geJsV4RJMujdvpf3JV2Cv

@lilyshen0722 lilyshen0722 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

37c99e5

Vera — verification gate, head 37c99e56

CLEARED. Base 6378266c, current with main. One small finding about the new test's vacuity guard, non-blocking.

The three-layer chain, verified independently of the PR's test

I derived it myself rather than reading the test's expectations:

  • hostedMcpIntakeService.ts:151 — entryId.toUpperCase().replace(/[^A-Z0-9]/g,'_') plus _CLIENT_ID/_CLIENT_SECRET.
  • googleCalendar.ts:47 — the entry id is literally 'google-calendar', so the derived names are GOOGLE_CALENDAR_CLIENT_ID / _CLIENT_SECRET. That literal is the single point of failure for the whole PR and it matches the chart exactly.
  • toolInstallables.ts — readiness: () => isHostedMcpClientConfigured(entry, env) ? available : { available: false, reason: 'not_configured' }. So the values.yaml claim ("the entry reads not_configured and the Tools page offers no Connect") is a property of the code, not just a comment. And resolvedClientId (:178) throws client_not_configured at the authorization boundary, so a half-configured instance is loud rather than silently broken.

Rendered both ways myself, and the off state is the safe one

helm lint clean (only the cosmetic icon is recommended). With the flag off: the two optional: true env refs render, and zero ExternalSecret remoteRefs — so ESO syncs api-keys without those keys, the env stays unset, readiness is not_configured. With -f values-dev.yaml: both remoteRefs appear. That is the ordering the comments promise, and it means an instance without the Secret Manager keys cannot wedge ESO.

The gate is written exactly like Slack's (api-keys.yaml:174 vs the new :193), and I probed the nil-pointer case with a control: an override of hostedMcp: {} renders fine, as does slack: {} — values files merge, so the defaults survive.

Mutations — one per layer, each failing exactly its own case

mutation result
deployment env name GOOGLE_CALENDAR_CLIENT_ID → ..._CLIENTID 1 of 3 fails
drop optional: true from the client-id ref 1 of 3 fails
ExternalSecret remoteRef.key → commonly-dev-gcal-client-id 1 of 3 fails

As reported. The test also opens with its own non-vacuity arm, which is the right instinct.

Finding: the vacuity guard is real but fires by accident, and its message won't name the cause

I mutated googleCalendar.ts's client: 'pre-registered' → 'dcr' to check the guard. The intended assertion (expect(preRegistered.map(e => e.id)).toContain('google-calendar')) never runs. preRegistered is empty, so describe.each([]) throws at load:

● Test suite failed to run
  Error: `.each` called with an empty Array of table data.
Tests: 0 total

The condition is still caught — a load failure is red in CI — but by jest's refusal rather than by the guard, and the message says nothing about a pre-registered entry disappearing. Tests: 0 total beside a failed suite is also the shape that reads green if someone checks the count rather than the suite line. Cheap fix if you want the guard to do its own job: assert on HOSTED_MCP_ENTRIES before the describe.each, or give .each a non-empty fallback so the named assertion is what fails.

Secrets hygiene

No secret values, and no project-scoped identifier in a committed file — values-dev.yaml says "the cluster project's Secret Manager" without naming it, which is the rule for this repo. I verified the two Secret Manager keys' existence only as far as this PR needs: the chart references commonly-dev-google-calendar-client-{id,secret}, matching the commonly-dev- prefix every other entry uses. I did not read either value.

Suite

Backend at this head: 504 suites passed, 4835 passed, 24 skipped, 0 failed.

…tered

Per Vera's #2111 review: with an empty pre-registered list, describe.each
threw jest's "empty table" error at load, so the guard never ran and the
failure did not say what disappeared. The table now falls back to a
placeholder id, so the named guard fails (and the placeholder's arms with
it). Reproduced with Google Calendar switched to 'dcr': 3 named failures
instead of a load error.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_013geJsV4RJMujdvpf3JV2Cv

@lilyshen0722 lilyshen0722 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

c49059e

Vera — verification gate, head c49059ee

CLEARED. This closes my vacuity finding from the 37c99e56 review.

Test-only, by tree hash

k8s is 743fd4d4 at both heads; backend/integrations is 46d5921f and backend/services is 4b1201f7 at both. The whole delta is 8 lines in hostedMcpClientWiring.test.js.

The guard now fails by name, and the layer arms did not weaken

At this head the placeholder is absent and the three real arms pass. Re-running my client: 'pre-registered' → 'dcr' mutation:

✕ the pre-registered entries include Google Calendar, so the checks below are not vacuous
✕ NO_PRE_REGISTERED_ENTRY_CLIENT_ID is mapped from api-keys and referenced by the ExternalSecret
✕ NO_PRE_REGISTERED_ENTRY_CLIENT_SECRET is mapped from api-keys and referenced by the ExternalSecret
Tests: 3 failed, 3 total

Three named failures, no load-time error, and 3 total rather than the 0 total that previously read green to a count-checker. The placeholder id derives NO_PRE_REGISTERED_ENTRY_CLIENT_*, which is mapped nowhere and cannot collide with a chart key. I also re-ran all three layer mutations — deployment env name, dropped optional: true, wrong remoteRef.key — and each still fails exactly 1 of 3, so the fallback did not blunt them.

Suite, and a number I will not let stand unexplained

Full backend at this head, three runs on the same machine: 504 suites / 4835 passed / 0 failed, then 1 failed (AgentMemory.test.ts "enforces unique (agentName, instanceId)" — expect(...).rejects.toThrow() received a resolved promise, the documented index-build race that passes 12/12 in isolation, which I confirmed), then 504 / 4835 / 0 failed again.

One of those runs first reported 8 suites / 114 tests failed, and I could not reproduce or attribute it: I had no capture of which suites, the base at 6378266c ran clean on the same machine (503 suites / 4832 passed / 0 failed), the delta is eight lines in a leaf test file that reads two chart files, and two later runs at this head were clean. The prior run had also logged "a worker process has failed to exit gracefully and has been force exited", which is the teardown condition that produces port collisions between back-to-back full runs here. I am recording it as environmental rather than silently dropping it, because a 114-failure reading is not something a gate should leave unmentioned — but it is not evidence against this head, and nothing in the diff can reach those suites.

@lilyshen0722
lilyshen0722 added this pull request to the merge queue Oct 9, 2026
Merged via the queue into main with commit b301e7a Oct 9, 2026
18 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