toolcraft 0.0.9 → 0.0.11
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/mcp.d.ts +6 -0
- package/dist/mcp.js +3 -3
- package/node_modules/tiny-mcp-client/.turbo/turbo-build.log +3 -0
- package/node_modules/tiny-mcp-client/dist/internal.d.ts +3 -3
- package/node_modules/tiny-mcp-client/dist/internal.js +2 -2
- package/node_modules/tiny-mcp-client/dist/oauth-discovery.d.ts +1 -1
- package/node_modules/tiny-mcp-client/dist/oauth-discovery.js +1 -1
- package/node_modules/tiny-mcp-client/src/http-oauth.integration.test.ts +23 -38
- package/node_modules/tiny-mcp-client/src/internal.ts +3 -3
- package/node_modules/tiny-mcp-client/src/oauth-discovery.ts +2 -2
- package/node_modules/tiny-mcp-client/src/package-runtime.test.ts +25 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -459,6 +459,7 @@ If you have an existing MCP server you want to keep running, use the MCP proxy:
|
|
|
459
459
|
- `services?` / `humanInLoop?` / `apiVersion?`
|
|
460
460
|
- `projectRoot?: string` — root used for MCP proxy cache files (`.toolcraft/mcp/*.json`).
|
|
461
461
|
- `tools?: string[]` — allowlist of MCP tool names or group prefixes. Tool names are `__`-joined snake_case path segments (`root__bot__create`); a prefix like `root__bot` includes every descendant tool.
|
|
462
|
+
- `omitRootToolNamePrefix?: boolean` — defaults to `false`. Set to `true` to omit the root group name from single-root MCP tool names (`bot__create`).
|
|
462
463
|
- `casing?: "snake" | "camel"` — affects MCP **input-schema property names** only. Tool names always stay `__`-joined snake_case.
|
|
463
464
|
|
|
464
465
|
### `HumanInLoopRuntimeOptions`
|
package/dist/mcp.d.ts
CHANGED
|
@@ -20,6 +20,12 @@ export interface RunMCPOptions<TServices extends object = Record<string, unknown
|
|
|
20
20
|
* that subtree.
|
|
21
21
|
*/
|
|
22
22
|
tools?: string[];
|
|
23
|
+
/**
|
|
24
|
+
* Omit the root group name from MCP tool names for a single root group.
|
|
25
|
+
*
|
|
26
|
+
* Defaults to false, so existing MCP tool names keep the root group prefix.
|
|
27
|
+
*/
|
|
28
|
+
omitRootToolNamePrefix?: boolean;
|
|
23
29
|
services?: TServices;
|
|
24
30
|
/**
|
|
25
31
|
* Controls MCP input-schema key casing and accepted argument-key casing.
|
package/dist/mcp.js
CHANGED
|
@@ -162,7 +162,7 @@ function matchesAllowlist(toolName, allowlist) {
|
|
|
162
162
|
function formatToolName(path) {
|
|
163
163
|
return path.map((segment) => formatSegment(segment, "snake")).join("__");
|
|
164
164
|
}
|
|
165
|
-
function enumerateTools(root, casing, allowlist) {
|
|
165
|
+
function enumerateTools(root, casing, allowlist, omitRootToolNamePrefix) {
|
|
166
166
|
const tools = [];
|
|
167
167
|
function visit(node, toolPath, commandPath) {
|
|
168
168
|
if (node.kind === "command") {
|
|
@@ -192,7 +192,7 @@ function enumerateTools(root, casing, allowlist) {
|
|
|
192
192
|
visit(child, nextToolPath, nextCommandPath);
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
|
-
const rootPath = root.name.length === 0 ? [] : [root.name];
|
|
195
|
+
const rootPath = omitRootToolNamePrefix || root.name.length === 0 ? [] : [root.name];
|
|
196
196
|
for (const child of root.children) {
|
|
197
197
|
visit(child, rootPath, []);
|
|
198
198
|
}
|
|
@@ -365,7 +365,7 @@ function createResolvedMCPServer(root, options) {
|
|
|
365
365
|
root,
|
|
366
366
|
};
|
|
367
367
|
validateServices(services);
|
|
368
|
-
const tools = enumerateTools(root, casing, options.tools);
|
|
368
|
+
const tools = enumerateTools(root, casing, options.tools, options.omitRootToolNamePrefix ?? false);
|
|
369
369
|
const version = resolveMCPVersion(options.version);
|
|
370
370
|
const server = createServer({ name: options.name, version });
|
|
371
371
|
for (const tool of tools) {
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
npm warn Unknown project config "link-workspace-packages". This will stop working in the next major version of npm. See `npm help npmrc` for supported config options.
|
|
2
|
+
npm warn Unknown project config "package-manager-strict". This will stop working in the next major version of npm. See `npm help npmrc` for supported config options.
|
|
3
|
+
npm warn Unknown project config "prefer-workspace-packages". This will stop working in the next major version of npm. See `npm help npmrc` for supported config options.
|
|
1
4
|
|
|
2
5
|
> tiny-mcp-client@0.1.0 build
|
|
3
6
|
> tsc
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { ChildProcessWithoutNullStreams, SpawnOptions } from "node:child_process";
|
|
2
2
|
import type { Readable, Writable } from "node:stream";
|
|
3
3
|
import type { JSONRPCMessage as SdkJsonRpcMessage } from "@modelcontextprotocol/sdk/types.js";
|
|
4
|
-
import { type OAuthClientProviderOptions } from "mcp-oauth";
|
|
4
|
+
import { type OAuthClientProviderOptions } from "../../mcp-oauth/dist/index.js";
|
|
5
5
|
import type { Server as TinyStdioMcpServer } from "tiny-stdio-mcp-server";
|
|
6
6
|
import type { OAuthDiscoveryCache } from "./oauth-discovery.js";
|
|
7
7
|
export { OAuthMetadataDiscovery, discoverOAuthMetadata, parseBearerWwwAuthenticateHeader, resolveAuthorizationServerMetadataUrl, resolveProtectedResourceMetadataUrl, } from "./oauth-discovery.js";
|
|
8
|
-
export { createAuthStoreSessionStore, createDefaultOAuthClientProvider, } from "mcp-oauth";
|
|
8
|
+
export { createAuthStoreSessionStore, createDefaultOAuthClientProvider, } from "../../mcp-oauth/dist/index.js";
|
|
9
9
|
export type { OAuthDiscoveryCache, } from "./oauth-discovery.js";
|
|
10
10
|
export type { OAuthAuthorizationServerMetadata, OAuthDiscoveryResult, OAuthMetadataFetch, OAuthProtectedResourceMetadata, OAuthUnauthorizedChallenge } from "./oauth-discovery.js";
|
|
11
|
-
export type { DefaultOAuthClientProviderOptions, OAuthClientProvider, OAuthClientProviderOptions, OAuthSessionStore, StoredOAuthSession, } from "mcp-oauth";
|
|
11
|
+
export type { DefaultOAuthClientProviderOptions, OAuthClientProvider, OAuthClientProviderOptions, OAuthSessionStore, StoredOAuthSession, } from "../../mcp-oauth/dist/index.js";
|
|
12
12
|
export type RequestId = number | string;
|
|
13
13
|
export interface Implementation {
|
|
14
14
|
name: string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { PassThrough } from "node:stream";
|
|
3
|
-
import { createOAuthClientProvider, OAuthError, } from "mcp-oauth";
|
|
3
|
+
import { createOAuthClientProvider, OAuthError, } from "../../mcp-oauth/dist/index.js";
|
|
4
4
|
import { OAuthMetadataDiscovery, parseBearerWwwAuthenticateHeader, } from "./oauth-discovery.js";
|
|
5
5
|
export { OAuthMetadataDiscovery, discoverOAuthMetadata, parseBearerWwwAuthenticateHeader, resolveAuthorizationServerMetadataUrl, resolveProtectedResourceMetadataUrl, } from "./oauth-discovery.js";
|
|
6
|
-
export { createAuthStoreSessionStore, createDefaultOAuthClientProvider, } from "mcp-oauth";
|
|
6
|
+
export { createAuthStoreSessionStore, createDefaultOAuthClientProvider, } from "../../mcp-oauth/dist/index.js";
|
|
7
7
|
const MCP_PROTOCOL_VERSION = "2025-03-26";
|
|
8
8
|
export class McpClient {
|
|
9
9
|
currentState = "disconnected";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { OAuthAuthorizationServerMetadata, OAuthDiscoveryResult, OAuthMetadataFetch, OAuthProtectedResourceMetadata, OAuthUnauthorizedChallenge } from "mcp-oauth";
|
|
1
|
+
import type { OAuthAuthorizationServerMetadata, OAuthDiscoveryResult, OAuthMetadataFetch, OAuthProtectedResourceMetadata, OAuthUnauthorizedChallenge } from "../../mcp-oauth/dist/index.js";
|
|
2
2
|
export type { OAuthAuthorizationServerMetadata, OAuthDiscoveryResult, OAuthMetadataFetch, OAuthProtectedResourceMetadata, OAuthUnauthorizedChallenge, };
|
|
3
3
|
export interface OAuthDiscoveryCache {
|
|
4
4
|
get(resourceUrl: string): OAuthDiscoveryResult | null | undefined | Promise<OAuthDiscoveryResult | null | undefined>;
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
OAuthError,
|
|
5
5
|
type OAuthSessionStore,
|
|
6
6
|
type StoredOAuthSession,
|
|
7
|
-
} from "mcp-oauth";
|
|
7
|
+
} from "../../mcp-oauth/dist/index.js";
|
|
8
8
|
import { nodeFetch } from "tiny-http-mcp-server/testing";
|
|
9
9
|
import {
|
|
10
10
|
createMcpOAuthTestServer,
|
|
@@ -86,7 +86,12 @@ function cloneResponse(response: Response, body: string): Response {
|
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
|
|
89
|
+
interface BoundLoopbackServerFactory {
|
|
90
|
+
createServer(): http.Server;
|
|
91
|
+
port: number;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function createBoundLoopbackServerFactory(hostname: string): Promise<BoundLoopbackServerFactory> {
|
|
90
95
|
const server = http.createServer();
|
|
91
96
|
|
|
92
97
|
await new Promise<void>((resolve, reject) => {
|
|
@@ -106,43 +111,23 @@ async function reservePort(hostname: string): Promise<number> {
|
|
|
106
111
|
resolve();
|
|
107
112
|
});
|
|
108
113
|
});
|
|
109
|
-
throw new Error("Expected
|
|
114
|
+
throw new Error("Expected loopback test server to bind to a TCP port");
|
|
110
115
|
}
|
|
111
116
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
resolve();
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
return port;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
function createFixedPortServerFactory(port: number): () => http.Server {
|
|
127
|
-
return () => {
|
|
128
|
-
const server = http.createServer();
|
|
129
|
-
const originalListen = server.listen.bind(server);
|
|
130
|
-
|
|
131
|
-
server.listen = ((...args: unknown[]) => {
|
|
132
|
-
let callback: (() => void) | undefined;
|
|
133
|
-
|
|
134
|
-
for (let index = args.length - 1; index >= 0; index -= 1) {
|
|
135
|
-
const value = args[index];
|
|
136
|
-
if (typeof value === "function") {
|
|
137
|
-
callback = value as () => void;
|
|
138
|
-
break;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return originalListen(port, "127.0.0.1", callback);
|
|
143
|
-
}) as typeof server.listen;
|
|
117
|
+
server.listen = ((...args: Parameters<http.Server["listen"]>) => {
|
|
118
|
+
const callback = [...args].reverse().find((value) => typeof value === "function");
|
|
119
|
+
if (typeof callback === "function") {
|
|
120
|
+
queueMicrotask(() => callback());
|
|
121
|
+
}
|
|
144
122
|
|
|
145
123
|
return server;
|
|
124
|
+
}) as typeof server.listen;
|
|
125
|
+
|
|
126
|
+
return {
|
|
127
|
+
createServer(): http.Server {
|
|
128
|
+
return server;
|
|
129
|
+
},
|
|
130
|
+
port: address.port,
|
|
146
131
|
};
|
|
147
132
|
}
|
|
148
133
|
|
|
@@ -557,10 +542,10 @@ describe("HttpTransport OAuth integration", () => {
|
|
|
557
542
|
});
|
|
558
543
|
|
|
559
544
|
it("skips DCR for a configured static client and still completes the PKCE flow", async () => {
|
|
560
|
-
const
|
|
561
|
-
const redirectUri = `http://127.0.0.1:${
|
|
545
|
+
const loopbackServer = await createBoundLoopbackServerFactory("127.0.0.1");
|
|
546
|
+
const redirectUri = `http://127.0.0.1:${loopbackServer.port}/callback`;
|
|
562
547
|
const harness = await createHarness({
|
|
563
|
-
createServer:
|
|
548
|
+
createServer: loopbackServer.createServer,
|
|
564
549
|
oauthClient: {
|
|
565
550
|
mode: "static",
|
|
566
551
|
clientId: "static-client",
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
OAuthError,
|
|
9
9
|
type OAuthClientProvider,
|
|
10
10
|
type OAuthClientProviderOptions,
|
|
11
|
-
} from "mcp-oauth";
|
|
11
|
+
} from "../../mcp-oauth/dist/index.js";
|
|
12
12
|
import type { Server as TinyStdioMcpServer } from "tiny-stdio-mcp-server";
|
|
13
13
|
import {
|
|
14
14
|
OAuthMetadataDiscovery,
|
|
@@ -28,7 +28,7 @@ export {
|
|
|
28
28
|
export {
|
|
29
29
|
createAuthStoreSessionStore,
|
|
30
30
|
createDefaultOAuthClientProvider,
|
|
31
|
-
} from "mcp-oauth";
|
|
31
|
+
} from "../../mcp-oauth/dist/index.js";
|
|
32
32
|
export type {
|
|
33
33
|
OAuthDiscoveryCache,
|
|
34
34
|
} from "./oauth-discovery.js";
|
|
@@ -39,7 +39,7 @@ export type {
|
|
|
39
39
|
OAuthClientProviderOptions,
|
|
40
40
|
OAuthSessionStore,
|
|
41
41
|
StoredOAuthSession,
|
|
42
|
-
} from "mcp-oauth";
|
|
42
|
+
} from "../../mcp-oauth/dist/index.js";
|
|
43
43
|
|
|
44
44
|
export type RequestId = number | string;
|
|
45
45
|
|
|
@@ -4,8 +4,8 @@ import type {
|
|
|
4
4
|
OAuthMetadataFetch,
|
|
5
5
|
OAuthProtectedResourceMetadata,
|
|
6
6
|
OAuthUnauthorizedChallenge,
|
|
7
|
-
} from "mcp-oauth";
|
|
8
|
-
import { canonicalizeResourceIndicator } from "mcp-oauth";
|
|
7
|
+
} from "../../mcp-oauth/dist/index.js";
|
|
8
|
+
import { canonicalizeResourceIndicator } from "../../mcp-oauth/dist/index.js";
|
|
9
9
|
|
|
10
10
|
export type {
|
|
11
11
|
OAuthAuthorizationServerMetadata,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { execFile } from "node:child_process";
|
|
2
|
+
import { pathToFileURL } from "node:url";
|
|
3
|
+
import { promisify } from "node:util";
|
|
4
|
+
import { describe, expect, it } from "vitest";
|
|
5
|
+
|
|
6
|
+
const execFileAsync = promisify(execFile);
|
|
7
|
+
|
|
8
|
+
describe("tiny-mcp-client runtime imports", () => {
|
|
9
|
+
it("loads the source entrypoint in a clean Node process", async () => {
|
|
10
|
+
const moduleUrl = pathToFileURL(new URL("./index.ts", import.meta.url).pathname).href;
|
|
11
|
+
|
|
12
|
+
const result = await execFileAsync(process.execPath, [
|
|
13
|
+
"--import",
|
|
14
|
+
"tsx",
|
|
15
|
+
"--input-type=module",
|
|
16
|
+
"--eval",
|
|
17
|
+
`await import(${JSON.stringify(moduleUrl)});`,
|
|
18
|
+
], {
|
|
19
|
+
cwd: new URL("../../..", import.meta.url),
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
expect(result.stdout).toBe("");
|
|
23
|
+
expect(result.stderr).not.toContain("SyntaxError");
|
|
24
|
+
});
|
|
25
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "toolcraft",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"commander": "^14.0.3",
|
|
46
46
|
"console-table-printer": "^2.15.0",
|
|
47
47
|
"tiny-stdio-mcp-server": "^0.1.0",
|
|
48
|
-
"toolcraft-schema": "^0.0.
|
|
48
|
+
"toolcraft-schema": "^0.0.11"
|
|
49
49
|
},
|
|
50
50
|
"files": [
|
|
51
51
|
"dist"
|