Skip to content

fix: use internal Auth and MCP service bindings in staging - #53

Merged
zskbot merged 9 commits into
mainfrom
fix/control-api-mcp-probe-timeout
Nov 16, 2026
Merged

zskbot merged 9 commits into
mainfrom
fix/control-api-mcp-probe-timeout

Conversation

@zskbot

@zskbot zskbot commented Nov 16, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Prefer internal Cloudflare service bindings for Control API → Auth and Control API → MCP health probes, with public URL fallbacks.
  • Increase the external MCP handshake timeout to 12 seconds and add safe phase/error-type diagnostics.
  • Add unit tests for both internal service-binding paths and document the staging-only bindings.

Staging deployment and verification

  • Worker: ocodejs-server-api-staging in the Huynh Cloudflare account.
  • MCP_SERVER → ocodejs-mcp-staging: healthy, MCP initialize/tools-list passed, 6 read-only tools discovered.
  • CLI_AUTH → ocodejs-auth: healthy, internal health reports GitHub OAuth/PAT bindings configured.
  • Control API health/readiness and CORS for https://ocodejs.co: passed.

Public Auth hostname remains unresolved

  • auth.ocodejs.dev returns HTTP 403 with cf-mitigated: challenge because the active ocodejs.dev zone is in Under Attack Mode.
  • The active public hostname is attached to the OCodeJS-account Worker mcp-auth-ocodejs; the configured Auth backend with D1 and GitHub OAuth/PAT bindings is the separate Huynh-account Worker ocodejs-auth.
  • The staging service binding validates the backend internally; it does not change public routing or prove end-to-end OAuth login.

Identity/Auth.js portal, AI runtime, MCP manager, and queryable audit storage remain unconfigured; telemetry is degraded until its optional bindings/storage are attached.

No Production routing, DNS, secrets, or account-wide security settings changed. Keep unmerged pending review.

@vercel

vercel Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
ocodejs-profile Error Error Nov 16, 2026 10:05pm UTC

Request Review

@sourcery-ai

sourcery-ai Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Implementation

Route MCP and Auth health probes through configured service bindings while retaining public fallbacks, and extend MCP timeout and failure diagnostics.

  • workers/control-api/worker.mjs L169-177, L223-231, L306-311 (+13 small edits)

Documentation

Document the staging-only MCP and Auth service bindings, their fallback behavior, and the limitations of internal health checks.

  • workers/control-api/README.md L61-79

Tests

Verify MCP and CLI Auth probes use their configured internal service bindings and return healthy service results.

  • workers/control-api/worker.test.mjs L444-508

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@qodo-code-review

Copy link
Copy Markdown

ⓘ Qodo reviews are paused because your trial has ended. Ask your workspace admin to add credits to resume reviews. Manage billing

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-16T21:49:21.455758Z
We couldn’t complete this review. Comment @codex review to try again.
743df3e PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@sourcery-ai sourcery-ai 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.

Hey - I've found 3 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="workers/control-api/worker.mjs" line_range="235" />
<code_context>
       cache: "no-store",
       redirect: "error",
-      signal: AbortSignal.timeout(4000)
+      signal: AbortSignal.timeout(12000)
     });
     if (!initializeResponse.ok) {
</code_context>
<issue_to_address>
**Public probes hold capacity longer**

When anonymous clients repeatedly call the public probe routes while the MCP endpoint responds slowly but within each request timeout, `handleRequest` calls `probeMcpServer` on public MCP connection routes without authentication or throttling. Its three serial fetches can now keep each Worker request and its upstream requests open for up to 36 seconds, allowing repeated callers to exhaust capacity during a slow MCP response.

Apply a rate limit or cache probe results, and enforce an overall deadline for the handshake.

Also at `workers/control-api/worker.mjs:252`, `workers/control-api/worker.mjs:263`.
</issue_to_address>

### Comment 2
<location path="workers/control-api/worker.mjs" line_range="235" />
<code_context>
       cache: "no-store",
       redirect: "error",
-      signal: AbortSignal.timeout(4000)
+      signal: AbortSignal.timeout(12000)
     });
     if (!initializeResponse.ok) {
</code_context>
<issue_to_address>
**Staging validation aborts early**

When the sequential MCP handshake takes longer than the staging checker’s 10-second `/services` budget, `probeMcpServer` can spend up to 36 seconds on its three sequential requests, so `check-control-api-staging.mjs` aborts before the probe returns and reports the staging result as unverified or failed.

Bound the total probe duration so it completes within the staging checker’s 10-second request budget.

Also at `workers/control-api/worker.mjs:251`, `workers/control-api/worker.mjs:263`.
</issue_to_address>

### Comment 3
<location path="workers/control-api/worker.mjs" line_range="281" />
<code_context>
     };
