You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Copy file name to clipboardExpand all lines: CLAUDE.md
+57-15Lines changed: 57 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,8 +29,7 @@ When making breaking changes, document them in **both**:
29
29
-`docs/migration.md` — human-readable guide with before/after code examples
30
30
-`docs/migration-SKILL.md` — LLM-optimized mapping tables for mechanical migration
31
31
32
-
Include what changed, why, and how to migrate. Search for related sections and group
33
-
related changes together rather than adding new standalone sections.
32
+
Include what changed, why, and how to migrate. Search for related sections and group related changes together rather than adding new standalone sections.
34
33
35
34
## Code Style Guidelines
36
35
@@ -146,37 +145,71 @@ When a request arrives from the remote side:
146
145
2.**`Protocol.connect()`** routes to `_onrequest()`, `_onresponse()`, or `_onnotification()`
147
146
3.**`Protocol._onrequest()`**:
148
147
- Looks up handler in `_requestHandlers` map (keyed by method name)
149
-
- Creates `RequestHandlerExtra` with `signal`, `sessionId`, `sendNotification`, `sendRequest`
148
+
- Creates a context object (`ServerContext` or `ClientContext`) via `createRequestContext()`
150
149
- Invokes handler, sends JSON-RPC response back via transport
151
150
4.**Handler** was registered via `setRequestHandler('method', handler)`
152
151
153
152
### Handler Registration
154
153
155
154
```typescript
156
155
// In Client (for server→client requests like sampling, elicitation)
0 commit comments