Skip to content

v2: Web standards Request object in ctx#1822

Open
KKonstantinov wants to merge 3 commits intomainfrom
feature/request-object-in-ctx
Open

v2: Web standards Request object in ctx#1822
KKonstantinov wants to merge 3 commits intomainfrom
feature/request-object-in-ctx

Conversation

@KKonstantinov
Copy link
Copy Markdown
Contributor

Replace custom RequestInfo with standard Web Request object

Motivation and Context

Closes #1351. The custom RequestInfo interface only exposed headers, discarding the rest of the incoming HTTP request (URL, query params, method). Instead of incrementally adding fields like queryString, this replaces the entire custom type with the standard Web Request object that the transport already receives. Users now have access to headers, URL, query parameters, HTTP method, and anything else the Web Request API provides.

How Has This Been Tested?

  • All 1,369 existing tests pass across all packages
  • Updated the existing request info test to also assert url and method on the exposed Request object
  • Added a new test verifying query parameters are accessible via new URL(req.url).searchParams when the client sends a request with query params
  • Full pnpm typecheck:all, pnpm lint:all, and pnpm test:all pass

Breaking Changes

ctx.http?.req is now a standard Web Request instead of the custom RequestInfo type. The most common access pattern (ctx.http?.req?.headers.get(...)) is unchanged since Request has the same headers: Headers property. The RequestInfo type has been removed — it was not part of the public API exports.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

  • Used globalThis.Request in type annotations to disambiguate from the MCP protocol's own Request type in types.ts and protocol.ts
  • Migration docs (migration.md and migration-SKILL.md) updated with new examples showing query param access

@KKonstantinov KKonstantinov requested a review from a team as a code owner March 30, 2026 17:07
@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 30, 2026

⚠️ No Changeset found

Latest commit: e76a233

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 30, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/client@1822

@modelcontextprotocol/server

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/server@1822

@modelcontextprotocol/express

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/express@1822

@modelcontextprotocol/hono

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/hono@1822

@modelcontextprotocol/node

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/node@1822

commit: e76a233

@KKonstantinov
Copy link
Copy Markdown
Contributor Author

@claude review

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.

Add query string to RequestInfo

2 participants