@mcpc-tech/core 0.2.0-beta.10

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,217 @@
1
+ // ../__mcpc__core_0.2.0-beta.10/node_modules/@mcpc/core/src/plugins/search-tool.ts
2
+ import rg from "@mcpc-tech/ripgrep-napi";
3
+ import { tmpdir } from "node:os";
4
+ import { jsonSchema } from "ai";
5
+ import { resolve } from "node:path";
6
+ import { relative } from "node:path";
7
+ function createSearchPlugin(options = {}) {
8
+ const maxResults = options.maxResults || 20;
9
+ const maxOutputSize = options.maxOutputSize || 5e3;
10
+ const allowedSearchDir = options.allowedDir || tmpdir();
11
+ const timeoutMs = options.timeoutMs || 3e4;
12
+ const global = options.global ?? true;
13
+ return {
14
+ name: "plugin-search",
15
+ configureServer: (server) => {
16
+ server.tool(
17
+ "search-tool-result",
18
+ `Search for text patterns in files and directories. Use this to find specific content, code, or information within files. Provide a simple literal string or a regular expression. If your pattern is a regex, ensure it's valid; otherwise use quotes or escape special characters to treat it as a literal string.
19
+ Only search within the allowed directory: ${allowedSearchDir}`,
20
+ jsonSchema({
21
+ type: "object",
22
+ properties: {
23
+ pattern: {
24
+ type: "string",
25
+ description: "Text to search for. Can be a plain string or a regular expression. For regexes, don't include delimiters (e.g. use `^foo` not `/^foo/`). If you get a regex parse error, try escaping special chars or using a simpler literal search."
26
+ },
27
+ path: {
28
+ type: "string",
29
+ description: "File or folder path to limit the search (optional). Must be within the allowed directory."
30
+ },
31
+ maxResults: {
32
+ type: "number",
33
+ description: "Maximum number of matches to return (optional). Lower this to reduce output size and runtime."
34
+ }
35
+ },
36
+ required: ["pattern"]
37
+ }),
38
+ async (args) => {
39
+ const isBroad = (raw) => {
40
+ const t = (raw ?? "").trim();
41
+ if (!t) return true;
42
+ if (/^[*.\s]{2,}$/.test(t)) return true;
43
+ if (t === ".*" || t === "." || t === "^.*$") return true;
44
+ if (/^\^?\.\*\$?$/.test(t)) return true;
45
+ if (/^\\s?\*+$/.test(t)) return true;
46
+ return false;
47
+ };
48
+ const appendMatchSafely = (current, addition, limit) => {
49
+ if ((current + addition).length > limit) {
50
+ return { current, added: false };
51
+ }
52
+ return { current: current + addition, added: true };
53
+ };
54
+ try {
55
+ const requestedPath = args.path || allowedSearchDir;
56
+ const limit = args.maxResults || maxResults;
57
+ if (args.path) {
58
+ const resolvedRequested = resolve(args.path);
59
+ const resolvedAllowed = resolve(allowedSearchDir);
60
+ const relativePath = relative(resolvedAllowed, resolvedRequested);
61
+ if (relativePath && relativePath.startsWith("..")) {
62
+ return {
63
+ content: [
64
+ {
65
+ type: "text",
66
+ text: `\u274C Path "${args.path}" not allowed. Must be within: ${allowedSearchDir}`
67
+ }
68
+ ],
69
+ isError: true
70
+ };
71
+ }
72
+ }
73
+ const searchPath = requestedPath;
74
+ const rawPattern = args.pattern ?? "";
75
+ if (isBroad(rawPattern)) {
76
+ return {
77
+ content: [
78
+ {
79
+ type: "text",
80
+ text: `\u274C Search pattern too broad: "${rawPattern}"
81
+ Provide a more specific pattern (e.g. include a filename fragment, a keyword, or limit with the "path" parameter). Avoid patterns that only contain wildcards like "*" or ".*".`
82
+ }
83
+ ],
84
+ isError: true
85
+ };
86
+ }
87
+ let timeoutId;
88
+ const timeoutPromise = new Promise((_, reject) => {
89
+ timeoutId = setTimeout(() => {
90
+ reject(new Error(`Search timeout after ${timeoutMs}ms`));
91
+ }, timeoutMs);
92
+ });
93
+ console.log(`Searching for "${args.pattern}" in ${searchPath}`);
94
+ const searchPromise = new Promise((resolve2, reject) => {
95
+ try {
96
+ const result2 = rg.search(args.pattern, [searchPath]);
97
+ resolve2(result2);
98
+ } catch (error) {
99
+ reject(error);
100
+ }
101
+ });
102
+ const result = await Promise.race([
103
+ searchPromise,
104
+ timeoutPromise
105
+ ]);
106
+ if (timeoutId) clearTimeout(timeoutId);
107
+ if (!result.success || !result.matches?.length) {
108
+ return {
109
+ content: [
110
+ {
111
+ type: "text",
112
+ text: `No matches found for: "${args.pattern}"
113
+
114
+ Try:
115
+ - **Simpler pattern** or \`*\`
116
+ - Check if files exist in: ${searchPath}
117
+ - Use specific file path`
118
+ }
119
+ ]
120
+ };
121
+ }
122
+ const matches = result.matches.slice(0, limit);
123
+ let output = `Found ${result.matches.length} matches (showing up to ${matches.length}):
124
+
125
+ `;
126
+ let matchesIncluded = 0;
127
+ for (const match of matches) {
128
+ const baseMatchText = `**${match.path}:${match.lineNumber}**
129
+ `;
130
+ const fullMatchText = `${baseMatchText}\`\`\`
131
+ ${match.line}
132
+ \`\`\`
133
+
134
+ `;
135
+ const res = appendMatchSafely(
136
+ output,
137
+ fullMatchText,
138
+ maxOutputSize
139
+ );
140
+ if (!res.added) {
141
+ if (matchesIncluded === 0) {
142
+ const remainingSpace = maxOutputSize - output.length - 100;
143
+ if (remainingSpace > 50) {
144
+ const truncatedLine = match.line.slice(0, remainingSpace);
145
+ output += `${baseMatchText}\`\`\`
146
+ ${truncatedLine}...
147
+ \`\`\`
148
+
149
+ `;
150
+ output += `\u26A0\uFE0F Content truncated
151
+ `;
152
+ matchesIncluded++;
153
+ } else {
154
+ output += `\u26A0\uFE0F Content too large, use specific file path
155
+ `;
156
+ }
157
+ }
158
+ break;
159
+ }
160
+ output = res.current;
161
+ matchesIncluded++;
162
+ }
163
+ if (matchesIncluded < matches.length) {
164
+ output += `
165
+ \u26A0\uFE0F Showing ${matchesIncluded}/${matches.length} matches (size limit)
166
+ `;
167
+ output += `
168
+ For more results:
169
+ `;
170
+ output += `- Use specific pattern: "${args.pattern} keyword"
171
+ `;
172
+ output += `- Search specific file: {"pattern": "${args.pattern}", "path": "/file.txt"}
173
+ `;
174
+ output += `- Use fewer results: {"maxResults": 5}`;
175
+ }
176
+ return {
177
+ content: [
178
+ {
179
+ type: "text",
180
+ text: output
181
+ }
182
+ ]
183
+ };
184
+ } catch (error) {
185
+ const errorMsg = error instanceof Error ? error.message : String(error);
186
+ const isTimeout = errorMsg.includes("timeout");
187
+ return {
188
+ content: [
189
+ {
190
+ type: "text",
191
+ text: `Search error: ${errorMsg}
192
+
193
+ ${isTimeout ? `Timeout after ${timeoutMs}ms. Try simpler pattern or smaller directory.` : `Check pattern syntax or directory exists.`}`
194
+ }
195
+ ]
196
+ };
197
+ }
198
+ },
199
+ { internal: !global }
200
+ );
201
+ }
202
+ };
203
+ }
204
+ var defaultSearchPlugin = createSearchPlugin({
205
+ global: true,
206
+ maxResults: 20,
207
+ maxOutputSize: 5e3,
208
+ caseSensitive: false,
209
+ timeoutMs: 3e4
210
+ });
211
+ var createPlugin = createSearchPlugin;
212
+ var search_tool_default = defaultSearchPlugin;
213
+ export {
214
+ createPlugin,
215
+ createSearchPlugin,
216
+ search_tool_default as default
217
+ };
package/types/mod.d.ts ADDED
@@ -0,0 +1,54 @@
1
+ /** MCPC Core - Build agentic MCP servers by composing existing MCP tools.
2
+ *
3
+ * Create powerful AI agents by combining tools from the MCP ecosystem.
4
+ * Write a simple description, select your tools, and get a working MCP server.
5
+ *
6
+ * ```ts
7
+ * import { type ComposeDefinition, mcpc } from "@mcpc/core";
8
+ * import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
9
+ *
10
+ * // Define MCP server dependencies
11
+ * const deps: ComposeDefinition['deps'] = {
12
+ * mcpServers: {
13
+ * "desktop-commander": {
14
+ * command: "npx",
15
+ * args: ["-y", "@wonderwhy-er/desktop-commander@latest"],
16
+ * transportType: "stdio",
17
+ * }
18
+ * }
19
+ * }
20
+ *
21
+ * // Write agent description with tool references
22
+ * const description = `
23
+ * I am a coding assistant that can read files and run terminal commands.
24
+ *
25
+ * Available tools:
26
+ * <tool name="desktop-commander.exec" />
27
+ * <tool name="desktop-commander.readFile" />
28
+ * <tool name="desktop-commander.writeFile" />
29
+ * `
30
+ *
31
+ * // Create and start the server
32
+ * const server = await mcpc(
33
+ * [{ name: "coding-agent", version: "1.0.0" }],
34
+ * [{ name: 'coding-agent', description, deps }]
35
+ * )
36
+ *
37
+ * const transport = new StdioServerTransport()
38
+ * await server.connect(transport)
39
+ * ```
40
+ *
41
+ * ## Documentation
42
+ *
43
+ * - [Getting Started](https://github.com/mcpc-tech/mcpc/tree/main/docs/quickstart/installation.md)
44
+ * - [Complete Tutorial](https://github.com/mcpc-tech/mcpc/tree/main/docs/quickstart/create-your-first-agentic-mcp.md)
45
+ * - [Examples](https://github.com/mcpc-tech/mcpc/tree/main/docs/examples/)
46
+ * - [FAQ](https://github.com/mcpc-tech/mcpc/tree/main/docs/faq.md)
47
+ *
48
+ * @module
49
+ */ export * from "./src/compose.js";
50
+ export * from "./src/utils/common/env.js";
51
+ export * from "./src/utils/common/json.js";
52
+ export * from "./src/utils/common/mcp.js";
53
+ export * from "./src/set-up-mcp-compose.js";
54
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sources":["../mod.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDC,GAED,iCAAiC;AAEjC,0CAA0C;AAC1C,2CAA2C;AAC3C,0CAA0C;AAE1C,4CAA4C"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * MCPC Core Plugins
3
+ *
4
+ * Collection of built-in and utility plugins for MCPC servers.
5
+ *
6
+ * @example
7
+ * ```ts
8
+ * import { createSearchPlugin, createLargeResultPlugin } from "@mcpc/core/plugins";
9
+ *
10
+ * const server = await mcpc([...], [...]);
11
+ *
12
+ * // Add search functionality
13
+ * await server.addPlugin(createSearchPlugin({
14
+ * maxResults: 50,
15
+ * searchDir: "./workspace"
16
+ * }));
17
+ *
18
+ * // Add large result handling
19
+ * await server.addPlugin(createLargeResultPlugin({
20
+ * maxSize: 10000
21
+ * }));
22
+ * ```
23
+ *
24
+ * @example Using default plugin instances
25
+ * ```ts
26
+ * // Import individual plugins with default configurations
27
+ * import searchPlugin from "@mcpc/core/plugins/search";
28
+ * import largeResultPlugin from "@mcpc/core/plugins/large-result";
29
+ *
30
+ * const server = await mcpc([...], [...]);
31
+ *
32
+ * // Use plugins with default settings
33
+ * await server.addPlugin(searchPlugin);
34
+ * await server.addPlugin(largeResultPlugin);
35
+ * ```
36
+ *
37
+ * @module
38
+ */ export { createSearchPlugin } from "./src/plugins/search-tool.js";
39
+ export { createLargeResultPlugin } from "./src/plugins/large-result.js";
40
+ export { default as defaultSearchPlugin } from "./src/plugins/search-tool.js";
41
+ export { default as defaultLargeResultPlugin } from "./src/plugins/large-result.js";
42
+ export type { SearchOptions } from "./src/plugins/search-tool.js";
43
+ //# sourceMappingURL=plugins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugins.d.ts","sources":["../plugins.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqCC,GAGD,SAAS,kBAAkB,uCAAuC;AAClE,SAAS,uBAAuB,wCAAwC;AAGxE,SAAS,WAAW,mBAAmB,uCAAuC;AAC9E,SAAS,WAAW,wBAAwB,wCAAwC;AAGpF,cAAc,aAAa,uCAAuC"}
@@ -0,0 +1,119 @@
1
+ import { type Implementation } from "@modelcontextprotocol/sdk/types.js";
2
+ import { type Schema } from "ai";
3
+ import type { McpSettingsSchema } from "./service/tools.js";
4
+ import { Server, type ServerOptions } from "@modelcontextprotocol/sdk/server/index.js";
5
+ import type z from "zod";
6
+ import type { ComposeDefinition } from "./set-up-mcp-compose.js";
7
+ import type { JSONSchema, ToolCallback } from "./types.js";
8
+ import type { ToolConfig, ToolPlugin } from "./plugin-types.js";
9
+ export declare class ComposableMCPServer extends Server {
10
+ private tools: any;
11
+ private toolRegistry: any;
12
+ private toolConfigs: any;
13
+ private globalPlugins: any;
14
+ toolNameMapping: Map<string, string>;
15
+ constructor(_serverInfo: Implementation, options: ServerOptions);
16
+ /**
17
+ * Initialize built-in plugins - called during setup
18
+ */ initBuiltInPlugins(): Promise<void>;
19
+ private applyPluginTransforms: any;
20
+ private resolveToolName: any;
21
+ tool<T>(name: string, description: string, paramsSchema: Schema<T>, cb: (args: T, extra?: unknown) => unknown, options?: {
22
+ internal?: boolean;
23
+ plugins?: ToolPlugin[];
24
+ }): void;
25
+ /**
26
+ * Register a tool override with description, hide, args transformation, and/or custom handler
27
+ */ /**
28
+ * Get tool callback from registry
29
+ */ getToolCallback(name: string): ToolCallback | undefined;
30
+ /**
31
+ * Find tool configuration (simplified - dot/underscore mapping now handled by plugin)
32
+ */ findToolConfig(toolId: string): ToolConfig | undefined;
33
+ /**
34
+ * Call any registered tool directly, whether it's public or internal
35
+ */ callTool(name: string, args: unknown): Promise<unknown>;
36
+ /**
37
+ * Get all internal tool names
38
+ */ getInternalToolNames(): string[];
39
+ /**
40
+ * Get all public tool names
41
+ */ getPublicToolNames(): string[];
42
+ /**
43
+ * Get all external (non-global, non-internal, non-hidden) tool names
44
+ */ getExternalToolNames(): string[];
45
+ /**
46
+ * Get all hidden tool names
47
+ */ getHiddenToolNames(): string[];
48
+ /**
49
+ * Get internal tool schema by name
50
+ */ getInternalToolSchema(name: string): {
51
+ description: string;
52
+ schema: JSONSchema;
53
+ } | undefined;
54
+ /**
55
+ * Check if a tool exists (visible or internal)
56
+ */ hasToolNamed(name: string): boolean;
57
+ /**
58
+ * Configure tool behavior (simplified replacement for middleware)
59
+ * @example
60
+ * ```typescript
61
+ * // Override description
62
+ * server.configTool('myTool', {
63
+ * callback: originalCallback,
64
+ * description: 'Enhanced tool description'
65
+ * });
66
+ *
67
+ * // Hide tool from agentic execution
68
+ * server.configTool('myTool', {
69
+ * callback: originalCallback,
70
+ * description: 'Hidden tool',
71
+ * visibility: { hide: true }
72
+ * });
73
+ *
74
+ * // Make tool globally available
75
+ * server.configTool('myTool', {
76
+ * callback: originalCallback,
77
+ * description: 'Global tool',
78
+ * visibility: { global: true }
79
+ * });
80
+ * ```
81
+ */ configTool(toolName: string, config: ToolConfig): void;
82
+ /**
83
+ * Get tool configuration
84
+ */ getToolConfig(toolName: string): ToolConfig | undefined;
85
+ /**
86
+ * Remove tool configuration
87
+ */ removeToolConfig(toolName: string): boolean;
88
+ /**
89
+ * Register a tool plugin
90
+ * @example
91
+ * ```typescript
92
+ * // Global plugin for all tools
93
+ * server.addPlugin({
94
+ * name: 'logger',
95
+ * transformTool: (tool, context) => {
96
+ * const originalExecute = tool.execute;
97
+ * tool.execute = async (args, extra) => {
98
+ * console.log(`Calling ${tool.name} with:`, args);
99
+ * const result = await originalExecute(args, extra);
100
+ * console.log(`Result:`, result);
101
+ * return result;
102
+ * };
103
+ * return tool;
104
+ * }
105
+ * });
106
+ * ```
107
+ */ addPlugin(plugin: ToolPlugin): Promise<void>;
108
+ /**
109
+ * Load and register a plugin from a file path with optional parameters
110
+ *
111
+ * Supports parameter passing via query string syntax:
112
+ * loadPluginFromPath("path/to/plugin.ts?param1=value1&param2=value2")
113
+ */ loadPluginFromPath(pluginPath: string): Promise<void>;
114
+ private applyTransformToolHooks: any;
115
+ private processToolsWithPlugins: any;
116
+ private triggerComposeEndHooks: any;
117
+ compose(name: string | null, description: string, depsConfig?: z.infer<typeof McpSettingsSchema>, options?: ComposeDefinition["options"]): Promise<void>;
118
+ }
119
+ //# sourceMappingURL=compose.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compose.d.ts","sources":["../../src/compose.ts"],"names":[],"mappings":"AAAA,SAGE,KAAK,cAAc,6CAGmC;AACxD,SAAqB,KAAK,MAAM,aAAwB;AACxD,cAAc,iBAAiB,6BAA6B;AAC5D,SACE,MAAM,EACN,KAAK,aAAa,oDAC2C;AAC/D,YAAY,aAAyB;AAGrC,cAAc,iBAAiB,kCAAkC;AAEjE,cAAc,UAAU,EAAE,YAAY,qBAAqB;AAO3D,cAGE,UAAU,EACV,UAAU,4BACe;AAK3B,OAAO,cAAM,4BAA4B;EACvC,QAAQ,WAAmB;EAC3B,QAAQ,kBAOM;EACd,QAAQ,iBAAiD;EACzD,QAAQ,mBAAiC;EACzC,iBAAiB,IAAI,MAAM,EAAE,MAAM,EAAc;EAEjD,YAAY,aAAa,cAAc,EAAE,SAAS,aAAa;EAI/D;;GAEC,GACD,AAAM,sBAAsB,QAAQ,IAAI;UAYhC;UAcA;EAwBR,KAAK,GACH,MAAM,MAAM,EACZ,aAAa,MAAM,EACnB,cAAc,OAAO,EAAE,EACvB,KAAK,MAAM,GAAG,QAAQ,OAAO,KAAK,OAAO,EACzC;IAAW,WAAW,OAAO;IAAE,UAAU;GAAmB;EAuD9D;;GAEC,GACD;;GAEC,GACD,gBAAgB,MAAM,MAAM,GAAG,eAAe,SAAS;EAIvD;;GAEC,GACD,eAAe,QAAQ,MAAM,GAAG,aAAa,SAAS;EActD;;GAEC,GACD,AAAM,SAAS,MAAM,MAAM,EAAE,MAAM,OAAO,GAAG,QAAQ,OAAO;EAoB5D;;GAEC,GACD,wBAAwB,MAAM;EAM9B;;GAEC,GACD,sBAAsB,MAAM;EAM5B;;GAEC,GACD,wBAAwB,MAAM;EAW9B;;GAEC,GACD,sBAAsB,MAAM;EAM5B;;GAEC,GACD,sBACE,MAAM,MAAM;IACT,aAAa,MAAM;IAAE,QAAQ;MAAe,SAAS;EAY1D;;GAEC,GACD,aAAa,MAAM,MAAM,GAAG,OAAO;EAQnC;;;;;;;;;;;;;;;;;;;;;;;;GAwBC,GACD,WAAW,UAAU,MAAM,EAAE,QAAQ,UAAU,GAAG,IAAI;EAItD;;GAEC,GACD,cAAc,UAAU,MAAM,GAAG,aAAa,SAAS;EAIvD;;GAEC,GACD,iBAAiB,UAAU,MAAM,GAAG,OAAO;EAI3C;;;;;;;;;;;;;;;;;;;GAmBC,GACD,AAAM,UAAU,QAAQ,UAAU,GAAG,QAAQ,IAAI;EASjD;;;;;GAKC,GACD,AAAM,mBAAmB,YAAY,MAAM,GAAG,QAAQ,IAAI;UAQ5C;UAyCA;UAuDA;EAcR,QACJ,MAAM,MAAM,GAAG,IAAI,EACnB,aAAa,MAAM,EACnB,aAAY,EAAE,aAAa,kBAAuC,EAClE,UAAS,kBAAkB,UAAgC;AA2R/D"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Plugin system types for MCP server composition
3
+ * Inspired by Vite's plugin system but adapted for MCP composition
4
+ */ import type { Tool } from "@modelcontextprotocol/sdk/types.js";
5
+ import type { ToolCallback } from "./types.js";
6
+ import type { ComposableMCPServer } from "./compose.js";
7
+ export interface ComposedTool extends Tool {
8
+ execute: ToolCallback;
9
+ }
10
+ export interface ToolPlugin {
11
+ /** Plugin name for identification */ name: string;
12
+ /** Plugin execution order - 'pre' (before core), 'post' (after core), or default */ enforce?: "pre" | "post";
13
+ /** Apply plugin conditionally based on mode */ apply?: "agentic" | "workflow" | ((mode: string) => boolean);
14
+ /** Called when plugin is added to server - for initial setup */ configureServer?: (server: ComposableMCPServer) => void | Promise<void>;
15
+ /** Called before composition starts - for validation and config */ composeStart?: (context: ComposeStartContext) => void | Promise<void>;
16
+ /** Called for each tool during composition - main transformation hook */ transformTool?: (tool: ComposedTool, context: TransformContext) => ComposedTool | void | Promise<ComposedTool | void>;
17
+ /** Called after all tools are composed but before registration */ finalizeComposition?: (tools: Record<string, ComposedTool>, context: FinalizeContext) => void | Promise<void>;
18
+ /** Called after composition is complete - for logging and cleanup */ composeEnd?: (result: ComposeEndContext) => void | Promise<void>;
19
+ }
20
+ /** Context for composeStart hook */ export interface ComposeStartContext {
21
+ serverName: string;
22
+ description: string;
23
+ mode: "agentic" | "agentic_workflow";
24
+ server: any;
25
+ }
26
+ /** Context for transformTool hook */ export interface TransformContext {
27
+ toolName: string;
28
+ server: any;
29
+ mode: "agentic" | "agentic_workflow";
30
+ }
31
+ /** Context for finalizeComposition hook */ export interface FinalizeContext {
32
+ serverName: string;
33
+ mode: "agentic" | "agentic_workflow";
34
+ server: any;
35
+ }
36
+ /** Context for composeEnd hook */ export interface ComposeEndContext {
37
+ toolName: string | null;
38
+ pluginNames: string[];
39
+ mode: "agentic" | "agentic_workflow";
40
+ server: any;
41
+ }
42
+ export interface ToolConfig {
43
+ /** Override the tool's description */ description?: string;
44
+ /** Tool visibility and access settings */ visibility?: {
45
+ /** Hide the tool from composed tools context */ hide?: boolean;
46
+ /** Register the tool as a global tool in the server's public tool list */ global?: boolean;
47
+ /** Internal tool - not visible in public list but accessible via callTool */ internal?: boolean;
48
+ };
49
+ }
50
+ //# sourceMappingURL=plugin-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin-types.d.ts","sources":["../../src/plugin-types.ts"],"names":[],"mappings":"AAAA;;;CAGC,GAED,cAAc,IAAI,6CAAyD;AAC3E,cAAc,YAAY,qBAAqB;AAC/C,cAAc,mBAAmB,uBAAuB;AAExD,iBAAiB,qBAAqB;EACpC,SAAS;;AAKX,iBAAiB;EACf,mCAAmC,GACnC,MAAM,MAAM;EAEZ,kFAAkF,GAClF,UAAU,QAAQ;EAElB,6CAA6C,GAC7C,QAAQ,YAAY,eAAe,MAAM,MAAM,KAAK,OAAO;EAI3D,8DAA8D,GAC9D,mBAAmB,QAAQ,wBAAwB,IAAI,GAAG,QAAQ,IAAI;EAEtE,iEAAiE,GACjE,gBAAgB,SAAS,wBAAwB,IAAI,GAAG,QAAQ,IAAI;EAEpE,uEAAuE,GACvE,iBACE,MAAM,cACN,SAAS,qBACN,eAAe,IAAI,GAAG,QAAQ,eAAe,IAAI;EAEtD,gEAAgE,GAChE,uBACE,OAAO,OAAO,MAAM,EAAE,eACtB,SAAS,oBACN,IAAI,GAAG,QAAQ,IAAI;EAExB,mEAAmE,GACnE,cAAc,QAAQ,sBAAsB,IAAI,GAAG,QAAQ,IAAI;;AAajE,kCAAkC,GAClC,iBAAiB;EACf,YAAY,MAAM;EAClB,aAAa,MAAM;EACnB,MAAM,YAAY;EAClB,QAAQ,GAAG;;AAGb,mCAAmC,GACnC,iBAAiB;EACf,UAAU,MAAM;EAChB,QAAQ,GAAG;EACX,MAAM,YAAY;;AAGpB,yCAAyC,GACzC,iBAAiB;EACf,YAAY,MAAM;EAClB,MAAM,YAAY;EAClB,QAAQ,GAAG;;AAGb,gCAAgC,GAChC,iBAAiB;EACf,UAAU,MAAM,GAAG,IAAI;EACvB,aAAa,MAAM;EACnB,MAAM,YAAY;EAClB,QAAQ,GAAG;;AAeb,iBAAiB;EACf,oCAAoC,GACpC,cAAc,MAAM;EACpB,wCAAwC,GACxC;IACE,8CAA8C,GAC9C,OAAO,OAAO;IACd,wEAAwE,GACxE,SAAS,OAAO;IAChB,2EAA2E,GAC3E,WAAW,OAAO"}
@@ -0,0 +1,68 @@
1
+ import { ComposableMCPServer } from "../mod.js";
2
+ import type { MCPCStep } from "./utils/state.js";
3
+ import type { MCPSetting } from "./service/tools.js";
4
+ import type { SamplingConfig } from "./types.js";
5
+ import type { ToolPlugin } from "./plugin-types.js";
6
+ import type { ToolRefXml } from "./types.js";
7
+ export interface ComposeDefinition {
8
+ /**
9
+ * Name of the composed agentic tool
10
+ * Set to null to skip creating the composed tool (composition-only mode).
11
+ */ name: string | null;
12
+ /**
13
+ * Description of the composed agent's purpose and capabilities.
14
+ */ description?: string;
15
+ deps?: MCPSetting;
16
+ /**
17
+ * Global plugins to load and apply to all tools
18
+ * Can be plugin objects or file paths to plugin files
19
+ * @example
20
+ * ```typescript
21
+ * plugins: [
22
+ * './plugins/logger.js',
23
+ * './plugins/cache.js',
24
+ * { name: 'inline', apply: (tool) => tool }
25
+ * ]
26
+ * ```
27
+ */ plugins?: (ToolPlugin | string)[];
28
+ options?: {
29
+ /**
30
+ * Execution mode for the agent
31
+ * - "agentic": Fully autonomous agent mode without any workflow structure
32
+ * - "agentic_workflow": Agent workflow mode that can either generate steps at runtime or use predefined steps
33
+ * @default "agentic"
34
+ */ mode?: "agentic" | "agentic_workflow";
35
+ /**
36
+ * Enable MCP sampling-based autonomous execution capability
37
+ * When enabled, adds sampling tools that can execute tasks autonomously
38
+ * @default false
39
+ */ sampling?: boolean | SamplingConfig;
40
+ /**
41
+ * Optional predefined workflow steps for agentic_workflow mode
42
+ * - If provided: Uses these predefined steps in agentic_workflow mode
43
+ * - If empty/undefined: Generates workflow steps dynamically at runtime in agentic_workflow mode
44
+ * - Ignored when mode is "agentic"
45
+ */ steps?: MCPCStep[];
46
+ /**
47
+ * Actions that must be included at least once in any workflow
48
+ * Validation will fail if these actions are not present in the workflow steps
49
+ * - Only applies to agentic_workflow mode
50
+ * - Ignored when mode is "agentic"
51
+ */ ensureStepActions?: string[];
52
+ /**
53
+ * Default references for the dependent mcps
54
+ *
55
+ * @example
56
+ * <tool name="example-tool" hide="true" global="false"/>
57
+ */ /**
58
+ * References to dependent tools using a compact XML-like string.
59
+ * Only the `name` attribute is required; other attributes are optional.
60
+ */ refs?: Array<ToolRefXml>;
61
+ };
62
+ }
63
+ export interface ComposibleMCPConfig {
64
+ [key: string]: ComposeDefinition[];
65
+ }
66
+ export declare function parseMcpcConfigs(conf?: ComposeDefinition[]): ComposeDefinition[];
67
+ export declare function mcpc(serverConf: ConstructorParameters<typeof ComposableMCPServer>, composeConf?: ComposeDefinition[], setupCallback?: (server: ComposableMCPServer) => void | Promise<void>): Promise<InstanceType<typeof ComposableMCPServer>>;
68
+ //# sourceMappingURL=set-up-mcp-compose.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"set-up-mcp-compose.d.ts","sources":["../../src/set-up-mcp-compose.ts"],"names":[],"mappings":"AAAA,SAAS,mBAAmB,oBAAoB;AAEhD,cAAc,QAAQ,2BAA2B;AACjD,cAAc,UAAU,6BAA6B;AACrD,cAAc,cAAc,qBAAqB;AACjD,cAAc,UAAU,4BAA4B;AACpD,cAAc,UAAU,qBAAqB;AAE7C,iBAAiB;EACf;;;GAGC,GACD,MAAM,MAAM,GAAG,IAAI;EACnB;;GAEC,GACD,cAAc,MAAM;EACpB,OAAO;EAEP;;;;;;;;;;;GAWC,GACD,WAAW,aAAa,MAAM;EAE9B;IACE;;;;;KAKC,GACD,OAAO,YAAY;IAEnB;;;;KAIC,GACD,WAAW,OAAO,GAAG;IAErB;;;;;KAKC,GACD,QAAQ;IAER;;;;;KAKC,GACD,oBAAoB,MAAM;IAE1B;;;;;KAKC,GACD;;;KAGC,GACD,OAAO,MAAM;;;AAMjB,iBAAiB;GACd,KAAK,MAAM,GAAG;;AAGjB,OAAO,iBAAS,iBACd,OAAO,mBAAmB,GACzB;AAuBH,OAAO,iBAAe,KACpB,YAAY,6BAA6B,oBAAoB,EAC7D,cAAc,mBAAmB,EACjC,iBAAiB,QAAQ,wBAAwB,IAAI,GAAG,QAAQ,IAAI,CAAC,GACpE,QAAQ,oBAAoB"}
@@ -0,0 +1,18 @@
1
+ export type JSONSchema = Record<string, unknown>;
2
+ export type ToolCallback = (args: unknown, extra?: unknown) => unknown;
3
+ export interface SamplingConfig {
4
+ maxIterations?: number;
5
+ }
6
+ /**
7
+ * XML-like tool reference string where only `name` is required.
8
+ * Examples accepted:
9
+ * - `<tool name="foo"/>`
10
+ * - `<tool name="foo" description="desc"/>`
11
+ * - `<tool name="foo" hide/>`
12
+ * - `<tool name="foo" global/>`
13
+ * - `<tool name="foo" description="desc" hide global/>`
14
+ */ export type ToolDesc = "" | ` description="${string}"`;
15
+ export type ToolFlags = "" | " hide" | " global" | " hide global" | " global hide";
16
+ export type ToolEnd = "/>" | " />";
17
+ export type ToolRefXml = `<tool name="${string}"${ToolDesc}${ToolFlags}${ToolEnd}` | `<tool name="${string}"${ToolFlags}${ToolDesc}${ToolEnd}`;
18
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,YAAY,aAAa,OAAO,MAAM,EAAE,OAAO;AAE/C,YAAY,gBAAgB,MAAM,OAAO,EAAE,QAAQ,OAAO,KAAK,OAAO;AAEtE,iBAAiB;EACf,gBAAgB,MAAM;;AAiDxB;;;;;;;;CAQC,GACD,YAAY,WAAW,MAAM,cAAc,EAAE,MAAM,CAAC,CAAC;AACrD,YAAY,YACR,KACA,UACA,YACA,iBACA;AACJ,YAAY,UAAU,OAAO;AAE7B,YAAY,cACP,YAAY,EAAE,MAAM,CAAC,CAAC,EAAE,WAAW,YAAY,aAC/C,YAAY,EAAE,MAAM,CAAC,CAAC,EAAE,YAAY,WAAW"}