-  } catch {
+  } catch (error) {
+    console.warn(JSON.stringify({ event: "control_api.mcp_probe_failed", errorType: error?.name || "Error" }));
     return {
       state: "unavailable",
</code_context>
<issue_to_address>
**Failed handshakes lack diagnostics**

When the endpoint returns an HTTP error or an invalid handshake response, the HTTP-status and protocol-mismatch branches return `unavailable` or `unknown` without throwing, so they bypass the `catch` that logs `control_api.mcp_probe_failed`; callers see a failed probe without the failure diagnostic.

Emit the failure warning on the HTTP-status and protocol-mismatch return branches as well as in the `catch`.
</issue_to_address>

Sourcery assessment

Approval pending. 3 findings to address first.

Blocking findings: workers/control-api/worker.mjs:235, workers/control-api/worker.mjs:235, workers/control-api/worker.mjs:281


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

cache: "no-store",
redirect: "error",
signal: AbortSignal.timeout(4000)
signal: AbortSignal.timeout(12000)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Public probes hold capacity longer

When anonymous clients repeatedly call the public probe routes while the MCP endpoint responds slowly but within each request timeout, handleRequest calls probeMcpServer on public MCP connection routes without authentication or throttling. Its three serial fetches can now keep each Worker request and its upstream requests open for up to 36 seconds, allowing repeated callers to exhaust capacity during a slow MCP response.

Apply a rate limit or cache probe results, and enforce an overall deadline for the handshake.

Also at workers/control-api/worker.mjs:252, workers/control-api/worker.mjs:263.

Prompt for AI agents
In `workers/control-api/worker.mjs` at line 235:

**Public probes hold capacity longer**

When anonymous clients repeatedly call the public probe routes while the MCP endpoint responds slowly but within each request timeout, `handleRequest` calls `probeMcpServer` on public MCP connection routes without authentication or throttling. Its three serial fetches can now keep each Worker request and its upstream requests open for up to 36 seconds, allowing repeated callers to exhaust capacity during a slow MCP response.

Apply a rate limit or cache probe results, and enforce an overall deadline for the handshake.

Also at `workers/control-api/worker.mjs:252`, `workers/control-api/worker.mjs:263`.

cache: "no-store",
redirect: "error",
signal: AbortSignal.timeout(4000)
signal: AbortSignal.timeout(12000)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Staging validation aborts early

When the sequential MCP handshake takes longer than the staging checker’s 10-second /services budget, probeMcpServer can spend up to 36 seconds on its three sequential requests, so check-control-api-staging.mjs aborts before the probe returns and reports the staging result as unverified or failed.

Bound the total probe duration so it completes within the staging checker’s 10-second request budget.

Also at workers/control-api/worker.mjs:251, workers/control-api/worker.mjs:263.

Prompt for AI agents
In `workers/control-api/worker.mjs` at line 235:

**Staging validation aborts early**

When the sequential MCP handshake takes longer than the staging checker’s 10-second `/services` budget, `probeMcpServer` can spend up to 36 seconds on its three sequential requests, so `check-control-api-staging.mjs` aborts before the probe returns and reports the staging result as unverified or failed.

Bound the total probe duration so it completes within the staging checker’s 10-second request budget.

Also at `workers/control-api/worker.mjs:251`, `workers/control-api/worker.mjs:263`.

};
} catch {
} catch (error) {
console.warn(JSON.stringify({ event: "control_api.mcp_probe_failed", errorType: error?.name || "Error" }));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Medium · Failed handshakes lack diagnostics

When the endpoint returns an HTTP error or an invalid handshake response, the HTTP-status and protocol-mismatch branches return unavailable or unknown without throwing, so they bypass the catch that logs control_api.mcp_probe_failed; callers see a failed probe without the failure diagnostic.

Emit the failure warning on the HTTP-status and protocol-mismatch return branches as well as in the catch.

Prompt for AI agents
In `workers/control-api/worker.mjs` at line 281:

**Failed handshakes lack diagnostics**

When the endpoint returns an HTTP error or an invalid handshake response, the HTTP-status and protocol-mismatch branches return `unavailable` or `unknown` without throwing, so they bypass the `catch` that logs `control_api.mcp_probe_failed`; callers see a failed probe without the failure diagnostic.

Emit the failure warning on the HTTP-status and protocol-mismatch return branches as well as in the `catch`.

@vercel

vercel Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Deployment failed for project ocodejs.github.io with the following error:

Resource is limited - try again in 1 day (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/ocodejs-co?upgradeToPro=build-rate-limit

@vercel

vercel Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Deployment failed for project pages.ocodejs.theme with the following error:

Resource is limited - try again in 24 hours (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/ocodejs-co?upgradeToPro=build-rate-limit

@vercel

vercel Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Deployment failed for project ocodejs.github.io with the following error:

Resource is limited - try again in 24 hours (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/ocodejs-co?upgradeToPro=build-rate-limit

@vercel

vercel Bot commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Deployment failed for project pages.ocodejs.theme with the following error:

Resource is limited - try again in 1 day (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/ocodejs-co?upgradeToPro=build-rate-limit

@zskbot zskbot changed the title fix: increase Control API staging MCP probe timeout fix: use internal service binding for staging MCP health probe Nov 16, 2026
@zskbot
zskbot merged commit 25ab221 into main Nov 16, 2026
5 of 8 checks passed
@zskbot zskbot changed the title fix: use internal service binding for staging MCP health probe fix: use internal Auth and MCP service bindings in staging Nov 16, 2026

This branch had an error being deployed

1 failed deployment
Preview – ocodejs-profile — 70480b93 Deployed Nov 16, 2026 by vercel[bot]
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