Skip to content

refactor(mcp): harden OAuth empty-token, chain resolver errors, sharpen docs#33

Merged
suleimansh merged 1 commit into
mainfrom
quality/mcp
Jun 26, 2026
Merged

refactor(mcp): harden OAuth empty-token, chain resolver errors, sharpen docs#33
suleimansh merged 1 commit into
mainfrom
quality/mcp

Conversation

@suleimansh

Copy link
Copy Markdown
Member

Code quality + docs pass for @gemstack/mcp (part of the per-package GemStack quality sweep).

A note on scope: several survey-flagged items were checked and intentionally not changed because they were already correct - the Bearer prefix is validated with the trailing space (so slice(7) is safe), new (...args: any[]) is the correct "any constructor" idiom (unknown[] would reject real class constructors), zod-to-json-schema already has a try/catch fallback, and the McpTool/McpResource/McpPrompt abstract methods + shouldRegister semantics are already well-documented.

Code quality

  • OAuth empty-token guard - an Authorization: Bearer header with no value is now rejected with 401 invalid_token before calling verifyToken, instead of forwarding an empty string.
  • Error chaining - a failed @Handle dependency resolution now chains the original error via { cause }.
  • Neutralized framework-specific wording in the OAuth core docs.

Docs

  • Documented McpResponse.text/json/error and when to prefer error() over throwing.
  • README OAuth section - added a real jose-based verifyToken, and spelled out that oauth2McpMiddleware and registerOAuth2Metadata must both be wired (with the client-discovery rationale). Softened the origin framing.

Verification

Added an empty-token test. Build + 105 tests green. Patch changeset included.

…en docs

Code quality + docs pass for @gemstack/mcp:

- OAuth: reject an empty bearer token ("Authorization: Bearer " with no
  value) up front with 401 invalid_token instead of forwarding an empty
  string to verifyToken. Neutralized the framework-specific wording in the
  oauth2 core docs (any JWT library / introspection endpoint).
- handle-deps: chain the original error via { cause } when a @handle
  dependency fails to resolve, preserving the stack.
- Documented McpResponse.text/json/error and when to prefer error() over
  throwing.
- README: completed the OAuth 2.1 section (real jose-based verifyToken;
  spelled out that oauth2McpMiddleware AND registerOAuth2Metadata must
  both be wired, with the discovery rationale); softened the origin framing.

Added an empty-token test. Build + 105 tests green.
@suleimansh suleimansh added the enhancement New feature or request label Jun 26, 2026
@suleimansh suleimansh self-assigned this Jun 26, 2026
@suleimansh suleimansh merged commit 36f56e2 into main Jun 26, 2026
1 check passed
@suleimansh suleimansh deleted the quality/mcp branch June 26, 2026 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant