@mcp-z/client 2.2.3 → 2.3.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.
Files changed (111) hide show
  1. package/README.md +12 -1
  2. package/dist/cjs/auth/capability-discovery.d.cts +3 -1
  3. package/dist/cjs/auth/capability-discovery.d.ts +3 -1
  4. package/dist/cjs/auth/capability-discovery.js +46 -32
  5. package/dist/cjs/auth/capability-discovery.js.map +1 -1
  6. package/dist/cjs/auth/discovery-fetch.d.cts +2 -0
  7. package/dist/cjs/auth/discovery-fetch.d.ts +2 -0
  8. package/dist/cjs/auth/discovery-fetch.js +85 -31
  9. package/dist/cjs/auth/discovery-fetch.js.map +1 -1
  10. package/dist/cjs/auth/interactive-oauth-flow.d.cts +1 -1
  11. package/dist/cjs/auth/interactive-oauth-flow.d.ts +1 -1
  12. package/dist/cjs/auth/interactive-oauth-flow.js +13 -6
  13. package/dist/cjs/auth/interactive-oauth-flow.js.map +1 -1
  14. package/dist/cjs/auth/oauth-callback-listener.d.cts +1 -1
  15. package/dist/cjs/auth/oauth-callback-listener.d.ts +1 -1
  16. package/dist/cjs/auth/oauth-callback-listener.js +40 -4
  17. package/dist/cjs/auth/oauth-callback-listener.js.map +1 -1
  18. package/dist/cjs/auth/rfc9728-discovery.d.cts +7 -2
  19. package/dist/cjs/auth/rfc9728-discovery.d.ts +7 -2
  20. package/dist/cjs/auth/rfc9728-discovery.js +120 -88
  21. package/dist/cjs/auth/rfc9728-discovery.js.map +1 -1
  22. package/dist/cjs/auth/types.d.cts +4 -0
  23. package/dist/cjs/auth/types.d.ts +4 -0
  24. package/dist/cjs/auth/types.js.map +1 -1
  25. package/dist/cjs/connection/connect-client.d.cts +9 -1
  26. package/dist/cjs/connection/connect-client.d.ts +9 -1
  27. package/dist/cjs/connection/connect-client.js +282 -75
  28. package/dist/cjs/connection/connect-client.js.map +1 -1
  29. package/dist/cjs/connection/existing-process-transport.d.cts +18 -18
  30. package/dist/cjs/connection/existing-process-transport.d.ts +18 -18
  31. package/dist/cjs/connection/existing-process-transport.js +187 -82
  32. package/dist/cjs/connection/existing-process-transport.js.map +1 -1
  33. package/dist/cjs/connection/wait-for-http-ready.d.cts +1 -1
  34. package/dist/cjs/connection/wait-for-http-ready.d.ts +1 -1
  35. package/dist/cjs/connection/wait-for-http-ready.js +30 -5
  36. package/dist/cjs/connection/wait-for-http-ready.js.map +1 -1
  37. package/dist/cjs/dcr/dcr-authenticator.d.cts +1 -1
  38. package/dist/cjs/dcr/dcr-authenticator.d.ts +1 -1
  39. package/dist/cjs/dcr/dcr-authenticator.js +29 -18
  40. package/dist/cjs/dcr/dcr-authenticator.js.map +1 -1
  41. package/dist/cjs/dcr/dynamic-client-registrar.js +2 -1
  42. package/dist/cjs/dcr/dynamic-client-registrar.js.map +1 -1
  43. package/dist/cjs/index.d.cts +1 -1
  44. package/dist/cjs/index.d.ts +1 -1
  45. package/dist/cjs/index.js.map +1 -1
  46. package/dist/cjs/spawn/owned-process-tree.d.cts +12 -0
  47. package/dist/cjs/spawn/owned-process-tree.d.ts +12 -0
  48. package/dist/cjs/spawn/owned-process-tree.js +93 -0
  49. package/dist/cjs/spawn/owned-process-tree.js.map +1 -0
  50. package/dist/cjs/spawn/spawn-server.d.cts +8 -32
  51. package/dist/cjs/spawn/spawn-server.d.ts +8 -32
  52. package/dist/cjs/spawn/spawn-server.js +406 -97
  53. package/dist/cjs/spawn/spawn-server.js.map +1 -1
  54. package/dist/cjs/spawn/spawn-servers.d.cts +18 -8
  55. package/dist/cjs/spawn/spawn-servers.d.ts +18 -8
  56. package/dist/cjs/spawn/spawn-servers.js +342 -113
  57. package/dist/cjs/spawn/spawn-servers.js.map +1 -1
  58. package/dist/cjs/types.d.cts +1 -1
  59. package/dist/cjs/types.d.ts +1 -1
  60. package/dist/cjs/types.js.map +1 -1
  61. package/dist/cjs/utils/path-utils.js +7 -4
  62. package/dist/cjs/utils/path-utils.js.map +1 -1
  63. package/dist/esm/auth/capability-discovery.d.ts +3 -1
  64. package/dist/esm/auth/capability-discovery.js +21 -11
  65. package/dist/esm/auth/capability-discovery.js.map +1 -1
  66. package/dist/esm/auth/discovery-fetch.d.ts +2 -0
  67. package/dist/esm/auth/discovery-fetch.js +64 -23
  68. package/dist/esm/auth/discovery-fetch.js.map +1 -1
  69. package/dist/esm/auth/interactive-oauth-flow.d.ts +1 -1
  70. package/dist/esm/auth/interactive-oauth-flow.js +13 -6
  71. package/dist/esm/auth/interactive-oauth-flow.js.map +1 -1
  72. package/dist/esm/auth/oauth-callback-listener.d.ts +1 -1
  73. package/dist/esm/auth/oauth-callback-listener.js +34 -4
  74. package/dist/esm/auth/oauth-callback-listener.js.map +1 -1
  75. package/dist/esm/auth/rfc9728-discovery.d.ts +7 -2
  76. package/dist/esm/auth/rfc9728-discovery.js +40 -16
  77. package/dist/esm/auth/rfc9728-discovery.js.map +1 -1
  78. package/dist/esm/auth/types.d.ts +4 -0
  79. package/dist/esm/auth/types.js.map +1 -1
  80. package/dist/esm/connection/connect-client.d.ts +9 -1
  81. package/dist/esm/connection/connect-client.js +97 -35
  82. package/dist/esm/connection/connect-client.js.map +1 -1
  83. package/dist/esm/connection/existing-process-transport.d.ts +18 -18
  84. package/dist/esm/connection/existing-process-transport.js +132 -70
  85. package/dist/esm/connection/existing-process-transport.js.map +1 -1
  86. package/dist/esm/connection/wait-for-http-ready.d.ts +1 -1
  87. package/dist/esm/connection/wait-for-http-ready.js +19 -4
  88. package/dist/esm/connection/wait-for-http-ready.js.map +1 -1
  89. package/dist/esm/dcr/dcr-authenticator.d.ts +1 -1
  90. package/dist/esm/dcr/dcr-authenticator.js +26 -15
  91. package/dist/esm/dcr/dcr-authenticator.js.map +1 -1
  92. package/dist/esm/dcr/dynamic-client-registrar.js +2 -1
  93. package/dist/esm/dcr/dynamic-client-registrar.js.map +1 -1
  94. package/dist/esm/index.d.ts +1 -1
  95. package/dist/esm/index.js.map +1 -1
  96. package/dist/esm/spawn/owned-process-tree.d.ts +12 -0
  97. package/dist/esm/spawn/owned-process-tree.js +39 -0
  98. package/dist/esm/spawn/owned-process-tree.js.map +1 -0
  99. package/dist/esm/spawn/spawn-server.d.ts +8 -32
  100. package/dist/esm/spawn/spawn-server.js +228 -99
  101. package/dist/esm/spawn/spawn-server.js.map +1 -1
  102. package/dist/esm/spawn/spawn-servers.d.ts +18 -8
  103. package/dist/esm/spawn/spawn-servers.js +180 -55
  104. package/dist/esm/spawn/spawn-servers.js.map +1 -1
  105. package/dist/esm/types.d.ts +1 -1
  106. package/dist/esm/types.js.map +1 -1
  107. package/dist/esm/utils/path-utils.js +7 -4
  108. package/dist/esm/utils/path-utils.js.map +1 -1
  109. package/package.json +8 -3
  110. package/schemas/servers.d.ts +24 -0
  111. package/schemas/servers.schema.json +31 -0
