feat: Context API - simplified types (alternative to #1241)#1465
Closed
felixweinberger wants to merge 1 commit intomainfrom
Closed
feat: Context API - simplified types (alternative to #1241)#1465felixweinberger wants to merge 1 commit intomainfrom
felixweinberger wants to merge 1 commit intomainfrom
Conversation
🦋 Changeset detectedLatest commit: d9abbf4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@modelcontextprotocol/client
@modelcontextprotocol/server
@modelcontextprotocol/express
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
ab4c876 to
b20a543
Compare
felixweinberger
commented
Feb 3, 2026
| /** | ||
| * Request-scoped TaskStore interface. | ||
| */ | ||
| export interface RequestTaskStore { |
Contributor
Author
There was a problem hiding this comment.
this just moved out of protocol into packages/core/src/experimental/requestTaskStore.ts
Replaces the flat RequestHandlerExtra type with a structured context system using 4 plain types: BaseContext, ServerContext, ClientContext, TaskContext. - Nested structure groups related fields (mcpReq, http, task, notification) - Separate ServerContext/ClientContext types for server and client handlers - Server-specific convenience methods (logging, sampling, elicitation) - Plain object (POJO) construction with closures - no classes - Type-safe contexts without runtime instanceof checks Based on the design from PR #1241, simplified from class hierarchy to plain types. BREAKING CHANGE: RequestHandlerExtra is replaced by BaseContext with nested structure. See docs/migration.md for migration guide.
b20a543 to
d9abbf4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Alternative implementation of the Context API from PR #1241, using plain types and POJOs instead of a class hierarchy.
This PR replaces the flat
RequestHandlerExtratype with a structured context system using 4 types:BaseContextServerContextClientContextTaskContextKey differences from #1241
BaseContextclass →ServerContext/ClientContextsubclasses)new ServerContext(...)/new ClientContext(...)ctx instanceof ServerContext"elicitInput" in ctx.mcpReq)RequestHandlerExtra)Context structure (same nested grouping as #1241)
Motivation
RequestHandlerExtrainstanceofchecksBreaking Changes
Same breaking changes as #1241 —
RequestHandlerExtraproperties move to the nested context structure.How Has This Been Tested
pnpm check:all(typecheck + lint) passespnpm test:allpassesTypes of changes
Checklist