@agiflowai/one-mcp 0.3.13 → 0.3.15

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/dist/index.cjs CHANGED
@@ -1,13 +1,19 @@
1
- const require_http = require('./http-SFQFxDCq.cjs');
1
+ const require_src = require('./src-CWShQS8u.cjs');
2
2
 
3
- exports.ConfigFetcherService = require_http.ConfigFetcherService;
4
- exports.DefinitionsCacheService = require_http.DefinitionsCacheService;
5
- exports.DescribeToolsTool = require_http.DescribeToolsTool;
6
- exports.HttpTransportHandler = require_http.HttpTransportHandler;
7
- exports.McpClientManagerService = require_http.McpClientManagerService;
8
- exports.SearchListToolsTool = require_http.SearchListToolsTool;
9
- exports.SkillService = require_http.SkillService;
10
- exports.SseTransportHandler = require_http.SseTransportHandler;
11
- exports.StdioTransportHandler = require_http.StdioTransportHandler;
12
- exports.UseToolTool = require_http.UseToolTool;
13
- exports.createServer = require_http.createServer;
3
+ exports.ConfigFetcherService = require_src.ConfigFetcherService;
4
+ exports.DefinitionsCacheService = require_src.DefinitionsCacheService;
5
+ exports.DescribeToolsTool = require_src.DescribeToolsTool;
6
+ exports.HttpTransportHandler = require_src.HttpTransportHandler;
7
+ exports.McpClientManagerService = require_src.McpClientManagerService;
8
+ exports.RuntimeStateService = require_src.RuntimeStateService;
9
+ exports.SearchListToolsTool = require_src.SearchListToolsTool;
10
+ exports.SkillService = require_src.SkillService;
11
+ exports.SseTransportHandler = require_src.SseTransportHandler;
12
+ exports.StdioHttpTransportHandler = require_src.StdioHttpTransportHandler;
13
+ exports.StdioTransportHandler = require_src.StdioTransportHandler;
14
+ exports.StopServerService = require_src.StopServerService;
15
+ exports.TRANSPORT_MODE = require_src.TRANSPORT_MODE;
16
+ exports.UseToolTool = require_src.UseToolTool;
17
+ exports.createServer = require_src.createServer;
18
+ exports.findConfigFile = require_src.findConfigFile;
19
+ exports.generateServerId = require_src.generateServerId;
package/dist/index.d.cts CHANGED
@@ -65,6 +65,97 @@ interface HttpTransportHandler$1 extends TransportHandler {
65
65
  getPort(): number;
66
66
  getHost(): string;
67
67
  }