@@ -4,10 +4,12 @@
4
4
  * Supports stdio, http, and ws transports.
5
5
  * Implements Claude Code-compatible configuration with start extension support.
6
6
  */
7
+ import type { VersionNegotiationOptions } from '@modelcontextprotocol/client';
7
8
  import { type ManagedClient } from '../client-helpers.js';
8
- import { connectMcpClient } from '../connection/connect-client.js';
9
+ import type { DcrAuthenticatorOptions } from '../dcr/dcr-authenticator.js';
9
10
  import { type SearchOptions, type SearchResponse } from '../search/index.js';
10
11
  import type { McpServerEntry } from '../types.js';
12
+ import { type Logger } from '../utils/logger.js';
11
13
  import { type ServerProcess } from './spawn-server.js';
12
14
  /**
13
15
  * Servers configuration type - a map of server names to their configurations.
@@ -45,16 +47,15 @@ export interface CreateServerRegistryOptions {
45
47
  * Result of closing the registry.
46
48
  */
47
49
  export interface CloseResult {
48
- /** Whether any process timed out during shutdown */
50
+ /** Whether any owned process exceeded its cooperative shutdown timeout */
49
51
  timedOut: boolean;
50
- /** Number of processes that were force-killed */
52
+ /** Number of owned processes that required emergency force termination */
51
53
  killedCount: number;
52
54
  }
