@mcp-z/client 1.0.0
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/AGENTS.md +159 -0
- package/LICENSE +21 -0
- package/README.md +90 -0
- package/dist/cjs/auth/capability-discovery.d.cts +25 -0
- package/dist/cjs/auth/capability-discovery.d.ts +25 -0
- package/dist/cjs/auth/capability-discovery.js +280 -0
- package/dist/cjs/auth/capability-discovery.js.map +1 -0
- package/dist/cjs/auth/index.d.cts +9 -0
- package/dist/cjs/auth/index.d.ts +9 -0
- package/dist/cjs/auth/index.js +28 -0
- package/dist/cjs/auth/index.js.map +1 -0
- package/dist/cjs/auth/interactive-oauth-flow.d.cts +58 -0
- package/dist/cjs/auth/interactive-oauth-flow.d.ts +58 -0
- package/dist/cjs/auth/interactive-oauth-flow.js +537 -0
- package/dist/cjs/auth/interactive-oauth-flow.js.map +1 -0
- package/dist/cjs/auth/oauth-callback-listener.d.cts +56 -0
- package/dist/cjs/auth/oauth-callback-listener.d.ts +56 -0
- package/dist/cjs/auth/oauth-callback-listener.js +333 -0
- package/dist/cjs/auth/oauth-callback-listener.js.map +1 -0
- package/dist/cjs/auth/pkce.d.cts +17 -0
- package/dist/cjs/auth/pkce.d.ts +17 -0
- package/dist/cjs/auth/pkce.js +192 -0
- package/dist/cjs/auth/pkce.js.map +1 -0
- package/dist/cjs/auth/rfc9728-discovery.d.cts +34 -0
- package/dist/cjs/auth/rfc9728-discovery.d.ts +34 -0
- package/dist/cjs/auth/rfc9728-discovery.js +436 -0
- package/dist/cjs/auth/rfc9728-discovery.js.map +1 -0
- package/dist/cjs/auth/types.d.cts +137 -0
- package/dist/cjs/auth/types.d.ts +137 -0
- package/dist/cjs/auth/types.js +9 -0
- package/dist/cjs/auth/types.js.map +1 -0
- package/dist/cjs/client-helpers.d.cts +55 -0
- package/dist/cjs/client-helpers.d.ts +55 -0
- package/dist/cjs/client-helpers.js +128 -0
- package/dist/cjs/client-helpers.js.map +1 -0
- package/dist/cjs/config/server-loader.d.cts +27 -0
- package/dist/cjs/config/server-loader.d.ts +27 -0
- package/dist/cjs/config/server-loader.js +111 -0
- package/dist/cjs/config/server-loader.js.map +1 -0
- package/dist/cjs/config/validate-config.d.cts +15 -0
- package/dist/cjs/config/validate-config.d.ts +15 -0
- package/dist/cjs/config/validate-config.js +128 -0
- package/dist/cjs/config/validate-config.js.map +1 -0
- package/dist/cjs/connection/connect-client.d.cts +59 -0
- package/dist/cjs/connection/connect-client.d.ts +59 -0
- package/dist/cjs/connection/connect-client.js +536 -0
- package/dist/cjs/connection/connect-client.js.map +1 -0
- package/dist/cjs/connection/existing-process-transport.d.cts +40 -0
- package/dist/cjs/connection/existing-process-transport.d.ts +40 -0
- package/dist/cjs/connection/existing-process-transport.js +274 -0
- package/dist/cjs/connection/existing-process-transport.js.map +1 -0
- package/dist/cjs/connection/types.d.cts +61 -0
- package/dist/cjs/connection/types.d.ts +61 -0
- package/dist/cjs/connection/types.js +53 -0
- package/dist/cjs/connection/types.js.map +1 -0
- package/dist/cjs/connection/wait-for-http-ready.d.cts +15 -0
- package/dist/cjs/connection/wait-for-http-ready.d.ts +15 -0
- package/dist/cjs/connection/wait-for-http-ready.js +232 -0
- package/dist/cjs/connection/wait-for-http-ready.js.map +1 -0
- package/dist/cjs/dcr/dcr-authenticator.d.cts +73 -0
- package/dist/cjs/dcr/dcr-authenticator.d.ts +73 -0
- package/dist/cjs/dcr/dcr-authenticator.js +655 -0
- package/dist/cjs/dcr/dcr-authenticator.js.map +1 -0
- package/dist/cjs/dcr/dynamic-client-registrar.d.cts +28 -0
- package/dist/cjs/dcr/dynamic-client-registrar.d.ts +28 -0
- package/dist/cjs/dcr/dynamic-client-registrar.js +245 -0
- package/dist/cjs/dcr/dynamic-client-registrar.js.map +1 -0
- package/dist/cjs/dcr/index.d.cts +8 -0
- package/dist/cjs/dcr/index.d.ts +8 -0
- package/dist/cjs/dcr/index.js +24 -0
- package/dist/cjs/dcr/index.js.map +1 -0
- package/dist/cjs/index.d.cts +21 -0
- package/dist/cjs/index.d.ts +21 -0
- package/dist/cjs/index.js +94 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/monkey-patches.d.cts +6 -0
- package/dist/cjs/monkey-patches.d.ts +6 -0
- package/dist/cjs/monkey-patches.js +236 -0
- package/dist/cjs/monkey-patches.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/response-wrappers.d.cts +41 -0
- package/dist/cjs/response-wrappers.d.ts +41 -0
- package/dist/cjs/response-wrappers.js +443 -0
- package/dist/cjs/response-wrappers.js.map +1 -0
- package/dist/cjs/search/index.d.cts +6 -0
- package/dist/cjs/search/index.d.ts +6 -0
- package/dist/cjs/search/index.js +25 -0
- package/dist/cjs/search/index.js.map +1 -0
- package/dist/cjs/search/search.d.cts +22 -0
- package/dist/cjs/search/search.d.ts +22 -0
- package/dist/cjs/search/search.js +630 -0
- package/dist/cjs/search/search.js.map +1 -0
- package/dist/cjs/search/types.d.cts +122 -0
- package/dist/cjs/search/types.d.ts +122 -0
- package/dist/cjs/search/types.js +10 -0
- package/dist/cjs/search/types.js.map +1 -0
- package/dist/cjs/spawn/spawn-server.d.cts +83 -0
- package/dist/cjs/spawn/spawn-server.d.ts +83 -0
- package/dist/cjs/spawn/spawn-server.js +410 -0
- package/dist/cjs/spawn/spawn-server.js.map +1 -0
- package/dist/cjs/spawn/spawn-servers.d.cts +151 -0
- package/dist/cjs/spawn/spawn-servers.d.ts +151 -0
- package/dist/cjs/spawn/spawn-servers.js +911 -0
- package/dist/cjs/spawn/spawn-servers.js.map +1 -0
- package/dist/cjs/types.d.cts +11 -0
- package/dist/cjs/types.d.ts +11 -0
- package/dist/cjs/types.js +10 -0
- package/dist/cjs/types.js.map +1 -0
- package/dist/cjs/utils/logger.d.cts +24 -0
- package/dist/cjs/utils/logger.d.ts +24 -0
- package/dist/cjs/utils/logger.js +80 -0
- package/dist/cjs/utils/logger.js.map +1 -0
- package/dist/cjs/utils/path-utils.d.cts +45 -0
- package/dist/cjs/utils/path-utils.d.ts +45 -0
- package/dist/cjs/utils/path-utils.js +158 -0
- package/dist/cjs/utils/path-utils.js.map +1 -0
- package/dist/cjs/utils/sanitizer.d.cts +30 -0
- package/dist/cjs/utils/sanitizer.d.ts +30 -0
- package/dist/cjs/utils/sanitizer.js +124 -0
- package/dist/cjs/utils/sanitizer.js.map +1 -0
- package/dist/esm/auth/capability-discovery.d.ts +25 -0
- package/dist/esm/auth/capability-discovery.js +110 -0
- package/dist/esm/auth/capability-discovery.js.map +1 -0
- package/dist/esm/auth/index.d.ts +9 -0
- package/dist/esm/auth/index.js +6 -0
- package/dist/esm/auth/index.js.map +1 -0
- package/dist/esm/auth/interactive-oauth-flow.d.ts +58 -0
- package/dist/esm/auth/interactive-oauth-flow.js +217 -0
- package/dist/esm/auth/interactive-oauth-flow.js.map +1 -0
- package/dist/esm/auth/oauth-callback-listener.d.ts +56 -0
- package/dist/esm/auth/oauth-callback-listener.js +166 -0
- package/dist/esm/auth/oauth-callback-listener.js.map +1 -0
- package/dist/esm/auth/pkce.d.ts +17 -0
- package/dist/esm/auth/pkce.js +41 -0
- package/dist/esm/auth/pkce.js.map +1 -0
- package/dist/esm/auth/rfc9728-discovery.d.ts +34 -0
- package/dist/esm/auth/rfc9728-discovery.js +157 -0
- package/dist/esm/auth/rfc9728-discovery.js.map +1 -0
- package/dist/esm/auth/types.d.ts +137 -0
- package/dist/esm/auth/types.js +7 -0
- package/dist/esm/auth/types.js.map +1 -0
- package/dist/esm/client-helpers.d.ts +55 -0
- package/dist/esm/client-helpers.js +81 -0
- package/dist/esm/client-helpers.js.map +1 -0
- package/dist/esm/config/server-loader.d.ts +27 -0
- package/dist/esm/config/server-loader.js +49 -0
- package/dist/esm/config/server-loader.js.map +1 -0
- package/dist/esm/config/validate-config.d.ts +15 -0
- package/dist/esm/config/validate-config.js +76 -0
- package/dist/esm/config/validate-config.js.map +1 -0
- package/dist/esm/connection/connect-client.d.ts +59 -0
- package/dist/esm/connection/connect-client.js +272 -0
- package/dist/esm/connection/connect-client.js.map +1 -0
- package/dist/esm/connection/existing-process-transport.d.ts +40 -0
- package/dist/esm/connection/existing-process-transport.js +103 -0
- package/dist/esm/connection/existing-process-transport.js.map +1 -0
- package/dist/esm/connection/types.d.ts +61 -0
- package/dist/esm/connection/types.js +34 -0
- package/dist/esm/connection/types.js.map +1 -0
- package/dist/esm/connection/wait-for-http-ready.d.ts +15 -0
- package/dist/esm/connection/wait-for-http-ready.js +43 -0
- package/dist/esm/connection/wait-for-http-ready.js.map +1 -0
- package/dist/esm/dcr/dcr-authenticator.d.ts +73 -0
- package/dist/esm/dcr/dcr-authenticator.js +235 -0
- package/dist/esm/dcr/dcr-authenticator.js.map +1 -0
- package/dist/esm/dcr/dynamic-client-registrar.d.ts +28 -0
- package/dist/esm/dcr/dynamic-client-registrar.js +66 -0
- package/dist/esm/dcr/dynamic-client-registrar.js.map +1 -0
- package/dist/esm/dcr/index.d.ts +8 -0
- package/dist/esm/dcr/index.js +5 -0
- package/dist/esm/dcr/index.js.map +1 -0
- package/dist/esm/index.d.ts +21 -0
- package/dist/esm/index.js +22 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/monkey-patches.d.ts +6 -0
- package/dist/esm/monkey-patches.js +32 -0
- package/dist/esm/monkey-patches.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/response-wrappers.d.ts +41 -0
- package/dist/esm/response-wrappers.js +201 -0
- package/dist/esm/response-wrappers.js.map +1 -0
- package/dist/esm/search/index.d.ts +6 -0
- package/dist/esm/search/index.js +3 -0
- package/dist/esm/search/index.js.map +1 -0
- package/dist/esm/search/search.d.ts +22 -0
- package/dist/esm/search/search.js +236 -0
- package/dist/esm/search/search.js.map +1 -0
- package/dist/esm/search/types.d.ts +122 -0
- package/dist/esm/search/types.js +8 -0
- package/dist/esm/search/types.js.map +1 -0
- package/dist/esm/spawn/spawn-server.d.ts +83 -0
- package/dist/esm/spawn/spawn-server.js +145 -0
- package/dist/esm/spawn/spawn-server.js.map +1 -0
- package/dist/esm/spawn/spawn-servers.d.ts +151 -0
- package/dist/esm/spawn/spawn-servers.js +406 -0
- package/dist/esm/spawn/spawn-servers.js.map +1 -0
- package/dist/esm/types.d.ts +11 -0
- package/dist/esm/types.js +9 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/esm/utils/logger.d.ts +24 -0
- package/dist/esm/utils/logger.js +59 -0
- package/dist/esm/utils/logger.js.map +1 -0
- package/dist/esm/utils/path-utils.d.ts +45 -0
- package/dist/esm/utils/path-utils.js +89 -0
- package/dist/esm/utils/path-utils.js.map +1 -0
- package/dist/esm/utils/sanitizer.d.ts +30 -0
- package/dist/esm/utils/sanitizer.js +43 -0
- package/dist/esm/utils/sanitizer.js.map +1 -0
- package/package.json +92 -0
- package/schemas/servers.d.ts +90 -0
- package/schemas/servers.schema.json +104 -0
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Path resolution utilities for cluster spawning.
|
|
3
|
+
* Handles ~, relative paths, absolute paths, and special cases (URLs, npm packages, flags).
|
|
4
|
+
*/ import * as os from 'os';
|
|
5
|
+
import * as path from 'path';
|
|
6
|
+
/**
|
|
7
|
+
* Resolve a file path relative to a working directory.
|
|
8
|
+
*
|
|
9
|
+
* Handles three cases:
|
|
10
|
+
* - `~` or `~/path` - Expands to home directory
|
|
11
|
+
* - Absolute paths - Returns as-is
|
|
12
|
+
* - Relative paths - Resolves relative to cwd
|
|
13
|
+
*
|
|
14
|
+
* @param filePath - The path to resolve
|
|
15
|
+
* @param cwd - The working directory for resolving relative paths
|
|
16
|
+
* @returns The resolved absolute path
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* resolvePath('~/config.json', '/unused') // → '/home/user/config.json'
|
|
20
|
+
* resolvePath('/absolute/path', '/unused') // → '/absolute/path'
|
|
21
|
+
* resolvePath('./relative', '/base') // → '/base/relative'
|
|
22
|
+
*/ export function resolvePath(filePath, cwd) {
|
|
23
|
+
// Expand ~ to home directory
|
|
24
|
+
if (filePath === '~' || filePath.startsWith('~/')) {
|
|
25
|
+
filePath = filePath.replace(/^~/, os.homedir());
|
|
26
|
+
}
|
|
27
|
+
// If absolute, return as-is
|
|
28
|
+
if (path.isAbsolute(filePath)) {
|
|
29
|
+
return filePath;
|
|
30
|
+
}
|
|
31
|
+
// Otherwise resolve relative to cwd
|
|
32
|
+
return path.resolve(cwd, filePath);
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Resolve paths in command arguments array.
|
|
36
|
+
*
|
|
37
|
+
* Intelligently handles different argument types:
|
|
38
|
+
* - Flags with paths: `--env-file=./path` → `--env-file=/absolute/path`
|
|
39
|
+
* - Flags without paths: `--port=3000` → unchanged
|
|
40
|
+
* - Command flags: `--verbose` → unchanged
|
|
41
|
+
* - URLs: `http://example.com` → unchanged
|
|
42
|
+
* - npm packages: `@scope/package` or `package-name` → unchanged
|
|
43
|
+
* - Regular paths: `./script.js` → `/absolute/script.js`
|
|
44
|
+
*
|
|
45
|
+
* @param args - Array of command arguments
|
|
46
|
+
* @param cwd - Working directory for resolving relative paths
|
|
47
|
+
* @returns Array with paths resolved
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* resolveArgsPaths(['./bin/server.js', '--env-file=./config.env', '--port=3000'], '/home/user')
|
|
51
|
+
* // → ['/home/user/bin/server.js', '--env-file=/home/user/config.env', '--port=3000']
|
|
52
|
+
*
|
|
53
|
+
* resolveArgsPaths(['@scope/package', 'https://example.com'], '/unused')
|
|
54
|
+
* // → ['@scope/package', 'https://example.com'] (unchanged)
|
|
55
|
+
*/ export function resolveArgsPaths(args, cwd) {
|
|
56
|
+
return args.map((arg)=>{
|
|
57
|
+
if (typeof arg !== 'string') {
|
|
58
|
+
return arg;
|
|
59
|
+
}
|
|
60
|
+
// Check for flags with path values like --env-file=path, --config=path, etc.
|
|
61
|
+
const flagMatch = arg.match(/^(--.+?)=(.+)$/);
|
|
62
|
+
if (flagMatch) {
|
|
63
|
+
const [, flag, value] = flagMatch;
|
|
64
|
+
// Only resolve if the value looks like a path (contains ./ or ../ or / )
|
|
65
|
+
if (value && value.includes('/')) {
|
|
66
|
+
// Skip URLs in flag values
|
|
67
|
+
if (/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(value)) {
|
|
68
|
+
return arg;
|
|
69
|
+
}
|
|
70
|
+
return `${flag}=${resolvePath(value, cwd)}`;
|
|
71
|
+
}
|
|
72
|
+
return arg; // Return as-is for non-path flag values like --port=3000
|
|
73
|
+
}
|
|
74
|
+
// Skip command-line flags, only resolve actual paths
|
|
75
|
+
if (arg.startsWith('-')) {
|
|
76
|
+
return arg; // Don't resolve command-line flags as paths
|
|
77
|
+
}
|
|
78
|
+
// Skip URLs (http://, https://, etc.)
|
|
79
|
+
if (/^[a-zA-Z][a-zA-Z0-9+.-]*:\/\//.test(arg)) {
|
|
80
|
+
return arg; // Return URLs as-is
|
|
81
|
+
}
|
|
82
|
+
// Skip npm package names (starting with @ or containing no path separators)
|
|
83
|
+
if (arg.startsWith('@') || !arg.includes('/') && !arg.includes('\\')) {
|
|
84
|
+
return arg; // Return npm package names as-is
|
|
85
|
+
}
|
|
86
|
+
// Regular arguments get resolved as paths
|
|
87
|
+
return resolvePath(arg, cwd);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/Projects/ai/mcp-z/libs/client/src/utils/path-utils.ts"],"sourcesContent":["/**\n * Path resolution utilities for cluster spawning.\n * Handles ~, relative paths, absolute paths, and special cases (URLs, npm packages, flags).\n */\n\nimport * as os from 'os';\nimport * as path from 'path';\n\n/**\n * Resolve a file path relative to a working directory.\n *\n * Handles three cases:\n * - `~` or `~/path` - Expands to home directory\n * - Absolute paths - Returns as-is\n * - Relative paths - Resolves relative to cwd\n *\n * @param filePath - The path to resolve\n * @param cwd - The working directory for resolving relative paths\n * @returns The resolved absolute path\n *\n * @example\n * resolvePath('~/config.json', '/unused') // → '/home/user/config.json'\n * resolvePath('/absolute/path', '/unused') // → '/absolute/path'\n * resolvePath('./relative', '/base') // → '/base/relative'\n */\nexport function resolvePath(filePath: string, cwd: string): string {\n // Expand ~ to home directory\n if (filePath === '~' || filePath.startsWith('~/')) {\n filePath = filePath.replace(/^~/, os.homedir());\n }\n\n // If absolute, return as-is\n if (path.isAbsolute(filePath)) {\n return filePath;\n }\n\n // Otherwise resolve relative to cwd\n return path.resolve(cwd, filePath);\n}\n\n/**\n * Resolve paths in command arguments array.\n *\n * Intelligently handles different argument types:\n * - Flags with paths: `--env-file=./path` → `--env-file=/absolute/path`\n * - Flags without paths: `--port=3000` → unchanged\n * - Command flags: `--verbose` → unchanged\n * - URLs: `http://example.com` → unchanged\n * - npm packages: `@scope/package` or `package-name` → unchanged\n * - Regular paths: `./script.js` → `/absolute/script.js`\n *\n * @param args - Array of command arguments\n * @param cwd - Working directory for resolving relative paths\n * @returns Array with paths resolved\n *\n * @example\n * resolveArgsPaths(['./bin/server.js', '--env-file=./config.env', '--port=3000'], '/home/user')\n * // → ['/home/user/bin/server.js', '--env-file=/home/user/config.env', '--port=3000']\n *\n * resolveArgsPaths(['@scope/package', 'https://example.com'], '/unused')\n * // → ['@scope/package', 'https://example.com'] (unchanged)\n */\nexport function resolveArgsPaths(args: string[], cwd: string): string[] {\n return args.map((arg) => {\n if (typeof arg !== 'string') {\n return arg;\n }\n\n // Check for flags with path values like --env-file=path, --config=path, etc.\n const flagMatch = arg.match(/^(--.+?)=(.+)$/);\n if (flagMatch) {\n const [, flag, value] = flagMatch;\n // Only resolve if the value looks like a path (contains ./ or ../ or / )\n if (value && value.includes('/')) {\n // Skip URLs in flag values\n if (/^[a-zA-Z][a-zA-Z0-9+.-]*:\\/\\//.test(value)) {\n return arg;\n }\n return `${flag}=${resolvePath(value, cwd)}`;\n }\n return arg; // Return as-is for non-path flag values like --port=3000\n }\n\n // Skip command-line flags, only resolve actual paths\n if (arg.startsWith('-')) {\n return arg; // Don't resolve command-line flags as paths\n }\n\n // Skip URLs (http://, https://, etc.)\n if (/^[a-zA-Z][a-zA-Z0-9+.-]*:\\/\\//.test(arg)) {\n return arg; // Return URLs as-is\n }\n\n // Skip npm package names (starting with @ or containing no path separators)\n if (arg.startsWith('@') || (!arg.includes('/') && !arg.includes('\\\\'))) {\n return arg; // Return npm package names as-is\n }\n\n // Regular arguments get resolved as paths\n return resolvePath(arg, cwd);\n });\n}\n"],"names":["os","path","resolvePath","filePath","cwd","startsWith","replace","homedir","isAbsolute","resolve","resolveArgsPaths","args","map","arg","flagMatch","match","flag","value","includes","test"],"mappings":"AAAA;;;CAGC,GAED,YAAYA,QAAQ,KAAK;AACzB,YAAYC,UAAU,OAAO;AAE7B;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,SAASC,YAAYC,QAAgB,EAAEC,GAAW;IACvD,6BAA6B;IAC7B,IAAID,aAAa,OAAOA,SAASE,UAAU,CAAC,OAAO;QACjDF,WAAWA,SAASG,OAAO,CAAC,MAAMN,GAAGO,OAAO;IAC9C;IAEA,4BAA4B;IAC5B,IAAIN,KAAKO,UAAU,CAACL,WAAW;QAC7B,OAAOA;IACT;IAEA,oCAAoC;IACpC,OAAOF,KAAKQ,OAAO,CAACL,KAAKD;AAC3B;AAEA;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,OAAO,SAASO,iBAAiBC,IAAc,EAAEP,GAAW;IAC1D,OAAOO,KAAKC,GAAG,CAAC,CAACC;QACf,IAAI,OAAOA,QAAQ,UAAU;YAC3B,OAAOA;QACT;QAEA,6EAA6E;QAC7E,MAAMC,YAAYD,IAAIE,KAAK,CAAC;QAC5B,IAAID,WAAW;YACb,MAAM,GAAGE,MAAMC,MAAM,GAAGH;YACxB,yEAAyE;YACzE,IAAIG,SAASA,MAAMC,QAAQ,CAAC,MAAM;gBAChC,2BAA2B;gBAC3B,IAAI,gCAAgCC,IAAI,CAACF,QAAQ;oBAC/C,OAAOJ;gBACT;gBACA,OAAO,GAAGG,KAAK,CAAC,EAAEd,YAAYe,OAAOb,MAAM;YAC7C;YACA,OAAOS,KAAK,yDAAyD;QACvE;QAEA,qDAAqD;QACrD,IAAIA,IAAIR,UAAU,CAAC,MAAM;YACvB,OAAOQ,KAAK,4CAA4C;QAC1D;QAEA,sCAAsC;QACtC,IAAI,gCAAgCM,IAAI,CAACN,MAAM;YAC7C,OAAOA,KAAK,oBAAoB;QAClC;QAEA,4EAA4E;QAC5E,IAAIA,IAAIR,UAAU,CAAC,QAAS,CAACQ,IAAIK,QAAQ,CAAC,QAAQ,CAACL,IAAIK,QAAQ,CAAC,OAAQ;YACtE,OAAOL,KAAK,iCAAiC;QAC/C;QAEA,0CAA0C;QAC1C,OAAOX,YAAYW,KAAKT;IAC1B;AACF"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal log sanitization for spawn operations
|
|
3
|
+
* Redacts credentials from environment variables and command arguments
|
|
4
|
+
*/
|
|
5
|
+
import type { SpawnMetadata } from '../connection/types.js';
|
|
6
|
+
/**
|
|
7
|
+
* Sanitize log messages and metadata to prevent credential leakage
|
|
8
|
+
*
|
|
9
|
+
* Redacts common credential patterns:
|
|
10
|
+
* - key=value, secret=value, token=value, password=value
|
|
11
|
+
* - Environment variables with sensitive names
|
|
12
|
+
*
|
|
13
|
+
* @param message - Log message to sanitize
|
|
14
|
+
* @param obj - Metadata object to sanitize
|
|
15
|
+
* @returns Sanitized message and metadata
|
|
16
|
+
*/
|
|
17
|
+
export declare function sanitizeForLogging(message: string, obj: SpawnMetadata): {
|
|
18
|
+
message: string;
|
|
19
|
+
meta: SpawnMetadata;
|
|
20
|
+
};
|
|
21
|
+
export declare function sanitizeForLoggingFormatter(): {
|
|
22
|
+
log: (obj: SpawnMetadata) => {
|
|
23
|
+
msg: string;
|
|
24
|
+
command?: string;
|
|
25
|
+
args?: string[];
|
|
26
|
+
env?: Record<string, string>;
|
|
27
|
+
cwd?: string;
|
|
28
|
+
pid?: number;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal log sanitization for spawn operations
|
|
3
|
+
* Redacts credentials from environment variables and command arguments
|
|
4
|
+
*/ /**
|
|
5
|
+
* Sanitize log messages and metadata to prevent credential leakage
|
|
6
|
+
*
|
|
7
|
+
* Redacts common credential patterns:
|
|
8
|
+
* - key=value, secret=value, token=value, password=value
|
|
9
|
+
* - Environment variables with sensitive names
|
|
10
|
+
*
|
|
11
|
+
* @param message - Log message to sanitize
|
|
12
|
+
* @param obj - Metadata object to sanitize
|
|
13
|
+
* @returns Sanitized message and metadata
|
|
14
|
+
*/ export function sanitizeForLogging(message, obj) {
|
|
15
|
+
// Redact common credential patterns in message
|
|
16
|
+
const cleanMessage = message.replace(/key[=:]\S+/gi, 'key=[REDACTED]').replace(/secret[=:]\S+/gi, 'secret=[REDACTED]').replace(/token[=:]\S+/gi, 'token=[REDACTED]').replace(/password[=:]\S+/gi, 'password=[REDACTED]').replace(/auth[=:]\S+/gi, 'auth=[REDACTED]');
|
|
17
|
+
// Deep clone and redact sensitive env var keys
|
|
18
|
+
const cleanMeta = JSON.parse(JSON.stringify(obj));
|
|
19
|
+
// Redact sensitive environment variable values
|
|
20
|
+
if (cleanMeta.env && typeof cleanMeta.env === 'object') {
|
|
21
|
+
for (const envKey of Object.keys(cleanMeta.env)){
|
|
22
|
+
if (/key|secret|token|password|auth|credential/i.test(envKey)) {
|
|
23
|
+
cleanMeta.env[envKey] = '[REDACTED]';
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
message: cleanMessage,
|
|
29
|
+
meta: cleanMeta
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
export function sanitizeForLoggingFormatter() {
|
|
33
|
+
return {
|
|
34
|
+
log: (obj)=>{
|
|
35
|
+
const message = obj.msg || obj.message || '';
|
|
36
|
+
const { message: clean, meta } = sanitizeForLogging(message, obj);
|
|
37
|
+
return {
|
|
38
|
+
...meta,
|
|
39
|
+
msg: clean
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/kevin/Dev/Projects/ai/mcp-z/libs/client/src/utils/sanitizer.ts"],"sourcesContent":["/**\n * Minimal log sanitization for spawn operations\n * Redacts credentials from environment variables and command arguments\n */\n\nimport type { SpawnMetadata } from '../connection/types.ts';\n\n/**\n * Sanitize log messages and metadata to prevent credential leakage\n *\n * Redacts common credential patterns:\n * - key=value, secret=value, token=value, password=value\n * - Environment variables with sensitive names\n *\n * @param message - Log message to sanitize\n * @param obj - Metadata object to sanitize\n * @returns Sanitized message and metadata\n */\nexport function sanitizeForLogging(message: string, obj: SpawnMetadata): { message: string; meta: SpawnMetadata } {\n // Redact common credential patterns in message\n const cleanMessage = message\n .replace(/key[=:]\\S+/gi, 'key=[REDACTED]')\n .replace(/secret[=:]\\S+/gi, 'secret=[REDACTED]')\n .replace(/token[=:]\\S+/gi, 'token=[REDACTED]')\n .replace(/password[=:]\\S+/gi, 'password=[REDACTED]')\n .replace(/auth[=:]\\S+/gi, 'auth=[REDACTED]');\n\n // Deep clone and redact sensitive env var keys\n const cleanMeta = JSON.parse(JSON.stringify(obj));\n\n // Redact sensitive environment variable values\n if (cleanMeta.env && typeof cleanMeta.env === 'object') {\n for (const envKey of Object.keys(cleanMeta.env)) {\n if (/key|secret|token|password|auth|credential/i.test(envKey)) {\n cleanMeta.env[envKey] = '[REDACTED]';\n }\n }\n }\n\n return { message: cleanMessage, meta: cleanMeta };\n}\n\nexport function sanitizeForLoggingFormatter() {\n return {\n log: (obj: SpawnMetadata) => {\n const message = (obj.msg || obj.message || '') as string;\n const { message: clean, meta } = sanitizeForLogging(message, obj);\n return { ...meta, msg: clean };\n },\n };\n}\n"],"names":["sanitizeForLogging","message","obj","cleanMessage","replace","cleanMeta","JSON","parse","stringify","env","envKey","Object","keys","test","meta","sanitizeForLoggingFormatter","log","msg","clean"],"mappings":"AAAA;;;CAGC,GAID;;;;;;;;;;CAUC,GACD,OAAO,SAASA,mBAAmBC,OAAe,EAAEC,GAAkB;IACpE,+CAA+C;IAC/C,MAAMC,eAAeF,QAClBG,OAAO,CAAC,gBAAgB,kBACxBA,OAAO,CAAC,mBAAmB,qBAC3BA,OAAO,CAAC,kBAAkB,oBAC1BA,OAAO,CAAC,qBAAqB,uBAC7BA,OAAO,CAAC,iBAAiB;IAE5B,+CAA+C;IAC/C,MAAMC,YAAYC,KAAKC,KAAK,CAACD,KAAKE,SAAS,CAACN;IAE5C,+CAA+C;IAC/C,IAAIG,UAAUI,GAAG,IAAI,OAAOJ,UAAUI,GAAG,KAAK,UAAU;QACtD,KAAK,MAAMC,UAAUC,OAAOC,IAAI,CAACP,UAAUI,GAAG,EAAG;YAC/C,IAAI,6CAA6CI,IAAI,CAACH,SAAS;gBAC7DL,UAAUI,GAAG,CAACC,OAAO,GAAG;YAC1B;QACF;IACF;IAEA,OAAO;QAAET,SAASE;QAAcW,MAAMT;IAAU;AAClD;AAEA,OAAO,SAASU;IACd,OAAO;QACLC,KAAK,CAACd;YACJ,MAAMD,UAAWC,IAAIe,GAAG,IAAIf,IAAID,OAAO,IAAI;YAC3C,MAAM,EAAEA,SAASiB,KAAK,EAAEJ,IAAI,EAAE,GAAGd,mBAAmBC,SAASC;YAC7D,OAAO;gBAAE,GAAGY,IAAI;gBAAEG,KAAKC;YAAM;QAC/B;IACF;AACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mcp-z/client",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Programmatic MCP client library for Node.js - connect, discover, and call tools on Model Context Protocol servers.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"mcp",
|
|
7
|
+
"model-context-protocol",
|
|
8
|
+
"mcp-server",
|
|
9
|
+
"mcp-client",
|
|
10
|
+
"server",
|
|
11
|
+
"client",
|
|
12
|
+
"lib",
|
|
13
|
+
"token-storage",
|
|
14
|
+
"testing",
|
|
15
|
+
"integration-testing",
|
|
16
|
+
"development-tools",
|
|
17
|
+
"server-management",
|
|
18
|
+
"lifecycle",
|
|
19
|
+
"graceful-shutdown",
|
|
20
|
+
"test-utilities",
|
|
21
|
+
"workflow",
|
|
22
|
+
"ai",
|
|
23
|
+
"claude"
|
|
24
|
+
],
|
|
25
|
+
"homepage": "https://github.com/mcp-z/cli#readme",
|
|
26
|
+
"bugs": {
|
|
27
|
+
"url": "https://github.com/mcp-z/cli/issues"
|
|
28
|
+
},
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/mcp-z/cli.git"
|
|
32
|
+
},
|
|
33
|
+
"license": "MIT",
|
|
34
|
+
"author": "Kevin Malakoff <kmalakoff.info@gmail.com>",
|
|
35
|
+
"type": "module",
|
|
36
|
+
"exports": {
|
|
37
|
+
".": {
|
|
38
|
+
"types": "./dist/esm/index.d.ts",
|
|
39
|
+
"import": "./dist/esm/index.js",
|
|
40
|
+
"require": "./dist/cjs/index.js"
|
|
41
|
+
},
|
|
42
|
+
"./package.json": "./package.json"
|
|
43
|
+
},
|
|
44
|
+
"main": "./dist/cjs/index.js",
|
|
45
|
+
"module": "./dist/esm/index.js",
|
|
46
|
+
"types": "./dist/esm/index.d.ts",
|
|
47
|
+
"files": [
|
|
48
|
+
"dist",
|
|
49
|
+
"schemas",
|
|
50
|
+
"AGENTS.md"
|
|
51
|
+
],
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsc -p . --noEmit && tsds build",
|
|
54
|
+
"format": "tsds format",
|
|
55
|
+
"generate:types": "json2ts schemas/servers.schema.json schemas/servers.d.ts --bannerComment \"/* eslint-disable */\n/* Auto-generated from schemas/servers.schema.json - DO NOT EDIT */\"",
|
|
56
|
+
"prepublish:check": "ncp",
|
|
57
|
+
"prepublishOnly": "tsds validate",
|
|
58
|
+
"test": "npm run test:unit && npm run test:integration",
|
|
59
|
+
"test:engines": "nvu engines tsds test:node --no-timeouts",
|
|
60
|
+
"test:integration": "tsds test:node --no-timeouts 'test/integration/**/*.test.ts'",
|
|
61
|
+
"test:unit": "tsds test:node --no-timeouts 'test/unit/**/*.test.ts'",
|
|
62
|
+
"version": "tsds version"
|
|
63
|
+
},
|
|
64
|
+
"dependencies": {
|
|
65
|
+
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
66
|
+
"ajv": "^8.17.1",
|
|
67
|
+
"ajv-formats": "^3.0.1",
|
|
68
|
+
"get-port": "^7.1.0",
|
|
69
|
+
"keyv": "^5.5.5",
|
|
70
|
+
"keyv-file": "^5.3.3",
|
|
71
|
+
"module-root-sync": "^2.0.2"
|
|
72
|
+
},
|
|
73
|
+
"devDependencies": {
|
|
74
|
+
"@types/express": "^5.0.6",
|
|
75
|
+
"@types/mocha": "^10.0.10",
|
|
76
|
+
"@types/node": "^25.0.2",
|
|
77
|
+
"dotenv": "^17.2.3",
|
|
78
|
+
"express": "^5.0.0",
|
|
79
|
+
"json-schema-to-typescript": "^15.0.4",
|
|
80
|
+
"node-version-use": "^2.1.6",
|
|
81
|
+
"ts-dev-stack": "^1.21.3",
|
|
82
|
+
"tsds-config": "^1.0.0",
|
|
83
|
+
"typescript": "^5.9.3",
|
|
84
|
+
"zod": "^4.0.0"
|
|
85
|
+
},
|
|
86
|
+
"engines": {
|
|
87
|
+
"node": ">=22"
|
|
88
|
+
},
|
|
89
|
+
"tsds": {
|
|
90
|
+
"source": "src/index.ts"
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/* Auto-generated from schemas/servers.schema.json - DO NOT EDIT */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Map of server names to their configurations. Compatible with Claude Code mcpServers and VS Code servers formats.
|
|
6
|
+
*/
|
|
7
|
+
export interface MCPServers {
|
|
8
|
+
[k: string]: McpServerEntry;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Configuration for a single MCP server. Transport type is determined by the 'type' field (defaults to 'stdio').
|
|
12
|
+
*/
|
|
13
|
+
export interface McpServerEntry {
|
|
14
|
+
/**
|
|
15
|
+
* Transport type. Defaults to 'stdio' if omitted.
|
|
16
|
+
*/
|
|
17
|
+
type?: 'stdio' | 'http' | 'sse-ide' | 'ws-ide' | 'sdk';
|
|
18
|
+
/**
|
|
19
|
+
* Command to execute (stdio transport)
|
|
20
|
+
*/
|
|
21
|
+
command?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Command arguments (stdio transport)
|
|
24
|
+
*/
|
|
25
|
+
args?: string[];
|
|
26
|
+
/**
|
|
27
|
+
* Environment variables
|
|
28
|
+
*/
|
|
29
|
+
env?: {
|
|
30
|
+
[k: string]: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Working directory
|
|
34
|
+
*/
|
|
35
|
+
cwd?: string;
|
|
36
|
+
/**
|
|
37
|
+
* Server URL (http, sse-ide, ws-ide transports)
|
|
38
|
+
*/
|
|
39
|
+
url?: string;
|
|
40
|
+
/**
|
|
41
|
+
* HTTP headers (http transport)
|
|
42
|
+
*/
|
|
43
|
+
headers?: {
|
|
44
|
+
[k: string]: string;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Helper command for dynamic header generation (http transport)
|
|
48
|
+
*/
|
|
49
|
+
headersHelper?: string;
|
|
50
|
+
/**
|
|
51
|
+
* IDE identifier (sse-ide, ws-ide transports)
|
|
52
|
+
*/
|
|
53
|
+
ideName?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Authentication token (ws-ide transport)
|
|
56
|
+
*/
|
|
57
|
+
authToken?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Whether IDE is running on Windows (sse-ide, ws-ide transports)
|
|
60
|
+
*/
|
|
61
|
+
ideRunningInWindows?: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* SDK name identifier (sdk transport)
|
|
64
|
+
*/
|
|
65
|
+
name?: string;
|
|
66
|
+
start?: StartConfig;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* MCP-Z extension: Auto-start configuration for HTTP servers
|
|
70
|
+
*/
|
|
71
|
+
export interface StartConfig {
|
|
72
|
+
/**
|
|
73
|
+
* Command to start the server
|
|
74
|
+
*/
|
|
75
|
+
command: string;
|
|
76
|
+
/**
|
|
77
|
+
* Command arguments
|
|
78
|
+
*/
|
|
79
|
+
args?: string[];
|
|
80
|
+
/**
|
|
81
|
+
* Environment variables
|
|
82
|
+
*/
|
|
83
|
+
env?: {
|
|
84
|
+
[k: string]: string;
|
|
85
|
+
};
|
|
86
|
+
/**
|
|
87
|
+
* Working directory
|
|
88
|
+
*/
|
|
89
|
+
cwd?: string;
|
|
90
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://mcpeasy.dev/schemas/servers.schema.json",
|
|
4
|
+
"title": "MCP Servers",
|
|
5
|
+
"description": "Map of server names to their configurations. Compatible with Claude Code mcpServers and VS Code servers formats.",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": {
|
|
8
|
+
"$ref": "#/definitions/McpServerEntry"
|
|
9
|
+
},
|
|
10
|
+
"definitions": {
|
|
11
|
+
"McpServerEntry": {
|
|
12
|
+
"type": "object",
|
|
13
|
+
"description": "Configuration for a single MCP server. Transport type is determined by the 'type' field (defaults to 'stdio').",
|
|
14
|
+
"properties": {
|
|
15
|
+
"type": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"enum": ["stdio", "http", "sse-ide", "ws-ide", "sdk"],
|
|
18
|
+
"description": "Transport type. Defaults to 'stdio' if omitted."
|
|
19
|
+
},
|
|
20
|
+
"command": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"minLength": 1,
|
|
23
|
+
"description": "Command to execute (stdio transport)"
|
|
24
|
+
},
|
|
25
|
+
"args": {
|
|
26
|
+
"type": "array",
|
|
27
|
+
"items": { "type": "string" },
|
|
28
|
+
"description": "Command arguments (stdio transport)"
|
|
29
|
+
},
|
|
30
|
+
"env": {
|
|
31
|
+
"type": "object",
|
|
32
|
+
"additionalProperties": { "type": "string" },
|
|
33
|
+
"description": "Environment variables"
|
|
34
|
+
},
|
|
35
|
+
"cwd": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"description": "Working directory"
|
|
38
|
+
},
|
|
39
|
+
"url": {
|
|
40
|
+
"type": "string",
|
|
41
|
+
"format": "uri",
|
|
42
|
+
"description": "Server URL (http, sse-ide, ws-ide transports)"
|
|
43
|
+
},
|
|
44
|
+
"headers": {
|
|
45
|
+
"type": "object",
|
|
46
|
+
"additionalProperties": { "type": "string" },
|
|
47
|
+
"description": "HTTP headers (http transport)"
|
|
48
|
+
},
|
|
49
|
+
"headersHelper": {
|
|
50
|
+
"type": "string",
|
|
51
|
+
"description": "Helper command for dynamic header generation (http transport)"
|
|
52
|
+
},
|
|
53
|
+
"ideName": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"description": "IDE identifier (sse-ide, ws-ide transports)"
|
|
56
|
+
},
|
|
57
|
+
"authToken": {
|
|
58
|
+
"type": "string",
|
|
59
|
+
"description": "Authentication token (ws-ide transport)"
|
|
60
|
+
},
|
|
61
|
+
"ideRunningInWindows": {
|
|
62
|
+
"type": "boolean",
|
|
63
|
+
"description": "Whether IDE is running on Windows (sse-ide, ws-ide transports)"
|
|
64
|
+
},
|
|
65
|
+
"name": {
|
|
66
|
+
"type": "string",
|
|
67
|
+
"description": "SDK name identifier (sdk transport)"
|
|
68
|
+
},
|
|
69
|
+
"start": {
|
|
70
|
+
"$ref": "#/definitions/StartConfig",
|
|
71
|
+
"description": "MCP-Z extension: Auto-start configuration for HTTP servers"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"additionalProperties": false
|
|
75
|
+
},
|
|
76
|
+
"StartConfig": {
|
|
77
|
+
"type": "object",
|
|
78
|
+
"description": "MCP-Z extension: Configuration for auto-starting HTTP servers",
|
|
79
|
+
"properties": {
|
|
80
|
+
"command": {
|
|
81
|
+
"type": "string",
|
|
82
|
+
"minLength": 1,
|
|
83
|
+
"description": "Command to start the server"
|
|
84
|
+
},
|
|
85
|
+
"args": {
|
|
86
|
+
"type": "array",
|
|
87
|
+
"items": { "type": "string" },
|
|
88
|
+
"description": "Command arguments"
|
|
89
|
+
},
|
|
90
|
+
"env": {
|
|
91
|
+
"type": "object",
|
|
92
|
+
"additionalProperties": { "type": "string" },
|
|
93
|
+
"description": "Environment variables"
|
|
94
|
+
},
|
|
95
|
+
"cwd": {
|
|
96
|
+
"type": "string",
|
|
97
|
+
"description": "Working directory"
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
"required": ["command"],
|
|
101
|
+
"additionalProperties": false
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|