68
+ /**
69
+ * Runtime state persisted for HTTP one-mcp instances.
70
+ * @property serverId - Unique one-mcp server identifier
71
+ * @property host - Host bound by the HTTP transport
72
+ * @property port - Port bound by the HTTP transport
73
+ * @property transport - Transport mode for the runtime record
74
+ * @property shutdownToken - Secret token required for admin shutdown requests
75
+ * @property startedAt - ISO timestamp when the runtime started
76
+ * @property pid - Process ID of the running one-mcp process
77
+ * @property configPath - Optional path to the config file used to start the server
78
+ */
79
+ interface RuntimeStateRecord {
80
+ serverId: string;
81
+ host: string;
82
+ port: number;
83
+ transport: 'http';
84
+ shutdownToken: string;
85
+ startedAt: string;
86
+ pid: number;
87
+ configPath?: string;
88
+ }
89
+ /**
90
+ * Optional admin settings for HTTP transport lifecycle actions.
91
+ * @property serverId - Server identifier surfaced via health responses
92
+ * @property shutdownToken - Secret token accepted by the admin shutdown endpoint
93
+ * @property onShutdownRequested - Callback invoked after a valid shutdown request is received
94
+ */
95
+ interface HttpTransportAdminOptions {
96
+ serverId?: string;
97
+ shutdownToken?: string;
98
+ onShutdownRequested?: () => Promise<void>;
99
+ }
100
+ /**
101
+ * Health payload exposed by HTTP transport.
102
+ * @property status - Health status string for liveness checks
103
+ * @property transport - Transport mode for the serving endpoint
104
+ * @property serverId - Optional server identifier for target verification
105
+ */
106
+ interface HttpTransportHealthResponse {
107
+ status: 'ok';
108
+ transport: 'http';
109
+ serverId?: string;
110
+ }
111
+ /**
112
+ * Admin shutdown response payload.
113
+ * @property ok - Whether shutdown request handling succeeded
114
+ * @property message - Human-readable outcome message
115
+ * @property serverId - Optional server identifier associated with this response
116
+ */
117
+ interface HttpTransportShutdownResponse {
118
+ ok: boolean;
119
+ message: string;
120
+ serverId?: string;
121
+ }
122
+ /**
123
+ * Runtime record lookup filters.
124
+ * @property host - Optional host filter for runtime discovery
125
+ * @property port - Optional port filter for runtime discovery
126
+ */
127
+ interface RuntimeLookupOptions {
128
+ host?: string;
129
+ port?: number;
130
+ }
131
+ /**
132
+ * Runtime service contract.
133
+ */
134
+ interface RuntimeStateManager {
135
+ /**
136
+ * Persist a runtime state record.
137
+ * @param record - Runtime metadata to persist
138
+ * @returns Promise that resolves when write completes
139
+ */
140
+ write(record: RuntimeStateRecord): Promise<void>;
141
+ /**
142
+ * Read a runtime state record by server ID.
143
+ * @param serverId - Target one-mcp server identifier
144
+ * @returns Matching runtime record, or null when no record exists
145
+ */
146
+ read(serverId: string): Promise<RuntimeStateRecord | null>;
147
+ /**
148
+ * List all persisted runtime records.
149
+ * @returns Array of runtime records
150
+ */
151
+ list(): Promise<RuntimeStateRecord[]>;
152
+ /**
153
+ * Remove a runtime state record by server ID.
154
+ * @param serverId - Target one-mcp server identifier
155
+ * @returns Promise that resolves when delete completes
156
+ */
157
+ remove(serverId: string): Promise<void>;
158
+ }
68
159
  /**
69
160
  * Remote MCP server configuration types
70
161
  */
@@ -332,20 +423,35 @@ interface ServerOptions {
332
423
  definitionsCachePath?: string;
333
424
  clearDefinitionsCache?: boolean;
334
425
  proxyMode?: 'meta' | 'flat' | 'search';
426
+ onServerIdResolved?: (serverId: string) => Promise<void> | void;
335
427
  }
336
428
  declare function createServer(options?: ServerOptions): Promise<Server>;
337
429
  //#endregion
338
- //#region src/transports/stdio.d.ts
430
+ //#region src/transports/http.d.ts
339
431
  /**
340
- * Stdio transport handler for MCP server
341
- * Used for command-line and direct integrations
432
+ * HTTP transport handler using Streamable HTTP (protocol version 2025-03-26)
433
+ * Provides stateful session management with resumability support
342
434
  */
