@agiflowai/one-mcp 0.3.5 → 0.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +2 -2
- package/dist/cli.mjs +2 -2
- package/dist/{http-DEoeeLtl.mjs → http-BzTXYfkN.mjs} +2 -3
- package/dist/{http-TVcVma3Q.cjs → http-CKXz9Gp8.cjs} +13 -2
- package/dist/index.cjs +6 -1
- package/dist/index.d.cts +452 -1
- package/dist/index.d.mts +452 -1
- package/dist/index.mjs +2 -2
- package/package.json +2 -2
package/dist/cli.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const require_http = require('./http-
|
|
2
|
+
const require_http = require('./http-CKXz9Gp8.cjs');
|
|
3
3
|
let node_fs_promises = require("node:fs/promises");
|
|
4
4
|
let node_path = require("node:path");
|
|
5
5
|
let liquidjs = require("liquidjs");
|
|
@@ -1051,7 +1051,7 @@ const prefetchCommand = new commander.Command("prefetch").description("Pre-downl
|
|
|
1051
1051
|
|
|
1052
1052
|
//#endregion
|
|
1053
1053
|
//#region package.json
|
|
1054
|
-
var version = "0.3.
|
|
1054
|
+
var version = "0.3.6";
|
|
1055
1055
|
|
|
1056
1056
|
//#endregion
|
|
1057
1057
|
//#region src/cli.ts
|
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { c as findConfigFile, i as createServer, l as McpClientManagerService, n as SseTransportHandler, r as StdioTransportHandler, s as SkillService, t as HttpTransportHandler, u as ConfigFetcherService } from "./http-BzTXYfkN.mjs";
|
|
3
3
|
import { writeFile } from "node:fs/promises";
|
|
4
4
|
import { resolve } from "node:path";
|
|
5
5
|
import { Liquid } from "liquidjs";
|
|
@@ -1051,7 +1051,7 @@ const prefetchCommand = new Command("prefetch").description("Pre-download packag
|
|
|
1051
1051
|
|
|
1052
1052
|
//#endregion
|
|
1053
1053
|
//#region package.json
|
|
1054
|
-
var version = "0.3.
|
|
1054
|
+
var version = "0.3.6";
|
|
1055
1055
|
|
|
1056
1056
|
//#endregion
|
|
1057
1057
|
//#region src/cli.ts
|
|
@@ -1860,8 +1860,7 @@ var DescribeToolsTool = class DescribeToolsTool {
|
|
|
1860
1860
|
toolNames: formattedTools.map((t) => t.displayName)
|
|
1861
1861
|
};
|
|
1862
1862
|
});
|
|
1863
|
-
const rawSkills = this.skillService ?
|
|
1864
|
-
const promptSkills = await this.collectPromptSkills();
|
|
1863
|
+
const [rawSkills, promptSkills] = await Promise.all([this.skillService ? this.skillService.getSkills() : Promise.resolve([]), this.collectPromptSkills()]);
|
|
1865
1864
|
const seenSkillNames = /* @__PURE__ */ new Set();
|
|
1866
1865
|
const allSkillsData = [];
|
|
1867
1866
|
for (const skill of rawSkills) if (!seenSkillNames.has(skill.name)) {
|
|
@@ -2838,4 +2837,4 @@ var HttpTransportHandler = class {
|
|
|
2838
2837
|
};
|
|
2839
2838
|
|
|
2840
2839
|
//#endregion
|
|
2841
|
-
export {
|
|
2840
|
+
export { UseToolTool as a, findConfigFile as c, createServer as i, McpClientManagerService as l, SseTransportHandler as n, DescribeToolsTool as o, StdioTransportHandler as r, SkillService as s, HttpTransportHandler as t, ConfigFetcherService as u };
|
|
@@ -1889,8 +1889,7 @@ var DescribeToolsTool = class DescribeToolsTool {
|
|
|
1889
1889
|
toolNames: formattedTools.map((t) => t.displayName)
|
|
1890
1890
|
};
|
|
1891
1891
|
});
|
|
1892
|
-
const rawSkills = this.skillService ?
|
|
1893
|
-
const promptSkills = await this.collectPromptSkills();
|
|
1892
|
+
const [rawSkills, promptSkills] = await Promise.all([this.skillService ? this.skillService.getSkills() : Promise.resolve([]), this.collectPromptSkills()]);
|
|
1894
1893
|
const seenSkillNames = /* @__PURE__ */ new Set();
|
|
1895
1894
|
const allSkillsData = [];
|
|
1896
1895
|
for (const skill of rawSkills) if (!seenSkillNames.has(skill.name)) {
|
|
@@ -2873,6 +2872,12 @@ Object.defineProperty(exports, 'ConfigFetcherService', {
|
|
|
2873
2872
|
return ConfigFetcherService;
|
|
2874
2873
|
}
|
|
2875
2874
|
});
|
|
2875
|
+
Object.defineProperty(exports, 'DescribeToolsTool', {
|
|
2876
|
+
enumerable: true,
|
|
2877
|
+
get: function () {
|
|
2878
|
+
return DescribeToolsTool;
|
|
2879
|
+
}
|
|
2880
|
+
});
|
|
2876
2881
|
Object.defineProperty(exports, 'HttpTransportHandler', {
|
|
2877
2882
|
enumerable: true,
|
|
2878
2883
|
get: function () {
|
|
@@ -2903,6 +2908,12 @@ Object.defineProperty(exports, 'StdioTransportHandler', {
|
|
|
2903
2908
|
return StdioTransportHandler;
|
|
2904
2909
|
}
|
|
2905
2910
|
});
|
|
2911
|
+
Object.defineProperty(exports, 'UseToolTool', {
|
|
2912
|
+
enumerable: true,
|
|
2913
|
+
get: function () {
|
|
2914
|
+
return UseToolTool;
|
|
2915
|
+
}
|
|
2916
|
+
});
|
|
2906
2917
|
Object.defineProperty(exports, '__toESM', {
|
|
2907
2918
|
enumerable: true,
|
|
2908
2919
|
get: function () {
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
|
-
const require_http = require('./http-
|
|
1
|
+
const require_http = require('./http-CKXz9Gp8.cjs');
|
|
2
2
|
|
|
3
|
+
exports.ConfigFetcherService = require_http.ConfigFetcherService;
|
|
4
|
+
exports.DescribeToolsTool = require_http.DescribeToolsTool;
|
|
3
5
|
exports.HttpTransportHandler = require_http.HttpTransportHandler;
|
|
6
|
+
exports.McpClientManagerService = require_http.McpClientManagerService;
|
|
7
|
+
exports.SkillService = require_http.SkillService;
|
|
4
8
|
exports.SseTransportHandler = require_http.SseTransportHandler;
|
|
5
9
|
exports.StdioTransportHandler = require_http.StdioTransportHandler;
|
|
10
|
+
exports.UseToolTool = require_http.UseToolTool;
|
|
6
11
|
exports.createServer = require_http.createServer;
|
package/dist/index.d.cts
CHANGED
|
@@ -341,4 +341,455 @@ declare class HttpTransportHandler implements HttpTransportHandler$1 {
|
|
|
341
341
|
getHost(): string;
|
|
342
342
|
}
|
|
343
343
|
//#endregion
|
|
344
|
-
|
|
344
|
+
//#region src/services/McpClientManagerService.d.ts
|
|
345
|
+
/**
|
|
346
|
+
* Service for managing MCP client connections to remote servers
|
|
347
|
+
*/
|
|
348
|
+
declare class McpClientManagerService {
|
|
349
|
+
private clients;
|
|
350
|
+
constructor();
|
|
351
|
+
/**
|
|
352
|
+
* Cleanup all resources on exit (child processes)
|
|
353
|
+
*/
|
|
354
|
+
private cleanupOnExit;
|
|
355
|
+
/**
|
|
356
|
+
* Connect to an MCP server based on its configuration with timeout
|
|
357
|
+
* Uses the timeout from server config, falling back to default (30s)
|
|
358
|
+
*/
|
|
359
|
+
connectToServer(serverName: string, config: McpServerConfig): Promise<void>;
|
|
360
|
+
/**
|
|
361
|
+
* Perform the actual connection to MCP server
|
|
362
|
+
*/
|
|
363
|
+
private performConnection;
|
|
364
|
+
private connectStdioClient;
|
|
365
|
+
private connectHttpClient;
|
|
366
|
+
private connectSseClient;
|
|
367
|
+
/**
|
|
368
|
+
* Get a connected client by server name
|
|
369
|
+
*/
|
|
370
|
+
getClient(serverName: string): McpClientConnection | undefined;
|
|
371
|
+
/**
|
|
372
|
+
* Get all connected clients
|
|
373
|
+
*/
|
|
374
|
+
getAllClients(): McpClientConnection[];
|
|
375
|
+
/**
|
|
376
|
+
* Disconnect from a specific server
|
|
377
|
+
*/
|
|
378
|
+
disconnectServer(serverName: string): Promise<void>;
|
|
379
|
+
/**
|
|
380
|
+
* Disconnect from all servers
|
|
381
|
+
*/
|
|
382
|
+
disconnectAll(): Promise<void>;
|
|
383
|
+
/**
|
|
384
|
+
* Check if a server is connected
|
|
385
|
+
*/
|
|
386
|
+
isConnected(serverName: string): boolean;
|
|
387
|
+
}
|
|
388
|
+
//#endregion
|
|
389
|
+
//#region src/services/SkillService.d.ts
|
|
390
|
+
/**
|
|
391
|
+
* Service for loading and managing skills from configured skill directories.
|
|
392
|
+
*
|
|
393
|
+
* Skills are markdown files with YAML frontmatter that can be invoked via
|
|
394
|
+
* the skill__ prefix in describe_tools and use_tool.
|
|
395
|
+
*
|
|
396
|
+
* Skills are only enabled when explicitly configured via the `skills.paths` array
|
|
397
|
+
* in the MCP config.
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
* // Config with skills enabled:
|
|
401
|
+
* // skills:
|
|
402
|
+
* // paths:
|
|
403
|
+
* // - ".claude/skills"
|
|
404
|
+
* // - "/absolute/path/to/skills"
|
|
405
|
+
*
|
|
406
|
+
* const skillService = new SkillService('/project/root', ['.claude/skills']);
|
|
407
|
+
* const skills = await skillService.getSkills();
|
|
408
|
+
*/
|
|
409
|
+
declare class SkillService {
|
|
410
|
+
private cwd;
|
|
411
|
+
private skillPaths;
|
|
412
|
+
private cachedSkills;
|
|
413
|
+
private skillsByName;
|
|
414
|
+
/** Active file watchers for skill directories */
|
|
415
|
+
private watchers;
|
|
416
|
+
/** Callback invoked when cache is invalidated due to file changes */
|
|
417
|
+
private onCacheInvalidated?;
|
|
418
|
+
/**
|
|
419
|
+
* Creates a new SkillService instance
|
|
420
|
+
* @param cwd - Current working directory for resolving relative paths
|
|
421
|
+
* @param skillPaths - Array of paths to skills directories
|
|
422
|
+
* @param options - Optional configuration
|
|
423
|
+
* @param options.onCacheInvalidated - Callback invoked when cache is invalidated due to file changes
|
|
424
|
+
*/
|
|
425
|
+
constructor(cwd: string, skillPaths: string[], options?: {
|
|
426
|
+
onCacheInvalidated?: () => void;
|
|
427
|
+
});
|
|
428
|
+
/**
|
|
429
|
+
* Get all available skills from configured directories.
|
|
430
|
+
* Results are cached after first load.
|
|
431
|
+
*
|
|
432
|
+
* Skills from earlier entries in the config take precedence over
|
|
433
|
+
* skills with the same name from later entries.
|
|
434
|
+
*
|
|
435
|
+
* @returns Array of loaded skills
|
|
436
|
+
* @throws SkillLoadError if a critical error occurs during loading
|
|
437
|
+
*/
|
|
438
|
+
getSkills(): Promise<Skill[]>;
|
|
439
|
+
/**
|
|
440
|
+
* Get a specific skill by name with O(1) lookup from cache.
|
|
441
|
+
* @param name - The skill name (without skill__ prefix)
|
|
442
|
+
* @returns The skill if found, undefined otherwise
|
|
443
|
+
*/
|
|
444
|
+
getSkill(name: string): Promise<Skill | undefined>;
|
|
445
|
+
/**
|
|
446
|
+
* Clears the cached skills to force a fresh reload on the next getSkills() or getSkill() call.
|
|
447
|
+
* Use this when skill files have been modified on disk.
|
|
448
|
+
*/
|
|
449
|
+
clearCache(): void;
|
|
450
|
+
/**
|
|
451
|
+
* Starts watching skill directories for changes to SKILL.md files.
|
|
452
|
+
* When changes are detected, the cache is automatically invalidated.
|
|
453
|
+
*
|
|
454
|
+
* Uses Node.js fs.watch with recursive option for efficient directory monitoring.
|
|
455
|
+
* Only invalidates cache when SKILL.md files are modified.
|
|
456
|
+
*
|
|
457
|
+
* @example
|
|
458
|
+
* const skillService = new SkillService(cwd, skillPaths, {
|
|
459
|
+
* onCacheInvalidated: () => console.log('Skills cache invalidated')
|
|
460
|
+
* });
|
|
461
|
+
* await skillService.startWatching();
|
|
462
|
+
*/
|
|
463
|
+
startWatching(): Promise<void>;
|
|
464
|
+
/**
|
|
465
|
+
* Stops all active file watchers.
|
|
466
|
+
* Should be called when the service is being disposed.
|
|
467
|
+
*/
|
|
468
|
+
stopWatching(): void;
|
|
469
|
+
/**
|
|
470
|
+
* Watches a directory for changes to SKILL.md files.
|
|
471
|
+
* @param dirPath - Directory path to watch
|
|
472
|
+
* @param signal - AbortSignal to stop watching
|
|
473
|
+
*/
|
|
474
|
+
private watchDirectory;
|
|
475
|
+
/**
|
|
476
|
+
* Load skills from a directory.
|
|
477
|
+
* Supports both flat structure (SKILL.md) and nested structure (name/SKILL.md).
|
|
478
|
+
*
|
|
479
|
+
* @param dirPath - Path to the skills directory
|
|
480
|
+
* @param location - Whether this is a 'project' or 'user' skill directory
|
|
481
|
+
* @returns Array of successfully loaded skills (skips invalid skills)
|
|
482
|
+
* @throws SkillLoadError if there's a critical I/O error
|
|
483
|
+
*
|
|
484
|
+
* @example
|
|
485
|
+
* // Load skills from project directory
|
|
486
|
+
* const skills = await this.loadSkillsFromDirectory('/path/to/.claude/skills', 'project');
|
|
487
|
+
* // Returns: [{ name: 'pdf', description: '...', location: 'project', ... }]
|
|
488
|
+
*/
|
|
489
|
+
private loadSkillsFromDirectory;
|
|
490
|
+
/**
|
|
491
|
+
* Load a single skill file and parse its frontmatter.
|
|
492
|
+
* Supports multi-line YAML values using literal (|) and folded (>) block scalars.
|
|
493
|
+
*
|
|
494
|
+
* @param filePath - Path to the SKILL.md file
|
|
495
|
+
* @param location - Whether this is a 'project' or 'user' skill
|
|
496
|
+
* @returns The loaded skill, or null if the file is invalid (missing required frontmatter)
|
|
497
|
+
* @throws SkillLoadError if there's an I/O error reading the file
|
|
498
|
+
*
|
|
499
|
+
* @example
|
|
500
|
+
* // Load a skill from a file
|
|
501
|
+
* const skill = await this.loadSkillFile('/path/to/pdf/SKILL.md', 'project');
|
|
502
|
+
* // Returns: { name: 'pdf', description: 'PDF skill', location: 'project', content: '...', basePath: '/path/to/pdf' }
|
|
503
|
+
* // Returns null if frontmatter is missing name or description
|
|
504
|
+
*/
|
|
505
|
+
private loadSkillFile;
|
|
506
|
+
}
|
|
507
|
+
//#endregion
|
|
508
|
+
//#region src/tools/DescribeToolsTool.d.ts
|
|
509
|
+
/**
|
|
510
|
+
* Input schema for the DescribeToolsTool
|
|
511
|
+
* @property toolNames - Array of tool names to get detailed information about
|
|
512
|
+
*/
|
|
513
|
+
interface DescribeToolsToolInput {
|
|
514
|
+
toolNames: string[];
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* DescribeToolsTool provides progressive disclosure of MCP tools and skills.
|
|
518
|
+
*
|
|
519
|
+
* This tool lists available tools from all connected MCP servers and skills
|
|
520
|
+
* from the configured skills directories. Users can query for specific tools
|
|
521
|
+
* or skills to get detailed input schemas and descriptions.
|
|
522
|
+
*
|
|
523
|
+
* Tool naming conventions:
|
|
524
|
+
* - Unique tools: use plain name (e.g., "browser_click")
|
|
525
|
+
* - Clashing tools: use serverName__toolName format (e.g., "playwright__click")
|
|
526
|
+
* - Skills: use skill__skillName format (e.g., "skill__pdf")
|
|
527
|
+
*
|
|
528
|
+
* @example
|
|
529
|
+
* const tool = new DescribeToolsTool(clientManager, skillService);
|
|
530
|
+
* const definition = await tool.getDefinition();
|
|
531
|
+
* const result = await tool.execute({ toolNames: ['browser_click', 'skill__pdf'] });
|
|
532
|
+
*/
|
|
533
|
+
declare class DescribeToolsTool implements Tool<DescribeToolsToolInput> {
|
|
534
|
+
static readonly TOOL_NAME = "describe_tools";
|
|
535
|
+
private clientManager;
|
|
536
|
+
private skillService;
|
|
537
|
+
private readonly liquid;
|
|
538
|
+
/** Cache for auto-detected skills from prompt front-matter */
|
|
539
|
+
private autoDetectedSkillsCache;
|
|
540
|
+
/** Unique server identifier for this one-mcp instance */
|
|
541
|
+
private serverId;
|
|
542
|
+
/**
|
|
543
|
+
* Creates a new DescribeToolsTool instance
|
|
544
|
+
* @param clientManager - The MCP client manager for accessing remote servers
|
|
545
|
+
* @param skillService - Optional skill service for loading skills
|
|
546
|
+
* @param serverId - Unique server identifier for this one-mcp instance
|
|
547
|
+
*/
|
|
548
|
+
constructor(clientManager: McpClientManagerService, skillService?: SkillService, serverId?: string);
|
|
549
|
+
/**
|
|
550
|
+
* Clears the cached auto-detected skills from prompt front-matter.
|
|
551
|
+
* Use this when prompt configurations may have changed or when
|
|
552
|
+
* the skill service cache is invalidated.
|
|
553
|
+
*/
|
|
554
|
+
clearAutoDetectedSkillsCache(): void;
|
|
555
|
+
/**
|
|
556
|
+
* Detects and caches skills from prompt front-matter across all connected MCP servers.
|
|
557
|
+
* Fetches all prompts and checks their content for YAML front-matter with name/description.
|
|
558
|
+
* Results are cached to avoid repeated fetches.
|
|
559
|
+
*
|
|
560
|
+
* Error Handling Strategy:
|
|
561
|
+
* - Errors are logged to stderr but do not fail the overall detection process
|
|
562
|
+
* - This ensures partial results are returned even if some servers/prompts fail
|
|
563
|
+
* - Common failure reasons: server temporarily unavailable, prompt requires arguments,
|
|
564
|
+
* network timeout, or server doesn't support listPrompts
|
|
565
|
+
* - Errors are prefixed with [skill-detection] for easy filtering in logs
|
|
566
|
+
*
|
|
567
|
+
* @returns Array of auto-detected skills from prompt front-matter
|
|
568
|
+
*/
|
|
569
|
+
private detectSkillsFromPromptFrontMatter;
|
|
570
|
+
/**
|
|
571
|
+
* Collects skills derived from prompt configurations across all connected MCP servers.
|
|
572
|
+
* Includes both explicitly configured prompts and auto-detected skills from front-matter.
|
|
573
|
+
*
|
|
574
|
+
* @returns Array of skill template data derived from prompts
|
|
575
|
+
*/
|
|
576
|
+
private collectPromptSkills;
|
|
577
|
+
/**
|
|
578
|
+
* Finds a prompt-based skill by name from all connected MCP servers.
|
|
579
|
+
* Searches both explicitly configured prompts and auto-detected skills from front-matter.
|
|
580
|
+
*
|
|
581
|
+
* @param skillName - The skill name to search for
|
|
582
|
+
* @returns Object with serverName, promptName, and skill config, or undefined if not found
|
|
583
|
+
*/
|
|
584
|
+
private findPromptSkill;
|
|
585
|
+
/**
|
|
586
|
+
* Retrieves skill content from a prompt-based skill configuration.
|
|
587
|
+
* Fetches the prompt from the MCP server and extracts text content.
|
|
588
|
+
* Handles both explicitly configured prompts and auto-detected skills from front-matter.
|
|
589
|
+
*
|
|
590
|
+
* @param skillName - The skill name being requested
|
|
591
|
+
* @returns SkillDescription if found and successfully fetched, undefined otherwise
|
|
592
|
+
*/
|
|
593
|
+
private getPromptSkillContent;
|
|
594
|
+
/**
|
|
595
|
+
* Builds the combined toolkit description using a single Liquid template.
|
|
596
|
+
*
|
|
597
|
+
* Collects all tools from connected MCP servers and all skills, then renders
|
|
598
|
+
* them together using the toolkit-description.liquid template.
|
|
599
|
+
*
|
|
600
|
+
* Tool names are prefixed with serverName__ when the same tool exists
|
|
601
|
+
* on multiple servers. Skill names are prefixed with skill__ when they
|
|
602
|
+
* clash with MCP tools or other skills.
|
|
603
|
+
*
|
|
604
|
+
* @returns Object with rendered description and set of all tool names
|
|
605
|
+
*/
|
|
606
|
+
private buildToolkitDescription;
|
|
607
|
+
/**
|
|
608
|
+
* Gets the tool definition including available tools and skills in a unified format.
|
|
609
|
+
*
|
|
610
|
+
* The definition includes:
|
|
611
|
+
* - All MCP tools from connected servers
|
|
612
|
+
* - All available skills (file-based and prompt-based)
|
|
613
|
+
* - Unified instructions for querying capability details
|
|
614
|
+
*
|
|
615
|
+
* Tool names are prefixed with serverName__ when clashing.
|
|
616
|
+
* Skill names are prefixed with skill__ when clashing.
|
|
617
|
+
*
|
|
618
|
+
* @returns Tool definition with description and input schema
|
|
619
|
+
*/
|
|
620
|
+
getDefinition(): Promise<ToolDefinition>;
|
|
621
|
+
/**
|
|
622
|
+
* Executes tool description lookup for the requested tool and skill names.
|
|
623
|
+
*
|
|
624
|
+
* Handles three types of lookups:
|
|
625
|
+
* 1. skill__name - Returns skill information from SkillService
|
|
626
|
+
* 2. serverName__toolName - Returns tool from specific server
|
|
627
|
+
* 3. plainToolName - Returns tool(s) from all servers (multiple if clashing)
|
|
628
|
+
*
|
|
629
|
+
* @param input - Object containing toolNames array
|
|
630
|
+
* @returns CallToolResult with tool/skill descriptions or error
|
|
631
|
+
*/
|
|
632
|
+
execute(input: DescribeToolsToolInput): Promise<CallToolResult>;
|
|
633
|
+
}
|
|
634
|
+
//#endregion
|
|
635
|
+
//#region src/tools/UseToolTool.d.ts
|
|
636
|
+
/**
|
|
637
|
+
* Input schema for UseToolTool
|
|
638
|
+
* @property toolName - Name of the tool or skill to execute
|
|
639
|
+
* @property toolArgs - Arguments to pass to the tool (from describe_tools schema)
|
|
640
|
+
*/
|
|
641
|
+
interface UseToolToolInput {
|
|
642
|
+
toolName: string;
|
|
643
|
+
toolArgs?: Record<string, unknown>;
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
646
|
+
* UseToolTool executes MCP tools and skills with proper error handling.
|
|
647
|
+
*
|
|
648
|
+
* This tool supports three invocation patterns:
|
|
649
|
+
* 1. skill__skillName - Invokes a skill from the configured skills directory
|
|
650
|
+
* 2. serverName__toolName - Invokes a tool on a specific MCP server
|
|
651
|
+
* 3. plainToolName - Searches all servers for a unique tool match
|
|
652
|
+
*
|
|
653
|
+
* @example
|
|
654
|
+
* const tool = new UseToolTool(clientManager, skillService);
|
|
655
|
+
* await tool.execute({ toolName: 'skill__pdf' }); // Invoke a skill
|
|
656
|
+
* await tool.execute({ toolName: 'playwright__browser_click', toolArgs: { ref: 'btn' } });
|
|
657
|
+
*/
|
|
658
|
+
declare class UseToolTool implements Tool<UseToolToolInput> {
|
|
659
|
+
static readonly TOOL_NAME = "use_tool";
|
|
660
|
+
private clientManager;
|
|
661
|
+
private skillService;
|
|
662
|
+
/** Unique server identifier for this one-mcp instance */
|
|
663
|
+
private serverId;
|
|
664
|
+
/**
|
|
665
|
+
* Creates a new UseToolTool instance
|
|
666
|
+
* @param clientManager - The MCP client manager for accessing remote servers
|
|
667
|
+
* @param skillService - Optional skill service for loading and executing skills
|
|
668
|
+
* @param serverId - Unique server identifier for this one-mcp instance
|
|
669
|
+
*/
|
|
670
|
+
constructor(clientManager: McpClientManagerService, skillService?: SkillService, serverId?: string);
|
|
671
|
+
/**
|
|
672
|
+
* Returns the MCP tool definition with name, description, and input schema.
|
|
673
|
+
*
|
|
674
|
+
* The definition describes how to use this tool to execute MCP tools or skills,
|
|
675
|
+
* including the skill__ prefix format for skill invocations.
|
|
676
|
+
*
|
|
677
|
+
* @returns The tool definition conforming to MCP spec
|
|
678
|
+
*/
|
|
679
|
+
getDefinition(): ToolDefinition;
|
|
680
|
+
/**
|
|
681
|
+
* Returns guidance message for skill invocation.
|
|
682
|
+
*
|
|
683
|
+
* Skills are not executed via use_tool - they provide instructions that should
|
|
684
|
+
* be followed directly. This method returns a message directing users to use
|
|
685
|
+
* describe_tools to get the skill details and follow its instructions.
|
|
686
|
+
*
|
|
687
|
+
* @param skill - The skill that was requested
|
|
688
|
+
* @returns CallToolResult with guidance message
|
|
689
|
+
*/
|
|
690
|
+
private executeSkill;
|
|
691
|
+
/**
|
|
692
|
+
* Finds a prompt-based skill by name from all connected MCP servers.
|
|
693
|
+
*
|
|
694
|
+
* @param skillName - The skill name to search for
|
|
695
|
+
* @returns PromptSkillMatch if found, undefined otherwise
|
|
696
|
+
*/
|
|
697
|
+
private findPromptSkill;
|
|
698
|
+
/**
|
|
699
|
+
* Returns guidance message for prompt-based skill invocation.
|
|
700
|
+
*
|
|
701
|
+
* @param promptSkill - The prompt skill match that was found
|
|
702
|
+
* @returns CallToolResult with guidance message
|
|
703
|
+
*/
|
|
704
|
+
private executePromptSkill;
|
|
705
|
+
/**
|
|
706
|
+
* Executes a tool or skill based on the provided input.
|
|
707
|
+
*
|
|
708
|
+
* Handles three invocation patterns:
|
|
709
|
+
* 1. skill__skillName - Routes to skill execution via SkillService
|
|
710
|
+
* 2. serverName__toolName - Routes to specific MCP server
|
|
711
|
+
* 3. plainToolName - Searches all servers for unique match
|
|
712
|
+
*
|
|
713
|
+
* Edge cases:
|
|
714
|
+
* - Returns error if skill not found when using skill__ prefix
|
|
715
|
+
* - Returns error if tool is blacklisted on target server
|
|
716
|
+
* - Returns disambiguation message if tool exists on multiple servers
|
|
717
|
+
*
|
|
718
|
+
* @param input - The tool/skill name and optional arguments
|
|
719
|
+
* @returns CallToolResult with execution output or error
|
|
720
|
+
*/
|
|
721
|
+
execute(input: UseToolToolInput): Promise<CallToolResult>;
|
|
722
|
+
}
|
|
723
|
+
//#endregion
|
|
724
|
+
//#region src/services/ConfigFetcherService.d.ts
|
|
725
|
+
interface ConfigFetcherOptions {
|
|
726
|
+
configFilePath?: string;
|
|
727
|
+
cacheTtlMs?: number;
|
|
728
|
+
useCache?: boolean;
|
|
729
|
+
remoteCacheTtlMs?: number;
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* Service for fetching and caching MCP server configurations from local file and remote sources
|
|
733
|
+
* Supports merging multiple remote configs with local config
|
|
734
|
+
*/
|
|
735
|
+
declare class ConfigFetcherService {
|
|
736
|
+
private configFilePath?;
|
|
737
|
+
private cacheTtlMs;
|
|
738
|
+
private cachedConfig;
|
|
739
|
+
private lastFetchTime;
|
|
740
|
+
private remoteConfigCache;
|
|
741
|
+
constructor(options: ConfigFetcherOptions);
|
|
742
|
+
/**
|
|
743
|
+
* Fetch MCP configuration from local file and remote sources with caching
|
|
744
|
+
* Merges remote configs with local config based on merge strategy
|
|
745
|
+
* @param forceRefresh - Force reload from source, bypassing cache
|
|
746
|
+
*/
|
|
747
|
+
fetchConfiguration(forceRefresh?: boolean): Promise<RemoteMcpConfiguration>;
|
|
748
|
+
/**
|
|
749
|
+
* Load raw configuration data from a local file (supports JSON and YAML)
|
|
750
|
+
* Returns unparsed config data to allow access to remoteConfigs
|
|
751
|
+
*/
|
|
752
|
+
private loadRawConfigFromFile;
|
|
753
|
+
/**
|
|
754
|
+
* Parse raw config data using Zod schema
|
|
755
|
+
* Filters out remoteConfigs to avoid including them in the final config
|
|
756
|
+
*/
|
|
757
|
+
private parseConfig;
|
|
758
|
+
/**
|
|
759
|
+
* Load configuration from a remote URL with caching
|
|
760
|
+
*
|
|
761
|
+
* SECURITY NOTE: This method fetches remote configs based on URLs from the local config file.
|
|
762
|
+
* This is intentional and safe because:
|
|
763
|
+
* 1. URLs are user-controlled via their local config file (not external input)
|
|
764
|
+
* 2. SSRF protection validates URLs before fetching (blocks private IPs, enforces HTTPS)
|
|
765
|
+
* 3. Users explicitly opt-in to remote configs in their local configuration
|
|
766
|
+
* 4. This enables centralized config management (intended feature, not a vulnerability)
|
|
767
|
+
*
|
|
768
|
+
* CodeQL alert "file-access-to-http" is a false positive here - we're not leaking
|
|
769
|
+
* file contents to arbitrary URLs, we're fetching configs from user-specified sources.
|
|
770
|
+
*/
|
|
771
|
+
private loadFromUrl;
|
|
772
|
+
/**
|
|
773
|
+
* Interpolate environment variables in a string
|
|
774
|
+
* Supports ${VAR_NAME} syntax
|
|
775
|
+
*/
|
|
776
|
+
private interpolateEnvVars;
|
|
777
|
+
/**
|
|
778
|
+
* Merge two MCP configurations based on the specified merge strategy
|
|
779
|
+
* @param localConfig Configuration loaded from local file
|
|
780
|
+
* @param remoteConfig Configuration loaded from remote URL
|
|
781
|
+
* @param mergeStrategy Strategy for merging configs
|
|
782
|
+
* @returns Merged configuration
|
|
783
|
+
*/
|
|
784
|
+
private mergeConfigurations;
|
|
785
|
+
/**
|
|
786
|
+
* Clear the cached configuration
|
|
787
|
+
*/
|
|
788
|
+
clearCache(): void;
|
|
789
|
+
/**
|
|
790
|
+
* Check if cache is valid
|
|
791
|
+
*/
|
|
792
|
+
isCacheValid(): boolean;
|
|
793
|
+
}
|
|
794
|
+
//#endregion
|
|
795
|
+
export { ConfigFetcherService, DescribeToolsTool, HttpTransportHandler, McpClientConnection, McpClientManagerService, McpHttpConfig, McpPromptInfo, McpResourceInfo, McpServerConfig, McpServerTransportConfig, McpServerTransportType, McpSseConfig, McpStdioConfig, McpToolInfo, PromptConfig, PromptSkillConfig, RemoteMcpConfiguration, type ServerOptions, Skill, SkillMetadata, SkillService, SkillsConfig, SseTransportHandler, StdioTransportHandler, TRANSPORT_MODE, Tool, ToolDefinition, TransportConfig, TransportHandler, TransportMode, UseToolTool, createServer };
|
package/dist/index.d.mts
CHANGED
|
@@ -341,4 +341,455 @@ declare class HttpTransportHandler implements HttpTransportHandler$1 {
|
|
|
341
341
|
getHost(): string;
|
|
342
342
|
}
|
|
343
343
|
//#endregion
|
|
344
|
-
|
|
344
|
+
//#region src/services/McpClientManagerService.d.ts
|
|
345
|
+
/**
|
|
346
|
+
* Service for managing MCP client connections to remote servers
|
|
347
|
+
*/
|
|
348
|
+
declare class McpClientManagerService {
|
|
349
|
+
private clients;
|
|
350
|
+
constructor();
|
|
351
|
+
/**
|
|
352
|
+
* Cleanup all resources on exit (child processes)
|
|
353
|
+
*/
|
|
354
|
+
private cleanupOnExit;
|
|
355
|
+
/**
|
|
356
|
+
* Connect to an MCP server based on its configuration with timeout
|
|
357
|
+
* Uses the timeout from server config, falling back to default (30s)
|
|
358
|
+
*/
|
|
359
|
+
connectToServer(serverName: string, config: McpServerConfig): Promise<void>;
|
|
360
|
+
/**
|
|
361
|
+
* Perform the actual connection to MCP server
|
|
362
|
+
*/
|
|
363
|
+
private performConnection;
|
|
364
|
+
private connectStdioClient;
|
|
365
|
+
private connectHttpClient;
|
|
366
|
+
private connectSseClient;
|
|
367
|
+
/**
|
|
368
|
+
* Get a connected client by server name
|
|
369
|
+
*/
|
|
370
|
+
getClient(serverName: string): McpClientConnection | undefined;
|
|
371
|
+
/**
|
|
372
|
+
* Get all connected clients
|
|
373
|
+
*/
|
|
374
|
+
getAllClients(): McpClientConnection[];
|
|
375
|
+
/**
|
|
376
|
+
* Disconnect from a specific server
|
|
377
|
+
*/
|
|
378
|
+
disconnectServer(serverName: string): Promise<void>;
|
|
379
|
+
/**
|
|
380
|
+
* Disconnect from all servers
|
|
381
|
+
*/
|
|
382
|
+
disconnectAll(): Promise<void>;
|
|
383
|
+
/**
|
|
384
|
+
* Check if a server is connected
|
|
385
|
+
*/
|
|
386
|
+
isConnected(serverName: string): boolean;
|
|
387
|
+
}
|
|
388
|
+
//#endregion
|
|
389
|
+
//#region src/services/SkillService.d.ts
|
|
390
|
+
/**
|
|
391
|
+
* Service for loading and managing skills from configured skill directories.
|
|
392
|
+
*
|
|
393
|
+
* Skills are markdown files with YAML frontmatter that can be invoked via
|
|
394
|
+
* the skill__ prefix in describe_tools and use_tool.
|
|
395
|
+
*
|
|
396
|
+
* Skills are only enabled when explicitly configured via the `skills.paths` array
|
|
397
|
+
* in the MCP config.
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
* // Config with skills enabled:
|
|
401
|
+
* // skills:
|
|
402
|
+
* // paths:
|
|
403
|
+
* // - ".claude/skills"
|
|
404
|
+
* // - "/absolute/path/to/skills"
|
|
405
|
+
*
|
|
406
|
+
* const skillService = new SkillService('/project/root', ['.claude/skills']);
|
|
407
|
+
* const skills = await skillService.getSkills();
|
|
408
|
+
*/
|
|
409
|
+
declare class SkillService {
|
|
410
|
+
private cwd;
|
|
411
|
+
private skillPaths;
|
|
412
|
+
private cachedSkills;
|
|
413
|
+
private skillsByName;
|
|
414
|
+
/** Active file watchers for skill directories */
|
|
415
|
+
private watchers;
|
|
416
|
+
/** Callback invoked when cache is invalidated due to file changes */
|
|
417
|
+
private onCacheInvalidated?;
|
|
418
|
+
/**
|
|
419
|
+
* Creates a new SkillService instance
|
|
420
|
+
* @param cwd - Current working directory for resolving relative paths
|
|
421
|
+
* @param skillPaths - Array of paths to skills directories
|
|
422
|
+
* @param options - Optional configuration
|
|
423
|
+
* @param options.onCacheInvalidated - Callback invoked when cache is invalidated due to file changes
|
|
424
|
+
*/
|
|
425
|
+
constructor(cwd: string, skillPaths: string[], options?: {
|
|
426
|
+
onCacheInvalidated?: () => void;
|
|
427
|
+
});
|
|
428
|
+
/**
|
|
429
|
+
* Get all available skills from configured directories.
|
|
430
|
+
* Results are cached after first load.
|
|
431
|
+
*
|
|
432
|
+
* Skills from earlier entries in the config take precedence over
|
|
433
|
+
* skills with the same name from later entries.
|
|
434
|
+
*
|
|
435
|
+
* @returns Array of loaded skills
|
|
436
|
+
* @throws SkillLoadError if a critical error occurs during loading
|
|
437
|
+
*/
|
|
438
|
+
getSkills(): Promise<Skill[]>;
|
|
439
|
+
/**
|
|
440
|
+
* Get a specific skill by name with O(1) lookup from cache.
|
|
441
|
+
* @param name - The skill name (without skill__ prefix)
|
|
442
|
+
* @returns The skill if found, undefined otherwise
|
|
443
|
+
*/
|
|
444
|
+
getSkill(name: string): Promise<Skill | undefined>;
|
|
445
|
+
/**
|
|
446
|
+
* Clears the cached skills to force a fresh reload on the next getSkills() or getSkill() call.
|
|
447
|
+
* Use this when skill files have been modified on disk.
|
|
448
|
+
*/
|
|
449
|
+
clearCache(): void;
|
|
450
|
+
/**
|
|
451
|
+
* Starts watching skill directories for changes to SKILL.md files.
|
|
452
|
+
* When changes are detected, the cache is automatically invalidated.
|
|
453
|
+
*
|
|
454
|
+
* Uses Node.js fs.watch with recursive option for efficient directory monitoring.
|
|
455
|
+
* Only invalidates cache when SKILL.md files are modified.
|
|
456
|
+
*
|
|
457
|
+
* @example
|
|
458
|
+
* const skillService = new SkillService(cwd, skillPaths, {
|
|
459
|
+
* onCacheInvalidated: () => console.log('Skills cache invalidated')
|
|
460
|
+
* });
|
|
461
|
+
* await skillService.startWatching();
|
|
462
|
+
*/
|
|
463
|
+
startWatching(): Promise<void>;
|
|
464
|
+
/**
|
|
465
|
+
* Stops all active file watchers.
|
|
466
|
+
* Should be called when the service is being disposed.
|
|
467
|
+
*/
|
|
468
|
+
stopWatching(): void;
|
|
469
|
+
/**
|
|
470
|
+
* Watches a directory for changes to SKILL.md files.
|
|
471
|
+
* @param dirPath - Directory path to watch
|
|
472
|
+
* @param signal - AbortSignal to stop watching
|
|
473
|
+
*/
|
|
474
|
+
private watchDirectory;
|
|
475
|
+
/**
|
|
476
|
+
* Load skills from a directory.
|
|
477
|
+
* Supports both flat structure (SKILL.md) and nested structure (name/SKILL.md).
|
|
478
|
+
*
|
|
479
|
+
* @param dirPath - Path to the skills directory
|
|
480
|
+
* @param location - Whether this is a 'project' or 'user' skill directory
|
|
481
|
+
* @returns Array of successfully loaded skills (skips invalid skills)
|
|
482
|
+
* @throws SkillLoadError if there's a critical I/O error
|
|
483
|
+
*
|
|
484
|
+
* @example
|
|
485
|
+
* // Load skills from project directory
|
|
486
|
+
* const skills = await this.loadSkillsFromDirectory('/path/to/.claude/skills', 'project');
|
|
487
|
+
* // Returns: [{ name: 'pdf', description: '...', location: 'project', ... }]
|
|
488
|
+
*/
|
|
489
|
+
private loadSkillsFromDirectory;
|
|
490
|
+
/**
|
|
491
|
+
* Load a single skill file and parse its frontmatter.
|
|
492
|
+
* Supports multi-line YAML values using literal (|) and folded (>) block scalars.
|
|
493
|
+
*
|
|
494
|
+
* @param filePath - Path to the SKILL.md file
|
|
495
|
+
* @param location - Whether this is a 'project' or 'user' skill
|
|
496
|
+
* @returns The loaded skill, or null if the file is invalid (missing required frontmatter)
|
|
497
|
+
* @throws SkillLoadError if there's an I/O error reading the file
|
|
498
|
+
*
|
|
499
|
+
* @example
|
|
500
|
+
* // Load a skill from a file
|
|
501
|
+
* const skill = await this.loadSkillFile('/path/to/pdf/SKILL.md', 'project');
|
|
502
|
+
* // Returns: { name: 'pdf', description: 'PDF skill', location: 'project', content: '...', basePath: '/path/to/pdf' }
|
|
503
|
+
* // Returns null if frontmatter is missing name or description
|
|
504
|
+
*/
|
|
505
|
+
private loadSkillFile;
|
|
506
|
+
}
|
|
507
|
+
//#endregion
|
|
508
|
+
//#region src/tools/DescribeToolsTool.d.ts
|
|
509
|
+
/**
|
|
510
|
+
* Input schema for the DescribeToolsTool
|
|
511
|
+
* @property toolNames - Array of tool names to get detailed information about
|
|
512
|
+
*/
|
|
513
|
+
interface DescribeToolsToolInput {
|
|
514
|
+
toolNames: string[];
|
|
515
|
+
}
|
|
516
|
+
/**
|
|
517
|
+
* DescribeToolsTool provides progressive disclosure of MCP tools and skills.
|
|
518
|
+
*
|
|
519
|
+
* This tool lists available tools from all connected MCP servers and skills
|
|
520
|
+
* from the configured skills directories. Users can query for specific tools
|
|
521
|
+
* or skills to get detailed input schemas and descriptions.
|
|
522
|
+
*
|
|
523
|
+
* Tool naming conventions:
|
|
524
|
+
* - Unique tools: use plain name (e.g., "browser_click")
|
|
525
|
+
* - Clashing tools: use serverName__toolName format (e.g., "playwright__click")
|
|
526
|
+
* - Skills: use skill__skillName format (e.g., "skill__pdf")
|
|
527
|
+
*
|
|
528
|
+
* @example
|
|
529
|
+
* const tool = new DescribeToolsTool(clientManager, skillService);
|
|
530
|
+
* const definition = await tool.getDefinition();
|
|
531
|
+
* const result = await tool.execute({ toolNames: ['browser_click', 'skill__pdf'] });
|
|
532
|
+
*/
|
|
533
|
+
declare class DescribeToolsTool implements Tool<DescribeToolsToolInput> {
|
|
534
|
+
static readonly TOOL_NAME = "describe_tools";
|
|
535
|
+
private clientManager;
|
|
536
|
+
private skillService;
|
|
537
|
+
private readonly liquid;
|
|
538
|
+
/** Cache for auto-detected skills from prompt front-matter */
|
|
539
|
+
private autoDetectedSkillsCache;
|
|
540
|
+
/** Unique server identifier for this one-mcp instance */
|
|
541
|
+
private serverId;
|
|
542
|
+
/**
|
|
543
|
+
* Creates a new DescribeToolsTool instance
|
|
544
|
+
* @param clientManager - The MCP client manager for accessing remote servers
|
|
545
|
+
* @param skillService - Optional skill service for loading skills
|
|
546
|
+
* @param serverId - Unique server identifier for this one-mcp instance
|
|
547
|
+
*/
|
|
548
|
+
constructor(clientManager: McpClientManagerService, skillService?: SkillService, serverId?: string);
|
|
549
|
+
/**
|
|
550
|
+
* Clears the cached auto-detected skills from prompt front-matter.
|
|
551
|
+
* Use this when prompt configurations may have changed or when
|
|
552
|
+
* the skill service cache is invalidated.
|
|
553
|
+
*/
|
|
554
|
+
clearAutoDetectedSkillsCache(): void;
|
|
555
|
+
/**
|
|
556
|
+
* Detects and caches skills from prompt front-matter across all connected MCP servers.
|
|
557
|
+
* Fetches all prompts and checks their content for YAML front-matter with name/description.
|
|
558
|
+
* Results are cached to avoid repeated fetches.
|
|
559
|
+
*
|
|
560
|
+
* Error Handling Strategy:
|
|
561
|
+
* - Errors are logged to stderr but do not fail the overall detection process
|
|
562
|
+
* - This ensures partial results are returned even if some servers/prompts fail
|
|
563
|
+
* - Common failure reasons: server temporarily unavailable, prompt requires arguments,
|
|
564
|
+
* network timeout, or server doesn't support listPrompts
|
|
565
|
+
* - Errors are prefixed with [skill-detection] for easy filtering in logs
|
|
566
|
+
*
|
|
567
|
+
* @returns Array of auto-detected skills from prompt front-matter
|
|
568
|
+
*/
|
|
569
|
+
private detectSkillsFromPromptFrontMatter;
|
|
570
|
+
/**
|
|
571
|
+
* Collects skills derived from prompt configurations across all connected MCP servers.
|
|
572
|
+
* Includes both explicitly configured prompts and auto-detected skills from front-matter.
|
|
573
|
+
*
|
|
574
|
+
* @returns Array of skill template data derived from prompts
|
|
575
|
+
*/
|
|
576
|
+
private collectPromptSkills;
|
|
577
|
+
/**
|
|
578
|
+
* Finds a prompt-based skill by name from all connected MCP servers.
|
|
579
|
+
* Searches both explicitly configured prompts and auto-detected skills from front-matter.
|
|
580
|
+
*
|
|
581
|
+
* @param skillName - The skill name to search for
|
|
582
|
+
* @returns Object with serverName, promptName, and skill config, or undefined if not found
|
|
583
|
+
*/
|
|
584
|
+
private findPromptSkill;
|
|
585
|
+
/**
|
|
586
|
+
* Retrieves skill content from a prompt-based skill configuration.
|
|
587
|
+
* Fetches the prompt from the MCP server and extracts text content.
|
|
588
|
+
* Handles both explicitly configured prompts and auto-detected skills from front-matter.
|
|
589
|
+
*
|
|
590
|
+
* @param skillName - The skill name being requested
|
|
591
|
+
* @returns SkillDescription if found and successfully fetched, undefined otherwise
|
|
592
|
+
*/
|
|
593
|
+
private getPromptSkillContent;
|
|
594
|
+
/**
|
|
595
|
+
* Builds the combined toolkit description using a single Liquid template.
|
|
596
|
+
*
|
|
597
|
+
* Collects all tools from connected MCP servers and all skills, then renders
|
|
598
|
+
* them together using the toolkit-description.liquid template.
|
|
599
|
+
*
|
|
600
|
+
* Tool names are prefixed with serverName__ when the same tool exists
|
|
601
|
+
* on multiple servers. Skill names are prefixed with skill__ when they
|
|
602
|
+
* clash with MCP tools or other skills.
|
|
603
|
+
*
|
|
604
|
+
* @returns Object with rendered description and set of all tool names
|
|
605
|
+
*/
|
|
606
|
+
private buildToolkitDescription;
|
|
607
|
+
/**
|
|
608
|
+
* Gets the tool definition including available tools and skills in a unified format.
|
|
609
|
+
*
|
|
610
|
+
* The definition includes:
|
|
611
|
+
* - All MCP tools from connected servers
|
|
612
|
+
* - All available skills (file-based and prompt-based)
|
|
613
|
+
* - Unified instructions for querying capability details
|
|
614
|
+
*
|
|
615
|
+
* Tool names are prefixed with serverName__ when clashing.
|
|
616
|
+
* Skill names are prefixed with skill__ when clashing.
|
|
617
|
+
*
|
|
618
|
+
* @returns Tool definition with description and input schema
|
|
619
|
+
*/
|
|
620
|
+
getDefinition(): Promise<ToolDefinition>;
|
|
621
|
+
/**
|
|
622
|
+
* Executes tool description lookup for the requested tool and skill names.
|
|
623
|
+
*
|
|
624
|
+
* Handles three types of lookups:
|
|
625
|
+
* 1. skill__name - Returns skill information from SkillService
|
|
626
|
+
* 2. serverName__toolName - Returns tool from specific server
|
|
627
|
+
* 3. plainToolName - Returns tool(s) from all servers (multiple if clashing)
|
|
628
|
+
*
|
|
629
|
+
* @param input - Object containing toolNames array
|
|
630
|
+
* @returns CallToolResult with tool/skill descriptions or error
|
|
631
|
+
*/
|
|
632
|
+
execute(input: DescribeToolsToolInput): Promise<CallToolResult>;
|
|
633
|
+
}
|
|
634
|
+
//#endregion
|
|
635
|
+
//#region src/tools/UseToolTool.d.ts
|
|
636
|
+
/**
|
|
637
|
+
* Input schema for UseToolTool
|
|
638
|
+
* @property toolName - Name of the tool or skill to execute
|
|
639
|
+
* @property toolArgs - Arguments to pass to the tool (from describe_tools schema)
|
|
640
|
+
*/
|
|
641
|
+
interface UseToolToolInput {
|
|
642
|
+
toolName: string;
|
|
643
|
+
toolArgs?: Record<string, unknown>;
|
|
644
|
+
}
|
|
645
|
+
/**
|
|
646
|
+
* UseToolTool executes MCP tools and skills with proper error handling.
|
|
647
|
+
*
|
|
648
|
+
* This tool supports three invocation patterns:
|
|
649
|
+
* 1. skill__skillName - Invokes a skill from the configured skills directory
|
|
650
|
+
* 2. serverName__toolName - Invokes a tool on a specific MCP server
|
|
651
|
+
* 3. plainToolName - Searches all servers for a unique tool match
|
|
652
|
+
*
|
|
653
|
+
* @example
|
|
654
|
+
* const tool = new UseToolTool(clientManager, skillService);
|
|
655
|
+
* await tool.execute({ toolName: 'skill__pdf' }); // Invoke a skill
|
|
656
|
+
* await tool.execute({ toolName: 'playwright__browser_click', toolArgs: { ref: 'btn' } });
|
|
657
|
+
*/
|
|
658
|
+
declare class UseToolTool implements Tool<UseToolToolInput> {
|
|
659
|
+
static readonly TOOL_NAME = "use_tool";
|
|
660
|
+
private clientManager;
|
|
661
|
+
private skillService;
|
|
662
|
+
/** Unique server identifier for this one-mcp instance */
|
|
663
|
+
private serverId;
|
|
664
|
+
/**
|
|
665
|
+
* Creates a new UseToolTool instance
|
|
666
|
+
* @param clientManager - The MCP client manager for accessing remote servers
|
|
667
|
+
* @param skillService - Optional skill service for loading and executing skills
|
|
668
|
+
* @param serverId - Unique server identifier for this one-mcp instance
|
|
669
|
+
*/
|
|
670
|
+
constructor(clientManager: McpClientManagerService, skillService?: SkillService, serverId?: string);
|
|
671
|
+
/**
|
|
672
|
+
* Returns the MCP tool definition with name, description, and input schema.
|
|
673
|
+
*
|
|
674
|
+
* The definition describes how to use this tool to execute MCP tools or skills,
|
|
675
|
+
* including the skill__ prefix format for skill invocations.
|
|
676
|
+
*
|
|
677
|
+
* @returns The tool definition conforming to MCP spec
|
|
678
|
+
*/
|
|
679
|
+
getDefinition(): ToolDefinition;
|
|
680
|
+
/**
|
|
681
|
+
* Returns guidance message for skill invocation.
|
|
682
|
+
*
|
|
683
|
+
* Skills are not executed via use_tool - they provide instructions that should
|
|
684
|
+
* be followed directly. This method returns a message directing users to use
|
|
685
|
+
* describe_tools to get the skill details and follow its instructions.
|
|
686
|
+
*
|
|
687
|
+
* @param skill - The skill that was requested
|
|
688
|
+
* @returns CallToolResult with guidance message
|
|
689
|
+
*/
|
|
690
|
+
private executeSkill;
|
|
691
|
+
/**
|
|
692
|
+
* Finds a prompt-based skill by name from all connected MCP servers.
|
|
693
|
+
*
|
|
694
|
+
* @param skillName - The skill name to search for
|
|
695
|
+
* @returns PromptSkillMatch if found, undefined otherwise
|
|
696
|
+
*/
|
|
697
|
+
private findPromptSkill;
|
|
698
|
+
/**
|
|
699
|
+
* Returns guidance message for prompt-based skill invocation.
|
|
700
|
+
*
|
|
701
|
+
* @param promptSkill - The prompt skill match that was found
|
|
702
|
+
* @returns CallToolResult with guidance message
|
|
703
|
+
*/
|
|
704
|
+
private executePromptSkill;
|
|
705
|
+
/**
|
|
706
|
+
* Executes a tool or skill based on the provided input.
|
|
707
|
+
*
|
|
708
|
+
* Handles three invocation patterns:
|
|
709
|
+
* 1. skill__skillName - Routes to skill execution via SkillService
|
|
710
|
+
* 2. serverName__toolName - Routes to specific MCP server
|
|
711
|
+
* 3. plainToolName - Searches all servers for unique match
|
|
712
|
+
*
|
|
713
|
+
* Edge cases:
|
|
714
|
+
* - Returns error if skill not found when using skill__ prefix
|
|
715
|
+
* - Returns error if tool is blacklisted on target server
|
|
716
|
+
* - Returns disambiguation message if tool exists on multiple servers
|
|
717
|
+
*
|
|
718
|
+
* @param input - The tool/skill name and optional arguments
|
|
719
|
+
* @returns CallToolResult with execution output or error
|
|
720
|
+
*/
|
|
721
|
+
execute(input: UseToolToolInput): Promise<CallToolResult>;
|
|
722
|
+
}
|
|
723
|
+
//#endregion
|
|
724
|
+
//#region src/services/ConfigFetcherService.d.ts
|
|
725
|
+
interface ConfigFetcherOptions {
|
|
726
|
+
configFilePath?: string;
|
|
727
|
+
cacheTtlMs?: number;
|
|
728
|
+
useCache?: boolean;
|
|
729
|
+
remoteCacheTtlMs?: number;
|
|
730
|
+
}
|
|
731
|
+
/**
|
|
732
|
+
* Service for fetching and caching MCP server configurations from local file and remote sources
|
|
733
|
+
* Supports merging multiple remote configs with local config
|
|
734
|
+
*/
|
|
735
|
+
declare class ConfigFetcherService {
|
|
736
|
+
private configFilePath?;
|
|
737
|
+
private cacheTtlMs;
|
|
738
|
+
private cachedConfig;
|
|
739
|
+
private lastFetchTime;
|
|
740
|
+
private remoteConfigCache;
|
|
741
|
+
constructor(options: ConfigFetcherOptions);
|
|
742
|
+
/**
|
|
743
|
+
* Fetch MCP configuration from local file and remote sources with caching
|
|
744
|
+
* Merges remote configs with local config based on merge strategy
|
|
745
|
+
* @param forceRefresh - Force reload from source, bypassing cache
|
|
746
|
+
*/
|
|
747
|
+
fetchConfiguration(forceRefresh?: boolean): Promise<RemoteMcpConfiguration>;
|
|
748
|
+
/**
|
|
749
|
+
* Load raw configuration data from a local file (supports JSON and YAML)
|
|
750
|
+
* Returns unparsed config data to allow access to remoteConfigs
|
|
751
|
+
*/
|
|
752
|
+
private loadRawConfigFromFile;
|
|
753
|
+
/**
|
|
754
|
+
* Parse raw config data using Zod schema
|
|
755
|
+
* Filters out remoteConfigs to avoid including them in the final config
|
|
756
|
+
*/
|
|
757
|
+
private parseConfig;
|
|
758
|
+
/**
|
|
759
|
+
* Load configuration from a remote URL with caching
|
|
760
|
+
*
|
|
761
|
+
* SECURITY NOTE: This method fetches remote configs based on URLs from the local config file.
|
|
762
|
+
* This is intentional and safe because:
|
|
763
|
+
* 1. URLs are user-controlled via their local config file (not external input)
|
|
764
|
+
* 2. SSRF protection validates URLs before fetching (blocks private IPs, enforces HTTPS)
|
|
765
|
+
* 3. Users explicitly opt-in to remote configs in their local configuration
|
|
766
|
+
* 4. This enables centralized config management (intended feature, not a vulnerability)
|
|
767
|
+
*
|
|
768
|
+
* CodeQL alert "file-access-to-http" is a false positive here - we're not leaking
|
|
769
|
+
* file contents to arbitrary URLs, we're fetching configs from user-specified sources.
|
|
770
|
+
*/
|
|
771
|
+
private loadFromUrl;
|
|
772
|
+
/**
|
|
773
|
+
* Interpolate environment variables in a string
|
|
774
|
+
* Supports ${VAR_NAME} syntax
|
|
775
|
+
*/
|
|
776
|
+
private interpolateEnvVars;
|
|
777
|
+
/**
|
|
778
|
+
* Merge two MCP configurations based on the specified merge strategy
|
|
779
|
+
* @param localConfig Configuration loaded from local file
|
|
780
|
+
* @param remoteConfig Configuration loaded from remote URL
|
|
781
|
+
* @param mergeStrategy Strategy for merging configs
|
|
782
|
+
* @returns Merged configuration
|
|
783
|
+
*/
|
|
784
|
+
private mergeConfigurations;
|
|
785
|
+
/**
|
|
786
|
+
* Clear the cached configuration
|
|
787
|
+
*/
|
|
788
|
+
clearCache(): void;
|
|
789
|
+
/**
|
|
790
|
+
* Check if cache is valid
|
|
791
|
+
*/
|
|
792
|
+
isCacheValid(): boolean;
|
|
793
|
+
}
|
|
794
|
+
//#endregion
|
|
795
|
+
export { ConfigFetcherService, DescribeToolsTool, HttpTransportHandler, McpClientConnection, McpClientManagerService, McpHttpConfig, McpPromptInfo, McpResourceInfo, McpServerConfig, McpServerTransportConfig, McpServerTransportType, McpSseConfig, McpStdioConfig, McpToolInfo, PromptConfig, PromptSkillConfig, RemoteMcpConfiguration, type ServerOptions, Skill, SkillMetadata, SkillService, SkillsConfig, SseTransportHandler, StdioTransportHandler, TRANSPORT_MODE, Tool, ToolDefinition, TransportConfig, TransportHandler, TransportMode, UseToolTool, createServer };
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { i as createServer, n as SseTransportHandler, r as StdioTransportHandler, t as HttpTransportHandler } from "./http-
|
|
1
|
+
import { a as UseToolTool, i as createServer, l as McpClientManagerService, n as SseTransportHandler, o as DescribeToolsTool, r as StdioTransportHandler, s as SkillService, t as HttpTransportHandler, u as ConfigFetcherService } from "./http-BzTXYfkN.mjs";
|
|
2
2
|
|
|
3
|
-
export { HttpTransportHandler, SseTransportHandler, StdioTransportHandler, createServer };
|
|
3
|
+
export { ConfigFetcherService, DescribeToolsTool, HttpTransportHandler, McpClientManagerService, SkillService, SseTransportHandler, StdioTransportHandler, UseToolTool, createServer };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agiflowai/one-mcp",
|
|
3
3
|
"description": "One MCP server package",
|
|
4
|
-
"version": "0.3.
|
|
4
|
+
"version": "0.3.7",
|
|
5
5
|
"license": "AGPL-3.0",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"mcp",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"js-yaml": "^4.1.0",
|
|
28
28
|
"liquidjs": "^10.21.0",
|
|
29
29
|
"zod": "^3.24.1",
|
|
30
|
-
"@agiflowai/aicode-utils": "1.0.
|
|
30
|
+
"@agiflowai/aicode-utils": "1.0.13"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/express": "^5.0.0",
|