Skip to content

Commit c698143

Browse files
fix: resolve merge conflict markers in docs and CLAUDE.md
1 parent 9ddaac4 commit c698143

3 files changed

Lines changed: 43 additions & 62 deletions

File tree

CLAUDE.md

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -153,21 +153,13 @@ When a request arrives from the remote side:
153153

154154
```typescript
155155
// In Client (for server→client requests like sampling, elicitation)
156-
<<<<<<< HEAD
157-
client.setRequestHandler(CreateMessageRequestSchema, async (request, ctx) => {
158-
=======
159-
client.setRequestHandler('sampling/createMessage', async (request, extra) => {
160-
>>>>>>> f6e8204b8621f55ee08c4f8cb8b2b85eff104842
156+
client.setRequestHandler('sampling/createMessage', async (request, ctx) => {
161157
// Handle sampling request from server
162158
return { role: "assistant", content: {...}, model: "..." };
163159
});
164160

165161
// In Server (for client→server requests like tools/call)
166-
<<<<<<< HEAD
167-
server.setRequestHandler(CallToolRequestSchema, async (request, ctx) => {
168-
=======
169-
server.setRequestHandler('tools/call', async (request, extra) => {
170-
>>>>>>> f6e8204b8621f55ee08c4f8cb8b2b85eff104842
162+
server.setRequestHandler('tools/call', async (request, ctx) => {
171163
// Handle tool call from client
172164
return { content: [...] };
173165
});
@@ -240,11 +232,7 @@ const result = await server.createMessage({
240232
});
241233

242234
// Client must have registered handler:
243-
<<<<<<< HEAD
244-
client.setRequestHandler(CreateMessageRequestSchema, async (request, ctx) => {
245-
=======
246-
client.setRequestHandler('sampling/createMessage', async (request, extra) => {
247-
>>>>>>> f6e8204b8621f55ee08c4f8cb8b2b85eff104842
235+
client.setRequestHandler('sampling/createMessage', async (request, ctx) => {
248236
// Client-side LLM call
249237
return { role: "assistant", content: {...} };
250238
});
@@ -255,13 +243,8 @@ client.setRequestHandler('sampling/createMessage', async (request, extra) => {
255243
### Request Handler Registration (Low-Level Server)
256244

257245
```typescript
258-
<<<<<<< HEAD
259-
server.setRequestHandler(SomeRequestSchema, async (request, ctx) => {
260-
// ctx provides mcpCtx, requestCtx, task, sendNotification, sendRequest
261-
=======
262-
server.setRequestHandler('tools/call', async (request, extra) => {
263-
// extra contains sessionId, authInfo, sendNotification, etc.
264-
>>>>>>> f6e8204b8621f55ee08c4f8cb8b2b85eff104842
246+
server.setRequestHandler('tools/call', async (request, ctx) => {
247+
// ctx provides mcpReq, http, task, notification
265248
return {
266249
/* result */
267250
};

docs/migration-SKILL.md

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,8 @@ Request/notification params remain fully typed. Remove unused schema imports aft
252252

253253
`Client.listPrompts()`, `listResources()`, `listResourceTemplates()`, `listTools()` now return empty results when the server lacks the corresponding capability (instead of sending the request). Set `enforceStrictCapabilities: true` in `ClientOptions` to throw an error instead.
254254

255-
<<<<<<< HEAD
256255

257-
## 10. Context API (replaces `RequestHandlerExtra`)
256+
## 11. Context API (replaces `RequestHandlerExtra`)
258257

259258
Tool, prompt, and resource callbacks now receive a structured context object (`ctx`) instead of the flat `extra` parameter.
260259

@@ -269,7 +268,7 @@ Tool, prompt, and resource callbacks now receive a structured context object (`c
269268
| `extra.authInfo` | `ctx.http?.authInfo` |
270269
| `extra.requestInfo?.headers` | `ctx.http?.req.headers` |
271270
| `extra.sendNotification(n)` | `ctx.notification.send(n)` |
272-
| `extra.sendRequest(r, s, o)` | `ctx.mcpReq.send(r, s, o)` |
271+
| `extra.sendRequest(r, s, o)` | `ctx.mcpReq.send(r, s, o)` |
273272
| `extra.taskId` | `ctx.task?.id` |
274273
| `extra.taskStore` | `ctx.task?.store` |
275274
| `extra.taskRequestedTtl` | `ctx.task?.requestedTtl` |
@@ -337,12 +336,6 @@ server.registerTool('my-tool', { inputSchema: { q: z.string() } }, async ({ q },
337336
338337
## 12. Migration Steps (apply in this order)
339338
340-
=======
341-
342-
## 11. Migration Steps (apply in this order)
343-
344-
> > > > > > > f6e8204b8621f55ee08c4f8cb8b2b85eff104842
345-
346339
1. Update `package.json`: `npm uninstall @modelcontextprotocol/sdk`, install the appropriate v2 packages
347340
2. Replace all imports from `@modelcontextprotocol/sdk/...` using the import mapping tables (sections 3-4), including `StreamableHTTPServerTransport``NodeStreamableHTTPServerTransport`
348341
3. Replace removed type aliases (`JSONRPCError``JSONRPCErrorResponse`, etc.) per section 5

docs/migration.md

Lines changed: 36 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -240,22 +240,13 @@ app.use(hostHeaderValidation(['example.com']));
240240

241241
Note: the v2 signature takes a plain `string[]` instead of an options object.
242242

243-
<<<<<<< HEAD
244-
245243
### Context API replaces `RequestHandlerExtra`
246244

247-
# The `extra` parameter in tool, prompt, and resource callbacks has been replaced with a structured context object (`ctx`). The old flat `RequestHandlerExtra` interface is replaced by `ServerContextInterface` (for server callbacks) and `ClientContextInterface` (for client callbacks).
248-
249-
### `setRequestHandler` and `setNotificationHandler` use method strings
250-
251-
The low-level `setRequestHandler` and `setNotificationHandler` methods on `Client`, `Server`, and `Protocol` now take a method string instead of a Zod schema.
252-
253-
> > > > > > > f6e8204b8621f55ee08c4f8cb8b2b85eff104842
245+
The `extra` parameter in tool, prompt, and resource callbacks has been replaced with a structured context object (`ctx`). The old flat `RequestHandlerExtra` interface is replaced by `ServerContextInterface` (for server callbacks) and `ClientContextInterface` (for client callbacks).
254246

255247
**Before (v1):**
256248

257249
```typescript
258-
<<<<<<< HEAD
259250
server.registerTool('my-tool', { inputSchema: { query: z.string() } }, async ({ query }, extra) => {
260251
// Flat properties
261252
console.log(extra.requestId);
@@ -277,27 +268,12 @@ server.registerTool('my-tool', { inputSchema: { query: z.string() } }, async ({
277268
extra.closeSSEStream?.();
278269

279270
return { content: [{ type: 'text', text: 'Done' }] };
280-
=======
281-
import { Server, InitializeRequestSchema, LoggingMessageNotificationSchema } from '@modelcontextprotocol/sdk/server/index.js';
282-
283-
const server = new Server({ name: 'my-server', version: '1.0.0' });
284-
285-
// Request handler with schema
286-
server.setRequestHandler(InitializeRequestSchema, async (request) => {
287-
return { protocolVersion: '...', capabilities: {}, serverInfo: { name: '...', version: '...' } };
288-
});
289-
290-
// Notification handler with schema
291-
server.setNotificationHandler(LoggingMessageNotificationSchema, (notification) => {
292-
console.log(notification.params.data);
293-
>>>>>>> f6e8204b8621f55ee08c4f8cb8b2b85eff104842
294271
});
295272
```
296273

297274
**After (v2):**
298275

299276
```typescript
300-
<<<<<<< HEAD
301277
server.registerTool('my-tool', { inputSchema: { query: z.string() } }, async ({ query }, ctx) => {
302278
// Grouped into nested objects
303279
console.log(ctx.mcpReq.id); // was extra.requestId
@@ -341,7 +317,7 @@ server.registerTool('my-tool', { inputSchema: { query: z.string() } }, async ({
341317
| `extra.authInfo` | `ctx.http?.authInfo` |
342318
| `extra.requestInfo?.headers` | `ctx.http?.req.headers` |
343319
| `extra.sendNotification(n)` | `ctx.notification.send(n)` |
344-
| `extra.sendRequest(r, s, o)` | `ctx.mcpReq.send(r, s, o)` |
320+
| `extra.sendRequest(r, s, o)` | `ctx.mcpReq.send(r, s, o)` |
345321
| `extra.taskId` | `ctx.task?.id` |
346322
| `extra.taskStore` | `ctx.task?.store` |
347323
| `extra.taskRequestedTtl` | `ctx.task?.requestedTtl` |
@@ -361,15 +337,45 @@ server.registerTool('my-tool', { inputSchema: { query: z.string() } }, async ({
361337
| `ctx.mcpReq.requestSampling(params, opts?)` | Request LLM sampling from client |
362338
| `ctx.http?.req` | Raw fetch `Request` object (access URL, headers, etc.) |
363339

364-
======= import { Server } from '@modelcontextprotocol/server';
340+
### `setRequestHandler` and `setNotificationHandler` use method strings
341+
342+
The low-level `setRequestHandler` and `setNotificationHandler` methods on `Client`, `Server`, and `Protocol` now take a method string instead of a Zod schema.
343+
344+
**Before (v1):**
345+
346+
```typescript
347+
import { Server, InitializeRequestSchema, LoggingMessageNotificationSchema } from '@modelcontextprotocol/sdk/server/index.js';
365348

366349
const server = new Server({ name: 'my-server', version: '1.0.0' });
367350

368-
// Request handler with method string server.setRequestHandler('initialize', async (request) => { return { protocolVersion: '...', capabilities: {}, serverInfo: { name: '...', version: '...' } }; });
351+
// Request handler with schema
352+
server.setRequestHandler(InitializeRequestSchema, async (request) => {
353+
return { protocolVersion: '...', capabilities: {}, serverInfo: { name: '...', version: '...' } };
354+
});
369355

370-
// Notification handler with method string server.setNotificationHandler('notifications/message', (notification) => { console.log(notification.params.data); });
356+
// Notification handler with schema
357+
server.setNotificationHandler(LoggingMessageNotificationSchema, (notification) => {
358+
console.log(notification.params.data);
359+
});
360+
```
371361

372-
````
362+
**After (v2):**
363+
364+
```typescript
365+
import { Server } from '@modelcontextprotocol/server';
366+
367+
const server = new Server({ name: 'my-server', version: '1.0.0' });
368+
369+
// Request handler with method string
370+
server.setRequestHandler('initialize', async (request) => {
371+
return { protocolVersion: '...', capabilities: {}, serverInfo: { name: '...', version: '...' } };
372+
});
373+
374+
// Notification handler with method string
375+
server.setNotificationHandler('notifications/message', (notification) => {
376+
console.log(notification.params.data);
377+
});
378+
```
373379

374380
The request and notification parameters remain fully typed via `RequestTypeMap` and `NotificationTypeMap`. You no longer need to import the individual `*RequestSchema` or `*NotificationSchema` constants for handler registration.
375381

@@ -390,7 +396,6 @@ Common method string replacements:
390396
| `ToolListChangedNotificationSchema` | `'notifications/tools/list_changed'` |
391397
| `ResourceListChangedNotificationSchema` | `'notifications/resources/list_changed'` |
392398
| `PromptListChangedNotificationSchema` | `'notifications/prompts/list_changed'` |
393-
>>>>>>> f6e8204b8621f55ee08c4f8cb8b2b85eff104842
394399

395400
### Client list methods return empty results for missing capabilities
396401

0 commit comments

Comments
 (0)