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,143 @@
|
|
|
1
|
+
import { createTestServer } from "tiny-stdio-mcp-test-server";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { McpClient, createTestPair } from "./internal.js";
|
|
4
|
+
|
|
5
|
+
describe("McpClient integration tools with tiny-stdio-mcp-test-server", () => {
|
|
6
|
+
it("completes full lifecycle: connect, list tools, call each tool, and close", async () => {
|
|
7
|
+
const server = createTestServer();
|
|
8
|
+
const { client, cleanup } = await createTestPair(server, () =>
|
|
9
|
+
new McpClient({
|
|
10
|
+
clientInfo: {
|
|
11
|
+
name: "test-client",
|
|
12
|
+
version: "1.0.0",
|
|
13
|
+
},
|
|
14
|
+
})
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
expect(client.serverInfo).toEqual({
|
|
19
|
+
name: "tiny-stdio-mcp-test-server",
|
|
20
|
+
version: "0.0.1",
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const { tools } = await client.listTools();
|
|
24
|
+
const toolNames = tools.map((tool) => tool.name).sort();
|
|
25
|
+
|
|
26
|
+
expect(toolNames).toEqual(["caesar_cipher_encrypt", "word_of_the_day"]);
|
|
27
|
+
|
|
28
|
+
const expectedCallResultsByTool: Record<
|
|
29
|
+
string,
|
|
30
|
+
{
|
|
31
|
+
arguments: Record<string, unknown>;
|
|
32
|
+
result: { content: [{ type: "text"; text: string }] };
|
|
33
|
+
}
|
|
34
|
+
> = {
|
|
35
|
+
caesar_cipher_encrypt: {
|
|
36
|
+
arguments: { text: "hello" },
|
|
37
|
+
result: {
|
|
38
|
+
content: [{ type: "text", text: "khoor" }],
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
word_of_the_day: {
|
|
42
|
+
arguments: {},
|
|
43
|
+
result: {
|
|
44
|
+
content: [{ type: "text", text: "Bumfuzzle - to confuse or fluster someone" }],
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
for (const toolName of toolNames) {
|
|
50
|
+
const expectedCall = expectedCallResultsByTool[toolName];
|
|
51
|
+
expect(expectedCall).toBeDefined();
|
|
52
|
+
|
|
53
|
+
if (expectedCall === undefined) {
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const result = await client.callTool({
|
|
58
|
+
name: toolName,
|
|
59
|
+
arguments: expectedCall.arguments,
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
expect(result).toEqual(expectedCall.result);
|
|
63
|
+
}
|
|
64
|
+
} finally {
|
|
65
|
+
await cleanup();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
expect(client.state).toBe("closed");
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("lists caesar_cipher_encrypt and word_of_the_day via createTestPair", async () => {
|
|
72
|
+
const server = createTestServer();
|
|
73
|
+
const { client, cleanup } = await createTestPair(server, () =>
|
|
74
|
+
new McpClient({
|
|
75
|
+
clientInfo: {
|
|
76
|
+
name: "test-client",
|
|
77
|
+
version: "1.0.0",
|
|
78
|
+
},
|
|
79
|
+
})
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
try {
|
|
83
|
+
const result = await client.listTools();
|
|
84
|
+
const toolNames = result.tools.map((tool) => tool.name);
|
|
85
|
+
|
|
86
|
+
expect(result.tools).toHaveLength(2);
|
|
87
|
+
expect(toolNames).toContain("caesar_cipher_encrypt");
|
|
88
|
+
expect(toolNames).toContain("word_of_the_day");
|
|
89
|
+
} finally {
|
|
90
|
+
await cleanup();
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it("returns khoor when calling caesar_cipher_encrypt with text=hello", async () => {
|
|
95
|
+
const server = createTestServer();
|
|
96
|
+
const { client, cleanup } = await createTestPair(server, () =>
|
|
97
|
+
new McpClient({
|
|
98
|
+
clientInfo: {
|
|
99
|
+
name: "test-client",
|
|
100
|
+
version: "1.0.0",
|
|
101
|
+
},
|
|
102
|
+
})
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
try {
|
|
106
|
+
const result = await client.callTool({
|
|
107
|
+
name: "caesar_cipher_encrypt",
|
|
108
|
+
arguments: { text: "hello" },
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
expect(result).toEqual({
|
|
112
|
+
content: [{ type: "text", text: "khoor" }],
|
|
113
|
+
});
|
|
114
|
+
} finally {
|
|
115
|
+
await cleanup();
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
it("returns the expected text for word_of_the_day", async () => {
|
|
120
|
+
const server = createTestServer();
|
|
121
|
+
const { client, cleanup } = await createTestPair(server, () =>
|
|
122
|
+
new McpClient({
|
|
123
|
+
clientInfo: {
|
|
124
|
+
name: "test-client",
|
|
125
|
+
version: "1.0.0",
|
|
126
|
+
},
|
|
127
|
+
})
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
try {
|
|
131
|
+
const result = await client.callTool({
|
|
132
|
+
name: "word_of_the_day",
|
|
133
|
+
arguments: {},
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
expect(result).toEqual({
|
|
137
|
+
content: [{ type: "text", text: "Bumfuzzle - to confuse or fluster someone" }],
|
|
138
|
+
});
|
|
139
|
+
} finally {
|
|
140
|
+
await cleanup();
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ClientCapabilities,
|
|
3
|
+
Implementation,
|
|
4
|
+
InitializeParams,
|
|
5
|
+
InitializeResult,
|
|
6
|
+
ServerCapabilities,
|
|
7
|
+
} from "./index.js";
|
|
8
|
+
|
|
9
|
+
const implementation: Implementation = {
|
|
10
|
+
name: "tiny-mcp-client",
|
|
11
|
+
version: "0.1.0",
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const clientCapabilities: ClientCapabilities = {
|
|
15
|
+
roots: {},
|
|
16
|
+
sampling: {},
|
|
17
|
+
experimental: {
|
|
18
|
+
supportsFastPath: true,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const serverCapabilities: ServerCapabilities = {
|
|
23
|
+
prompts: {},
|
|
24
|
+
resources: {},
|
|
25
|
+
tools: {},
|
|
26
|
+
logging: {},
|
|
27
|
+
completions: {},
|
|
28
|
+
experimental: {
|
|
29
|
+
rollout: "beta",
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
const initializeParams: InitializeParams = {
|
|
34
|
+
protocolVersion: "2025-03-26",
|
|
35
|
+
capabilities: clientCapabilities,
|
|
36
|
+
clientInfo: implementation,
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const initializeResult: InitializeResult = {
|
|
40
|
+
protocolVersion: "2025-03-26",
|
|
41
|
+
capabilities: serverCapabilities,
|
|
42
|
+
serverInfo: implementation,
|
|
43
|
+
instructions: "Do not execute destructive tools without confirmation.",
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// @ts-expect-error Implementation.version is required.
|
|
47
|
+
const implementationMissingVersion: Implementation = { name: "tiny-mcp-client" };
|
|
48
|
+
|
|
49
|
+
// @ts-expect-error InitializeParams.protocolVersion is required.
|
|
50
|
+
const initializeParamsMissingProtocolVersion: InitializeParams = {
|
|
51
|
+
capabilities: clientCapabilities,
|
|
52
|
+
clientInfo: implementation,
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// @ts-expect-error InitializeResult.capabilities is required.
|
|
56
|
+
const initializeResultMissingCapabilities: InitializeResult = {
|
|
57
|
+
protocolVersion: "2025-03-26",
|
|
58
|
+
serverInfo: implementation,
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
void implementationMissingVersion;
|
|
62
|
+
void initializeParamsMissingProtocolVersion;
|
|
63
|
+
void initializeResultMissingCapabilities;
|
|
64
|
+
void initializeParams;
|
|
65
|
+
void initializeResult;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ContentItem,
|
|
3
|
+
GetPromptResult,
|
|
4
|
+
Prompt,
|
|
5
|
+
PromptArgument,
|
|
6
|
+
PromptMessage,
|
|
7
|
+
} from "./index.js";
|
|
8
|
+
|
|
9
|
+
const promptArgument: PromptArgument = {
|
|
10
|
+
name: "topic",
|
|
11
|
+
description: "Topic to generate a prompt for",
|
|
12
|
+
required: true,
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
const prompt: Prompt = {
|
|
16
|
+
name: "summarize",
|
|
17
|
+
description: "Summarize provided text",
|
|
18
|
+
arguments: [promptArgument],
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const promptMessage: PromptMessage = {
|
|
22
|
+
role: "user",
|
|
23
|
+
content: {
|
|
24
|
+
type: "text",
|
|
25
|
+
text: "Summarize this text.",
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const promptResult: GetPromptResult = {
|
|
30
|
+
description: "Prompt for summarizing text",
|
|
31
|
+
messages: [promptMessage],
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const contentItems: ContentItem[] = [promptMessage.content];
|
|
35
|
+
|
|
36
|
+
// @ts-expect-error Prompt.name is required.
|
|
37
|
+
const promptMissingName: Prompt = {
|
|
38
|
+
description: "missing name",
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// @ts-expect-error PromptArgument.name is required.
|
|
42
|
+
const promptArgumentMissingName: PromptArgument = {
|
|
43
|
+
description: "missing name",
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const invalidPromptMessageRole: PromptMessage = {
|
|
47
|
+
// @ts-expect-error PromptMessage.role must be "user" | "assistant".
|
|
48
|
+
role: "system",
|
|
49
|
+
content: {
|
|
50
|
+
type: "text",
|
|
51
|
+
text: "nope",
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// @ts-expect-error GetPromptResult.messages is required.
|
|
56
|
+
const promptResultMissingMessages: GetPromptResult = {
|
|
57
|
+
description: "missing messages",
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
void contentItems;
|
|
61
|
+
void prompt;
|
|
62
|
+
void promptResult;
|
|
63
|
+
void promptMissingName;
|
|
64
|
+
void promptArgumentMissingName;
|
|
65
|
+
void invalidPromptMessageRole;
|
|
66
|
+
void promptResultMissingMessages;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
BlobResourceContents,
|
|
3
|
+
PaginatedParams,
|
|
4
|
+
PaginatedResult,
|
|
5
|
+
Resource,
|
|
6
|
+
ResourceContents,
|
|
7
|
+
ResourceTemplate,
|
|
8
|
+
TextResourceContents,
|
|
9
|
+
} from "./index.js";
|
|
10
|
+
|
|
11
|
+
const resource: Resource = {
|
|
12
|
+
uri: "file:///tmp/readme.md",
|
|
13
|
+
name: "README",
|
|
14
|
+
description: "Project readme",
|
|
15
|
+
mimeType: "text/markdown",
|
|
16
|
+
size: 1024,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const resourceTemplate: ResourceTemplate = {
|
|
20
|
+
uriTemplate: "file:///tmp/{filename}",
|
|
21
|
+
name: "Project file",
|
|
22
|
+
description: "Template for project files",
|
|
23
|
+
mimeType: "text/plain",
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const paginatedParams: PaginatedParams = {
|
|
27
|
+
cursor: "next-page",
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const paginatedResult: PaginatedResult = {
|
|
31
|
+
nextCursor: "cursor-2",
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const textResourceContents: TextResourceContents = {
|
|
35
|
+
uri: resource.uri,
|
|
36
|
+
mimeType: "text/plain",
|
|
37
|
+
text: "hello",
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
const blobResourceContents: BlobResourceContents = {
|
|
41
|
+
uri: resource.uri,
|
|
42
|
+
mimeType: "application/octet-stream",
|
|
43
|
+
blob: "aGVsbG8=",
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const resourceContentsItems: ResourceContents[] = [textResourceContents, blobResourceContents];
|
|
47
|
+
|
|
48
|
+
// @ts-expect-error Resource.uri is required.
|
|
49
|
+
const resourceMissingUri: Resource = {
|
|
50
|
+
name: "README",
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// @ts-expect-error ResourceTemplate.uriTemplate is required.
|
|
54
|
+
const resourceTemplateMissingUriTemplate: ResourceTemplate = {
|
|
55
|
+
name: "Project file",
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
// @ts-expect-error ResourceContents must include text or blob.
|
|
59
|
+
const invalidResourceContents: ResourceContents = {
|
|
60
|
+
uri: resource.uri,
|
|
61
|
+
mimeType: "text/plain",
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
void resourceMissingUri;
|
|
65
|
+
void resourceTemplateMissingUriTemplate;
|
|
66
|
+
void invalidResourceContents;
|
|
67
|
+
void resourceContentsItems;
|
|
68
|
+
void paginatedParams;
|
|
69
|
+
void paginatedResult;
|
|
70
|
+
void resourceTemplate;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AudioContent,
|
|
3
|
+
CallToolParams,
|
|
4
|
+
CallToolResult,
|
|
5
|
+
ContentItem,
|
|
6
|
+
EmbeddedResource,
|
|
7
|
+
ImageContent,
|
|
8
|
+
ResourceContents,
|
|
9
|
+
TextContent,
|
|
10
|
+
Tool,
|
|
11
|
+
ToolAnnotations,
|
|
12
|
+
} from "./index.js";
|
|
13
|
+
|
|
14
|
+
const annotations: ToolAnnotations = {
|
|
15
|
+
title: "Word of the day",
|
|
16
|
+
readOnlyHint: true,
|
|
17
|
+
destructiveHint: false,
|
|
18
|
+
idempotentHint: true,
|
|
19
|
+
openWorldHint: false,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const tool: Tool = {
|
|
23
|
+
name: "word_of_the_day",
|
|
24
|
+
description: "Returns a random word.",
|
|
25
|
+
inputSchema: {
|
|
26
|
+
type: "object",
|
|
27
|
+
properties: {
|
|
28
|
+
locale: { type: "string" },
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
annotations,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const callToolParams: CallToolParams = {
|
|
35
|
+
name: tool.name,
|
|
36
|
+
arguments: {
|
|
37
|
+
locale: "en-US",
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const resourceContents: ResourceContents = {
|
|
42
|
+
uri: "file:///tmp/word.txt",
|
|
43
|
+
text: "quotidian",
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const textContent: TextContent = {
|
|
47
|
+
type: "text",
|
|
48
|
+
text: "quotidian",
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const imageContent: ImageContent = {
|
|
52
|
+
type: "image",
|
|
53
|
+
data: "YmFzZTY0",
|
|
54
|
+
mimeType: "image/png",
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const audioContent: AudioContent = {
|
|
58
|
+
type: "audio",
|
|
59
|
+
data: "YmFzZTY0",
|
|
60
|
+
mimeType: "audio/wav",
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const embeddedResource: EmbeddedResource = {
|
|
64
|
+
type: "resource",
|
|
65
|
+
resource: resourceContents,
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const contentItems: ContentItem[] = [
|
|
69
|
+
textContent,
|
|
70
|
+
imageContent,
|
|
71
|
+
audioContent,
|
|
72
|
+
embeddedResource,
|
|
73
|
+
];
|
|
74
|
+
|
|
75
|
+
const callToolResult: CallToolResult = {
|
|
76
|
+
content: contentItems,
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const callToolErrorResult: CallToolResult = {
|
|
80
|
+
content: [textContent],
|
|
81
|
+
isError: true,
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// @ts-expect-error Tool.name is required.
|
|
85
|
+
const toolMissingName: Tool = {
|
|
86
|
+
inputSchema: {},
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// @ts-expect-error Tool.inputSchema is required.
|
|
90
|
+
const toolMissingInputSchema: Tool = {
|
|
91
|
+
name: "word_of_the_day",
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
// @ts-expect-error CallToolParams.name is required.
|
|
95
|
+
const callToolParamsMissingName: CallToolParams = {
|
|
96
|
+
arguments: {},
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const invalidTextContent: TextContent = {
|
|
100
|
+
// @ts-expect-error TextContent.type must be "text".
|
|
101
|
+
type: "image",
|
|
102
|
+
text: "oops",
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
// @ts-expect-error EmbeddedResource.resource is required.
|
|
106
|
+
const embeddedResourceMissingResource: EmbeddedResource = {
|
|
107
|
+
type: "resource",
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
void toolMissingName;
|
|
111
|
+
void toolMissingInputSchema;
|
|
112
|
+
void callToolParamsMissingName;
|
|
113
|
+
void invalidTextContent;
|
|
114
|
+
void embeddedResourceMissingResource;
|
|
115
|
+
void callToolParams;
|
|
116
|
+
void callToolResult;
|
|
117
|
+
void callToolErrorResult;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { Readable, Writable } from "node:stream";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
HttpTransport,
|
|
5
|
+
type HttpTransportFetch,
|
|
6
|
+
type OAuthClientProvider,
|
|
7
|
+
type OAuthClientProviderOptions,
|
|
8
|
+
type OAuthDiscoveryCache,
|
|
9
|
+
type OAuthDiscoveryResult,
|
|
10
|
+
} from "./index.js";
|
|
11
|
+
import type { McpTransport, McpTransportClosedEvent } from "./index.js";
|
|
12
|
+
|
|
13
|
+
declare const readable: Readable;
|
|
14
|
+
declare const writable: Writable;
|
|
15
|
+
|
|
16
|
+
const closedEvent: McpTransportClosedEvent = {
|
|
17
|
+
reason: new Error("transport closed"),
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
const transport: McpTransport = {
|
|
21
|
+
readable,
|
|
22
|
+
writable,
|
|
23
|
+
closed: Promise.resolve(closedEvent),
|
|
24
|
+
dispose(reason?: Error): void {
|
|
25
|
+
void reason;
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const closed: Promise<McpTransportClosedEvent> = transport.closed;
|
|
30
|
+
const customFetch: HttpTransportFetch = async () => new Response(null, { status: 202 });
|
|
31
|
+
const oauthProvider: OAuthClientProvider = {
|
|
32
|
+
authorizeRequest: async () => {},
|
|
33
|
+
handleUnauthorized: async () => ({ action: "retry" }),
|
|
34
|
+
};
|
|
35
|
+
const oauthOptions: OAuthClientProviderOptions = {
|
|
36
|
+
provider: oauthProvider,
|
|
37
|
+
};
|
|
38
|
+
const oauthDiscoveryResult: OAuthDiscoveryResult = {
|
|
39
|
+
resource: "https://example.com/mcp",
|
|
40
|
+
resourceMetadataUrl: "https://example.com/.well-known/oauth-protected-resource/mcp",
|
|
41
|
+
resourceMetadata: {
|
|
42
|
+
resource: "https://example.com/mcp",
|
|
43
|
+
authorization_servers: ["https://auth.example.com"],
|
|
44
|
+
},
|
|
45
|
+
authorizationServer: "https://auth.example.com",
|
|
46
|
+
authorizationServerMetadataUrl:
|
|
47
|
+
"https://auth.example.com/.well-known/oauth-authorization-server",
|
|
48
|
+
authorizationServerMetadata: {
|
|
49
|
+
issuer: "https://auth.example.com",
|
|
50
|
+
authorization_endpoint: "https://auth.example.com/authorize",
|
|
51
|
+
token_endpoint: "https://auth.example.com/token",
|
|
52
|
+
response_types_supported: ["code"],
|
|
53
|
+
code_challenge_methods_supported: ["S256"],
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
const oauthDiscoveryCache: OAuthDiscoveryCache = {
|
|
57
|
+
get: () => oauthDiscoveryResult,
|
|
58
|
+
set: () => {},
|
|
59
|
+
};
|
|
60
|
+
const httpTransport: McpTransport = new HttpTransport({
|
|
61
|
+
url: "https://example.com/mcp",
|
|
62
|
+
headers: {
|
|
63
|
+
Authorization: "Bearer test",
|
|
64
|
+
},
|
|
65
|
+
fetch: customFetch,
|
|
66
|
+
oauth: oauthOptions,
|
|
67
|
+
oauthDiscoveryCache,
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// @ts-expect-error reason must be an Error.
|
|
71
|
+
const invalidClosedEvent: McpTransportClosedEvent = { reason: "closed" };
|
|
72
|
+
|
|
73
|
+
void closed;
|
|
74
|
+
void httpTransport;
|
|
75
|
+
void invalidClosedEvent;
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
CompleteParams,
|
|
3
|
+
CompleteResult,
|
|
4
|
+
CreateMessageParams,
|
|
5
|
+
CreateMessageResult,
|
|
6
|
+
LogLevel,
|
|
7
|
+
LogMessage,
|
|
8
|
+
ModelPreferences,
|
|
9
|
+
ProgressParams,
|
|
10
|
+
PromptReference,
|
|
11
|
+
ResourceReference,
|
|
12
|
+
Root,
|
|
13
|
+
SamplingMessage,
|
|
14
|
+
} from "./index.js";
|
|
15
|
+
|
|
16
|
+
const root: Root = {
|
|
17
|
+
uri: "file:///workspace",
|
|
18
|
+
name: "workspace",
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const logLevel: LogLevel = "info";
|
|
22
|
+
|
|
23
|
+
const logMessage: LogMessage = {
|
|
24
|
+
level: logLevel,
|
|
25
|
+
logger: "tiny-mcp-client",
|
|
26
|
+
data: {
|
|
27
|
+
message: "connected",
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const progress: ProgressParams = {
|
|
32
|
+
progressToken: "request-1",
|
|
33
|
+
progress: 40,
|
|
34
|
+
total: 100,
|
|
35
|
+
message: "Processing",
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const samplingMessage: SamplingMessage = {
|
|
39
|
+
role: "user",
|
|
40
|
+
content: {
|
|
41
|
+
type: "text",
|
|
42
|
+
text: "Generate a summary.",
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const modelPreferences: ModelPreferences = {
|
|
47
|
+
hints: [{ name: "claude" }],
|
|
48
|
+
costPriority: 0.5,
|
|
49
|
+
speedPriority: 0.6,
|
|
50
|
+
intelligencePriority: 0.9,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const createMessageParams: CreateMessageParams = {
|
|
54
|
+
messages: [samplingMessage],
|
|
55
|
+
modelPreferences,
|
|
56
|
+
systemPrompt: "Be concise.",
|
|
57
|
+
includeContext: "none",
|
|
58
|
+
temperature: 0.3,
|
|
59
|
+
maxTokens: 512,
|
|
60
|
+
stopSequences: ["\n\n"],
|
|
61
|
+
metadata: {
|
|
62
|
+
traceId: "trace-1",
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
const createMessageResult: CreateMessageResult = {
|
|
67
|
+
model: "claude-sonnet-4.5",
|
|
68
|
+
role: "assistant",
|
|
69
|
+
content: {
|
|
70
|
+
type: "text",
|
|
71
|
+
text: "Here is the summary.",
|
|
72
|
+
},
|
|
73
|
+
stopReason: "endTurn",
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const promptReference: PromptReference = {
|
|
77
|
+
type: "ref/prompt",
|
|
78
|
+
name: "summarize",
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
const resourceReference: ResourceReference = {
|
|
82
|
+
type: "ref/resource",
|
|
83
|
+
uri: "file:///workspace/{path}",
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const completePromptParams: CompleteParams = {
|
|
87
|
+
ref: promptReference,
|
|
88
|
+
argument: {
|
|
89
|
+
name: "topic",
|
|
90
|
+
value: "machine learning",
|
|
91
|
+
},
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const completeResourceParams: CompleteParams = {
|
|
95
|
+
ref: resourceReference,
|
|
96
|
+
argument: {
|
|
97
|
+
name: "path",
|
|
98
|
+
value: "docs/",
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
const completeResult: CompleteResult = {
|
|
103
|
+
completion: {
|
|
104
|
+
values: ["docs/guide.md", "docs/api.md"],
|
|
105
|
+
hasMore: true,
|
|
106
|
+
total: 10,
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
// @ts-expect-error Root.uri is required.
|
|
111
|
+
const rootMissingUri: Root = {
|
|
112
|
+
name: "workspace",
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// @ts-expect-error LogLevel must be one of syslog severities.
|
|
116
|
+
const invalidLogLevel: LogLevel = "trace";
|
|
117
|
+
|
|
118
|
+
// @ts-expect-error LogMessage.data is required.
|
|
119
|
+
const logMessageMissingData: LogMessage = {
|
|
120
|
+
level: "info",
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
// @ts-expect-error ProgressParams.progressToken is required.
|
|
124
|
+
const progressMissingToken: ProgressParams = {
|
|
125
|
+
progress: 1,
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
// @ts-expect-error CreateMessageParams.maxTokens is required.
|
|
129
|
+
const createMessageParamsMissingMaxTokens: CreateMessageParams = {
|
|
130
|
+
messages: [samplingMessage],
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const invalidSamplingRole: SamplingMessage = {
|
|
134
|
+
// @ts-expect-error SamplingMessage.role must be "user" | "assistant".
|
|
135
|
+
role: "system",
|
|
136
|
+
content: {
|
|
137
|
+
type: "text",
|
|
138
|
+
text: "invalid",
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
// @ts-expect-error CreateMessageResult.model is required.
|
|
143
|
+
const createMessageResultMissingModel: CreateMessageResult = {
|
|
144
|
+
role: "assistant",
|
|
145
|
+
content: {
|
|
146
|
+
type: "text",
|
|
147
|
+
text: "missing model",
|
|
148
|
+
},
|
|
149
|
+
stopReason: "endTurn",
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const invalidCompleteParams: CompleteParams = {
|
|
153
|
+
ref:
|
|
154
|
+
// @ts-expect-error CompleteParams.ref.type must be "ref/prompt" | "ref/resource".
|
|
155
|
+
{ type: "prompt", name: "summarize" },
|
|
156
|
+
argument: {
|
|
157
|
+
name: "topic",
|
|
158
|
+
value: "a",
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
// @ts-expect-error CompleteResult.completion is required.
|
|
163
|
+
const completeResultMissingCompletion: CompleteResult = {};
|
|
164
|
+
|
|
165
|
+
void rootMissingUri;
|
|
166
|
+
void invalidLogLevel;
|
|
167
|
+
void logMessageMissingData;
|
|
168
|
+
void progressMissingToken;
|
|
169
|
+
void createMessageParamsMissingMaxTokens;
|
|
170
|
+
void invalidSamplingRole;
|
|
171
|
+
void createMessageResultMissingModel;
|
|
172
|
+
void invalidCompleteParams;
|
|
173
|
+
void completeResultMissingCompletion;
|
|
174
|
+
void root;
|
|
175
|
+
void logMessage;
|
|
176
|
+
void progress;
|
|
177
|
+
void createMessageParams;
|
|
178
|
+
void createMessageResult;
|
|
179
|
+
void completePromptParams;
|
|
180
|
+
void completeResourceParams;
|
|
181
|
+
void completeResult;
|