Merge branch 'main' into ihrpr/http-streamable-server
This commit is contained in:
commit
251bb9d97d
3 changed files with 133 additions and 464 deletions
|
|
@ -230,10 +230,19 @@ test("should respect server capabilities", async () => {
|
|||
await expect(client.listResources()).resolves.not.toThrow();
|
||||
await expect(client.listTools()).resolves.not.toThrow();
|
||||
|
||||
// This should throw because prompts are not supported
|
||||
// These should throw because prompts, logging, and completions are not supported
|
||||
await expect(client.listPrompts()).rejects.toThrow(
|
||||
"Server does not support prompts",
|
||||
);
|
||||
await expect(client.setLoggingLevel("error")).rejects.toThrow(
|
||||
"Server does not support logging",
|
||||
);
|
||||
await expect(
|
||||
client.complete({
|
||||
ref: { type: "ref/prompt", name: "test" },
|
||||
argument: { name: "test", value: "test" },
|
||||
}),
|
||||
).rejects.toThrow("Server does not support completions");
|
||||
});
|
||||
|
||||
test("should respect client notification capabilities", async () => {
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ export class Client<
|
|||
}
|
||||
}
|
||||
|
||||
override async connect(transport: Transport): Promise<void> {
|
||||
override async connect(transport: Transport, options?: RequestOptions): Promise<void> {
|
||||
await super.connect(transport);
|
||||
|
||||
try {
|
||||
|
|
@ -138,6 +138,7 @@ export class Client<
|
|||
},
|
||||
},
|
||||
InitializeResultSchema,
|
||||
options
|
||||
);
|
||||
|
||||
if (result === undefined) {
|
||||
|
|
@ -237,9 +238,9 @@ export class Client<
|
|||
break;
|
||||
|
||||
case "completion/complete":
|
||||
if (!this._serverCapabilities?.prompts) {
|
||||
if (!this._serverCapabilities?.completions) {
|
||||
throw new Error(
|
||||
`Server does not support prompts (required for ${method})`,
|
||||
`Server does not support completions (required for ${method})`,
|
||||
);
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ describe("SSEClientTransport", () => {
|
|||
// Send SSE headers
|
||||
res.writeHead(200, {
|
||||
"Content-Type": "text/event-stream",
|
||||
"Cache-Control": "no-cache",
|
||||
"Cache-Control": "no-cache, no-transform",
|
||||
Connection: "keep-alive",
|
||||
});
|
||||
|
||||
|
|
@ -56,6 +56,8 @@ describe("SSEClientTransport", () => {
|
|||
baseUrl = new URL(`http://127.0.0.1:${addr.port}`);
|
||||
done();
|
||||
});
|
||||
|
||||
jest.spyOn(console, 'error').mockImplementation(() => {});
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
|
|
@ -183,7 +185,7 @@ describe("SSEClientTransport", () => {
|
|||
if (req.method === "GET") {
|
||||
res.writeHead(200, {
|
||||
"Content-Type": "text/event-stream",
|
||||
"Cache-Control": "no-cache",
|
||||
"Cache-Control": "no-cache, no-transform",
|
||||
Connection: "keep-alive",
|
||||
});
|
||||
res.write("event: endpoint\n");
|
||||
|
|
@ -397,7 +399,7 @@ describe("SSEClientTransport", () => {
|
|||
|
||||
res.writeHead(200, {
|
||||
"Content-Type": "text/event-stream",
|
||||
"Cache-Control": "no-cache",
|
||||
"Cache-Control": "no-cache, no-transform",
|
||||
Connection: "keep-alive",
|
||||
});
|
||||
res.write("event: endpoint\n");
|
||||
|
|
@ -524,7 +526,7 @@ describe("SSEClientTransport", () => {
|
|||
if (auth === "Bearer new-token") {
|
||||
res.writeHead(200, {
|
||||
"Content-Type": "text/event-stream",
|
||||
"Cache-Control": "no-cache",
|
||||
"Cache-Control": "no-cache, no-transform",
|
||||
Connection: "keep-alive",
|
||||
});
|
||||
res.write("event: endpoint\n");
|
||||
|
|
@ -610,7 +612,7 @@ describe("SSEClientTransport", () => {
|
|||
|
||||
res.writeHead(200, {
|
||||
"Content-Type": "text/event-stream",
|
||||
"Cache-Control": "no-cache",
|
||||
"Cache-Control": "no-cache, no-transform",
|
||||
Connection: "keep-alive",
|
||||
});
|
||||
res.write("event: endpoint\n");
|
||||
|
|
|
|||
Loading…
Reference in a new issue