Skip to content

fix: replace URLSearchParams with manual query parsing in mcp-oauth callback#136

Merged
donbader merged 1 commit into
mainfrom
fix/mcp-oauth-urlsearchparams
Jun 9, 2026
Merged

fix: replace URLSearchParams with manual query parsing in mcp-oauth callback#136
donbader merged 1 commit into
mainfrom
fix/mcp-oauth-urlsearchparams

Conversation

@donbader

@donbader donbader commented Jun 9, 2026

Copy link
Copy Markdown
Owner

The gateway JS runtime (goja) does not provide Web Platform APIs like URLSearchParams. The OAuth callback handler was using new URLSearchParams(query) which threw ReferenceError: URLSearchParams is not defined when the browser redirected back after authorization.

Fix: Replace with a parseQuery() helper that uses only core ECMAScript (split, decodeURIComponent) which goja supports natively.

Tested: All tests pass (go test ./...).

ctx.request.query is already a parsed map[string]string provided by Go's
URL.Query() — no need for URLSearchParams or manual parsing. The original
code failed because URLSearchParams is not available in the goja runtime.

Adds integration tests that load the real mcp-oauth plugin source through
the goja VM to catch runtime API incompatibilities.
@donbader donbader force-pushed the fix/mcp-oauth-urlsearchparams branch from 31f7583 to e342196 Compare June 9, 2026 10:21
@donbader donbader merged commit 06a2a00 into main Jun 9, 2026
3 checks passed
@donbader donbader deleted the fix/mcp-oauth-urlsearchparams branch June 9, 2026 10:22
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