53
55
  /**
54
56
  * A registry of spawned MCP servers with connection management.
55
57
  * Provides access to individual server handles, connection management, and collection-wide close.
56
58
  */
57
- type RegistryConnectOptions = Parameters<typeof connectMcpClient>[2];
58
59
  export interface ServerRegistry {
59
60
  /**
60
61
  * The resolved servers configuration that was used.
@@ -76,16 +77,26 @@ export interface ServerRegistry {
76
77
  * The connected client is automatically tracked for close.
77
78
  *
78
79
  * @param name - Server name from configuration
80
+ * @param options - Authentication, logging, and protocol negotiation options
79
81
  * @returns Connected MCP SDK Client
80
82
  */
81
- connect: (name: string, options?: RegistryConnectOptions) => Promise<ManagedClient>;
83
+ connect: (name: string, options?: {
84
+ dcrAuthenticator?: Partial<DcrAuthenticatorOptions>;
85
+ logger?: Logger;
86
+ versionNegotiation?: VersionNegotiationOptions;
87
+ }) => Promise<ManagedClient>;
82
88
  /**
83
89
  * Close all clients and servers gracefully.
84
- * First closes all tracked clients, then sends the specified signal to all server processes.
90
+ * Stops new connections, waits for in-flight connections, closes tracked clients, and then
91
+ * stops only processes owned by this registry. Stdio children receive stdin EOF first
92
+ * and the requested signal on POSIX if they remain open; owned HTTP children may use
93
+ * their configured application-specific stop command. POSIX cleanup tracks the detached
94
+ * process group; Windows can terminate only the direct child and cannot verify descendants.
95
+ * Cleanup failures are reported after every owned resource has been attempted.
85
96
  *
86
97
  * @param signal - Signal to send to processes (default: SIGINT)
87
98
  * @param opts - Options including timeout
88
- * @returns Promise resolving to whether any process timed out and how many were force-killed
99
+ * @returns Promise resolving to whether any process timed out and how many required emergency force termination
89
100
  */
90
101
  close: (signal?: NodeJS.Signals, opts?: {
91
102
  timeoutMs?: number;
@@ -148,4 +159,3 @@ export interface ServerRegistry {
148
159
  * // Auto-disposed when scope exits
149
160
  */
150
161
  export declare function createServerRegistry(serversConfig: ServersConfig, options?: CreateServerRegistryOptions): ServerRegistry;
151
- export {};
@@ -4,10 +4,12 @@
4
4
  * Supports stdio, http, and ws transports.
5
5
  * Implements Claude Code-compatible configuration with start extension support.
6
6
  */
7
+ import type { VersionNegotiationOptions } from '@modelcontextprotocol/client';
7
8
  import { type ManagedClient } from '../client-helpers.js';
8
- import { connectMcpClient } from '../connection/connect-client.js';
9
+ import type { DcrAuthenticatorOptions } from '../dcr/dcr-authenticator.js';
9
10
  import { type SearchOptions, type SearchResponse } from '../search/index.js';
10
11
  import type { McpServerEntry } from '../types.js';
12
+ import { type Logger } from '../utils/logger.js';
11
13
  import { type ServerProcess } from './spawn-server.js';
12
14
  /**
13
15
  * Servers configuration type - a map of server names to their configurations.
@@ -45,16 +47,15 @@ export interface CreateServerRegistryOptions {
45
47
  * Result of closing the registry.
46
48
  */
47
49
  export interface CloseResult {
48
- /** Whether any process timed out during shutdown */
50
+ /** Whether any owned process exceeded its cooperative shutdown timeout */
49
51
  timedOut: boolean;
50
- /** Number of processes that were force-killed */
52
+ /** Number of owned processes that required emergency force termination */
51
53
  killedCount: number;
52
54
  }
53
55
  /**
54
56
  * A registry of spawned MCP servers with connection management.
55
57
  * Provides access to individual server handles, connection management, and collection-wide close.
56
58
  */
57
- type RegistryConnectOptions = Parameters<typeof connectMcpClient>[2];
58
59
  export interface ServerRegistry {
59
60
  /**
60
61
  * The resolved servers configuration that was used.
@@ -76,16 +77,26 @@ export interface ServerRegistry {
76
77
  * The connected client is automatically tracked for close.
77
78
  *
78
79
  * @param name - Server name from configuration
80
+ * @param options - Authentication, logging, and protocol negotiation options
79
81
  * @returns Connected MCP SDK Client
80
82
  */
81
- connect: (name: string, options?: RegistryConnectOptions) => Promise<ManagedClient>;
83
+ connect: (name: string, options?: {
84
+ dcrAuthenticator?: Partial<DcrAuthenticatorOptions>;
85
+ logger?: Logger;
86
+ versionNegotiation?: VersionNegotiationOptions;
87
+ }) => Promise<ManagedClient>;
82
88
  /**
83
89
  * Close all clients and servers gracefully.
84
- * First closes all tracked clients, then sends the specified signal to all server processes.
90
+ * Stops new connections, waits for in-flight connections, closes tracked clients, and then
91
+ * stops only processes owned by this registry. Stdio children receive stdin EOF first
92
+ * and the requested signal on POSIX if they remain open; owned HTTP children may use
93
+ * their configured application-specific stop command. POSIX cleanup tracks the detached
94
+ * process group; Windows can terminate only the direct child and cannot verify descendants.
95
+ * Cleanup failures are reported after every owned resource has been attempted.
85
96
  *
86
97
  * @param signal - Signal to send to processes (default: SIGINT)
87
98
  * @param opts - Options including timeout
88
- * @returns Promise resolving to whether any process timed out and how many were force-killed
99
+ * @returns Promise resolving to whether any process timed out and how many required emergency force termination
89
100
  */
90
101
  close: (signal?: NodeJS.Signals, opts?: {
91
102
  timeoutMs?: number;
@@ -148,4 +159,3 @@ export interface ServerRegistry {
148
159
  * // Auto-disposed when scope exits
149
160
  */
150
161
  export declare function createServerRegistry(serversConfig: ServersConfig, options?: CreateServerRegistryOptions): ServerRegistry;
151
- export {};