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