toolcraft 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +77 -59
- package/node_modules/@poe-code/agent-defs/dist/agents/claude-code.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/claude-code.js +15 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/claude-desktop.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/claude-desktop.js +13 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/codex.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/codex.js +14 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/goose.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/goose.js +14 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/index.d.ts +7 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/index.js +7 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/kimi.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/kimi.js +15 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/opencode.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/opencode.js +14 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/poe-agent.d.ts +2 -0
- package/node_modules/@poe-code/agent-defs/dist/agents/poe-agent.js +13 -0
- package/node_modules/@poe-code/agent-defs/dist/index.d.ts +5 -0
- package/node_modules/@poe-code/agent-defs/dist/index.js +3 -0
- package/node_modules/@poe-code/agent-defs/dist/registry.d.ts +3 -0
- package/node_modules/@poe-code/agent-defs/dist/registry.js +26 -0
- package/node_modules/@poe-code/agent-defs/dist/specifier.d.ts +7 -0
- package/node_modules/@poe-code/agent-defs/dist/specifier.js +27 -0
- package/node_modules/@poe-code/agent-defs/dist/types.d.ts +16 -0
- package/node_modules/@poe-code/agent-defs/dist/types.js +1 -0
- package/node_modules/@poe-code/agent-defs/package.json +20 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/apply-mutation.d.ts +5 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/apply-mutation.js +552 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.d.ts +17 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/path-utils.js +58 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/run-mutations.d.ts +7 -0
- package/node_modules/@poe-code/config-mutations/dist/execution/run-mutations.js +46 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/index.d.ts +13 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/index.js +49 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/json.d.ts +31 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/json.js +140 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/toml.d.ts +2 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/toml.js +72 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/yaml.d.ts +2 -0
- package/node_modules/@poe-code/config-mutations/dist/formats/yaml.js +73 -0
- package/node_modules/@poe-code/config-mutations/dist/fs-utils.d.ts +18 -0
- package/node_modules/@poe-code/config-mutations/dist/fs-utils.js +45 -0
- package/node_modules/@poe-code/config-mutations/dist/index.d.ts +8 -0
- package/node_modules/@poe-code/config-mutations/dist/index.js +8 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/config-mutation.d.ts +47 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/config-mutation.js +34 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/file-mutation.d.ts +52 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/file-mutation.js +46 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/template-mutation.d.ts +40 -0
- package/node_modules/@poe-code/config-mutations/dist/mutations/template-mutation.js +32 -0
- package/node_modules/@poe-code/config-mutations/dist/template/render.d.ts +7 -0
- package/node_modules/@poe-code/config-mutations/dist/template/render.js +28 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/format-utils.d.ts +7 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/format-utils.js +21 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/index.d.ts +3 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/index.js +2 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.d.ts +25 -0
- package/node_modules/@poe-code/config-mutations/dist/testing/mock-fs.js +170 -0
- package/node_modules/@poe-code/config-mutations/dist/types.d.ts +156 -0
- package/node_modules/@poe-code/config-mutations/dist/types.js +6 -0
- package/node_modules/@poe-code/config-mutations/package.json +33 -0
- package/node_modules/@poe-code/file-lock/README.md +52 -0
- package/node_modules/@poe-code/file-lock/dist/index.d.ts +1 -0
- package/node_modules/@poe-code/file-lock/dist/index.js +1 -0
- package/node_modules/@poe-code/file-lock/dist/lock.d.ts +27 -0
- package/node_modules/@poe-code/file-lock/dist/lock.js +203 -0
- package/node_modules/@poe-code/file-lock/package.json +23 -0
- package/node_modules/auth-store/README.md +47 -0
- package/node_modules/auth-store/dist/create-secret-store.d.ts +2 -0
- package/node_modules/auth-store/dist/create-secret-store.js +35 -0
- package/node_modules/auth-store/dist/encrypted-file-store.d.ts +39 -0
- package/node_modules/auth-store/dist/encrypted-file-store.js +156 -0
- package/node_modules/auth-store/dist/index.d.ts +7 -0
- package/node_modules/auth-store/dist/index.js +4 -0
- package/node_modules/auth-store/dist/keychain-store.d.ts +22 -0
- package/node_modules/auth-store/dist/keychain-store.js +111 -0
- package/node_modules/auth-store/dist/provider-store.d.ts +10 -0
- package/node_modules/auth-store/dist/provider-store.js +28 -0
- package/node_modules/auth-store/dist/types.d.ts +20 -0
- package/node_modules/auth-store/dist/types.js +1 -0
- package/node_modules/auth-store/package.json +25 -0
- package/node_modules/mcp-oauth/README.md +31 -0
- package/node_modules/mcp-oauth/dist/client/auth-store-session-store.d.ts +14 -0
- package/node_modules/mcp-oauth/dist/client/auth-store-session-store.js +97 -0
- package/node_modules/mcp-oauth/dist/client/authorization-state.d.ts +8 -0
- package/node_modules/mcp-oauth/dist/client/authorization-state.js +34 -0
- package/node_modules/mcp-oauth/dist/client/default-oauth-client-provider.d.ts +3 -0
- package/node_modules/mcp-oauth/dist/client/default-oauth-client-provider.js +491 -0
- package/node_modules/mcp-oauth/dist/client/loopback-authorization.d.ts +20 -0
- package/node_modules/mcp-oauth/dist/client/loopback-authorization.js +169 -0
- package/node_modules/mcp-oauth/dist/client/pkce.d.ts +2 -0
- package/node_modules/mcp-oauth/dist/client/pkce.js +7 -0
- package/node_modules/mcp-oauth/dist/client/token-endpoint.d.ts +40 -0
- package/node_modules/mcp-oauth/dist/client/token-endpoint.js +143 -0
- package/node_modules/mcp-oauth/dist/client/types.d.ts +113 -0
- package/node_modules/mcp-oauth/dist/client/types.js +1 -0
- package/node_modules/mcp-oauth/dist/index.d.ts +10 -0
- package/node_modules/mcp-oauth/dist/index.js +7 -0
- package/node_modules/mcp-oauth/dist/resource-indicator.d.ts +1 -0
- package/node_modules/mcp-oauth/dist/resource-indicator.js +11 -0
- package/node_modules/mcp-oauth/dist/server/jwks-token-verifier.d.ts +27 -0
- package/node_modules/mcp-oauth/dist/server/jwks-token-verifier.js +259 -0
- package/node_modules/mcp-oauth/dist/types.compile-check.d.ts +1 -0
- package/node_modules/mcp-oauth/dist/types.compile-check.js +22 -0
- package/node_modules/mcp-oauth/package.json +31 -0
- package/node_modules/tiny-mcp-client/.turbo/turbo-build.log +4 -0
- package/node_modules/tiny-mcp-client/dist/index.d.ts +2 -0
- package/node_modules/tiny-mcp-client/dist/index.js +1 -0
- package/node_modules/tiny-mcp-client/dist/internal.d.ts +547 -0
- package/node_modules/tiny-mcp-client/dist/internal.js +2404 -0
- package/node_modules/tiny-mcp-client/dist/jsonrpc-types.compile-check.d.ts +1 -0
- package/node_modules/tiny-mcp-client/dist/jsonrpc-types.compile-check.js +37 -0
- package/node_modules/tiny-mcp-client/dist/mcp-lifecycle-types.compile-check.d.ts +1 -0
- package/node_modules/tiny-mcp-client/dist/mcp-lifecycle-types.compile-check.js +50 -0
- package/node_modules/tiny-mcp-client/dist/mcp-prompt-types.compile-check.d.ts +1 -0
- package/node_modules/tiny-mcp-client/dist/mcp-prompt-types.compile-check.js +50 -0
- package/node_modules/tiny-mcp-client/dist/mcp-resource-types.compile-check.d.ts +1 -0
- package/node_modules/tiny-mcp-client/dist/mcp-resource-types.compile-check.js +51 -0
- package/node_modules/tiny-mcp-client/dist/mcp-tool-types.compile-check.d.ts +1 -0
- package/node_modules/tiny-mcp-client/dist/mcp-tool-types.compile-check.js +89 -0
- package/node_modules/tiny-mcp-client/dist/mcp-transport-types.compile-check.d.ts +1 -0
- package/node_modules/tiny-mcp-client/dist/mcp-transport-types.compile-check.js +56 -0
- package/node_modules/tiny-mcp-client/dist/mcp-utility-types.compile-check.d.ts +1 -0
- package/node_modules/tiny-mcp-client/dist/mcp-utility-types.compile-check.js +145 -0
- package/node_modules/tiny-mcp-client/dist/oauth-discovery.d.ts +24 -0
- package/node_modules/tiny-mcp-client/dist/oauth-discovery.js +385 -0
- package/node_modules/tiny-mcp-client/package.json +22 -0
- package/node_modules/tiny-mcp-client/src/http-oauth.integration.test.ts +823 -0
- package/node_modules/tiny-mcp-client/src/http-oauth.test.ts +882 -0
- package/node_modules/tiny-mcp-client/src/index.ts +94 -0
- package/node_modules/tiny-mcp-client/src/internal.ts +3566 -0
- package/node_modules/tiny-mcp-client/src/jsonrpc-types.compile-check.ts +66 -0
- package/node_modules/tiny-mcp-client/src/mcp-client-http-transport.integration.test.ts +222 -0
- package/node_modules/tiny-mcp-client/src/mcp-client-sdk.test.ts +1294 -0
- package/node_modules/tiny-mcp-client/src/mcp-client-tiny-stdio-test-server-tools.test.ts +143 -0
- package/node_modules/tiny-mcp-client/src/mcp-lifecycle-types.compile-check.ts +65 -0
- package/node_modules/tiny-mcp-client/src/mcp-prompt-types.compile-check.ts +66 -0
- package/node_modules/tiny-mcp-client/src/mcp-resource-types.compile-check.ts +70 -0
- package/node_modules/tiny-mcp-client/src/mcp-tool-types.compile-check.ts +117 -0
- package/node_modules/tiny-mcp-client/src/mcp-transport-types.compile-check.ts +75 -0
- package/node_modules/tiny-mcp-client/src/mcp-utility-types.compile-check.ts +181 -0
- package/node_modules/tiny-mcp-client/src/mock-servers.test.ts +980 -0
- package/node_modules/tiny-mcp-client/src/oauth-discovery.ts +583 -0
- package/node_modules/tiny-mcp-client/src/transports.test.ts +8139 -0
- package/node_modules/tiny-mcp-client/src/utilities.test.ts +372 -0
- package/node_modules/tiny-mcp-client/tsconfig.json +11 -0
- package/package.json +24 -11
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
JsonRpcErrorObject,
|
|
3
|
+
JsonRpcErrorResponse,
|
|
4
|
+
JsonRpcNotification,
|
|
5
|
+
JsonRpcRequest,
|
|
6
|
+
JsonRpcResponse,
|
|
7
|
+
JsonRpcSuccessResponse,
|
|
8
|
+
RequestId,
|
|
9
|
+
} from "./index.js";
|
|
10
|
+
|
|
11
|
+
const requestIdFromNumber: RequestId = 1;
|
|
12
|
+
const requestIdFromString: RequestId = "request-1";
|
|
13
|
+
|
|
14
|
+
// @ts-expect-error MCP does not allow null request ids.
|
|
15
|
+
const requestIdFromNull: RequestId = null;
|
|
16
|
+
|
|
17
|
+
const request: JsonRpcRequest = {
|
|
18
|
+
jsonrpc: "2.0",
|
|
19
|
+
id: requestIdFromNumber,
|
|
20
|
+
method: "tools/list",
|
|
21
|
+
params: { cursor: "next" },
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const notification: JsonRpcNotification = {
|
|
25
|
+
jsonrpc: "2.0",
|
|
26
|
+
method: "notifications/initialized",
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// @ts-expect-error Notifications must not define an id.
|
|
30
|
+
const notificationWithId: JsonRpcNotification = { jsonrpc: "2.0", id: requestIdFromString, method: "notifications/initialized" };
|
|
31
|
+
|
|
32
|
+
const successResponse: JsonRpcSuccessResponse = {
|
|
33
|
+
jsonrpc: "2.0",
|
|
34
|
+
id: requestIdFromNumber,
|
|
35
|
+
result: { tools: [] },
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const errorObject: JsonRpcErrorObject = {
|
|
39
|
+
code: -32601,
|
|
40
|
+
message: "Method not found",
|
|
41
|
+
data: { method: request.method },
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const errorResponse: JsonRpcErrorResponse = {
|
|
45
|
+
jsonrpc: "2.0",
|
|
46
|
+
id: requestIdFromString,
|
|
47
|
+
error: errorObject,
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const responses: JsonRpcResponse[] = [successResponse, errorResponse];
|
|
51
|
+
|
|
52
|
+
type AssertAssignable<To, ignoredFrom extends To> = true;
|
|
53
|
+
|
|
54
|
+
type ignoredResponseIncludesSuccess = AssertAssignable<
|
|
55
|
+
JsonRpcResponse,
|
|
56
|
+
JsonRpcSuccessResponse
|
|
57
|
+
>;
|
|
58
|
+
type ignoredResponseIncludesError = AssertAssignable<
|
|
59
|
+
JsonRpcResponse,
|
|
60
|
+
JsonRpcErrorResponse
|
|
61
|
+
>;
|
|
62
|
+
|
|
63
|
+
void requestIdFromNull;
|
|
64
|
+
void notification;
|
|
65
|
+
void notificationWithId;
|
|
66
|
+
void responses;
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { HttpTransport, McpClient } from "./internal.js";
|
|
3
|
+
|
|
4
|
+
interface JsonRpcRequest {
|
|
5
|
+
jsonrpc: string;
|
|
6
|
+
id?: number | string | null;
|
|
7
|
+
method: string;
|
|
8
|
+
params?: unknown;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface RecordedPostRequest {
|
|
12
|
+
methodName: string;
|
|
13
|
+
sessionId: string | null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const isObjectRecord = (value: unknown): value is Record<string, unknown> =>
|
|
17
|
+
typeof value === "object" && value !== null && !Array.isArray(value);
|
|
18
|
+
|
|
19
|
+
const parseJsonRpcRequest = (body: BodyInit | null | undefined): JsonRpcRequest => {
|
|
20
|
+
if (typeof body !== "string") {
|
|
21
|
+
throw new Error("Expected HTTP POST body to be a JSON string");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const parsed = JSON.parse(body) as unknown;
|
|
25
|
+
if (!isObjectRecord(parsed) || typeof parsed.method !== "string") {
|
|
26
|
+
throw new Error("Expected HTTP POST body to contain a JSON-RPC request object");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return parsed as JsonRpcRequest;
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const requireRequestId = (request: JsonRpcRequest): number | string => {
|
|
33
|
+
if (request.id === undefined || request.id === null) {
|
|
34
|
+
throw new Error(`Expected JSON-RPC request "${request.method}" to include an id`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return request.id;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
describe("McpClient HTTP transport integration", () => {
|
|
41
|
+
it("initializes, lists tools, calls tool, tracks session, and sends DELETE on close", async () => {
|
|
42
|
+
const sessionId = "session-http-integration-1";
|
|
43
|
+
const recordedPostRequests: RecordedPostRequest[] = [];
|
|
44
|
+
const deleteSessionIds: Array<string | null> = [];
|
|
45
|
+
|
|
46
|
+
const mockFetch = vi.fn(async (_input: string | URL, init?: RequestInit): Promise<Response> => {
|
|
47
|
+
const method = init?.method ?? "GET";
|
|
48
|
+
|
|
49
|
+
if (method === "GET") {
|
|
50
|
+
return new Response(null, { status: 405 });
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const headers = new Headers(init?.headers);
|
|
54
|
+
|
|
55
|
+
if (method === "DELETE") {
|
|
56
|
+
deleteSessionIds.push(headers.get("mcp-session-id"));
|
|
57
|
+
return new Response(null, { status: 204 });
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (method !== "POST") {
|
|
61
|
+
throw new Error(`Unexpected HTTP method: ${method}`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const request = parseJsonRpcRequest(init?.body);
|
|
65
|
+
recordedPostRequests.push({
|
|
66
|
+
methodName: request.method,
|
|
67
|
+
sessionId: headers.get("mcp-session-id"),
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
if (request.method === "initialize") {
|
|
71
|
+
return new Response(
|
|
72
|
+
JSON.stringify({
|
|
73
|
+
jsonrpc: "2.0",
|
|
74
|
+
id: requireRequestId(request),
|
|
75
|
+
result: {
|
|
76
|
+
protocolVersion: "2025-03-26",
|
|
77
|
+
capabilities: {
|
|
78
|
+
tools: {},
|
|
79
|
+
},
|
|
80
|
+
serverInfo: {
|
|
81
|
+
name: "mock-http-server",
|
|
82
|
+
version: "1.0.0",
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
}),
|
|
86
|
+
{
|
|
87
|
+
status: 200,
|
|
88
|
+
headers: {
|
|
89
|
+
"Content-Type": "application/json",
|
|
90
|
+
"Mcp-Session-Id": sessionId,
|
|
91
|
+
},
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (request.method === "notifications/initialized") {
|
|
97
|
+
return new Response(null, { status: 202 });
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (request.method === "tools/list") {
|
|
101
|
+
return new Response(
|
|
102
|
+
JSON.stringify({
|
|
103
|
+
jsonrpc: "2.0",
|
|
104
|
+
id: requireRequestId(request),
|
|
105
|
+
result: {
|
|
106
|
+
tools: [
|
|
107
|
+
{
|
|
108
|
+
name: "echo",
|
|
109
|
+
inputSchema: {
|
|
110
|
+
type: "object",
|
|
111
|
+
properties: {
|
|
112
|
+
message: {
|
|
113
|
+
type: "string",
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
required: ["message"],
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
],
|
|
120
|
+
},
|
|
121
|
+
}),
|
|
122
|
+
{
|
|
123
|
+
status: 200,
|
|
124
|
+
headers: {
|
|
125
|
+
"Content-Type": "application/json",
|
|
126
|
+
},
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
if (request.method === "tools/call") {
|
|
132
|
+
if (
|
|
133
|
+
!isObjectRecord(request.params) ||
|
|
134
|
+
request.params.name !== "echo" ||
|
|
135
|
+
!isObjectRecord(request.params.arguments) ||
|
|
136
|
+
typeof request.params.arguments.message !== "string"
|
|
137
|
+
) {
|
|
138
|
+
throw new Error("Expected tools/call params with name=echo and string arguments.message");
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
return new Response(
|
|
142
|
+
JSON.stringify({
|
|
143
|
+
jsonrpc: "2.0",
|
|
144
|
+
id: requireRequestId(request),
|
|
145
|
+
result: {
|
|
146
|
+
content: [
|
|
147
|
+
{
|
|
148
|
+
type: "text",
|
|
149
|
+
text: request.params.arguments.message,
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
},
|
|
153
|
+
}),
|
|
154
|
+
{
|
|
155
|
+
status: 200,
|
|
156
|
+
headers: {
|
|
157
|
+
"Content-Type": "application/json",
|
|
158
|
+
},
|
|
159
|
+
}
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
throw new Error(`Unexpected JSON-RPC method: ${request.method}`);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
const client = new McpClient({
|
|
167
|
+
clientInfo: {
|
|
168
|
+
name: "http-integration-test-client",
|
|
169
|
+
version: "1.0.0",
|
|
170
|
+
},
|
|
171
|
+
});
|
|
172
|
+
const transport = new HttpTransport({
|
|
173
|
+
url: "https://example.com/mcp",
|
|
174
|
+
fetch: mockFetch,
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
try {
|
|
178
|
+
await client.connect(transport);
|
|
179
|
+
|
|
180
|
+
const toolsResult = await client.listTools();
|
|
181
|
+
expect(toolsResult.tools).toHaveLength(1);
|
|
182
|
+
expect(toolsResult.tools[0]).toMatchObject({
|
|
183
|
+
name: "echo",
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
const callResult = await client.callTool({
|
|
187
|
+
name: "echo",
|
|
188
|
+
arguments: {
|
|
189
|
+
message: "hello from HTTP integration",
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
expect(callResult).toEqual({
|
|
194
|
+
content: [{ type: "text", text: "hello from HTTP integration" }],
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
await client.close();
|
|
198
|
+
|
|
199
|
+
await vi.waitFor(() => {
|
|
200
|
+
expect(deleteSessionIds).toEqual([sessionId]);
|
|
201
|
+
});
|
|
202
|
+
|
|
203
|
+
expect(recordedPostRequests.map((request) => request.methodName)).toEqual([
|
|
204
|
+
"initialize",
|
|
205
|
+
"notifications/initialized",
|
|
206
|
+
"tools/list",
|
|
207
|
+
"tools/call",
|
|
208
|
+
]);
|
|
209
|
+
|
|
210
|
+
const sessionByMethod = new Map(
|
|
211
|
+
recordedPostRequests.map((request) => [request.methodName, request.sessionId] as const)
|
|
212
|
+
);
|
|
213
|
+
|
|
214
|
+
expect(sessionByMethod.get("initialize")).toBeNull();
|
|
215
|
+
expect(sessionByMethod.get("notifications/initialized")).toBe(sessionId);
|
|
216
|
+
expect(sessionByMethod.get("tools/list")).toBe(sessionId);
|
|
217
|
+
expect(sessionByMethod.get("tools/call")).toBe(sessionId);
|
|
218
|
+
} finally {
|
|
219
|
+
await client.close();
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
});
|