@agimon-ai/mcp-proxy 0.7.3 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.cjs +73 -85
- package/dist/cli.mjs +64 -76
- package/dist/index.cjs +3 -3
- package/dist/index.d.cts +5 -5
- package/dist/index.d.mts +5 -5
- package/dist/index.mjs +2 -3
- package/dist/{src-Y-cyyxaw.mjs → src-DA5H3rpr.mjs} +201 -313
- package/dist/{src-Dp2m9_I_.cjs → src-DJJH7z8i.cjs} +389 -506
- package/package.json +18 -18
package/dist/cli.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { C as DefinitionsCacheService, D as version, T as findConfigFile, b as RuntimeStateService, d as StdioHttpTransportHandler, f as StdioTransportHandler, m as HttpTransportHandler, n as createServer, o as createProxyIoCContainer, p as SseTransportHandler, r as createSessionServer, t as TRANSPORT_MODE, u as initializeSharedServices, w as generateServerId, y as StopServerService } from "./src-
|
|
2
|
+
import { C as DefinitionsCacheService, D as version, T as findConfigFile, b as RuntimeStateService, d as StdioHttpTransportHandler, f as StdioTransportHandler, m as HttpTransportHandler, n as createServer, o as createProxyIoCContainer, p as SseTransportHandler, r as createSessionServer, t as TRANSPORT_MODE, u as initializeSharedServices, w as generateServerId, y as StopServerService } from "./src-DA5H3rpr.mjs";
|
|
3
3
|
import { constants, existsSync, readFileSync } from "node:fs";
|
|
4
4
|
import { access, writeFile } from "node:fs/promises";
|
|
5
5
|
import yaml from "js-yaml";
|
|
@@ -11,14 +11,11 @@ import { Command } from "commander";
|
|
|
11
11
|
import { DEFAULT_PORT_RANGE, PortRegistryService } from "@agimon-ai/foundation-port-registry";
|
|
12
12
|
import { ProcessRegistryService, createProcessLease, resolveSiblingRegistryPath } from "@agimon-ai/foundation-process-registry";
|
|
13
13
|
import { fileURLToPath } from "node:url";
|
|
14
|
-
|
|
15
14
|
//#region src/templates/mcp-config.json?raw
|
|
16
15
|
var mcp_config_default = "{\n \"_comment\": \"MCP Server Configuration - Use ${VAR_NAME} syntax for environment variable interpolation\",\n \"_instructions\": \"config.instruction: Server's default instruction | instruction: User override (takes precedence)\",\n \"mcpServers\": {\n \"example-server\": {\n \"command\": \"node\",\n \"args\": [\"/path/to/mcp-server/build/index.js\"],\n \"env\": {\n \"LOG_LEVEL\": \"info\",\n \"_comment\": \"You can use environment variable interpolation:\",\n \"_example_DATABASE_URL\": \"${DATABASE_URL}\",\n \"_example_API_KEY\": \"${MY_API_KEY}\"\n },\n \"config\": {\n \"instruction\": \"Use this server for...\"\n },\n \"_instruction_override\": \"Optional user override - takes precedence over config.instruction\"\n }\n }\n}\n";
|
|
17
|
-
|
|
18
16
|
//#endregion
|
|
19
17
|
//#region src/templates/mcp-config.yaml.liquid?raw
|
|
20
18
|
var mcp_config_yaml_default = "# MCP Server Configuration\n# This file configures the MCP servers that mcp-proxy will connect to\n#\n# Environment Variable Interpolation:\n# Use ${VAR_NAME} syntax to reference environment variables\n# Example: ${HOME}, ${API_KEY}, ${DATABASE_URL}\n#\n# Instructions:\n# - config.instruction: Server's default instruction (from server documentation)\n# - instruction: User override (optional, takes precedence over config.instruction)\n# - config.toolBlacklist: Array of tool names to hide/block from this server\n# - config.omitToolDescription: Boolean to show only tool names without descriptions (saves tokens)\n\n# Remote Configuration Sources (OPTIONAL)\n# Fetch and merge configurations from remote URLs\n# Remote configs are merged with local configs based on merge strategy\n#\n# SECURITY: SSRF Protection is ENABLED by default\n# - Only HTTPS URLs are allowed (set security.enforceHttps: false to allow HTTP)\n# - Private IPs and localhost are blocked (set security.allowPrivateIPs: true for internal networks)\n# - Blocked ranges: 127.0.0.0/8, 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 169.254.0.0/16\nremoteConfigs:\n # Example 1: Basic remote config with default security\n # - url: ${AGIFLOW_URL}/api/v1/mcp-configs\n # headers:\n # Authorization: Bearer ${AGIFLOW_API_KEY}\n # mergeStrategy: local-priority # Options: local-priority (default), remote-priority, merge-deep\n #\n # Example 2: Remote config with custom security settings (for internal networks)\n # - url: ${INTERNAL_URL}/mcp-configs\n # headers:\n # Authorization: Bearer ${INTERNAL_TOKEN}\n # security:\n # allowPrivateIPs: true # Allow internal IPs (default: false)\n # enforceHttps: false # Allow HTTP (default: true, HTTPS only)\n # mergeStrategy: local-priority\n #\n # Example 3: Remote config with additional validation (OPTIONAL)\n # - url: ${AGIFLOW_URL}/api/v1/mcp-configs\n # headers:\n # Authorization: Bearer ${AGIFLOW_API_KEY}\n # X-API-Key: ${AGIFLOW_API_KEY}\n # security:\n # enforceHttps: true # Require HTTPS (default: true)\n # allowPrivateIPs: false # Block private IPs (default: false)\n # validation: # OPTIONAL: Additional regex validation on top of security checks\n # url: ^https://.*\\.agiflow\\.io/.* # OPTIONAL: Regex pattern to validate URL format\n # headers: # OPTIONAL: Regex patterns to validate header values\n # Authorization: ^Bearer [A-Za-z0-9_-]+$\n # X-API-Key: ^[A-Za-z0-9_-]{32,}$\n # mergeStrategy: local-priority\n\nmcpServers:\n{%- if mcpServers %}{% for server in mcpServers %}\n {{ server.name }}:\n command: {{ server.command }}\n args:{% for arg in server.args %}\n - '{{ arg }}'{% endfor %}\n # env:\n # LOG_LEVEL: info\n # # API_KEY: ${MY_API_KEY}\n # config:\n # instruction: Use this server for...\n # # toolBlacklist:\n # # - tool_to_block\n # # omitToolDescription: true\n{% endfor %}\n # Example MCP server using SSE transport\n # remote-server:\n # url: https://example.com/mcp\n # type: sse\n # headers:\n # Authorization: Bearer ${API_KEY}\n # config:\n # instruction: This server provides tools for...\n{% else %}\n # Example MCP server using stdio transport\n example-server:\n command: node\n args:\n - /path/to/mcp-server/build/index.js\n env:\n # Environment variables for the MCP server\n LOG_LEVEL: info\n # You can use environment variable interpolation:\n # DATABASE_URL: ${DATABASE_URL}\n # API_KEY: ${MY_API_KEY}\n config:\n # Server's default instruction (from server documentation)\n instruction: Use this server for...\n # Optional: Block specific tools from being listed or executed\n # toolBlacklist:\n # - dangerous_tool_name\n # - another_blocked_tool\n # Optional: Omit tool descriptions to save tokens (default: false)\n # omitToolDescription: true\n # instruction: Optional user override - takes precedence over config.instruction\n\n # Example MCP server using SSE transport with environment variables\n # remote-server:\n # url: https://example.com/mcp\n # type: sse\n # headers:\n # # Use ${VAR_NAME} to interpolate environment variables\n # Authorization: Bearer ${API_KEY}\n # config:\n # instruction: This server provides tools for...\n # # Optional: Block specific tools from being listed or executed\n # # toolBlacklist:\n # # - tool_to_block\n # # Optional: Omit tool descriptions to save tokens (default: false)\n # # omitToolDescription: true\n # # instruction: Optional user override\n{% endif %}\n";
|
|
21
|
-
|
|
22
19
|
//#endregion
|
|
23
20
|
//#region src/utils/output.ts
|
|
24
21
|
function writeLine(message = "") {
|
|
@@ -42,7 +39,6 @@ const print = {
|
|
|
42
39
|
item: (message) => writeLine(`- ${message}`),
|
|
43
40
|
indent: (message) => writeLine(` ${message}`)
|
|
44
41
|
};
|
|
45
|
-
|
|
46
42
|
//#endregion
|
|
47
43
|
//#region src/commands/init.ts
|
|
48
44
|
/**
|
|
@@ -112,7 +108,6 @@ const initCommand = new Command("init").description("Initialize MCP configuratio
|
|
|
112
108
|
process.exit(1);
|
|
113
109
|
}
|
|
114
110
|
});
|
|
115
|
-
|
|
116
111
|
//#endregion
|
|
117
112
|
//#region src/commands/prestart-http.ts
|
|
118
113
|
/**
|
|
@@ -139,36 +134,35 @@ function resolveWorkspaceRoot(startPath = process.env.PROJECT_PATH || process.cw
|
|
|
139
134
|
}
|
|
140
135
|
}
|
|
141
136
|
const PROCESS_REGISTRY_SERVICE_HTTP$1 = "mcp-proxy-http";
|
|
142
|
-
async function
|
|
137
|
+
async function findExistingRuntime(workspaceRoot) {
|
|
143
138
|
const match = (await new ProcessRegistryService(process.env.PROCESS_REGISTRY_PATH).listProcesses({
|
|
144
139
|
repositoryPath: workspaceRoot,
|
|
145
140
|
serviceName: PROCESS_REGISTRY_SERVICE_HTTP$1
|
|
146
141
|
}))[0];
|
|
147
142
|
if (!match?.host || !match?.port) return null;
|
|
143
|
+
const metadata = match.metadata;
|
|
144
|
+
return {
|
|
145
|
+
host: match.host,
|
|
146
|
+
port: match.port,
|
|
147
|
+
serverId: metadata?.serverId ?? "unknown"
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
async function isRuntimeHealthy(host, port) {
|
|
148
151
|
try {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
host: match.host,
|
|
154
|
-
port: match.port,
|
|
155
|
-
serverId: metadata?.serverId ?? "unknown",
|
|
156
|
-
workspaceRoot,
|
|
157
|
-
reusedExistingRuntime: true
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
} catch {}
|
|
161
|
-
return null;
|
|
152
|
+
return (await fetch(`http://${host}:${port}/health`)).ok;
|
|
153
|
+
} catch {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
162
156
|
}
|
|
163
157
|
function buildCliCandidates() {
|
|
164
|
-
const
|
|
165
|
-
const
|
|
158
|
+
const currentFile = fileURLToPath(import.meta.url);
|
|
159
|
+
const currentDir = path.dirname(currentFile);
|
|
166
160
|
const distCandidates = [
|
|
167
|
-
path.resolve(
|
|
168
|
-
path.resolve(
|
|
169
|
-
path.resolve(
|
|
161
|
+
path.resolve(currentDir, "cli.mjs"),
|
|
162
|
+
path.resolve(currentDir, "..", "dist", "cli.mjs"),
|
|
163
|
+
path.resolve(currentDir, "..", "..", "dist", "cli.mjs")
|
|
170
164
|
];
|
|
171
|
-
const srcCandidates = [path.resolve(
|
|
165
|
+
const srcCandidates = [path.resolve(currentDir, "..", "cli.ts"), path.resolve(currentDir, "..", "..", "src", "cli.ts")];
|
|
172
166
|
for (const candidate of distCandidates) if (existsSync(candidate)) return {
|
|
173
167
|
command: process.execPath,
|
|
174
168
|
args: [candidate]
|
|
@@ -196,7 +190,7 @@ async function waitForFile(filePath, timeoutMs) {
|
|
|
196
190
|
await access(filePath);
|
|
197
191
|
return;
|
|
198
192
|
} catch {}
|
|
199
|
-
await new Promise((resolve
|
|
193
|
+
await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
|
|
200
194
|
}
|
|
201
195
|
throw new Error(`Timed out waiting for runtime state file: ${filePath}`);
|
|
202
196
|
}
|
|
@@ -218,7 +212,7 @@ async function waitForHealthyRuntime(serverId, timeoutMs) {
|
|
|
218
212
|
}
|
|
219
213
|
} catch {}
|
|
220
214
|
}
|
|
221
|
-
await new Promise((resolve
|
|
215
|
+
await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
|
|
222
216
|
}
|
|
223
217
|
throw new Error(`Timed out waiting for HTTP runtime '${serverId}' to become healthy`);
|
|
224
218
|
}
|
|
@@ -257,9 +251,16 @@ async function prestartHttpRuntime(options) {
|
|
|
257
251
|
const timeoutMs = parseTimeoutMs(options.timeoutMs);
|
|
258
252
|
const registryPath = options.registryPath || options.registryDir;
|
|
259
253
|
const workspaceRoot = resolveWorkspaceRoot();
|
|
260
|
-
const existing = await
|
|
261
|
-
if (existing) return
|
|
262
|
-
|
|
254
|
+
const existing = await findExistingRuntime(workspaceRoot);
|
|
255
|
+
if (existing && await isRuntimeHealthy(existing.host, existing.port)) return {
|
|
256
|
+
host: existing.host,
|
|
257
|
+
port: existing.port,
|
|
258
|
+
serverId: existing.serverId,
|
|
259
|
+
workspaceRoot,
|
|
260
|
+
reusedExistingRuntime: true
|
|
261
|
+
};
|
|
262
|
+
const targetPort = options.port ?? existing?.port;
|
|
263
|
+
await stopExistingRuntime(new RuntimeStateService(), options.id, options.host, targetPort);
|
|
263
264
|
const childEnv = {
|
|
264
265
|
...process.env,
|
|
265
266
|
...registryPath ? {
|
|
@@ -275,7 +276,7 @@ async function prestartHttpRuntime(options) {
|
|
|
275
276
|
serverId,
|
|
276
277
|
"--host",
|
|
277
278
|
options.host || DEFAULT_HOST$1,
|
|
278
|
-
...
|
|
279
|
+
...targetPort !== void 0 ? ["--port", String(targetPort)] : [],
|
|
279
280
|
...options.config ? ["--config", options.config] : [],
|
|
280
281
|
...options.cache === false ? ["--no-cache"] : [],
|
|
281
282
|
...options.definitionsCache ? ["--definitions-cache", options.definitionsCache] : [],
|
|
@@ -314,7 +315,6 @@ const prestartHttpCommand = new Command("prestart-http").description("Start an m
|
|
|
314
315
|
throw new Error(`Failed to prestart HTTP runtime '${options.id || "generated-server-id"}': ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
315
316
|
}
|
|
316
317
|
});
|
|
317
|
-
|
|
318
318
|
//#endregion
|
|
319
319
|
//#region src/commands/mcp-serve.ts
|
|
320
320
|
/**
|
|
@@ -828,7 +828,6 @@ const mcpServeCommand = new Command("mcp-serve").description("Start MCP server w
|
|
|
828
828
|
process.exit(1);
|
|
829
829
|
}
|
|
830
830
|
});
|
|
831
|
-
|
|
832
831
|
//#endregion
|
|
833
832
|
//#region src/commands/bootstrap.ts
|
|
834
833
|
function toErrorMessage$8(error) {
|
|
@@ -918,7 +917,6 @@ async function withConnectedCommandContext(options, run) {
|
|
|
918
917
|
if (config.proxy?.port) return await withProxiedContext(container, config, configFilePath, options, run);
|
|
919
918
|
return await withDirectContext(container, config, configFilePath, options, run);
|
|
920
919
|
}
|
|
921
|
-
|
|
922
920
|
//#endregion
|
|
923
921
|
//#region src/commands/list-tools.ts
|
|
924
922
|
/**
|
|
@@ -989,7 +987,6 @@ const searchToolsCommand = new Command("search-tools").description("Search proxi
|
|
|
989
987
|
process.exit(1);
|
|
990
988
|
}
|
|
991
989
|
});
|
|
992
|
-
|
|
993
990
|
//#endregion
|
|
994
991
|
//#region src/commands/describe-tools.ts
|
|
995
992
|
/**
|
|
@@ -1130,7 +1127,6 @@ const describeToolsCommand = new Command("describe-tools").description("Describe
|
|
|
1130
1127
|
process.exit(1);
|
|
1131
1128
|
}
|
|
1132
1129
|
});
|
|
1133
|
-
|
|
1134
1130
|
//#endregion
|
|
1135
1131
|
//#region src/commands/use-tool.ts
|
|
1136
1132
|
/**
|
|
@@ -1172,34 +1168,34 @@ const useToolCommand = new Command("use-tool").description("Execute an MCP tool
|
|
|
1172
1168
|
await withConnectedCommandContext(options, async ({ container, config, clientManager }) => {
|
|
1173
1169
|
const clients = clientManager.getAllClients();
|
|
1174
1170
|
if (options.server) {
|
|
1175
|
-
const client
|
|
1176
|
-
if (!client
|
|
1171
|
+
const client = clientManager.getClient(options.server);
|
|
1172
|
+
if (!client) throw new Error(`Server "${options.server}" not found`);
|
|
1177
1173
|
if (!options.json) console.error(`Executing ${toolName} on ${options.server}...`);
|
|
1178
|
-
const requestOptions
|
|
1179
|
-
const result
|
|
1180
|
-
if (options.json) console.log(JSON.stringify(result
|
|
1174
|
+
const requestOptions = options.timeout ? { timeout: options.timeout } : void 0;
|
|
1175
|
+
const result = await client.callTool(toolName, toolArgs, requestOptions);
|
|
1176
|
+
if (options.json) console.log(JSON.stringify(result, null, 2));
|
|
1181
1177
|
else {
|
|
1182
1178
|
console.log("\nResult:");
|
|
1183
|
-
if (result
|
|
1179
|
+
if (result.content) for (const content of result.content) if (content.type === "text") console.log(content.text);
|
|
1184
1180
|
else console.log(JSON.stringify(content, null, 2));
|
|
1185
|
-
if (result
|
|
1181
|
+
if (result.isError) {
|
|
1186
1182
|
console.error("\n⚠️ Tool execution returned an error");
|
|
1187
1183
|
process.exit(1);
|
|
1188
1184
|
}
|
|
1189
1185
|
}
|
|
1190
1186
|
return;
|
|
1191
1187
|
}
|
|
1192
|
-
const searchResults = await Promise.all(clients.map(async (client
|
|
1188
|
+
const searchResults = await Promise.all(clients.map(async (client) => {
|
|
1193
1189
|
try {
|
|
1194
|
-
const hasTool = (await client
|
|
1190
|
+
const hasTool = (await client.listTools()).some((t) => t.name === toolName);
|
|
1195
1191
|
return {
|
|
1196
|
-
serverName: client
|
|
1192
|
+
serverName: client.serverName,
|
|
1197
1193
|
hasTool,
|
|
1198
1194
|
error: null
|
|
1199
1195
|
};
|
|
1200
1196
|
} catch (error) {
|
|
1201
1197
|
return {
|
|
1202
|
-
serverName: client
|
|
1198
|
+
serverName: client.serverName,
|
|
1203
1199
|
hasTool: false,
|
|
1204
1200
|
error
|
|
1205
1201
|
};
|
|
@@ -1221,11 +1217,11 @@ const useToolCommand = new Command("use-tool").description("Execute an MCP tool
|
|
|
1221
1217
|
const skillName = toolName.startsWith("skill__") ? toolName.slice(7) : toolName;
|
|
1222
1218
|
const skill = await skillService.getSkill(skillName);
|
|
1223
1219
|
if (skill) {
|
|
1224
|
-
const result
|
|
1220
|
+
const result = { content: [{
|
|
1225
1221
|
type: "text",
|
|
1226
1222
|
text: skill.content
|
|
1227
1223
|
}] };
|
|
1228
|
-
if (options.json) console.log(JSON.stringify(result
|
|
1224
|
+
if (options.json) console.log(JSON.stringify(result, null, 2));
|
|
1229
1225
|
else {
|
|
1230
1226
|
console.log("\nSkill content:");
|
|
1231
1227
|
console.log(skill.content);
|
|
@@ -1260,7 +1256,6 @@ const useToolCommand = new Command("use-tool").description("Execute an MCP tool
|
|
|
1260
1256
|
process.exit(1);
|
|
1261
1257
|
}
|
|
1262
1258
|
});
|
|
1263
|
-
|
|
1264
1259
|
//#endregion
|
|
1265
1260
|
//#region src/commands/list-resources.ts
|
|
1266
1261
|
/**
|
|
@@ -1331,7 +1326,6 @@ const listResourcesCommand = new Command("list-resources").description("List all
|
|
|
1331
1326
|
process.exit(1);
|
|
1332
1327
|
}
|
|
1333
1328
|
});
|
|
1334
|
-
|
|
1335
1329
|
//#endregion
|
|
1336
1330
|
//#region src/commands/read-resource.ts
|
|
1337
1331
|
/**
|
|
@@ -1366,26 +1360,26 @@ const readResourceCommand = new Command("read-resource").description("Read a res
|
|
|
1366
1360
|
await withConnectedCommandContext(options, async ({ clientManager }) => {
|
|
1367
1361
|
const clients = clientManager.getAllClients();
|
|
1368
1362
|
if (options.server) {
|
|
1369
|
-
const client
|
|
1370
|
-
if (!client
|
|
1363
|
+
const client = clientManager.getClient(options.server);
|
|
1364
|
+
if (!client) throw new Error(`Server "${options.server}" not found`);
|
|
1371
1365
|
if (!options.json) console.error(`Reading ${uri} from ${options.server}...`);
|
|
1372
|
-
const result
|
|
1373
|
-
if (options.json) console.log(JSON.stringify(result
|
|
1374
|
-
else for (const content of result
|
|
1366
|
+
const result = await client.readResource(uri);
|
|
1367
|
+
if (options.json) console.log(JSON.stringify(result, null, 2));
|
|
1368
|
+
else for (const content of result.contents) if ("text" in content) console.log(content.text);
|
|
1375
1369
|
else console.log(JSON.stringify(content, null, 2));
|
|
1376
1370
|
return;
|
|
1377
1371
|
}
|
|
1378
|
-
const searchResults = await Promise.all(clients.map(async (client
|
|
1372
|
+
const searchResults = await Promise.all(clients.map(async (client) => {
|
|
1379
1373
|
try {
|
|
1380
|
-
const hasResource = (await client
|
|
1374
|
+
const hasResource = (await client.listResources()).some((r) => r.uri === uri);
|
|
1381
1375
|
return {
|
|
1382
|
-
serverName: client
|
|
1376
|
+
serverName: client.serverName,
|
|
1383
1377
|
hasResource,
|
|
1384
1378
|
error: null
|
|
1385
1379
|
};
|
|
1386
1380
|
} catch (error) {
|
|
1387
1381
|
return {
|
|
1388
|
-
serverName: client
|
|
1382
|
+
serverName: client.serverName,
|
|
1389
1383
|
hasResource: false,
|
|
1390
1384
|
error
|
|
1391
1385
|
};
|
|
@@ -1415,7 +1409,6 @@ const readResourceCommand = new Command("read-resource").description("Read a res
|
|
|
1415
1409
|
process.exit(1);
|
|
1416
1410
|
}
|
|
1417
1411
|
});
|
|
1418
|
-
|
|
1419
1412
|
//#endregion
|
|
1420
1413
|
//#region src/commands/list-prompts.ts
|
|
1421
1414
|
function toErrorMessage$2(error) {
|
|
@@ -1456,7 +1449,6 @@ const listPromptsCommand = new Command("list-prompts").description("List all ava
|
|
|
1456
1449
|
process.exit(1);
|
|
1457
1450
|
}
|
|
1458
1451
|
});
|
|
1459
|
-
|
|
1460
1452
|
//#endregion
|
|
1461
1453
|
//#region src/commands/get-prompt.ts
|
|
1462
1454
|
function toErrorMessage$1(error) {
|
|
@@ -1473,11 +1465,11 @@ const getPromptCommand = new Command("get-prompt").description("Get a prompt by
|
|
|
1473
1465
|
await withConnectedCommandContext(options, async ({ clientManager }) => {
|
|
1474
1466
|
const clients = clientManager.getAllClients();
|
|
1475
1467
|
if (options.server) {
|
|
1476
|
-
const client
|
|
1477
|
-
if (!client
|
|
1478
|
-
const prompt
|
|
1479
|
-
if (options.json) console.log(JSON.stringify(prompt
|
|
1480
|
-
else for (const message of prompt
|
|
1468
|
+
const client = clientManager.getClient(options.server);
|
|
1469
|
+
if (!client) throw new Error(`Server "${options.server}" not found`);
|
|
1470
|
+
const prompt = await client.getPrompt(promptName, promptArgs);
|
|
1471
|
+
if (options.json) console.log(JSON.stringify(prompt, null, 2));
|
|
1472
|
+
else for (const message of prompt.messages) {
|
|
1481
1473
|
const content = message.content;
|
|
1482
1474
|
if (typeof content === "object" && content && "text" in content) console.log(content.text);
|
|
1483
1475
|
else console.log(JSON.stringify(message, null, 2));
|
|
@@ -1485,11 +1477,11 @@ const getPromptCommand = new Command("get-prompt").description("Get a prompt by
|
|
|
1485
1477
|
return;
|
|
1486
1478
|
}
|
|
1487
1479
|
const matchingServers = [];
|
|
1488
|
-
await Promise.all(clients.map(async (client
|
|
1480
|
+
await Promise.all(clients.map(async (client) => {
|
|
1489
1481
|
try {
|
|
1490
|
-
if ((await client
|
|
1482
|
+
if ((await client.listPrompts()).some((prompt) => prompt.name === promptName)) matchingServers.push(client.serverName);
|
|
1491
1483
|
} catch (error) {
|
|
1492
|
-
if (!options.json) console.error(`Failed to list prompts from ${client
|
|
1484
|
+
if (!options.json) console.error(`Failed to list prompts from ${client.serverName}: ${toErrorMessage$1(error)}`);
|
|
1493
1485
|
}
|
|
1494
1486
|
}));
|
|
1495
1487
|
if (matchingServers.length === 0) throw new Error(`Prompt "${promptName}" not found on any connected server`);
|
|
@@ -1509,7 +1501,6 @@ const getPromptCommand = new Command("get-prompt").description("Get a prompt by
|
|
|
1509
1501
|
process.exit(1);
|
|
1510
1502
|
}
|
|
1511
1503
|
});
|
|
1512
|
-
|
|
1513
1504
|
//#endregion
|
|
1514
1505
|
//#region src/commands/prefetch.ts
|
|
1515
1506
|
/**
|
|
@@ -1636,7 +1627,6 @@ const prefetchCommand = new Command("prefetch").description("Pre-download packag
|
|
|
1636
1627
|
process.exit(1);
|
|
1637
1628
|
}
|
|
1638
1629
|
});
|
|
1639
|
-
|
|
1640
1630
|
//#endregion
|
|
1641
1631
|
//#region src/commands/stop.ts
|
|
1642
1632
|
/**
|
|
@@ -1682,7 +1672,6 @@ const stopCommand = new Command("stop").description("Stop a running HTTP mcp-pro
|
|
|
1682
1672
|
process.exit(1);
|
|
1683
1673
|
}
|
|
1684
1674
|
});
|
|
1685
|
-
|
|
1686
1675
|
//#endregion
|
|
1687
1676
|
//#region src/cli.ts
|
|
1688
1677
|
/**
|
|
@@ -1732,6 +1721,5 @@ main().catch((error) => {
|
|
|
1732
1721
|
console.error(`Fatal error: ${error instanceof Error ? error.message : error}`);
|
|
1733
1722
|
process.exit(1);
|
|
1734
1723
|
});
|
|
1735
|
-
|
|
1736
1724
|
//#endregion
|
|
1737
|
-
export {
|
|
1725
|
+
export {};
|
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_src = require("./src-DJJH7z8i.cjs");
|
|
3
3
|
exports.ConfigFetcherService = require_src.ConfigFetcherService;
|
|
4
4
|
exports.DefinitionsCacheService = require_src.DefinitionsCacheService;
|
|
5
5
|
exports.DescribeToolsTool = require_src.DescribeToolsTool;
|
|
@@ -24,4 +24,4 @@ exports.createStdioHttpTransportHandler = require_src.createStdioHttpTransportHa
|
|
|
24
24
|
exports.createStdioTransportHandler = require_src.createStdioTransportHandler;
|
|
25
25
|
exports.findConfigFile = require_src.findConfigFile;
|
|
26
26
|
exports.generateServerId = require_src.generateServerId;
|
|
27
|
-
exports.initializeSharedServices = require_src.initializeSharedServices;
|
|
27
|
+
exports.initializeSharedServices = require_src.initializeSharedServices;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import * as _modelcontextprotocol_sdk_server_index_js0 from "@modelcontextprotocol/sdk/server/index.js";
|
|
1
|
+
import * as _$_modelcontextprotocol_sdk_server_index_js0 from "@modelcontextprotocol/sdk/server/index.js";
|
|
2
2
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
3
|
import { CallToolResult, GetPromptResult, ReadResourceResult } from "@modelcontextprotocol/sdk/types.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { NodeTelemetryHandle } from "@agimon-ai/log-sink-mcp";
|
|
6
6
|
|
|
7
7
|
//#region src/types/index.d.ts
|
|
8
|
-
|
|
9
8
|
/**
|
|
10
9
|
* Tool definition for MCP
|
|
11
10
|
* @property name - The unique name of the tool
|
|
@@ -999,6 +998,7 @@ declare class DescribeToolsTool implements Tool<DescribeToolsToolInput> {
|
|
|
999
998
|
*/
|
|
1000
999
|
getInputSchema(): z.ZodObject<z.ZodRawShape>;
|
|
1001
1000
|
getDefinition(): Promise<ToolDefinition>;
|
|
1001
|
+
private runLookups;
|
|
1002
1002
|
/**
|
|
1003
1003
|
* Executes tool description lookup for the requested tool and skill names.
|
|
1004
1004
|
*
|
|
@@ -1274,15 +1274,15 @@ declare function createProxyContainer(options?: ServerOptions): Promise<SharedSe
|
|
|
1274
1274
|
/**
|
|
1275
1275
|
* Create a sessionless stdio transport handler from the shared server factory.
|
|
1276
1276
|
*/
|
|
1277
|
-
declare function createStdioTransportHandler(createServer: () => Promise<_modelcontextprotocol_sdk_server_index_js0.Server>): Promise<StdioTransportHandler>;
|
|
1277
|
+
declare function createStdioTransportHandler(createServer: () => Promise<_$_modelcontextprotocol_sdk_server_index_js0.Server>): Promise<StdioTransportHandler>;
|
|
1278
1278
|
/**
|
|
1279
1279
|
* Create an SSE transport handler from the shared server factory.
|
|
1280
1280
|
*/
|
|
1281
|
-
declare function createSseTransportHandler(createServer: () => Promise<_modelcontextprotocol_sdk_server_index_js0.Server>, config: TransportConfig): Promise<SseTransportHandler>;
|
|
1281
|
+
declare function createSseTransportHandler(createServer: () => Promise<_$_modelcontextprotocol_sdk_server_index_js0.Server>, config: TransportConfig): Promise<SseTransportHandler>;
|
|
1282
1282
|
/**
|
|
1283
1283
|
* Create an HTTP transport handler from shared services.
|
|
1284
1284
|
*/
|
|
1285
|
-
declare function createHttpTransportHandler(createServer: () => Promise<_modelcontextprotocol_sdk_server_index_js0.Server>, config: TransportConfig, adminOptions?: HttpTransportAdminOptions$1): HttpTransportHandler;
|
|
1285
|
+
declare function createHttpTransportHandler(createServer: () => Promise<_$_modelcontextprotocol_sdk_server_index_js0.Server>, config: TransportConfig, adminOptions?: HttpTransportAdminOptions$1): HttpTransportHandler;
|
|
1286
1286
|
/**
|
|
1287
1287
|
* Create a stdio-http transport handler from an endpoint URL.
|
|
1288
1288
|
*/
|
package/dist/index.d.mts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import * as _modelcontextprotocol_sdk_server_index_js0 from "@modelcontextprotocol/sdk/server/index.js";
|
|
1
|
+
import * as _$_modelcontextprotocol_sdk_server_index_js0 from "@modelcontextprotocol/sdk/server/index.js";
|
|
2
2
|
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
3
|
import { CallToolResult, GetPromptResult, ReadResourceResult } from "@modelcontextprotocol/sdk/types.js";
|
|
4
4
|
import { z } from "zod";
|
|
5
5
|
import { NodeTelemetryHandle } from "@agimon-ai/log-sink-mcp";
|
|
6
6
|
|
|
7
7
|
//#region src/types/index.d.ts
|
|
8
|
-
|
|
9
8
|
/**
|
|
10
9
|
* Tool definition for MCP
|
|
11
10
|
* @property name - The unique name of the tool
|
|
@@ -999,6 +998,7 @@ declare class DescribeToolsTool implements Tool<DescribeToolsToolInput> {
|
|
|
999
998
|
*/
|
|
1000
999
|
getInputSchema(): z.ZodObject<z.ZodRawShape>;
|
|
1001
1000
|
getDefinition(): Promise<ToolDefinition>;
|
|
1001
|
+
private runLookups;
|
|
1002
1002
|
/**
|
|
1003
1003
|
* Executes tool description lookup for the requested tool and skill names.
|
|
1004
1004
|
*
|
|
@@ -1274,15 +1274,15 @@ declare function createProxyContainer(options?: ServerOptions): Promise<SharedSe
|
|
|
1274
1274
|
/**
|
|
1275
1275
|
* Create a sessionless stdio transport handler from the shared server factory.
|
|
1276
1276
|
*/
|
|
1277
|
-
declare function createStdioTransportHandler(createServer: () => Promise<_modelcontextprotocol_sdk_server_index_js0.Server>): Promise<StdioTransportHandler>;
|
|
1277
|
+
declare function createStdioTransportHandler(createServer: () => Promise<_$_modelcontextprotocol_sdk_server_index_js0.Server>): Promise<StdioTransportHandler>;
|
|
1278
1278
|
/**
|
|
1279
1279
|
* Create an SSE transport handler from the shared server factory.
|
|
1280
1280
|
*/
|
|
1281
|
-
declare function createSseTransportHandler(createServer: () => Promise<_modelcontextprotocol_sdk_server_index_js0.Server>, config: TransportConfig): Promise<SseTransportHandler>;
|
|
1281
|
+
declare function createSseTransportHandler(createServer: () => Promise<_$_modelcontextprotocol_sdk_server_index_js0.Server>, config: TransportConfig): Promise<SseTransportHandler>;
|
|
1282
1282
|
/**
|
|
1283
1283
|
* Create an HTTP transport handler from shared services.
|
|
1284
1284
|
*/
|
|
1285
|
-
declare function createHttpTransportHandler(createServer: () => Promise<_modelcontextprotocol_sdk_server_index_js0.Server>, config: TransportConfig, adminOptions?: HttpTransportAdminOptions$1): HttpTransportHandler;
|
|
1285
|
+
declare function createHttpTransportHandler(createServer: () => Promise<_$_modelcontextprotocol_sdk_server_index_js0.Server>, config: TransportConfig, adminOptions?: HttpTransportAdminOptions$1): HttpTransportHandler;
|
|
1286
1286
|
/**
|
|
1287
1287
|
* Create a stdio-http transport handler from an endpoint URL.
|
|
1288
1288
|
*/
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
import { C as DefinitionsCacheService, E as ConfigFetcherService, S as createProxyLogger, T as findConfigFile, _ as DescribeToolsTool, a as createProxyContainer, b as RuntimeStateService, c as createStdioHttpTransportHandler, d as StdioHttpTransportHandler, f as StdioTransportHandler, g as SearchListToolsTool, h as UseToolTool, i as createHttpTransportHandler, l as createStdioTransportHandler, m as HttpTransportHandler, n as createServer, p as SseTransportHandler, r as createSessionServer, s as createSseTransportHandler, t as TRANSPORT_MODE, u as initializeSharedServices, v as SkillService, w as generateServerId, x as McpClientManagerService, y as StopServerService } from "./src-
|
|
2
|
-
|
|
3
|
-
export { ConfigFetcherService, DefinitionsCacheService, DescribeToolsTool, HttpTransportHandler, McpClientManagerService, RuntimeStateService, SearchListToolsTool, SkillService, SseTransportHandler, StdioHttpTransportHandler, StdioTransportHandler, StopServerService, TRANSPORT_MODE, UseToolTool, createHttpTransportHandler, createProxyContainer, createProxyLogger, createServer, createSessionServer, createSseTransportHandler, createStdioHttpTransportHandler, createStdioTransportHandler, findConfigFile, generateServerId, initializeSharedServices };
|
|
1
|
+
import { C as DefinitionsCacheService, E as ConfigFetcherService, S as createProxyLogger, T as findConfigFile, _ as DescribeToolsTool, a as createProxyContainer, b as RuntimeStateService, c as createStdioHttpTransportHandler, d as StdioHttpTransportHandler, f as StdioTransportHandler, g as SearchListToolsTool, h as UseToolTool, i as createHttpTransportHandler, l as createStdioTransportHandler, m as HttpTransportHandler, n as createServer, p as SseTransportHandler, r as createSessionServer, s as createSseTransportHandler, t as TRANSPORT_MODE, u as initializeSharedServices, v as SkillService, w as generateServerId, x as McpClientManagerService, y as StopServerService } from "./src-DA5H3rpr.mjs";
|
|
2
|
+
export { ConfigFetcherService, DefinitionsCacheService, DescribeToolsTool, HttpTransportHandler, McpClientManagerService, RuntimeStateService, SearchListToolsTool, SkillService, SseTransportHandler, StdioHttpTransportHandler, StdioTransportHandler, StopServerService, TRANSPORT_MODE, UseToolTool, createHttpTransportHandler, createProxyContainer, createProxyLogger, createServer, createSessionServer, createSseTransportHandler, createStdioHttpTransportHandler, createStdioTransportHandler, findConfigFile, generateServerId, initializeSharedServices };
|