@agimon-ai/mcp-proxy 0.4.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/LICENSE +52 -0
- package/README.md +530 -0
- package/dist/cli.cjs +1513 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +1514 -0
- package/dist/index.cjs +27 -0
- package/dist/index.d.cts +1350 -0
- package/dist/index.d.mts +1351 -0
- package/dist/index.mjs +3 -0
- package/dist/src-6KF7hZTe.cjs +4975 -0
- package/dist/src-DQ_MagA0.mjs +4779 -0
- package/package.json +61 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,1350 @@
|
|
|
1
|
+
import * as _modelcontextprotocol_sdk_server_index_js0 from "@modelcontextprotocol/sdk/server/index.js";
|
|
2
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
|
+
import { CallToolResult, GetPromptResult, ReadResourceResult } from "@modelcontextprotocol/sdk/types.js";
|
|
4
|
+
import { NodeTelemetryHandle } from "@agimon-ai/log-sink-mcp";
|
|
5
|
+
|
|
6
|
+
//#region src/types/index.d.ts
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Tool definition for MCP
|
|
10
|
+
* @property name - The unique name of the tool
|
|
11
|
+
* @property description - Human-readable description of what the tool does
|
|
12
|
+
* @property inputSchema - JSON Schema defining the tool's input parameters
|
|
13
|
+
*/
|
|
14
|
+
interface ToolDefinition {
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
inputSchema: {
|
|
18
|
+
type: string;
|
|
19
|
+
properties: Record<string, unknown>;
|
|
20
|
+
required?: string[];
|
|
21
|
+
additionalProperties?: boolean;
|
|
22
|
+
};
|
|
23
|
+
_meta?: Record<string, unknown>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Base tool interface following MCP SDK patterns
|
|
27
|
+
* @template TInput - The type of input the tool accepts
|
|
28
|
+
*/
|
|
29
|
+
interface Tool<TInput = unknown> {
|
|
30
|
+
getDefinition(): ToolDefinition | Promise<ToolDefinition>;
|
|
31
|
+
execute(input: TInput): Promise<CallToolResult>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Transport mode constants
|
|
35
|
+
*/
|
|
36
|
+
declare const TRANSPORT_MODE: {
|
|
37
|
+
readonly STDIO: "stdio";
|
|
38
|
+
readonly HTTP: "http";
|
|
39
|
+
readonly SSE: "sse";
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Transport mode type derived from TRANSPORT_MODE constants
|
|
43
|
+
*/
|
|
44
|
+
type TransportMode = (typeof TRANSPORT_MODE)[keyof typeof TRANSPORT_MODE];
|
|
45
|
+
/**
|
|
46
|
+
* Transport configuration options
|
|
47
|
+
* @property mode - The transport mode to use (stdio, http, or sse)
|
|
48
|
+
* @property port - Port number for HTTP/SSE modes (not used for STDIO)
|
|
49
|
+
* @property host - Host address for HTTP/SSE modes (not used for STDIO)
|
|
50
|
+
*/
|
|
51
|
+
interface TransportConfig {
|
|
52
|
+
mode: TransportMode;
|
|
53
|
+
port?: number;
|
|
54
|
+
host?: string;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Base interface for all transport handlers
|
|
58
|
+
*/
|
|
59
|
+
interface TransportHandler {
|
|
60
|
+
start(): Promise<void>;
|
|
61
|
+
stop(): Promise<void>;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* HTTP transport specific types
|
|
65
|
+
*/
|
|
66
|
+
interface HttpTransportHandler$1 extends TransportHandler {
|
|
67
|
+
getPort(): number;
|
|
68
|
+
getHost(): string;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Runtime state persisted for HTTP mcp-proxy instances.
|
|
72
|
+
* @property serverId - Unique mcp-proxy server identifier
|
|
73
|
+
* @property host - Host bound by the HTTP transport
|
|
74
|
+
* @property port - Port bound by the HTTP transport
|
|
75
|
+
* @property transport - Transport mode for the runtime record
|
|
76
|
+
* @property shutdownToken - Secret token required for admin shutdown requests
|
|
77
|
+
* @property startedAt - ISO timestamp when the runtime started
|
|
78
|
+
* @property pid - Process ID of the running mcp-proxy process
|
|
79
|
+
* @property configPath - Optional path to the config file used to start the server
|
|
80
|
+
*/
|
|
81
|
+
interface RuntimeStateRecord {
|
|
82
|
+
serverId: string;
|
|
83
|
+
host: string;
|
|
84
|
+
port: number;
|
|
85
|
+
transport: 'http';
|
|
86
|
+
shutdownToken: string;
|
|
87
|
+
startedAt: string;
|
|
88
|
+
pid: number;
|
|
89
|
+
configPath?: string;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Optional admin settings for HTTP transport lifecycle actions.
|
|
93
|
+
* @property serverId - Server identifier surfaced via health responses
|
|
94
|
+
* @property shutdownToken - Secret token accepted by the admin shutdown endpoint
|
|
95
|
+
* @property onShutdownRequested - Callback invoked after a valid shutdown request is received
|
|
96
|
+
*/
|
|
97
|
+
interface HttpTransportAdminOptions {
|
|
98
|
+
serverId?: string;
|
|
99
|
+
shutdownToken?: string;
|
|
100
|
+
onShutdownRequested?: () => Promise<void>;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Health payload exposed by HTTP transport.
|
|
104
|
+
* @property status - Health status string for liveness checks
|
|
105
|
+
* @property transport - Transport mode for the serving endpoint
|
|
106
|
+
* @property serverId - Optional server identifier for target verification
|
|
107
|
+
*/
|
|
108
|
+
interface HttpTransportHealthResponse {
|
|
109
|
+
status: 'ok';
|
|
110
|
+
transport: 'http';
|
|
111
|
+
serverId?: string;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Admin shutdown response payload.
|
|
115
|
+
* @property ok - Whether shutdown request handling succeeded
|
|
116
|
+
* @property message - Human-readable outcome message
|
|
117
|
+
* @property serverId - Optional server identifier associated with this response
|
|
118
|
+
*/
|
|
119
|
+
interface HttpTransportShutdownResponse {
|
|
120
|
+
ok: boolean;
|
|
121
|
+
message: string;
|
|
122
|
+
serverId?: string;
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Runtime record lookup filters.
|
|
126
|
+
* @property host - Optional host filter for runtime discovery
|
|
127
|
+
* @property port - Optional port filter for runtime discovery
|
|
128
|
+
*/
|
|
129
|
+
interface RuntimeLookupOptions {
|
|
130
|
+
host?: string;
|
|
131
|
+
port?: number;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Runtime service contract.
|
|
135
|
+
*/
|
|
136
|
+
interface RuntimeStateManager {
|
|
137
|
+
/**
|
|
138
|
+
* Persist a runtime state record.
|
|
139
|
+
* @param record - Runtime metadata to persist
|
|
140
|
+
* @returns Promise that resolves when write completes
|
|
141
|
+
*/
|
|
142
|
+
write(record: RuntimeStateRecord): Promise<void>;
|
|
143
|
+
/**
|
|
144
|
+
* Read a runtime state record by server ID.
|
|
145
|
+
* @param serverId - Target mcp-proxy server identifier
|
|
146
|
+
* @returns Matching runtime record, or null when no record exists
|
|
147
|
+
*/
|
|
148
|
+
read(serverId: string): Promise<RuntimeStateRecord | null>;
|
|
149
|
+
/**
|
|
150
|
+
* List all persisted runtime records.
|
|
151
|
+
* @returns Array of runtime records
|
|
152
|
+
*/
|
|
153
|
+
list(): Promise<RuntimeStateRecord[]>;
|
|
154
|
+
/**
|
|
155
|
+
* Remove a runtime state record by server ID.
|
|
156
|
+
* @param serverId - Target mcp-proxy server identifier
|
|
157
|
+
* @returns Promise that resolves when delete completes
|
|
158
|
+
*/
|
|
159
|
+
remove(serverId: string): Promise<void>;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Remote MCP server configuration types
|
|
163
|
+
*/
|
|
164
|
+
type McpServerTransportType = 'stdio' | 'http' | 'sse';
|
|
165
|
+
/**
|
|
166
|
+
* Configuration for stdio-based MCP server connections
|
|
167
|
+
* @property command - The command to execute to start the server
|
|
168
|
+
* @property args - Optional arguments to pass to the command
|
|
169
|
+
* @property env - Optional environment variables for the subprocess
|
|
170
|
+
*/
|
|
171
|
+
interface McpStdioConfig {
|
|
172
|
+
command: string;
|
|
173
|
+
args?: string[];
|
|
174
|
+
env?: Record<string, string>;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Configuration for HTTP-based MCP server connections
|
|
178
|
+
* @property url - The URL of the HTTP endpoint
|
|
179
|
+
* @property headers - Optional HTTP headers to include in requests
|
|
180
|
+
*/
|
|
181
|
+
interface McpHttpConfig {
|
|
182
|
+
url: string;
|
|
183
|
+
headers?: Record<string, string>;
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Configuration for SSE-based MCP server connections
|
|
187
|
+
* @property url - The URL of the SSE endpoint
|
|
188
|
+
* @property headers - Optional HTTP headers to include in requests
|
|
189
|
+
*/
|
|
190
|
+
interface McpSseConfig {
|
|
191
|
+
url: string;
|
|
192
|
+
headers?: Record<string, string>;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Union type for MCP server transport configurations
|
|
196
|
+
* - McpStdioConfig: Used for local subprocess communication via stdio (has 'command' property)
|
|
197
|
+
* - McpHttpConfig: Used for HTTP-based remote connections (has 'url' property)
|
|
198
|
+
* - McpSseConfig: Used for Server-Sent Events streaming connections (has 'url' property)
|
|
199
|
+
*
|
|
200
|
+
* Note: McpHttpConfig and McpSseConfig have identical structure. Discrimination between
|
|
201
|
+
* them should be done using the transport type field in McpServerConfig, not by
|
|
202
|
+
* structural inspection of the config object.
|
|
203
|
+
*/
|
|
204
|
+
type McpServerTransportConfig = McpStdioConfig | McpHttpConfig | McpSseConfig;
|
|
205
|
+
/**
|
|
206
|
+
* Configuration for an MCP server connection
|
|
207
|
+
* @property name - Unique identifier for the server
|
|
208
|
+
* @property instruction - Optional instruction text describing the server's purpose
|
|
209
|
+
* @property toolBlacklist - Optional list of tool names to exclude from this server
|
|
210
|
+
* @property omitToolDescription - Whether to omit tool descriptions in listings
|
|
211
|
+
* @property prompts - Optional prompts configuration for skill conversion
|
|
212
|
+
* @property transport - The transport type (stdio, http, or sse)
|
|
213
|
+
* @property config - Transport-specific configuration options
|
|
214
|
+
* @property timeout - Optional connection timeout in milliseconds (default: 30000)
|
|
215
|
+
* @property disabled - Whether this server is disabled and should not be started
|
|
216
|
+
*/
|
|
217
|
+
interface McpServerConfig {
|
|
218
|
+
name: string;
|
|
219
|
+
instruction?: string;
|
|
220
|
+
toolBlacklist?: string[];
|
|
221
|
+
omitToolDescription?: boolean;
|
|
222
|
+
prompts?: Record<string, PromptConfig>;
|
|
223
|
+
transport: McpServerTransportType;
|
|
224
|
+
config: McpServerTransportConfig;
|
|
225
|
+
timeout?: number;
|
|
226
|
+
/** Optional per-request timeout in milliseconds for tool calls (default: 60000 from MCP SDK) */
|
|
227
|
+
requestTimeout?: number;
|
|
228
|
+
disabled?: boolean;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Skills configuration
|
|
232
|
+
* @property paths - Array of paths to skills directories
|
|
233
|
+
*/
|
|
234
|
+
interface SkillsConfig {
|
|
235
|
+
paths: string[];
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Prompt skill configuration for converting prompts to executable skills
|
|
239
|
+
* @property name - Skill name identifier
|
|
240
|
+
* @property description - Skill description shown in describe_tools
|
|
241
|
+
* @property folder - Optional folder path for skill resources
|
|
242
|
+
*/
|
|
243
|
+
interface PromptSkillConfig {
|
|
244
|
+
name: string;
|
|
245
|
+
description: string;
|
|
246
|
+
folder?: string;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Prompt configuration that can be converted to a skill
|
|
250
|
+
* @property skill - Optional skill conversion configuration
|
|
251
|
+
*/
|
|
252
|
+
interface PromptConfig {
|
|
253
|
+
skill?: PromptSkillConfig;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Remote configuration response containing MCP server definitions
|
|
257
|
+
* @property id - Optional unique server identifier
|
|
258
|
+
* @property mcpServers - Map of server names to their configurations
|
|
259
|
+
* @property skills - Optional skills configuration with paths
|
|
260
|
+
*/
|
|
261
|
+
interface RemoteMcpConfiguration {
|
|
262
|
+
id?: string;
|
|
263
|
+
mcpServers: Record<string, McpServerConfig>;
|
|
264
|
+
skills?: SkillsConfig;
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* MCP tool information returned from listTools
|
|
268
|
+
* @property name - The tool name
|
|
269
|
+
* @property description - Human-readable description
|
|
270
|
+
* @property inputSchema - JSON Schema for tool inputs
|
|
271
|
+
*/
|
|
272
|
+
interface McpToolInfo {
|
|
273
|
+
name: string;
|
|
274
|
+
description?: string;
|
|
275
|
+
inputSchema: Record<string, unknown>;
|
|
276
|
+
_meta?: Record<string, unknown>;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* MCP resource information returned from listResources
|
|
280
|
+
* @property uri - Resource URI
|
|
281
|
+
* @property name - Display name
|
|
282
|
+
* @property description - Human-readable description
|
|
283
|
+
* @property mimeType - Optional MIME type
|
|
284
|
+
*/
|
|
285
|
+
interface McpResourceInfo {
|
|
286
|
+
uri: string;
|
|
287
|
+
name?: string;
|
|
288
|
+
description?: string;
|
|
289
|
+
mimeType?: string;
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* MCP prompt information returned from listPrompts
|
|
293
|
+
* @property name - Prompt name
|
|
294
|
+
* @property description - Human-readable description
|
|
295
|
+
* @property arguments - Optional argument definitions
|
|
296
|
+
*/
|
|
297
|
+
interface McpPromptInfo {
|
|
298
|
+
name: string;
|
|
299
|
+
description?: string;
|
|
300
|
+
arguments?: Array<{
|
|
301
|
+
name: string;
|
|
302
|
+
description?: string;
|
|
303
|
+
required?: boolean;
|
|
304
|
+
}>;
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* MCP client connection interface for communicating with remote MCP servers
|
|
308
|
+
* @property serverName - The name identifier for this server connection
|
|
309
|
+
* @property serverInstruction - Optional instruction text for the server
|
|
310
|
+
* @property toolBlacklist - Optional list of tool names to exclude
|
|
311
|
+
* @property omitToolDescription - Whether to omit tool descriptions
|
|
312
|
+
* @property prompts - Optional prompts configuration for skill conversion
|
|
313
|
+
* @property transport - The transport type used for this connection
|
|
314
|
+
*/
|
|
315
|
+
interface McpClientConnection {
|
|
316
|
+
serverName: string;
|
|
317
|
+
serverInstruction?: string;
|
|
318
|
+
toolBlacklist?: string[];
|
|
319
|
+
omitToolDescription?: boolean;
|
|
320
|
+
prompts?: Record<string, PromptConfig>;
|
|
321
|
+
transport: McpServerTransportType;
|
|
322
|
+
/** List available tools from the server */
|
|
323
|
+
listTools(): Promise<McpToolInfo[]>;
|
|
324
|
+
/** List available resources from the server */
|
|
325
|
+
listResources(): Promise<McpResourceInfo[]>;
|
|
326
|
+
/** List available prompts from the server */
|
|
327
|
+
listPrompts(): Promise<McpPromptInfo[]>;
|
|
328
|
+
/** Call a tool with the given name and arguments */
|
|
329
|
+
callTool(name: string, args: Record<string, unknown>, options?: {
|
|
330
|
+
timeout?: number;
|
|
331
|
+
}): Promise<CallToolResult>;
|
|
332
|
+
/** Read a resource by URI */
|
|
333
|
+
readResource(uri: string): Promise<ReadResourceResult>;
|
|
334
|
+
/** Get a prompt by name with optional arguments */
|
|
335
|
+
getPrompt(name: string, args?: Record<string, unknown>): Promise<GetPromptResult>;
|
|
336
|
+
/** Close the connection */
|
|
337
|
+
close(): Promise<void>;
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Cached prompt-based skill metadata.
|
|
341
|
+
* Used to avoid re-fetching prompt front matter during startup discovery.
|
|
342
|
+
*/
|
|
343
|
+
interface CachedPromptSkillInfo {
|
|
344
|
+
promptName: string;
|
|
345
|
+
skill: PromptSkillConfig;
|
|
346
|
+
autoDetected?: boolean;
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Cached server metadata used for startup-time capability discovery.
|
|
350
|
+
*/
|
|
351
|
+
interface CachedServerDefinition {
|
|
352
|
+
serverName: string;
|
|
353
|
+
serverInstruction?: string;
|
|
354
|
+
omitToolDescription?: boolean;
|
|
355
|
+
toolBlacklist?: string[];
|
|
356
|
+
tools: McpToolInfo[];
|
|
357
|
+
resources: McpResourceInfo[];
|
|
358
|
+
prompts: McpPromptInfo[];
|
|
359
|
+
promptSkills: CachedPromptSkillInfo[];
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Cached file-based skill metadata.
|
|
363
|
+
*/
|
|
364
|
+
interface CachedFileSkillInfo {
|
|
365
|
+
name: string;
|
|
366
|
+
description: string;
|
|
367
|
+
location: 'project' | 'user';
|
|
368
|
+
basePath: string;
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Cache file storing precomputed definitions for mcp-proxy startup.
|
|
372
|
+
*/
|
|
373
|
+
interface DefinitionsCacheFile {
|
|
374
|
+
version: 1;
|
|
375
|
+
oneMcpVersion?: string;
|
|
376
|
+
generatedAt: string;
|
|
377
|
+
configPath?: string;
|
|
378
|
+
configHash?: string;
|
|
379
|
+
serverId?: string;
|
|
380
|
+
servers: Record<string, CachedServerDefinition>;
|
|
381
|
+
skills: CachedFileSkillInfo[];
|
|
382
|
+
failures: Array<{
|
|
383
|
+
serverName: string;
|
|
384
|
+
error: string;
|
|
385
|
+
}>;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Skill metadata from YAML frontmatter in SKILL.md files
|
|
389
|
+
* @property name - Skill identifier used with skill__ prefix
|
|
390
|
+
* @property description - Short description shown in describe_tools
|
|
391
|
+
* @property license - Optional license information
|
|
392
|
+
*/
|
|
393
|
+
interface SkillMetadata {
|
|
394
|
+
name: string;
|
|
395
|
+
description: string;
|
|
396
|
+
license?: string;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Skill definition loaded from skill files
|
|
400
|
+
* @property name - Skill identifier used with skill__ prefix
|
|
401
|
+
* @property description - Short description shown in describe_tools
|
|
402
|
+
* @property location - Where the skill was loaded from ('project' or 'user')
|
|
403
|
+
* @property content - The markdown content of the skill (without frontmatter)
|
|
404
|
+
* @property basePath - The directory path where the skill is located
|
|
405
|
+
*/
|
|
406
|
+
interface Skill {
|
|
407
|
+
name: string;
|
|
408
|
+
description: string;
|
|
409
|
+
location: 'project' | 'user';
|
|
410
|
+
content: string;
|
|
411
|
+
basePath: string;
|
|
412
|
+
}
|
|
413
|
+
//#endregion
|
|
414
|
+
//#region src/services/logger.d.ts
|
|
415
|
+
interface LoggerLike {
|
|
416
|
+
trace(message: string, data?: unknown): void;
|
|
417
|
+
debug(message: string, data?: unknown): void;
|
|
418
|
+
info(message: string, data?: unknown): void;
|
|
419
|
+
warn(message: string, data?: unknown): void;
|
|
420
|
+
error(message: string, data?: unknown): void;
|
|
421
|
+
getTraceContext?(): {
|
|
422
|
+
traceId?: string;
|
|
423
|
+
spanId?: string;
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
interface ProxyLoggerHandle extends LoggerLike {
|
|
427
|
+
backend: NodeTelemetryHandle['backend'];
|
|
428
|
+
enabled: boolean;
|
|
429
|
+
endpoint?: string;
|
|
430
|
+
filePath?: string;
|
|
431
|
+
flush(): Promise<void>;
|
|
432
|
+
shutdown(): Promise<void>;
|
|
433
|
+
}
|
|
434
|
+
interface ProxyLoggerOptions {
|
|
435
|
+
env?: NodeJS.ProcessEnv;
|
|
436
|
+
workspaceRoot?: string;
|
|
437
|
+
serviceName?: string;
|
|
438
|
+
serviceVersion?: string;
|
|
439
|
+
logDir?: string;
|
|
440
|
+
logFileName?: string;
|
|
441
|
+
maxFileSizeBytes?: number;
|
|
442
|
+
maxFileCount?: number;
|
|
443
|
+
}
|
|
444
|
+
declare function createProxyLogger(options?: ProxyLoggerOptions): Promise<ProxyLoggerHandle>;
|
|
445
|
+
//#endregion
|
|
446
|
+
//#region src/services/ConfigFetcherService.d.ts
|
|
447
|
+
interface ConfigFetcherOptions {
|
|
448
|
+
configFilePath?: string;
|
|
449
|
+
cacheTtlMs?: number;
|
|
450
|
+
useCache?: boolean;
|
|
451
|
+
remoteCacheTtlMs?: number;
|
|
452
|
+
}
|
|
453
|
+
/**
|
|
454
|
+
* Service for fetching and caching MCP server configurations from local file and remote sources
|
|
455
|
+
* Supports merging multiple remote configs with local config
|
|
456
|
+
*/
|
|
457
|
+
declare class ConfigFetcherService {
|
|
458
|
+
private configFilePath?;
|
|
459
|
+
private cacheTtlMs;
|
|
460
|
+
private cachedConfig;
|
|
461
|
+
private lastFetchTime;
|
|
462
|
+
private remoteConfigCache;
|
|
463
|
+
private logger;
|
|
464
|
+
constructor(options: ConfigFetcherOptions, logger?: LoggerLike);
|
|
465
|
+
/**
|
|
466
|
+
* Fetch MCP configuration from local file and remote sources with caching
|
|
467
|
+
* Merges remote configs with local config based on merge strategy
|
|
468
|
+
* @param forceRefresh - Force reload from source, bypassing cache
|
|
469
|
+
*/
|
|
470
|
+
fetchConfiguration(forceRefresh?: boolean): Promise<RemoteMcpConfiguration>;
|
|
471
|
+
/**
|
|
472
|
+
* Load raw configuration data from a local file (supports JSON and YAML)
|
|
473
|
+
* Returns unparsed config data to allow access to remoteConfigs
|
|
474
|
+
*/
|
|
475
|
+
private loadRawConfigFromFile;
|
|
476
|
+
/**
|
|
477
|
+
* Parse raw config data using Zod schema
|
|
478
|
+
* Filters out remoteConfigs to avoid including them in the final config
|
|
479
|
+
*/
|
|
480
|
+
private parseConfig;
|
|
481
|
+
/**
|
|
482
|
+
* Load configuration from a remote URL with caching
|
|
483
|
+
*
|
|
484
|
+
* SECURITY NOTE: This method fetches remote configs based on URLs from the local config file.
|
|
485
|
+
* This is intentional and safe because:
|
|
486
|
+
* 1. URLs are user-controlled via their local config file (not external input)
|
|
487
|
+
* 2. SSRF protection validates URLs before fetching (blocks private IPs, enforces HTTPS)
|
|
488
|
+
* 3. Users explicitly opt-in to remote configs in their local configuration
|
|
489
|
+
* 4. This enables centralized config management (intended feature, not a vulnerability)
|
|
490
|
+
*
|
|
491
|
+
* CodeQL alert "file-access-to-http" is a false positive here - we're not leaking
|
|
492
|
+
* file contents to arbitrary URLs, we're fetching configs from user-specified sources.
|
|
493
|
+
*/
|
|
494
|
+
private loadFromUrl;
|
|
495
|
+
/**
|
|
496
|
+
* Interpolate environment variables in a string
|
|
497
|
+
* Supports ${VAR_NAME} syntax
|
|
498
|
+
*/
|
|
499
|
+
private interpolateEnvVars;
|
|
500
|
+
/**
|
|
501
|
+
* Merge two MCP configurations based on the specified merge strategy
|
|
502
|
+
* @param localConfig Configuration loaded from local file
|
|
503
|
+
* @param remoteConfig Configuration loaded from remote URL
|
|
504
|
+
* @param mergeStrategy Strategy for merging configs
|
|
505
|
+
* @returns Merged configuration
|
|
506
|
+
*/
|
|
507
|
+
private mergeConfigurations;
|
|
508
|
+
/**
|
|
509
|
+
* Clear the cached configuration
|
|
510
|
+
*/
|
|
511
|
+
clearCache(): void;
|
|
512
|
+
/**
|
|
513
|
+
* Check if cache is valid
|
|
514
|
+
*/
|
|
515
|
+
isCacheValid(): boolean;
|
|
516
|
+
}
|
|
517
|
+
//#endregion
|
|
518
|
+
//#region src/services/SkillService.d.ts
|
|
519
|
+
/**
|
|
520
|
+
* Service for loading and managing skills from configured skill directories.
|
|
521
|
+
*
|
|
522
|
+
* Skills are markdown files with YAML frontmatter that can be invoked via
|
|
523
|
+
* the skill__ prefix in describe_tools and use_tool.
|
|
524
|
+
*
|
|
525
|
+
* Skills are only enabled when explicitly configured via the `skills.paths` array
|
|
526
|
+
* in the MCP config.
|
|
527
|
+
*
|
|
528
|
+
* @example
|
|
529
|
+
* // Config with skills enabled:
|
|
530
|
+
* // skills:
|
|
531
|
+
* // paths:
|
|
532
|
+
* // - ".claude/skills"
|
|
533
|
+
* // - "/absolute/path/to/skills"
|
|
534
|
+
*
|
|
535
|
+
* const skillService = new SkillService('/project/root', ['.claude/skills']);
|
|
536
|
+
* const skills = await skillService.getSkills();
|
|
537
|
+
*/
|
|
538
|
+
declare class SkillService {
|
|
539
|
+
private cwd;
|
|
540
|
+
private skillPaths;
|
|
541
|
+
private cachedSkills;
|
|
542
|
+
private skillsByName;
|
|
543
|
+
/** Active file watchers for skill directories */
|
|
544
|
+
private watchers;
|
|
545
|
+
/** Polling timers used when native file watching is unavailable */
|
|
546
|
+
private pollingTimers;
|
|
547
|
+
/** Callback invoked when cache is invalidated due to file changes */
|
|
548
|
+
private onCacheInvalidated?;
|
|
549
|
+
private logger;
|
|
550
|
+
/**
|
|
551
|
+
* Creates a new SkillService instance
|
|
552
|
+
* @param cwd - Current working directory for resolving relative paths
|
|
553
|
+
* @param skillPaths - Array of paths to skills directories
|
|
554
|
+
* @param options - Optional configuration
|
|
555
|
+
* @param options.onCacheInvalidated - Callback invoked when cache is invalidated due to file changes
|
|
556
|
+
*/
|
|
557
|
+
constructor(cwd: string, skillPaths: string[], options?: {
|
|
558
|
+
onCacheInvalidated?: () => void;
|
|
559
|
+
}, logger?: LoggerLike);
|
|
560
|
+
/**
|
|
561
|
+
* Get all available skills from configured directories.
|
|
562
|
+
* Results are cached after first load.
|
|
563
|
+
*
|
|
564
|
+
* Skills from earlier entries in the config take precedence over
|
|
565
|
+
* skills with the same name from later entries.
|
|
566
|
+
*
|
|
567
|
+
* @returns Array of loaded skills
|
|
568
|
+
* @throws SkillLoadError if a critical error occurs during loading
|
|
569
|
+
*/
|
|
570
|
+
getSkills(): Promise<Skill[]>;
|
|
571
|
+
/**
|
|
572
|
+
* Get a specific skill by name with O(1) lookup from cache.
|
|
573
|
+
* @param name - The skill name (without skill__ prefix)
|
|
574
|
+
* @returns The skill if found, undefined otherwise
|
|
575
|
+
*/
|
|
576
|
+
getSkill(name: string): Promise<Skill | undefined>;
|
|
577
|
+
/**
|
|
578
|
+
* Clears the cached skills to force a fresh reload on the next getSkills() or getSkill() call.
|
|
579
|
+
* Use this when skill files have been modified on disk.
|
|
580
|
+
*/
|
|
581
|
+
clearCache(): void;
|
|
582
|
+
/**
|
|
583
|
+
* Starts watching skill directories for changes to SKILL.md files.
|
|
584
|
+
* When changes are detected, the cache is automatically invalidated.
|
|
585
|
+
*
|
|
586
|
+
* Uses Node.js fs.watch with recursive option for efficient directory monitoring.
|
|
587
|
+
* Only invalidates cache when SKILL.md files are modified.
|
|
588
|
+
*
|
|
589
|
+
* @example
|
|
590
|
+
* const skillService = new SkillService(cwd, skillPaths, {
|
|
591
|
+
* onCacheInvalidated: () => console.log('Skills cache invalidated')
|
|
592
|
+
* });
|
|
593
|
+
* await skillService.startWatching();
|
|
594
|
+
*/
|
|
595
|
+
startWatching(): Promise<void>;
|
|
596
|
+
/**
|
|
597
|
+
* Stops all active file watchers.
|
|
598
|
+
* Should be called when the service is being disposed.
|
|
599
|
+
*/
|
|
600
|
+
stopWatching(): void;
|
|
601
|
+
/**
|
|
602
|
+
* Watches a directory for changes to SKILL.md files.
|
|
603
|
+
* @param dirPath - Directory path to watch
|
|
604
|
+
* @param signal - AbortSignal to stop watching
|
|
605
|
+
*/
|
|
606
|
+
private watchDirectory;
|
|
607
|
+
private invalidateCache;
|
|
608
|
+
private isWatchResourceLimitError;
|
|
609
|
+
private startPollingDirectory;
|
|
610
|
+
private createSkillSnapshot;
|
|
611
|
+
private collectSkillSnapshots;
|
|
612
|
+
private snapshotsEqual;
|
|
613
|
+
/**
|
|
614
|
+
* Load skills from a directory.
|
|
615
|
+
* Supports both flat structure (SKILL.md) and nested structure (name/SKILL.md).
|
|
616
|
+
*
|
|
617
|
+
* @param dirPath - Path to the skills directory
|
|
618
|
+
* @param location - Whether this is a 'project' or 'user' skill directory
|
|
619
|
+
* @returns Array of successfully loaded skills (skips invalid skills)
|
|
620
|
+
* @throws SkillLoadError if there's a critical I/O error
|
|
621
|
+
*
|
|
622
|
+
* @example
|
|
623
|
+
* // Load skills from project directory
|
|
624
|
+
* const skills = await this.loadSkillsFromDirectory('/path/to/.claude/skills', 'project');
|
|
625
|
+
* // Returns: [{ name: 'pdf', description: '...', location: 'project', ... }]
|
|
626
|
+
*/
|
|
627
|
+
private loadSkillsFromDirectory;
|
|
628
|
+
/**
|
|
629
|
+
* Load a single skill file and parse its frontmatter.
|
|
630
|
+
* Supports multi-line YAML values using literal (|) and folded (>) block scalars.
|
|
631
|
+
*
|
|
632
|
+
* @param filePath - Path to the SKILL.md file
|
|
633
|
+
* @param location - Whether this is a 'project' or 'user' skill
|
|
634
|
+
* @returns The loaded skill, or null if the file is invalid (missing required frontmatter)
|
|
635
|
+
* @throws SkillLoadError if there's an I/O error reading the file
|
|
636
|
+
*
|
|
637
|
+
* @example
|
|
638
|
+
* // Load a skill from a file
|
|
639
|
+
* const skill = await this.loadSkillFile('/path/to/pdf/SKILL.md', 'project');
|
|
640
|
+
* // Returns: { name: 'pdf', description: 'PDF skill', location: 'project', content: '...', basePath: '/path/to/pdf' }
|
|
641
|
+
* // Returns null if frontmatter is missing name or description
|
|
642
|
+
*/
|
|
643
|
+
private loadSkillFile;
|
|
644
|
+
}
|
|
645
|
+
//#endregion
|
|
646
|
+
//#region src/services/McpClientManagerService.d.ts
|
|
647
|
+
/**
|
|
648
|
+
* Service for managing MCP client connections to remote servers
|
|
649
|
+
*/
|
|
650
|
+
declare class McpClientManagerService {
|
|
651
|
+
private clients;
|
|
652
|
+
private serverConfigs;
|
|
653
|
+
private connectionPromises;
|
|
654
|
+
private logger;
|
|
655
|
+
constructor(logger?: LoggerLike);
|
|
656
|
+
/**
|
|
657
|
+
* Synchronously kill all stdio MCP server child processes.
|
|
658
|
+
* Must be called by the owner (e.g. transport/command layer) during shutdown.
|
|
659
|
+
*/
|
|
660
|
+
cleanupChildProcesses(): void;
|
|
661
|
+
/**
|
|
662
|
+
* Connect to an MCP server based on its configuration with timeout
|
|
663
|
+
* Uses the timeout from server config, falling back to default (30s)
|
|
664
|
+
*/
|
|
665
|
+
connectToServer(serverName: string, config: McpServerConfig): Promise<void>;
|
|
666
|
+
registerServerConfigs(configs: Record<string, McpServerConfig>): void;
|
|
667
|
+
getKnownServerNames(): string[];
|
|
668
|
+
getServerRequestTimeout(serverName: string): number | undefined;
|
|
669
|
+
ensureConnected(serverName: string): Promise<McpClientConnection>;
|
|
670
|
+
private createConnection;
|
|
671
|
+
/**
|
|
672
|
+
* Perform the actual connection to MCP server
|
|
673
|
+
*/
|
|
674
|
+
private performConnection;
|
|
675
|
+
private connectStdioClient;
|
|
676
|
+
private connectHttpClient;
|
|
677
|
+
private connectSseClient;
|
|
678
|
+
/**
|
|
679
|
+
* Get a connected client by server name
|
|
680
|
+
*/
|
|
681
|
+
getClient(serverName: string): McpClientConnection | undefined;
|
|
682
|
+
/**
|
|
683
|
+
* Get all connected clients
|
|
684
|
+
*/
|
|
685
|
+
getAllClients(): McpClientConnection[];
|
|
686
|
+
/**
|
|
687
|
+
* Disconnect from a specific server
|
|
688
|
+
*/
|
|
689
|
+
disconnectServer(serverName: string): Promise<void>;
|
|
690
|
+
/**
|
|
691
|
+
* Disconnect from all servers
|
|
692
|
+
*/
|
|
693
|
+
disconnectAll(): Promise<void>;
|
|
694
|
+
/**
|
|
695
|
+
* Check if a server is connected
|
|
696
|
+
*/
|
|
697
|
+
isConnected(serverName: string): boolean;
|
|
698
|
+
}
|
|
699
|
+
//#endregion
|
|
700
|
+
//#region src/services/DefinitionsCacheService.d.ts
|
|
701
|
+
interface DefinitionsCacheServiceOptions {
|
|
702
|
+
cacheData?: DefinitionsCacheFile;
|
|
703
|
+
}
|
|
704
|
+
interface PromptSkillMatch {
|
|
705
|
+
serverName: string;
|
|
706
|
+
promptName: string;
|
|
707
|
+
skill: PromptSkillConfig;
|
|
708
|
+
autoDetected?: boolean;
|
|
709
|
+
}
|
|
710
|
+
interface CollectOptions {
|
|
711
|
+
serverId?: string;
|
|
712
|
+
configPath?: string;
|
|
713
|
+
configHash?: string;
|
|
714
|
+
oneMcpVersion?: string;
|
|
715
|
+
}
|
|
716
|
+
declare class DefinitionsCacheService {
|
|
717
|
+
private clientManager;
|
|
718
|
+
private skillService?;
|
|
719
|
+
private cacheData?;
|
|
720
|
+
private liveDefinitionsPromise;
|
|
721
|
+
private mergedDefinitionsPromise;
|
|
722
|
+
private logger;
|
|
723
|
+
constructor(clientManager: McpClientManagerService, skillService?: SkillService, options?: DefinitionsCacheServiceOptions, logger?: LoggerLike);
|
|
724
|
+
static readFromFile(filePath: string): Promise<DefinitionsCacheFile>;
|
|
725
|
+
static writeToFile(filePath: string, cache: DefinitionsCacheFile): Promise<void>;
|
|
726
|
+
static getDefaultCachePath(configFilePath: string): string;
|
|
727
|
+
static generateConfigHash(config: unknown): string;
|
|
728
|
+
static isCacheValid(cache: DefinitionsCacheFile, options: {
|
|
729
|
+
configHash?: string;
|
|
730
|
+
oneMcpVersion?: string;
|
|
731
|
+
}): boolean;
|
|
732
|
+
static clearFile(filePath: string): Promise<void>;
|
|
733
|
+
clearLiveCache(): void;
|
|
734
|
+
setCacheData(cacheData?: DefinitionsCacheFile): void;
|
|
735
|
+
collectForCache(options?: CollectOptions): Promise<DefinitionsCacheFile>;
|
|
736
|
+
getDefinitions(): Promise<DefinitionsCacheFile>;
|
|
737
|
+
getServerDefinitions(): Promise<CachedServerDefinition[]>;
|
|
738
|
+
getServersForTool(toolName: string): Promise<string[]>;
|
|
739
|
+
getServersForResource(uri: string): Promise<string[]>;
|
|
740
|
+
getPromptSkillByName(skillName: string): Promise<PromptSkillMatch | undefined>;
|
|
741
|
+
getCachedFileSkills(): Promise<CachedFileSkillInfo[]>;
|
|
742
|
+
private getLiveDefinitions;
|
|
743
|
+
private collectLiveDefinitions;
|
|
744
|
+
private collectFileSkills;
|
|
745
|
+
private toCachedFileSkill;
|
|
746
|
+
private listPromptsSafe;
|
|
747
|
+
private listResourcesSafe;
|
|
748
|
+
private collectPromptSkillsForClient;
|
|
749
|
+
}
|
|
750
|
+
//#endregion
|
|
751
|
+
//#region src/services/RuntimeStateService.d.ts
|
|
752
|
+
/**
|
|
753
|
+
* Runtime state persistence implementation.
|
|
754
|
+
*/
|
|
755
|
+
declare class RuntimeStateService implements RuntimeStateManager {
|
|
756
|
+
private runtimeDir;
|
|
757
|
+
private logger;
|
|
758
|
+
constructor(runtimeDir?: string, logger?: LoggerLike);
|
|
759
|
+
/**
|
|
760
|
+
* Resolve default runtime directory under the user's home cache path.
|
|
761
|
+
* @returns Absolute runtime directory path
|
|
762
|
+
*/
|
|
763
|
+
static getDefaultRuntimeDir(): string;
|
|
764
|
+
/**
|
|
765
|
+
* Build runtime state file path for a given server ID.
|
|
766
|
+
* @param serverId - Target mcp-proxy server identifier
|
|
767
|
+
* @returns Absolute runtime file path
|
|
768
|
+
*/
|
|
769
|
+
private getRecordPath;
|
|
770
|
+
/**
|
|
771
|
+
* Persist a runtime state record.
|
|
772
|
+
* @param record - Runtime metadata to persist
|
|
773
|
+
* @returns Promise that resolves when write completes
|
|
774
|
+
*/
|
|
775
|
+
write(record: RuntimeStateRecord): Promise<void>;
|
|
776
|
+
/**
|
|
777
|
+
* Read a runtime state record by server ID.
|
|
778
|
+
* @param serverId - Target mcp-proxy server identifier
|
|
779
|
+
* @returns Matching runtime record, or null when no record exists
|
|
780
|
+
*/
|
|
781
|
+
read(serverId: string): Promise<RuntimeStateRecord | null>;
|
|
782
|
+
/**
|
|
783
|
+
* List all persisted runtime records.
|
|
784
|
+
* @returns Array of runtime records
|
|
785
|
+
*/
|
|
786
|
+
list(): Promise<RuntimeStateRecord[]>;
|
|
787
|
+
/**
|
|
788
|
+
* Remove a runtime state record by server ID.
|
|
789
|
+
* @param serverId - Target mcp-proxy server identifier
|
|
790
|
+
* @returns Promise that resolves when delete completes
|
|
791
|
+
*/
|
|
792
|
+
remove(serverId: string): Promise<void>;
|
|
793
|
+
}
|
|
794
|
+
//#endregion
|
|
795
|
+
//#region src/services/StopServerService/types.d.ts
|
|
796
|
+
/**
|
|
797
|
+
* Stop request options.
|
|
798
|
+
* @property serverId - Explicit mcp-proxy server identifier to stop
|
|
799
|
+
* @property host - Host fallback for runtime lookup
|
|
800
|
+
* @property port - Port fallback for runtime lookup
|
|
801
|
+
* @property token - Optional shutdown token override
|
|
802
|
+
* @property force - Skip server ID verification against /health when true
|
|
803
|
+
* @property timeoutMs - Maximum time to wait for shutdown completion
|
|
804
|
+
*/
|
|
805
|
+
interface StopServerRequest {
|
|
806
|
+
serverId?: string;
|
|
807
|
+
host?: string;
|
|
808
|
+
port?: number;
|
|
809
|
+
token?: string;
|
|
810
|
+
force?: boolean;
|
|
811
|
+
timeoutMs?: number;
|
|
812
|
+
}
|
|
813
|
+
/**
|
|
814
|
+
* Stop command result payload.
|
|
815
|
+
* @property ok - Whether the shutdown completed successfully
|
|
816
|
+
* @property serverId - Stopped mcp-proxy server identifier
|
|
817
|
+
* @property host - Host that served the runtime
|
|
818
|
+
* @property port - Port that served the runtime
|
|
819
|
+
* @property message - Human-readable shutdown result message
|
|
820
|
+
*/
|
|
821
|
+
interface StopServerResult {
|
|
822
|
+
ok: true;
|
|
823
|
+
serverId: string;
|
|
824
|
+
host: string;
|
|
825
|
+
port: number;
|
|
826
|
+
message: string;
|
|
827
|
+
}
|
|
828
|
+
//#endregion
|
|
829
|
+
//#region src/services/StopServerService/StopServerService.d.ts
|
|
830
|
+
/**
|
|
831
|
+
* Service for resolving runtime targets and stopping them safely.
|
|
832
|
+
*/
|
|
833
|
+
declare class StopServerService {
|
|
834
|
+
private runtimeStateService;
|
|
835
|
+
private logger;
|
|
836
|
+
constructor(runtimeStateService?: RuntimeStateManager, logger?: LoggerLike);
|
|
837
|
+
/**
|
|
838
|
+
* Resolve a target runtime and stop it cooperatively.
|
|
839
|
+
* @param request - Stop request options
|
|
840
|
+
* @returns Stop result payload
|
|
841
|
+
*/
|
|
842
|
+
stop(request: StopServerRequest): Promise<StopServerResult>;
|
|
843
|
+
/**
|
|
844
|
+
* Resolve a runtime record from explicit ID or a unique host/port pair.
|
|
845
|
+
* @param request - Stop request options
|
|
846
|
+
* @returns Matching runtime record
|
|
847
|
+
*/
|
|
848
|
+
private resolveRuntime;
|
|
849
|
+
/**
|
|
850
|
+
* Read the runtime health payload.
|
|
851
|
+
* @param runtime - Runtime to query
|
|
852
|
+
* @param timeoutMs - Request timeout in milliseconds
|
|
853
|
+
* @returns Reachability status and optional payload
|
|
854
|
+
*/
|
|
855
|
+
private fetchHealth;
|
|
856
|
+
/**
|
|
857
|
+
* Send authenticated shutdown request to the admin endpoint.
|
|
858
|
+
* @param runtime - Runtime to stop
|
|
859
|
+
* @param shutdownToken - Bearer token for the admin endpoint
|
|
860
|
+
* @param timeoutMs - Request timeout in milliseconds
|
|
861
|
+
* @returns Parsed shutdown response payload
|
|
862
|
+
*/
|
|
863
|
+
private requestShutdown;
|
|
864
|
+
/**
|
|
865
|
+
* Poll until the target runtime is no longer reachable.
|
|
866
|
+
* @param runtime - Runtime expected to stop
|
|
867
|
+
* @param timeoutMs - Maximum wait time in milliseconds
|
|
868
|
+
* @returns Promise that resolves when shutdown is observed
|
|
869
|
+
*/
|
|
870
|
+
private waitForShutdown;
|
|
871
|
+
/**
|
|
872
|
+
* Perform a fetch with an abort timeout.
|
|
873
|
+
* @param url - Target URL
|
|
874
|
+
* @param init - Fetch options
|
|
875
|
+
* @param timeoutMs - Timeout in milliseconds
|
|
876
|
+
* @returns Fetch response
|
|
877
|
+
*/
|
|
878
|
+
private fetchWithTimeout;
|
|
879
|
+
}
|
|
880
|
+
//#endregion
|
|
881
|
+
//#region src/tools/DescribeToolsTool.d.ts
|
|
882
|
+
/**
|
|
883
|
+
* Input schema for the DescribeToolsTool
|
|
884
|
+
* @property toolNames - Array of tool names to get detailed information about
|
|
885
|
+
*/
|
|
886
|
+
interface DescribeToolsToolInput {
|
|
887
|
+
toolNames: string[];
|
|
888
|
+
}
|
|
889
|
+
/**
|
|
890
|
+
* DescribeToolsTool provides progressive disclosure of MCP tools and skills.
|
|
891
|
+
*
|
|
892
|
+
* This tool lists available tools from all connected MCP servers and skills
|
|
893
|
+
* from the configured skills directories. Users can query for specific tools
|
|
894
|
+
* or skills to get detailed input schemas and descriptions.
|
|
895
|
+
*
|
|
896
|
+
* Tool naming conventions:
|
|
897
|
+
* - Unique tools: use plain name (e.g., "browser_click")
|
|
898
|
+
* - Clashing tools: use serverName__toolName format (e.g., "playwright__click")
|
|
899
|
+
* - Skills: use skill__skillName format (e.g., "skill__pdf")
|
|
900
|
+
*
|
|
901
|
+
* @example
|
|
902
|
+
* const tool = new DescribeToolsTool(clientManager, skillService);
|
|
903
|
+
* const definition = await tool.getDefinition();
|
|
904
|
+
* const result = await tool.execute({ toolNames: ['browser_click', 'skill__pdf'] });
|
|
905
|
+
*/
|
|
906
|
+
declare class DescribeToolsTool implements Tool<DescribeToolsToolInput> {
|
|
907
|
+
static readonly TOOL_NAME = "describe_tools";
|
|
908
|
+
private clientManager;
|
|
909
|
+
private skillService;
|
|
910
|
+
private definitionsCacheService;
|
|
911
|
+
private readonly liquid;
|
|
912
|
+
/** Cache for auto-detected skills from prompt front-matter */
|
|
913
|
+
private autoDetectedSkillsCache;
|
|
914
|
+
/** Unique server identifier for this mcp-proxy instance */
|
|
915
|
+
private serverId;
|
|
916
|
+
/**
|
|
917
|
+
* Creates a new DescribeToolsTool instance
|
|
918
|
+
* @param clientManager - The MCP client manager for accessing remote servers
|
|
919
|
+
* @param skillService - Optional skill service for loading skills
|
|
920
|
+
* @param serverId - Unique server identifier for this mcp-proxy instance
|
|
921
|
+
*/
|
|
922
|
+
constructor(clientManager: McpClientManagerService, skillService?: SkillService, serverId?: string, definitionsCacheService?: DefinitionsCacheService);
|
|
923
|
+
/**
|
|
924
|
+
* Clears the cached auto-detected skills from prompt front-matter.
|
|
925
|
+
* Use this when prompt configurations may have changed or when
|
|
926
|
+
* the skill service cache is invalidated.
|
|
927
|
+
*/
|
|
928
|
+
clearAutoDetectedSkillsCache(): void;
|
|
929
|
+
/**
|
|
930
|
+
* Detects and caches skills from prompt front-matter across all connected MCP servers.
|
|
931
|
+
* Fetches all prompts and checks their content for YAML front-matter with name/description.
|
|
932
|
+
* Results are cached to avoid repeated fetches.
|
|
933
|
+
*
|
|
934
|
+
* Error Handling Strategy:
|
|
935
|
+
* - Errors are logged to stderr but do not fail the overall detection process
|
|
936
|
+
* - This ensures partial results are returned even if some servers/prompts fail
|
|
937
|
+
* - Common failure reasons: server temporarily unavailable, prompt requires arguments,
|
|
938
|
+
* network timeout, or server doesn't support listPrompts
|
|
939
|
+
* - Errors are prefixed with [skill-detection] for easy filtering in logs
|
|
940
|
+
*
|
|
941
|
+
* @returns Array of auto-detected skills from prompt front-matter
|
|
942
|
+
*/
|
|
943
|
+
private detectSkillsFromPromptFrontMatter;
|
|
944
|
+
/**
|
|
945
|
+
* Collects skills derived from prompt configurations across all connected MCP servers.
|
|
946
|
+
* Includes both explicitly configured prompts and auto-detected skills from front-matter.
|
|
947
|
+
*
|
|
948
|
+
* @returns Array of skill template data derived from prompts
|
|
949
|
+
*/
|
|
950
|
+
private collectPromptSkills;
|
|
951
|
+
/**
|
|
952
|
+
* Finds a prompt-based skill by name from all connected MCP servers.
|
|
953
|
+
* Searches both explicitly configured prompts and auto-detected skills from front-matter.
|
|
954
|
+
*
|
|
955
|
+
* @param skillName - The skill name to search for
|
|
956
|
+
* @returns Object with serverName, promptName, and skill config, or undefined if not found
|
|
957
|
+
*/
|
|
958
|
+
private findPromptSkill;
|
|
959
|
+
/**
|
|
960
|
+
* Retrieves skill content from a prompt-based skill configuration.
|
|
961
|
+
* Fetches the prompt from the MCP server and extracts text content.
|
|
962
|
+
* Handles both explicitly configured prompts and auto-detected skills from front-matter.
|
|
963
|
+
*
|
|
964
|
+
* @param skillName - The skill name being requested
|
|
965
|
+
* @returns SkillDescription if found and successfully fetched, undefined otherwise
|
|
966
|
+
*/
|
|
967
|
+
private getPromptSkillContent;
|
|
968
|
+
/**
|
|
969
|
+
* Builds the combined toolkit description using a single Liquid template.
|
|
970
|
+
*
|
|
971
|
+
* Collects all tools from connected MCP servers and all skills, then renders
|
|
972
|
+
* them together using the toolkit-description.liquid template.
|
|
973
|
+
*
|
|
974
|
+
* Tool names are prefixed with serverName__ when the same tool exists
|
|
975
|
+
* on multiple servers. Skill names are prefixed with skill__ when they
|
|
976
|
+
* clash with MCP tools or other skills.
|
|
977
|
+
*
|
|
978
|
+
* @returns Object with rendered description and set of all tool names
|
|
979
|
+
*/
|
|
980
|
+
private buildToolkitDescription;
|
|
981
|
+
/**
|
|
982
|
+
* Gets the tool definition including available tools and skills in a unified format.
|
|
983
|
+
*
|
|
984
|
+
* The definition includes:
|
|
985
|
+
* - All MCP tools from connected servers
|
|
986
|
+
* - All available skills (file-based and prompt-based)
|
|
987
|
+
* - Unified instructions for querying capability details
|
|
988
|
+
*
|
|
989
|
+
* Tool names are prefixed with serverName__ when clashing.
|
|
990
|
+
* Skill names are prefixed with skill__ when clashing.
|
|
991
|
+
*
|
|
992
|
+
* @returns Tool definition with description and input schema
|
|
993
|
+
*/
|
|
994
|
+
getDefinition(): Promise<ToolDefinition>;
|
|
995
|
+
/**
|
|
996
|
+
* Executes tool description lookup for the requested tool and skill names.
|
|
997
|
+
*
|
|
998
|
+
* Handles three types of lookups:
|
|
999
|
+
* 1. skill__name - Returns skill information from SkillService
|
|
1000
|
+
* 2. serverName__toolName - Returns tool from specific server
|
|
1001
|
+
* 3. plainToolName - Returns tool(s) from all servers (multiple if clashing)
|
|
1002
|
+
*
|
|
1003
|
+
* @param input - Object containing toolNames array
|
|
1004
|
+
* @returns CallToolResult with tool/skill descriptions or error
|
|
1005
|
+
*/
|
|
1006
|
+
execute(input: DescribeToolsToolInput): Promise<CallToolResult>;
|
|
1007
|
+
}
|
|
1008
|
+
//#endregion
|
|
1009
|
+
//#region src/tools/SearchListToolsTool.d.ts
|
|
1010
|
+
interface SearchListToolsToolInput {
|
|
1011
|
+
capability?: string;
|
|
1012
|
+
serverName?: string;
|
|
1013
|
+
}
|
|
1014
|
+
declare class SearchListToolsTool implements Tool<SearchListToolsToolInput> {
|
|
1015
|
+
private readonly _clientManager;
|
|
1016
|
+
private readonly definitionsCacheService;
|
|
1017
|
+
static readonly TOOL_NAME = "list_tools";
|
|
1018
|
+
constructor(_clientManager: unknown, definitionsCacheService: DefinitionsCacheService);
|
|
1019
|
+
private formatToolName;
|
|
1020
|
+
getDefinition(): Promise<ToolDefinition>;
|
|
1021
|
+
execute(input: SearchListToolsToolInput): Promise<CallToolResult>;
|
|
1022
|
+
}
|
|
1023
|
+
//#endregion
|
|
1024
|
+
//#region src/tools/UseToolTool.d.ts
|
|
1025
|
+
/**
|
|
1026
|
+
* Input schema for UseToolTool
|
|
1027
|
+
* @property toolName - Name of the tool or skill to execute
|
|
1028
|
+
* @property toolArgs - Arguments to pass to the tool (from describe_tools schema)
|
|
1029
|
+
*/
|
|
1030
|
+
interface UseToolToolInput {
|
|
1031
|
+
toolName: string;
|
|
1032
|
+
toolArgs?: Record<string, unknown>;
|
|
1033
|
+
}
|
|
1034
|
+
/**
|
|
1035
|
+
* UseToolTool executes MCP tools and skills with proper error handling.
|
|
1036
|
+
*
|
|
1037
|
+
* This tool supports three invocation patterns:
|
|
1038
|
+
* 1. skill__skillName - Invokes a skill from the configured skills directory
|
|
1039
|
+
* 2. serverName__toolName - Invokes a tool on a specific MCP server
|
|
1040
|
+
* 3. plainToolName - Searches all servers for a unique tool match
|
|
1041
|
+
*
|
|
1042
|
+
* @example
|
|
1043
|
+
* const tool = new UseToolTool(clientManager, skillService);
|
|
1044
|
+
* await tool.execute({ toolName: 'skill__pdf' }); // Invoke a skill
|
|
1045
|
+
* await tool.execute({ toolName: 'playwright__browser_click', toolArgs: { ref: 'btn' } });
|
|
1046
|
+
*/
|
|
1047
|
+
declare class UseToolTool implements Tool<UseToolToolInput> {
|
|
1048
|
+
static readonly TOOL_NAME = "use_tool";
|
|
1049
|
+
private clientManager;
|
|
1050
|
+
private skillService;
|
|
1051
|
+
private definitionsCacheService;
|
|
1052
|
+
/** Unique server identifier for this mcp-proxy instance */
|
|
1053
|
+
private serverId;
|
|
1054
|
+
/**
|
|
1055
|
+
* Creates a new UseToolTool instance
|
|
1056
|
+
* @param clientManager - The MCP client manager for accessing remote servers
|
|
1057
|
+
* @param skillService - Optional skill service for loading and executing skills
|
|
1058
|
+
* @param serverId - Unique server identifier for this mcp-proxy instance
|
|
1059
|
+
*/
|
|
1060
|
+
constructor(clientManager: McpClientManagerService, skillService?: SkillService, serverId?: string, definitionsCacheService?: DefinitionsCacheService);
|
|
1061
|
+
/**
|
|
1062
|
+
* Returns the MCP tool definition with name, description, and input schema.
|
|
1063
|
+
*
|
|
1064
|
+
* The definition describes how to use this tool to execute MCP tools or skills,
|
|
1065
|
+
* including the skill__ prefix format for skill invocations.
|
|
1066
|
+
*
|
|
1067
|
+
* @returns The tool definition conforming to MCP spec
|
|
1068
|
+
*/
|
|
1069
|
+
getDefinition(): ToolDefinition;
|
|
1070
|
+
/**
|
|
1071
|
+
* Returns guidance message for skill invocation.
|
|
1072
|
+
*
|
|
1073
|
+
* Skills are not executed via use_tool - they provide instructions that should
|
|
1074
|
+
* be followed directly. This method returns a message directing users to use
|
|
1075
|
+
* describe_tools to get the skill details and follow its instructions.
|
|
1076
|
+
*
|
|
1077
|
+
* @param skill - The skill that was requested
|
|
1078
|
+
* @returns CallToolResult with guidance message
|
|
1079
|
+
*/
|
|
1080
|
+
private executeSkill;
|
|
1081
|
+
/**
|
|
1082
|
+
* Finds a prompt-based skill by name from all connected MCP servers.
|
|
1083
|
+
*
|
|
1084
|
+
* @param skillName - The skill name to search for
|
|
1085
|
+
* @returns PromptSkillMatch if found, undefined otherwise
|
|
1086
|
+
*/
|
|
1087
|
+
private findPromptSkill;
|
|
1088
|
+
/**
|
|
1089
|
+
* Returns guidance message for prompt-based skill invocation.
|
|
1090
|
+
*
|
|
1091
|
+
* @param promptSkill - The prompt skill match that was found
|
|
1092
|
+
* @returns CallToolResult with guidance message
|
|
1093
|
+
*/
|
|
1094
|
+
private executePromptSkill;
|
|
1095
|
+
/**
|
|
1096
|
+
* Executes a tool or skill based on the provided input.
|
|
1097
|
+
*
|
|
1098
|
+
* Handles three invocation patterns:
|
|
1099
|
+
* 1. skill__skillName - Routes to skill execution via SkillService
|
|
1100
|
+
* 2. serverName__toolName - Routes to specific MCP server
|
|
1101
|
+
* 3. plainToolName - Searches all servers for unique match
|
|
1102
|
+
*
|
|
1103
|
+
* Edge cases:
|
|
1104
|
+
* - Returns error if skill not found when using skill__ prefix
|
|
1105
|
+
* - Returns error if tool is blacklisted on target server
|
|
1106
|
+
* - Returns disambiguation message if tool exists on multiple servers
|
|
1107
|
+
*
|
|
1108
|
+
* @param input - The tool/skill name and optional arguments
|
|
1109
|
+
* @returns CallToolResult with execution output or error
|
|
1110
|
+
*/
|
|
1111
|
+
execute(input: UseToolToolInput): Promise<CallToolResult>;
|
|
1112
|
+
}
|
|
1113
|
+
//#endregion
|
|
1114
|
+
//#region src/transports/http.d.ts
|
|
1115
|
+
/**
|
|
1116
|
+
* HTTP transport handler using Streamable HTTP (protocol version 2025-03-26)
|
|
1117
|
+
* Provides stateful session management with resumability support
|
|
1118
|
+
*/
|
|
1119
|
+
declare class HttpTransportHandler implements HttpTransportHandler$1 {
|
|
1120
|
+
private serverFactory;
|
|
1121
|
+
private app;
|
|
1122
|
+
private server;
|
|
1123
|
+
private sessionManager;
|
|
1124
|
+
private config;
|
|
1125
|
+
private adminOptions?;
|
|
1126
|
+
private adminRateLimiter;
|
|
1127
|
+
private logger;
|
|
1128
|
+
constructor(serverFactory: (() => Server | Promise<Server>), config: TransportConfig, adminOptions?: HttpTransportAdminOptions, logger?: LoggerLike);
|
|
1129
|
+
private setupMiddleware;
|
|
1130
|
+
private setupRoutes;
|
|
1131
|
+
private isAuthorizedShutdownRequest;
|
|
1132
|
+
private handleAdminShutdownRequest;
|
|
1133
|
+
private handlePostRequest;
|
|
1134
|
+
private handleGetRequest;
|
|
1135
|
+
private handleDeleteRequest;
|
|
1136
|
+
start(): Promise<void>;
|
|
1137
|
+
stop(): Promise<void>;
|
|
1138
|
+
getPort(): number;
|
|
1139
|
+
getHost(): string;
|
|
1140
|
+
}
|
|
1141
|
+
//#endregion
|
|
1142
|
+
//#region src/transports/sse.d.ts
|
|
1143
|
+
/**
|
|
1144
|
+
* SSE (Server-Sent Events) transport handler
|
|
1145
|
+
* Legacy transport for backwards compatibility (protocol version 2024-11-05)
|
|
1146
|
+
* Uses separate endpoints: /sse for SSE stream (GET) and /messages for client messages (POST)
|
|
1147
|
+
*/
|
|
1148
|
+
declare class SseTransportHandler implements HttpTransportHandler$1 {
|
|
1149
|
+
private serverFactory;
|
|
1150
|
+
private app;
|
|
1151
|
+
private server;
|
|
1152
|
+
private sessionManager;
|
|
1153
|
+
private config;
|
|
1154
|
+
private logger;
|
|
1155
|
+
constructor(serverFactory: Server | (() => Server), config: TransportConfig, logger?: LoggerLike);
|
|
1156
|
+
private setupMiddleware;
|
|
1157
|
+
private setupRoutes;
|
|
1158
|
+
private handleSseConnection;
|
|
1159
|
+
private handlePostMessage;
|
|
1160
|
+
start(): Promise<void>;
|
|
1161
|
+
stop(): Promise<void>;
|
|
1162
|
+
getPort(): number;
|
|
1163
|
+
getHost(): string;
|
|
1164
|
+
}
|
|
1165
|
+
//#endregion
|
|
1166
|
+
//#region src/transports/stdio.d.ts
|
|
1167
|
+
/**
|
|
1168
|
+
* Stdio transport handler for MCP server
|
|
1169
|
+
* Used for command-line and direct integrations
|
|
1170
|
+
*/
|
|
1171
|
+
declare class StdioTransportHandler implements TransportHandler {
|
|
1172
|
+
private server;
|
|
1173
|
+
private transport;
|
|
1174
|
+
private logger;
|
|
1175
|
+
constructor(server: Server, logger?: LoggerLike);
|
|
1176
|
+
start(): Promise<void>;
|
|
1177
|
+
stop(): Promise<void>;
|
|
1178
|
+
}
|
|
1179
|
+
//#endregion
|
|
1180
|
+
//#region src/transports/stdio-http.d.ts
|
|
1181
|
+
interface StdioHttpProxyTransportConfig {
|
|
1182
|
+
endpoint: URL;
|
|
1183
|
+
}
|
|
1184
|
+
/**
|
|
1185
|
+
* Transport that serves MCP over stdio and forwards MCP requests to an HTTP endpoint.
|
|
1186
|
+
*/
|
|
1187
|
+
declare class StdioHttpTransportHandler implements TransportHandler {
|
|
1188
|
+
private readonly endpoint;
|
|
1189
|
+
private stdioProxyServer;
|
|
1190
|
+
private stdioTransport;
|
|
1191
|
+
private httpClient;
|
|
1192
|
+
private logger;
|
|
1193
|
+
constructor(config: StdioHttpProxyTransportConfig, logger?: LoggerLike);
|
|
1194
|
+
start(): Promise<void>;
|
|
1195
|
+
stop(): Promise<void>;
|
|
1196
|
+
private createProxyServer;
|
|
1197
|
+
}
|
|
1198
|
+
//#endregion
|
|
1199
|
+
//#region src/container/index.d.ts
|
|
1200
|
+
/**
|
|
1201
|
+
* Configuration options for creating an MCP proxy container.
|
|
1202
|
+
*/
|
|
1203
|
+
interface ServerOptions {
|
|
1204
|
+
configFilePath?: string;
|
|
1205
|
+
noCache?: boolean;
|
|
1206
|
+
skills?: {
|
|
1207
|
+
paths: string[];
|
|
1208
|
+
};
|
|
1209
|
+
serverId?: string;
|
|
1210
|
+
definitionsCachePath?: string;
|
|
1211
|
+
clearDefinitionsCache?: boolean;
|
|
1212
|
+
proxyMode?: 'meta' | 'flat' | 'search';
|
|
1213
|
+
onServerIdResolved?: (serverId: string) => Promise<void> | void;
|
|
1214
|
+
}
|
|
1215
|
+
/**
|
|
1216
|
+
* Shared services and tools for multi-session HTTP transport.
|
|
1217
|
+
*/
|
|
1218
|
+
interface SharedServices {
|
|
1219
|
+
clientManager: McpClientManagerService;
|
|
1220
|
+
definitionsCacheService: DefinitionsCacheService;
|
|
1221
|
+
skillService?: SkillService;
|
|
1222
|
+
describeTools: DescribeToolsTool;
|
|
1223
|
+
useTool: UseToolTool;
|
|
1224
|
+
searchListTools: SearchListToolsTool;
|
|
1225
|
+
serverId: string;
|
|
1226
|
+
proxyMode: 'meta' | 'flat' | 'search';
|
|
1227
|
+
dispose: () => Promise<void>;
|
|
1228
|
+
}
|
|
1229
|
+
interface HttpTransportAdminOptions$1 {
|
|
1230
|
+
serverId: string;
|
|
1231
|
+
shutdownToken: string;
|
|
1232
|
+
onShutdownRequested: () => Promise<void>;
|
|
1233
|
+
}
|
|
1234
|
+
/**
|
|
1235
|
+
* Create the shared proxy container for a session or server startup.
|
|
1236
|
+
*
|
|
1237
|
+
* This is the composition root for the package: it owns service wiring,
|
|
1238
|
+
* cache warmup, and cleanup for all proxy-specific resources.
|
|
1239
|
+
*/
|
|
1240
|
+
declare function createProxyContainer(options?: ServerOptions): Promise<SharedServices>;
|
|
1241
|
+
/**
|
|
1242
|
+
* Create a sessionless stdio transport handler from the shared server factory.
|
|
1243
|
+
*/
|
|
1244
|
+
declare function createStdioTransportHandler(createServer: () => Promise<_modelcontextprotocol_sdk_server_index_js0.Server>): Promise<StdioTransportHandler>;
|
|
1245
|
+
/**
|
|
1246
|
+
* Create an SSE transport handler from the shared server factory.
|
|
1247
|
+
*/
|
|
1248
|
+
declare function createSseTransportHandler(createServer: () => Promise<_modelcontextprotocol_sdk_server_index_js0.Server>, config: TransportConfig): Promise<SseTransportHandler>;
|
|
1249
|
+
/**
|
|
1250
|
+
* Create an HTTP transport handler from shared services.
|
|
1251
|
+
*/
|
|
1252
|
+
declare function createHttpTransportHandler(createServer: () => Promise<_modelcontextprotocol_sdk_server_index_js0.Server>, config: TransportConfig, adminOptions?: HttpTransportAdminOptions$1): HttpTransportHandler;
|
|
1253
|
+
/**
|
|
1254
|
+
* Create a stdio-http transport handler from an endpoint URL.
|
|
1255
|
+
*/
|
|
1256
|
+
declare function createStdioHttpTransportHandler(endpoint: URL): StdioHttpTransportHandler;
|
|
1257
|
+
/**
|
|
1258
|
+
* Backward-compatible alias for the shared-service composition root.
|
|
1259
|
+
*/
|
|
1260
|
+
declare function initializeSharedServices(options?: ServerOptions): Promise<SharedServices>;
|
|
1261
|
+
//#endregion
|
|
1262
|
+
//#region src/server/index.d.ts
|
|
1263
|
+
/**
|
|
1264
|
+
* Initialize shared services and tools once for use across multiple sessions.
|
|
1265
|
+
* Use with createSessionServer() for HTTP transport where multiple agents
|
|
1266
|
+
* connect concurrently. This avoids duplicating downstream connections,
|
|
1267
|
+
* file watchers, caches, and tool instances per session.
|
|
1268
|
+
*/
|
|
1269
|
+
/**
|
|
1270
|
+
* Create a lightweight per-session MCP Server instance that delegates
|
|
1271
|
+
* to shared services and tools. Use with createProxyContainer()
|
|
1272
|
+
* for multi-session HTTP transport.
|
|
1273
|
+
*/
|
|
1274
|
+
declare function createSessionServer(shared: SharedServices): Promise<Server>;
|
|
1275
|
+
/**
|
|
1276
|
+
* Create a single MCP server instance (backward-compatible wrapper).
|
|
1277
|
+
* For multi-session HTTP transport, use createProxyContainer() + createSessionServer() instead.
|
|
1278
|
+
*/
|
|
1279
|
+
declare function createServer(options?: ServerOptions): Promise<Server>;
|
|
1280
|
+
//#endregion
|
|
1281
|
+
//#region src/utils/findConfigFile.d.ts
|
|
1282
|
+
/**
|
|
1283
|
+
* Config File Finder Utility
|
|
1284
|
+
*
|
|
1285
|
+
* DESIGN PATTERNS:
|
|
1286
|
+
* - Utility function pattern for reusable logic
|
|
1287
|
+
* - Fail-fast pattern with early returns
|
|
1288
|
+
* - Environment variable configuration pattern
|
|
1289
|
+
*
|
|
1290
|
+
* CODING STANDARDS:
|
|
1291
|
+
* - Use sync filesystem operations for config discovery (performance)
|
|
1292
|
+
* - Check PROJECT_PATH environment variable first
|
|
1293
|
+
* - Fall back to current working directory
|
|
1294
|
+
* - Support both .yaml and .json extensions
|
|
1295
|
+
* - Return null if no config file is found
|
|
1296
|
+
*
|
|
1297
|
+
* AVOID:
|
|
1298
|
+
* - Throwing errors (return null instead for optional config)
|
|
1299
|
+
* - Hardcoded file names without extension variants
|
|
1300
|
+
* - Ignoring environment variables
|
|
1301
|
+
*/
|
|
1302
|
+
/**
|
|
1303
|
+
* Find MCP configuration file by checking PROJECT_PATH first, then cwd
|
|
1304
|
+
* Looks for both mcp-config.yaml and mcp-config.json
|
|
1305
|
+
*
|
|
1306
|
+
* @returns Absolute path to config file, or null if not found
|
|
1307
|
+
*/
|
|
1308
|
+
declare function findConfigFile(): string | null;
|
|
1309
|
+
//#endregion
|
|
1310
|
+
//#region src/utils/generateServerId.d.ts
|
|
1311
|
+
/**
|
|
1312
|
+
* generateServerId Utilities
|
|
1313
|
+
*
|
|
1314
|
+
* DESIGN PATTERNS:
|
|
1315
|
+
* - Pure functions with no side effects
|
|
1316
|
+
* - Single responsibility per function
|
|
1317
|
+
* - Functional programming approach
|
|
1318
|
+
*
|
|
1319
|
+
* CODING STANDARDS:
|
|
1320
|
+
* - Export individual functions, not classes
|
|
1321
|
+
* - Use descriptive function names with verbs
|
|
1322
|
+
* - Add JSDoc comments for complex logic
|
|
1323
|
+
* - Keep functions small and focused
|
|
1324
|
+
*
|
|
1325
|
+
* AVOID:
|
|
1326
|
+
* - Side effects (mutating external state)
|
|
1327
|
+
* - Stateful logic (use services for state)
|
|
1328
|
+
* - Complex external dependencies
|
|
1329
|
+
*/
|
|
1330
|
+
/**
|
|
1331
|
+
* Generate a short, human-readable server ID.
|
|
1332
|
+
*
|
|
1333
|
+
* Uses Node.js crypto.randomBytes for cryptographically secure randomness
|
|
1334
|
+
* with rejection sampling to avoid modulo bias.
|
|
1335
|
+
*
|
|
1336
|
+
* The generated ID:
|
|
1337
|
+
* - Is 6 characters long by default
|
|
1338
|
+
* - Uses only lowercase alphanumeric characters
|
|
1339
|
+
* - Excludes confusing characters (0, O, 1, l, I)
|
|
1340
|
+
*
|
|
1341
|
+
* @param length - Length of the ID to generate (default: 6)
|
|
1342
|
+
* @returns A random, human-readable ID
|
|
1343
|
+
*
|
|
1344
|
+
* @example
|
|
1345
|
+
* generateServerId() // "abc234"
|
|
1346
|
+
* generateServerId(4) // "x7mn"
|
|
1347
|
+
*/
|
|
1348
|
+
declare function generateServerId(length?: number): string;
|
|
1349
|
+
//#endregion
|
|
1350
|
+
export { CachedFileSkillInfo, CachedPromptSkillInfo, CachedServerDefinition, ConfigFetcherService, DefinitionsCacheFile, DefinitionsCacheService, DescribeToolsTool, HttpTransportAdminOptions, HttpTransportHandler, HttpTransportHealthResponse, HttpTransportShutdownResponse, type LoggerLike, McpClientConnection, McpClientManagerService, McpHttpConfig, McpPromptInfo, McpResourceInfo, McpServerConfig, McpServerTransportConfig, McpServerTransportType, McpSseConfig, McpStdioConfig, McpToolInfo, PromptConfig, PromptSkillConfig, type ProxyLoggerHandle, type ProxyLoggerOptions, RemoteMcpConfiguration, RuntimeLookupOptions, RuntimeStateManager, RuntimeStateRecord, RuntimeStateService, SearchListToolsTool, type ServerOptions, type SharedServices, Skill, SkillMetadata, SkillService, SkillsConfig, SseTransportHandler, StdioHttpTransportHandler, StdioTransportHandler, type StopServerRequest, type StopServerResult, StopServerService, TRANSPORT_MODE, Tool, ToolDefinition, TransportConfig, TransportHandler, TransportMode, UseToolTool, createHttpTransportHandler, createProxyContainer, createProxyLogger, createServer, createSessionServer, createSseTransportHandler, createStdioHttpTransportHandler, createStdioTransportHandler, findConfigFile, generateServerId, initializeSharedServices };
|