Skip to content

Commit db9ba7b

Browse files
committed
raw request propagation in tools - implementation, unit tests, types
1 parent df0d9c4 commit db9ba7b

File tree

14 files changed

+641
-226
lines changed

14 files changed

+641
-226
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@modelcontextprotocol/sdk",
3-
"version": "1.12.0",
3+
"version": "1.12.2",
44
"description": "Model Context Protocol implementation for TypeScript",
55
"license": "MIT",
66
"author": "Anthropic, PBC (https://anthropic.com)",

src/client/index.test.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,14 @@ import {
2020
import { Transport } from "../shared/transport.js";
2121
import { Server } from "../server/index.js";
2222
import { InMemoryTransport } from "../inMemory.js";
23-
23+
import { RequestInfo } from "../server/types/types.js";
24+
25+
const mockRequestInfo: RequestInfo = {
26+
headers: {
27+
'content-type': 'application/json',
28+
'accept': 'application/json',
29+
},
30+
};
2431
/***
2532
* Test: Initialize with Matching Protocol Version
2633
*/
@@ -42,7 +49,7 @@ test("should initialize with matching protocol version", async () => {
4249
},
4350
instructions: "test instructions",
4451
},
45-
});
52+
}, { requestInfo: mockRequestInfo });
4653
}
4754
return Promise.resolve();
4855
}),
@@ -100,7 +107,7 @@ test("should initialize with supported older protocol version", async () => {
100107
version: "1.0",
101108
},
102109
},
103-
});
110+
}, { requestInfo: mockRequestInfo });
104111
}
105112
return Promise.resolve();
106113
}),
@@ -150,7 +157,7 @@ test("should reject unsupported protocol version", async () => {
150157
version: "1.0",
151158
},
152159
},
153-
});
160+
}, { requestInfo: mockRequestInfo });
154161
}
155162
return Promise.resolve();
156163
}),

src/server/index.test.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ import {
1919
import { Transport } from "../shared/transport.js";
2020
import { InMemoryTransport } from "../inMemory.js";
2121
import { Client } from "../client/index.js";
22+
import { RequestInfo } from "./types/types.js";
23+
24+
const mockRequestInfo: RequestInfo = {
25+
headers: {
26+
'content-type': 'application/json',
27+
'traceparent': '00-4bf92f3577b34da6a3ce929d0e0e4736-00f067aa0ba902b7-01',
28+
},
29+
};
2230

2331
test("should accept latest protocol version", async () => {
2432
let sendPromiseResolve: (value: unknown) => void;
@@ -77,7 +85,7 @@ test("should accept latest protocol version", async () => {
7785
version: "1.0",
7886
},
7987
},
80-
});
88+
}, { requestInfo: mockRequestInfo });
8189

8290
await expect(sendPromise).resolves.toBeUndefined();
8391
});
@@ -138,7 +146,7 @@ test("should accept supported older protocol version", async () => {
138146
version: "1.0",
139147
},
140148
},
141-
});
149+
}, { requestInfo: mockRequestInfo });
142150

143151
await expect(sendPromise).resolves.toBeUndefined();
144152
});
@@ -198,7 +206,7 @@ test("should handle unsupported protocol version", async () => {
198206
version: "1.0",
199207
},
200208
},
201-
});
209+
}, { requestInfo: mockRequestInfo });
202210

203211
await expect(sendPromise).resolves.toBeUndefined();
204212
});

0 commit comments

Comments
 (0)