343
- declare class StdioTransportHandler implements TransportHandler {
435
+ declare class HttpTransportHandler implements HttpTransportHandler$1 {
436
+ private serverFactory;
437
+ private app;
344
438
  private server;
345
- private transport;
346
- constructor(server: Server);
439
+ private sessionManager;
440
+ private config;
441
+ private adminOptions?;
442
+ private adminRateLimiter;
443
+ constructor(serverFactory: (() => Server | Promise<Server>), config: TransportConfig, adminOptions?: HttpTransportAdminOptions);
444
+ private setupMiddleware;
445
+ private setupRoutes;
446
+ private isAuthorizedShutdownRequest;
447
+ private handleAdminShutdownRequest;
448
+ private handlePostRequest;
449
+ private handleGetRequest;
450
+ private handleDeleteRequest;
347
451
  start(): Promise<void>;
348
452
  stop(): Promise<void>;
453
+ getPort(): number;
454
+ getHost(): string;
349
455
  }
350
456
  //#endregion
351
457
  //#region src/transports/sse.d.ts
@@ -371,27 +477,35 @@ declare class SseTransportHandler implements HttpTransportHandler$1 {
371
477
  getHost(): string;
372
478
  }
373
479
  //#endregion
374
- //#region src/transports/http.d.ts
480
+ //#region src/transports/stdio.d.ts
375
481
  /**
376
- * HTTP transport handler using Streamable HTTP (protocol version 2025-03-26)
377
- * Provides stateful session management with resumability support
482
+ * Stdio transport handler for MCP server
483
+ * Used for command-line and direct integrations
378
484
  */
379
- declare class HttpTransportHandler implements HttpTransportHandler$1 {
380
- private serverFactory;
381
- private app;
485
+ declare class StdioTransportHandler implements TransportHandler {
382
486
  private server;
383
- private sessionManager;
384
- private config;
385
- constructor(serverFactory: Server | (() => Server), config: TransportConfig);
386
- private setupMiddleware;
387
- private setupRoutes;
388
- private handlePostRequest;
389
- private handleGetRequest;
390
- private handleDeleteRequest;
487
+ private transport;
488
+ constructor(server: Server);
391
489
  start(): Promise<void>;
392
490
  stop(): Promise<void>;
393
- getPort(): number;
394
- getHost(): string;
491
+ }
492
+ //#endregion
493
+ //#region src/transports/stdio-http.d.ts
494
+ interface StdioHttpProxyTransportConfig {
495
+ endpoint: URL;
496
+ }
497
+ /**
498
+ * Transport that serves MCP over stdio and forwards MCP requests to an HTTP endpoint.
499
+ */
500
+ declare class StdioHttpTransportHandler implements TransportHandler {
501
+ private readonly endpoint;
502
+ private stdioProxyServer;
503
+ private stdioTransport;
504
+ private httpClient;
505
+ constructor(config: StdioHttpProxyTransportConfig);
506
+ start(): Promise<void>;
507
+ stop(): Promise<void>;
508
+ private createProxyServer;
395
509
  }
396
510
  //#endregion
397
511
  //#region src/services/McpClientManagerService.d.ts
@@ -926,4 +1040,201 @@ declare class ConfigFetcherService {
926
1040
  isCacheValid(): boolean;
927
1041
  }
928
1042
  //#endregion
929
- export { CachedFileSkillInfo, CachedPromptSkillInfo, CachedServerDefinition, ConfigFetcherService, DefinitionsCacheFile, DefinitionsCacheService, DescribeToolsTool, HttpTransportHandler, McpClientConnection, McpClientManagerService, McpHttpConfig, McpPromptInfo, McpResourceInfo, McpServerConfig, McpServerTransportConfig, McpServerTransportType, McpSseConfig, McpStdioConfig, McpToolInfo, PromptConfig, PromptSkillConfig, RemoteMcpConfiguration, SearchListToolsTool, type ServerOptions, Skill, SkillMetadata, SkillService, SkillsConfig, SseTransportHandler, StdioTransportHandler, TRANSPORT_MODE, Tool, ToolDefinition, TransportConfig, TransportHandler, TransportMode, UseToolTool, createServer };
1043
+ //#region src/services/RuntimeStateService.d.ts
1044
+ /**
1045
+ * Runtime state persistence implementation.
1046
+ */
1047
+ declare class RuntimeStateService implements RuntimeStateManager {
1048
+ private runtimeDir;
1049
+ constructor(runtimeDir?: string);
1050
+ /**
1051
+ * Resolve default runtime directory under the user's home cache path.
1052
+ * @returns Absolute runtime directory path
1053
+ */
1054
+ static getDefaultRuntimeDir(): string;
1055
+ /**
1056
+ * Build runtime state file path for a given server ID.
1057
+ * @param serverId - Target one-mcp server identifier
1058
+ * @returns Absolute runtime file path
1059
+ */
1060
+ private getRecordPath;
1061
+ /**
1062
+ * Persist a runtime state record.
1063
+ * @param record - Runtime metadata to persist
1064
+ * @returns Promise that resolves when write completes
1065
+ */
1066
+ write(record: RuntimeStateRecord): Promise<void>;
1067
+ /**
1068
+ * Read a runtime state record by server ID.
1069
+ * @param serverId - Target one-mcp server identifier
1070
+ * @returns Matching runtime record, or null when no record exists
1071
+ */
1072
+ read(serverId: string): Promise<RuntimeStateRecord | null>;
1073
+ /**
1074
+ * List all persisted runtime records.
1075
+ * @returns Array of runtime records
1076
+ */
1077
+ list(): Promise<RuntimeStateRecord[]>;
1078
+ /**
1079
+ * Remove a runtime state record by server ID.
1080
+ * @param serverId - Target one-mcp server identifier
1081
+ * @returns Promise that resolves when delete completes
1082
+ */
1083
+ remove(serverId: string): Promise<void>;
1084
+ }
1085
+ //#endregion
1086
+ //#region src/services/StopServerService/types.d.ts
1087
+ /**
1088
+ * Stop request options.
1089
+ * @property serverId - Explicit one-mcp server identifier to stop
1090
+ * @property host - Host fallback for runtime lookup
1091
+ * @property port - Port fallback for runtime lookup
1092
+ * @property token - Optional shutdown token override
1093
+ * @property force - Skip server ID verification against /health when true
1094
+ * @property timeoutMs - Maximum time to wait for shutdown completion
1095
+ */
1096
+ interface StopServerRequest {
1097
+ serverId?: string;
1098
+ host?: string;
1099
+ port?: number;
1100
+ token?: string;
1101
+ force?: boolean;
1102
+ timeoutMs?: number;
1103
+ }
1104
+ /**
1105
+ * Stop command result payload.
1106
+ * @property ok - Whether the shutdown completed successfully
1107
+ * @property serverId - Stopped one-mcp server identifier
1108
+ * @property host - Host that served the runtime
1109
+ * @property port - Port that served the runtime
1110
+ * @property message - Human-readable shutdown result message
1111
+ */
1112
+ interface StopServerResult {
1113
+ ok: true;
1114
+ serverId: string;
1115
+ host: string;
1116
+ port: number;
1117
+ message: string;
1118
+ }
1119
+ //#endregion
1120
+ //#region src/services/StopServerService/StopServerService.d.ts
1121
+ /**
1122
+ * Service for resolving runtime targets and stopping them safely.
1123
+ */
1124
+ declare class StopServerService {
1125
+ private runtimeStateService;
1126
+ constructor(runtimeStateService?: RuntimeStateManager);
1127
+ /**
1128
+ * Resolve a target runtime and stop it cooperatively.
1129
+ * @param request - Stop request options
1130
+ * @returns Stop result payload
1131
+ */
1132
+ stop(request: StopServerRequest): Promise<StopServerResult>;
1133
+ /**
1134
+ * Resolve a runtime record from explicit ID or a unique host/port pair.
1135
+ * @param request - Stop request options
1136
+ * @returns Matching runtime record
1137
+ */
1138
+ private resolveRuntime;
1139
+ /**
1140
+ * Read the runtime health payload.
1141
+ * @param runtime - Runtime to query
1142
+ * @param timeoutMs - Request timeout in milliseconds
1143
+ * @returns Reachability status and optional payload
1144
+ */
1145
+ private fetchHealth;
1146
+ /**
1147
+ * Send authenticated shutdown request to the admin endpoint.
1148
+ * @param runtime - Runtime to stop
1149
+ * @param shutdownToken - Bearer token for the admin endpoint
1150
+ * @param timeoutMs - Request timeout in milliseconds
1151
+ * @returns Parsed shutdown response payload
1152
+ */
1153
+ private requestShutdown;
1154
+ /**
1155
+ * Poll until the target runtime is no longer reachable.
1156
+ * @param runtime - Runtime expected to stop
1157
+ * @param timeoutMs - Maximum wait time in milliseconds
1158
+ * @returns Promise that resolves when shutdown is observed
1159
+ */
1160
+ private waitForShutdown;
1161
+ /**
1162
+ * Perform a fetch with an abort timeout.
1163
+ * @param url - Target URL
1164
+ * @param init - Fetch options
1165
+ * @param timeoutMs - Timeout in milliseconds
1166
+ * @returns Fetch response
1167
+ */
1168
+ private fetchWithTimeout;
1169
+ }
1170
+ //#endregion
1171
+ //#region src/utils/findConfigFile.d.ts
1172
+ /**
1173
+ * Config File Finder Utility
1174
+ *
1175
+ * DESIGN PATTERNS:
1176
+ * - Utility function pattern for reusable logic
1177
+ * - Fail-fast pattern with early returns
1178
+ * - Environment variable configuration pattern
1179
+ *
1180
+ * CODING STANDARDS:
1181
+ * - Use sync filesystem operations for config discovery (performance)
1182
+ * - Check PROJECT_PATH environment variable first
1183
+ * - Fall back to current working directory
1184
+ * - Support both .yaml and .json extensions
1185
+ * - Return null if no config file is found
1186
+ *
1187
+ * AVOID:
1188
+ * - Throwing errors (return null instead for optional config)
1189
+ * - Hardcoded file names without extension variants
1190
+ * - Ignoring environment variables
1191
+ */
1192
+ /**
1193
+ * Find MCP configuration file by checking PROJECT_PATH first, then cwd
1194
+ * Looks for both mcp-config.yaml and mcp-config.json
1195
+ *
1196
+ * @returns Absolute path to config file, or null if not found
1197
+ */
1198
+ declare function findConfigFile(): string | null;
1199
+ //#endregion
1200
+ //#region src/utils/generateServerId.d.ts
1201
+ /**
1202
+ * generateServerId Utilities
1203
+ *
1204
+ * DESIGN PATTERNS:
1205
+ * - Pure functions with no side effects
1206
+ * - Single responsibility per function
1207
+ * - Functional programming approach
1208
+ *
1209
+ * CODING STANDARDS:
1210
+ * - Export individual functions, not classes
1211
+ * - Use descriptive function names with verbs
1212
+ * - Add JSDoc comments for complex logic
1213
+ * - Keep functions small and focused
1214
+ *
1215
+ * AVOID:
1216
+ * - Side effects (mutating external state)
1217
+ * - Stateful logic (use services for state)
1218
+ * - Complex external dependencies
1219
+ */
1220
+ /**
1221
+ * Generate a short, human-readable server ID.
1222
+ *
1223
+ * Uses Node.js crypto.randomBytes for cryptographically secure randomness
1224
+ * with rejection sampling to avoid modulo bias.
1225
+ *
1226
+ * The generated ID:
1227
+ * - Is 6 characters long by default
1228
+ * - Uses only lowercase alphanumeric characters
1229
+ * - Excludes confusing characters (0, O, 1, l, I)
1230
+ *
1231
+ * @param length - Length of the ID to generate (default: 6)
1232
+ * @returns A random, human-readable ID
1233
+ *
1234
+ * @example
1235
+ * generateServerId() // "abc234"
1236
+ * generateServerId(4) // "x7mn"
1237
+ */
1238
+ declare function generateServerId(length?: number): string;
1239
+ //#endregion
1240
+ export { CachedFileSkillInfo, CachedPromptSkillInfo, CachedServerDefinition, ConfigFetcherService, DefinitionsCacheFile, DefinitionsCacheService, DescribeToolsTool, HttpTransportAdminOptions, HttpTransportHandler, HttpTransportHealthResponse, HttpTransportShutdownResponse, McpClientConnection, McpClientManagerService, McpHttpConfig, McpPromptInfo, McpResourceInfo, McpServerConfig, McpServerTransportConfig, McpServerTransportType, McpSseConfig, McpStdioConfig, McpToolInfo, PromptConfig, PromptSkillConfig, RemoteMcpConfiguration, RuntimeLookupOptions, RuntimeStateManager, RuntimeStateRecord, RuntimeStateService, SearchListToolsTool, type ServerOptions, Skill, SkillMetadata, SkillService, SkillsConfig, SseTransportHandler, StdioHttpTransportHandler, StdioTransportHandler, type StopServerRequest, type StopServerResult, StopServerService, TRANSPORT_MODE, Tool, ToolDefinition, TransportConfig, TransportHandler, TransportMode, UseToolTool, createServer, findConfigFile, generateServerId };