Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 251bb9d

Browse files
committed
Merge branch 'main' into ihrpr/http-streamable-server
2 parents 4068e6f + 0d0af54 commit 251bb9d

22 files changed

+133
-464
lines changed

.github/workflows/main.yml

+1-2
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ jobs:
4646

4747
- run: npm ci
4848

49-
# TODO: Add --provenance once the repo is public
50-
- run: npm publish --access public
49+
- run: npm publish --provenance --access public
5150
env:
5251
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.prettierrc

-8
This file was deleted.

README.md

+8-10
Original file line numberDiff line numberDiff line change
@@ -455,13 +455,6 @@ const client = new Client(
455455
{
456456
name: "example-client",
457457
version: "1.0.0"
458-
},
459-
{
460-
capabilities: {
461-
prompts: {},
462-
resources: {},
463-
tools: {}
464-
}
465458
}
466459
);
467460

@@ -471,15 +464,20 @@ await client.connect(transport);
471464
const prompts = await client.listPrompts();
472465

473466
// Get a prompt
474-
const prompt = await client.getPrompt("example-prompt", {
475-
arg1: "value"
467+
const prompt = await client.getPrompt({
468+
name: "example-prompt",
469+
arguments: {
470+
arg1: "value"
471+
}
476472
});
477473

478474
// List resources
479475
const resources = await client.listResources();
480476

481477
// Read a resource
482-
const resource = await client.readResource("file:///example.txt");
478+
const resource = await client.readResource({
479+
uri: "file:///example.txt"
480+
});
483481

484482
// Call a tool
485483
const result = await client.callTool({

jest.config.js

-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@ export default {
1212
transformIgnorePatterns: [
1313
"/node_modules/(?!eventsource)/"
1414
],
15-
collectCoverageFrom: ["src/**/*.ts"],
1615
testPathIgnorePatterns: ["/node_modules/", "/dist/"],
1716
};

package-lock.json

+28-23
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@modelcontextprotocol/sdk",
3-
"version": "1.8.0",
3+
"version": "1.9.0",
44
"description": "Model Context Protocol implementation for TypeScript",
55
"license": "MIT",
66
"author": "Anthropic, PBC (https://anthropic.com)",
@@ -41,7 +41,6 @@
4141
"prepack": "npm run build:esm && npm run build:cjs",
4242
"lint": "eslint src/",
4343
"test": "jest",
44-
"coverage": "jest --coverage",
4544
"start": "npm run server",
4645
"server": "tsx watch --clear-screen=false src/cli.ts server",
4746
"client": "tsx src/cli.ts client"

src/client/index.test.ts

+10-1
Original file line numberDiff line numberDiff line change
@@ -230,10 +230,19 @@ test("should respect server capabilities", async () => {
230230
await expect(client.listResources()).resolves.not.toThrow();
231231
await expect(client.listTools()).resolves.not.toThrow();
232232

233-
// This should throw because prompts are not supported
233+
// These should throw because prompts, logging, and completions are not supported
234234
await expect(client.listPrompts()).rejects.toThrow(
235235
"Server does not support prompts",
236236
);
237+
await expect(client.setLoggingLevel("error")).rejects.toThrow(
238+
"Server does not support logging",
239+
);
240+
await expect(
241+
client.complete({
242+
ref: { type: "ref/prompt", name: "test" },
243+
argument: { name: "test", value: "test" },
244+
}),
245+
).rejects.toThrow("Server does not support completions");
237246
});
238247

239248
test("should respect client notification capabilities", async () => {

src/client/index.ts

+4-3
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export class Client<
124124
}
125125
}
126126

127-
override async connect(transport: Transport): Promise<void> {
127+
override async connect(transport: Transport, options?: RequestOptions): Promise<void> {
128128
await super.connect(transport);
129129

130130
try {
@@ -138,6 +138,7 @@ export class Client<
138138
},
139139
},
140140
InitializeResultSchema,
141+
options
141142
);
142143

143144
if (result === undefined) {
@@ -237,9 +238,9 @@ export class Client<
237238
break;
238239

239240
case "completion/complete":
240-
if (!this._serverCapabilities?.prompts) {
241+
if (!this._serverCapabilities?.completions) {
241242
throw new Error(
242-
`Server does not support prompts (required for ${method})`,
243+
`Server does not support completions (required for ${method})`,
243244
);
244245
}
245246
break;

src/client/sse.test.ts

+7-5
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe("SSEClientTransport", () => {
2424
// Send SSE headers
2525
res.writeHead(200, {
2626
"Content-Type": "text/event-stream",
27-
"Cache-Control": "no-cache",
27+
"Cache-Control": "no-cache, no-transform",
2828
Connection: "keep-alive",
2929
});
3030

@@ -56,6 +56,8 @@ describe("SSEClientTransport", () => {
5656
baseUrl = new URL(`http://127.0.0.1:${addr.port}`);
5757
done();
5858
});
59+
60+
jest.spyOn(console, 'error').mockImplementation(() => {});
5961
});
6062

6163
afterEach(async () => {
@@ -183,7 +185,7 @@ describe("SSEClientTransport", () => {
183185
if (req.method === "GET") {
184186
res.writeHead(200, {
185187
"Content-Type": "text/event-stream",
186-
"Cache-Control": "no-cache",
188+
"Cache-Control": "no-cache, no-transform",
187189
Connection: "keep-alive",
188190
});
189191
res.write("event: endpoint\n");
@@ -397,7 +399,7 @@ describe("SSEClientTransport", () => {
397399

398400
res.writeHead(200, {
399401
"Content-Type": "text/event-stream",
400-
"Cache-Control": "no-cache",
402+
"Cache-Control": "no-cache, no-transform",
401403
Connection: "keep-alive",
402404
});
403405
res.write("event: endpoint\n");
@@ -524,7 +526,7 @@ describe("SSEClientTransport", () => {
524526
if (auth === "Bearer new-token") {
525527
res.writeHead(200, {
526528
"Content-Type": "text/event-stream",
527-
"Cache-Control": "no-cache",
529+
"Cache-Control": "no-cache, no-transform",
528530
Connection: "keep-alive",
529531
});
530532
res.write("event: endpoint\n");
@@ -610,7 +612,7 @@ describe("SSEClientTransport", () => {
610612

611613
res.writeHead(200, {
612614
"Content-Type": "text/event-stream",
613-
"Cache-Control": "no-cache",
615+
"Cache-Control": "no-cache, no-transform",
614616
Connection: "keep-alive",
615617
});
616618
res.write("event: endpoint\n");

src/inMemory.ts

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ export class InMemoryTransport implements Transport {
1212
onerror?: (error: Error) => void;
1313
onmessage?: (message: JSONRPCMessage) => void;
1414
sessionId?: string;
15-
user?: unknown;
1615

1716
/**
1817
* Creates a pair of linked in-memory transports that can communicate with each other. One should be passed to a Client and one to a Server.

src/server/auth/middleware/bearerAuth.test.ts

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ describe("requireBearerAuth middleware", () => {
3131
set: jest.fn().mockReturnThis(),
3232
};
3333
nextFunction = jest.fn();
34+
jest.spyOn(console, 'error').mockImplementation(() => {});
35+
})
36+
37+
afterEach(() => {
3438
jest.clearAllMocks();
3539
});
3640

src/server/auth/router.test.ts

+5
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,11 @@ describe('MCP Auth Router', () => {
259259
issuerUrl: new URL('https://auth.example.com')
260260
};
261261
app.use(mcpAuthRouter(options));
262+
jest.spyOn(console, 'error').mockImplementation(() => {});
263+
});
264+
265+
afterEach(() => {
266+
jest.restoreAllMocks();
262267
});
263268

264269
it('routes to authorization endpoint', async () => {

0 commit comments

Comments
 (0)