specrun 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +21 -0
- package/README.md +319 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +123 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts.d.ts +38 -0
- package/dist/prompts.d.ts.map +1 -0
- package/dist/prompts.js +537 -0
- package/dist/prompts.js.map +1 -0
- package/dist/server.d.ts +38 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +305 -0
- package/dist/server.js.map +1 -0
- package/dist/tools.d.ts +43 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +249 -0
- package/dist/tools.js.map +1 -0
- package/dist/types.d.ts +60 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/auth.d.ts +6 -0
- package/dist/utils/auth.d.ts.map +1 -0
- package/dist/utils/auth.js +173 -0
- package/dist/utils/auth.js.map +1 -0
- package/dist/utils/http-client.d.ts +17 -0
- package/dist/utils/http-client.d.ts.map +1 -0
- package/dist/utils/http-client.js +233 -0
- package/dist/utils/http-client.js.map +1 -0
- package/dist/utils/openapi-parser.d.ts +6 -0
- package/dist/utils/openapi-parser.d.ts.map +1 -0
- package/dist/utils/openapi-parser.js +398 -0
- package/dist/utils/openapi-parser.js.map +1 -0
- package/package.json +62 -0
- package/specs/.env +20 -0
- package/specs/cars.swagger.json +105 -0
- package/specs/github.yaml +164 -0
package/dist/server.js
ADDED
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.OpenApiMcpServer = void 0;
|
|
7
|
+
const fastmcp_1 = require("fastmcp");
|
|
8
|
+
const openapi_parser_1 = require("./utils/openapi-parser");
|
|
9
|
+
const http_client_1 = require("./utils/http-client");
|
|
10
|
+
const auth_1 = require("./utils/auth");
|
|
11
|
+
const prompts_1 = require("./prompts");
|
|
12
|
+
const tools_1 = require("./tools");
|
|
13
|
+
const fs_1 = __importDefault(require("fs"));
|
|
14
|
+
const path_1 = __importDefault(require("path"));
|
|
15
|
+
function debugLog(message) {
|
|
16
|
+
try {
|
|
17
|
+
const debugPath = path_1.default.join(__dirname, "../debug.log");
|
|
18
|
+
fs_1.default.appendFileSync(debugPath, `${new Date().toISOString()}: ${message}\n`);
|
|
19
|
+
}
|
|
20
|
+
catch (e) { }
|
|
21
|
+
}
|
|
22
|
+
class OpenApiMcpServer {
|
|
23
|
+
fastMCP;
|
|
24
|
+
httpClient;
|
|
25
|
+
parsedSpecs = new Map();
|
|
26
|
+
toolRegistry = new Map();
|
|
27
|
+
authConfig = {};
|
|
28
|
+
config;
|
|
29
|
+
envPath;
|
|
30
|
+
lastEnvMtimeMs = null;
|
|
31
|
+
envWatcher;
|
|
32
|
+
envWatchTimeout;
|
|
33
|
+
resourceCounter = 0;
|
|
34
|
+
promptRegistrar;
|
|
35
|
+
toolRegistrar;
|
|
36
|
+
constructor(config) {
|
|
37
|
+
this.config = config;
|
|
38
|
+
this.httpClient = new http_client_1.HttpClient();
|
|
39
|
+
this.envPath = path_1.default.join(this.config.specsPath, ".env");
|
|
40
|
+
this.fastMCP = new fastmcp_1.FastMCP({
|
|
41
|
+
name: "SpecRun",
|
|
42
|
+
version: "1.0.0",
|
|
43
|
+
instructions: "I SpecRun OpenAPI specifications to MCP tools. I load .json, .yaml, and .yml files containing OpenAPI specs from a specified folder and automatically generate tools for each endpoint. Authentication is handled via environment variables with naming patterns like {API_NAME}_API_KEY.",
|
|
44
|
+
});
|
|
45
|
+
this.toolRegistrar = new tools_1.ToolRegistrar({
|
|
46
|
+
fastMCP: this.fastMCP,
|
|
47
|
+
toolRegistry: this.toolRegistry,
|
|
48
|
+
httpClient: this.httpClient,
|
|
49
|
+
getAuthConfig: () => this.authConfig,
|
|
50
|
+
refreshEnvConfigIfChanged: this.refreshEnvConfigIfChanged.bind(this),
|
|
51
|
+
createResponseResourceContent: this.createResponseResourceContent.bind(this),
|
|
52
|
+
});
|
|
53
|
+
this.promptRegistrar = new prompts_1.PromptRegistrar({
|
|
54
|
+
fastMCP: this.fastMCP,
|
|
55
|
+
toolRegistry: this.toolRegistry,
|
|
56
|
+
});
|
|
57
|
+
this.registerResponseResourceSupport();
|
|
58
|
+
this.setupServerEvents();
|
|
59
|
+
this.toolRegistrar.registerBatchDispatcherTool();
|
|
60
|
+
this.promptRegistrar.registerPrompts();
|
|
61
|
+
}
|
|
62
|
+
setupServerEvents() {
|
|
63
|
+
this.fastMCP.on("connect", (event) => {
|
|
64
|
+
this.authConfig = (0, auth_1.loadAuthConfig)(this.config.specsPath);
|
|
65
|
+
this.lastEnvMtimeMs = this.getEnvMtimeMs();
|
|
66
|
+
});
|
|
67
|
+
this.fastMCP.on("disconnect", (event) => { });
|
|
68
|
+
}
|
|
69
|
+
async start() {
|
|
70
|
+
// Only log to console if not in stdio mode (which would interfere with MCP protocol)
|
|
71
|
+
const isStdioMode = this.config.transportType !== "httpStream";
|
|
72
|
+
debugLog(`Starting SpecRun with specsPath: ${this.config.specsPath}`);
|
|
73
|
+
if (!isStdioMode) {
|
|
74
|
+
console.log("Starting SpecRun...");
|
|
75
|
+
}
|
|
76
|
+
// Load authentication config
|
|
77
|
+
await this.loadSpecs();
|
|
78
|
+
this.startEnvWatcher();
|
|
79
|
+
debugLog(`After loading specs: ${this.parsedSpecs.size} specs, ${this.getTotalToolsCount()} tools`);
|
|
80
|
+
// Start FastMCP server AFTER all tools are registered
|
|
81
|
+
const transportConfig = this.config.transportType === "httpStream" && this.config.port
|
|
82
|
+
? {
|
|
83
|
+
transportType: "httpStream",
|
|
84
|
+
httpStream: { port: this.config.port },
|
|
85
|
+
}
|
|
86
|
+
: { transportType: "stdio" };
|
|
87
|
+
this.fastMCP.start(transportConfig);
|
|
88
|
+
if (!isStdioMode) {
|
|
89
|
+
console.log(`SpecRun started. Loaded ${this.parsedSpecs.size} API specifications with ${this.getTotalToolsCount()} tools from ${this.config.specsPath}.`);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
async loadSpecs() {
|
|
93
|
+
const existingFiles = await this.getExistingFiles();
|
|
94
|
+
(0, auth_1.ensureEnvKeysForSpecs)(this.config.specsPath, existingFiles);
|
|
95
|
+
this.authConfig = (0, auth_1.loadAuthConfig)(this.config.specsPath);
|
|
96
|
+
(0, openapi_parser_1.updateSpecServerUrls)(existingFiles, process.env);
|
|
97
|
+
this.lastEnvMtimeMs = this.getEnvMtimeMs();
|
|
98
|
+
await this.loadExistingSpecs(existingFiles);
|
|
99
|
+
}
|
|
100
|
+
async stop() {
|
|
101
|
+
if (this.envWatchTimeout) {
|
|
102
|
+
clearTimeout(this.envWatchTimeout);
|
|
103
|
+
this.envWatchTimeout = undefined;
|
|
104
|
+
}
|
|
105
|
+
if (this.envWatcher) {
|
|
106
|
+
this.envWatcher.close();
|
|
107
|
+
this.envWatcher = undefined;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
async loadExistingSpecs(existingFiles) {
|
|
111
|
+
debugLog(`Found ${existingFiles.length} existing files: ${existingFiles.join(", ")}`);
|
|
112
|
+
for (const filePath of existingFiles) {
|
|
113
|
+
debugLog(`Processing file: ${filePath}`);
|
|
114
|
+
await this.handleSpecAdded(filePath);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
async getExistingFiles() {
|
|
118
|
+
try {
|
|
119
|
+
debugLog(`Reading directory: ${this.config.specsPath}`);
|
|
120
|
+
// Ensure directory exists
|
|
121
|
+
try {
|
|
122
|
+
await fs_1.default.promises.access(this.config.specsPath);
|
|
123
|
+
}
|
|
124
|
+
catch {
|
|
125
|
+
await fs_1.default.promises.mkdir(this.config.specsPath, { recursive: true });
|
|
126
|
+
return [];
|
|
127
|
+
}
|
|
128
|
+
const files = await fs_1.default.promises.readdir(this.config.specsPath);
|
|
129
|
+
debugLog(`Found files: ${files.join(", ")}`);
|
|
130
|
+
const filteredFiles = files.filter((file) => {
|
|
131
|
+
const isValid = (0, openapi_parser_1.isOpenAPIFile)(file);
|
|
132
|
+
debugLog(`File ${file}: isOpenAPIFile = ${isValid}`);
|
|
133
|
+
return isValid;
|
|
134
|
+
});
|
|
135
|
+
const fullPaths = filteredFiles.map((file) => path_1.default.join(this.config.specsPath, file));
|
|
136
|
+
debugLog(`Returning files: ${fullPaths.join(", ")}`);
|
|
137
|
+
return fullPaths;
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
debugLog(`Error reading directory ${this.config.specsPath}: ${error}`);
|
|
141
|
+
return [];
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
async handleSpecAdded(filePath) {
|
|
145
|
+
debugLog(`Attempting to parse: ${filePath}`);
|
|
146
|
+
const parsedSpec = await (0, openapi_parser_1.parseOpenApiSpec)(filePath);
|
|
147
|
+
if (parsedSpec) {
|
|
148
|
+
debugLog(`Successfully parsed ${filePath}: ${parsedSpec.tools.length} tools`);
|
|
149
|
+
this.parsedSpecs.set(filePath, parsedSpec);
|
|
150
|
+
this.toolRegistrar.registerToolsFromSpec(parsedSpec);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
debugLog(`Failed to parse: ${filePath}`);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
getEnvMtimeMs() {
|
|
157
|
+
try {
|
|
158
|
+
return fs_1.default.statSync(this.envPath).mtimeMs;
|
|
159
|
+
}
|
|
160
|
+
catch {
|
|
161
|
+
return null;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
refreshEnvConfigIfChanged(force = false) {
|
|
165
|
+
const currentMtimeMs = this.getEnvMtimeMs();
|
|
166
|
+
if (!force && currentMtimeMs === this.lastEnvMtimeMs) {
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
this.authConfig = (0, auth_1.loadAuthConfig)(this.config.specsPath);
|
|
170
|
+
(0, openapi_parser_1.updateSpecServerUrls)(Array.from(this.parsedSpecs.keys()), process.env);
|
|
171
|
+
this.updateToolBaseUrlsFromEnv();
|
|
172
|
+
this.lastEnvMtimeMs = currentMtimeMs;
|
|
173
|
+
}
|
|
174
|
+
updateToolBaseUrlsFromEnv() {
|
|
175
|
+
for (const spec of this.parsedSpecs.values()) {
|
|
176
|
+
const newBaseUrl = (0, openapi_parser_1.resolveServerUrl)(spec.apiName, process.env);
|
|
177
|
+
if (!newBaseUrl) {
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
const resolvedBaseUrl = this.resolveToolBaseUrl(spec, newBaseUrl);
|
|
181
|
+
for (const tool of spec.tools) {
|
|
182
|
+
tool.baseUrl = resolvedBaseUrl;
|
|
183
|
+
}
|
|
184
|
+
for (const entry of this.toolRegistry.values()) {
|
|
185
|
+
if (entry.spec.apiName === spec.apiName) {
|
|
186
|
+
entry.tool.baseUrl = resolvedBaseUrl;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
resolveToolBaseUrl(spec, newBaseUrl) {
|
|
192
|
+
const swaggerSpec = spec.spec;
|
|
193
|
+
if (swaggerSpec && swaggerSpec.swagger === "2.0") {
|
|
194
|
+
try {
|
|
195
|
+
const parsed = new URL(newBaseUrl);
|
|
196
|
+
const hasPath = parsed.pathname && parsed.pathname !== "/";
|
|
197
|
+
if (!hasPath && typeof swaggerSpec.basePath === "string") {
|
|
198
|
+
const basePath = swaggerSpec.basePath.trim();
|
|
199
|
+
if (basePath) {
|
|
200
|
+
parsed.pathname = basePath;
|
|
201
|
+
return parsed.toString().replace(/\/$/, "");
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
catch {
|
|
206
|
+
return newBaseUrl;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
if (swaggerSpec && swaggerSpec.openapi) {
|
|
210
|
+
return this.appendOpenApiBasePath(newBaseUrl, swaggerSpec);
|
|
211
|
+
}
|
|
212
|
+
return newBaseUrl;
|
|
213
|
+
}
|
|
214
|
+
appendOpenApiBasePath(baseUrl, spec) {
|
|
215
|
+
const basePath = this.getOpenApiBasePath(spec);
|
|
216
|
+
if (!basePath) {
|
|
217
|
+
return baseUrl;
|
|
218
|
+
}
|
|
219
|
+
try {
|
|
220
|
+
const parsed = new URL(baseUrl);
|
|
221
|
+
const hasPath = parsed.pathname && parsed.pathname !== "/";
|
|
222
|
+
if (hasPath) {
|
|
223
|
+
return baseUrl;
|
|
224
|
+
}
|
|
225
|
+
parsed.pathname = basePath;
|
|
226
|
+
return parsed.toString().replace(/\/$/, "");
|
|
227
|
+
}
|
|
228
|
+
catch {
|
|
229
|
+
return baseUrl;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
getOpenApiBasePath(spec) {
|
|
233
|
+
const raw = (typeof spec?.basePath === "string" && spec.basePath) || "";
|
|
234
|
+
const trimmed = String(raw).trim();
|
|
235
|
+
if (!trimmed) {
|
|
236
|
+
return null;
|
|
237
|
+
}
|
|
238
|
+
return trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
|
|
239
|
+
}
|
|
240
|
+
startEnvWatcher() {
|
|
241
|
+
if (this.envWatcher) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
try {
|
|
245
|
+
this.envWatcher = fs_1.default.watch(this.envPath, (eventType) => {
|
|
246
|
+
if (eventType !== "change" && eventType !== "rename") {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
if (this.envWatchTimeout) {
|
|
250
|
+
clearTimeout(this.envWatchTimeout);
|
|
251
|
+
}
|
|
252
|
+
this.envWatchTimeout = setTimeout(() => {
|
|
253
|
+
this.refreshEnvConfigIfChanged(true);
|
|
254
|
+
}, 50);
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
catch {
|
|
258
|
+
// Watching is best-effort; fall back to refresh-on-request only.
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
registerResponseResourceSupport() {
|
|
262
|
+
this.fastMCP.addResource({
|
|
263
|
+
uri: "specrun://responses",
|
|
264
|
+
name: "SpecRun Responses",
|
|
265
|
+
description: "SpecRun response resources",
|
|
266
|
+
mimeType: "application/json",
|
|
267
|
+
load: async () => ({
|
|
268
|
+
text: JSON.stringify({
|
|
269
|
+
message: "SpecRun response resources are available by URI.",
|
|
270
|
+
}),
|
|
271
|
+
}),
|
|
272
|
+
});
|
|
273
|
+
}
|
|
274
|
+
async createResponseResourceContent(name, description, payload) {
|
|
275
|
+
const uri = `specrun://responses/${this.createResourceId()}`;
|
|
276
|
+
this.fastMCP.addResource({
|
|
277
|
+
uri,
|
|
278
|
+
name,
|
|
279
|
+
description,
|
|
280
|
+
mimeType: "application/json",
|
|
281
|
+
load: async () => ({
|
|
282
|
+
text: JSON.stringify(payload, null, 2),
|
|
283
|
+
}),
|
|
284
|
+
});
|
|
285
|
+
return {
|
|
286
|
+
type: "resource",
|
|
287
|
+
resource: await this.fastMCP.embedded(uri),
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
createResourceId() {
|
|
291
|
+
this.resourceCounter += 1;
|
|
292
|
+
return `${Date.now()}-${this.resourceCounter}-${Math.floor(Math.random() * 1_000_000)}`;
|
|
293
|
+
}
|
|
294
|
+
getTotalToolsCount() {
|
|
295
|
+
return Array.from(this.parsedSpecs.values()).reduce((total, spec) => total + spec.tools.length, 0);
|
|
296
|
+
}
|
|
297
|
+
getLoadedSpecs() {
|
|
298
|
+
return Array.from(this.parsedSpecs.values());
|
|
299
|
+
}
|
|
300
|
+
getAuthConfig() {
|
|
301
|
+
return this.authConfig;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
exports.OpenApiMcpServer = OpenApiMcpServer;
|
|
305
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":";;;;;;AAAA,qCAAkC;AAGlC,2DAKgC;AAChC,qDAAiD;AACjD,uCAAqE;AACrE,uCAA4C;AAC5C,mCAAwC;AACxC,4CAAoB;AACpB,gDAAwB;AAExB,SAAS,QAAQ,CAAC,OAAe;IAC/B,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;QACvD,YAAE,CAAC,cAAc,CAAC,SAAS,EAAE,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,OAAO,IAAI,CAAC,CAAC;IAC5E,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC,CAAA,CAAC;AAChB,CAAC;AAED,MAAa,gBAAgB;IACnB,OAAO,CAAU;IACjB,UAAU,CAAa;IACvB,WAAW,GAA4B,IAAI,GAAG,EAAE,CAAC;IACjD,YAAY,GAGhB,IAAI,GAAG,EAAE,CAAC;IACN,UAAU,GAAe,EAAE,CAAC;IAC5B,MAAM,CAAe;IACrB,OAAO,CAAS;IAChB,cAAc,GAAkB,IAAI,CAAC;IACrC,UAAU,CAAgB;IAC1B,eAAe,CAAkB;IACjC,eAAe,GAAG,CAAC,CAAC;IACpB,eAAe,CAAkB;IACjC,aAAa,CAAgB;IAErC,YAAY,MAAoB;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,UAAU,GAAG,IAAI,wBAAU,EAAE,CAAC;QACnC,IAAI,CAAC,OAAO,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;QAExD,IAAI,CAAC,OAAO,GAAG,IAAI,iBAAO,CAA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CAAC,CAAC;aACvC,CAAC;SACH,CAAC,CAAC;QAEH,OAAO;YACL,IAAI,EAAE,UAAU;YAChB,QAAQ,EAAE,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;SAC3C,CAAC;IACJ,CAAC;IAEO,gBAAgB;QACtB,IAAI,CAAC,eAAe,IAAI,CAAC,CAAC;QAC1B,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,KAAK,CACxD,IAAI,CAAC,MAAM,EAAE,GAAG,SAAS,CAC1B,EAAE,CAAC;IACN,CAAC;IAEO,kBAAkB;QACxB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC,MAAM,CACjD,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAC1C,CAAC,CACF,CAAC;IACJ,CAAC;IAEM,cAAc;QACnB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;IAC/C,CAAC;IAEM,aAAa;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;CACF;AA7VD,4CA6VC"}
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { FastMCP } from "fastmcp";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { ParsedSpec, GeneratedTool, AuthConfig } from "./types";
|
|
4
|
+
import { HttpClient } from "./utils/http-client";
|
|
5
|
+
type ToolRegistryEntry = {
|
|
6
|
+
spec: ParsedSpec;
|
|
7
|
+
tool: GeneratedTool;
|
|
8
|
+
schema: z.ZodObject<any>;
|
|
9
|
+
};
|
|
10
|
+
type ToolRegistry = Map<string, ToolRegistryEntry>;
|
|
11
|
+
type ToolRegistrarOptions = {
|
|
12
|
+
fastMCP: FastMCP;
|
|
13
|
+
toolRegistry: ToolRegistry;
|
|
14
|
+
httpClient: HttpClient;
|
|
15
|
+
getAuthConfig: () => AuthConfig;
|
|
16
|
+
refreshEnvConfigIfChanged: () => void;
|
|
17
|
+
createResponseResourceContent: (name: string, description: string, payload: unknown) => Promise<{
|
|
18
|
+
type: "resource";
|
|
19
|
+
resource: any;
|
|
20
|
+
}>;
|
|
21
|
+
};
|
|
22
|
+
export declare class ToolRegistrar {
|
|
23
|
+
private static readonly largeBatchThreshold;
|
|
24
|
+
private static readonly largeBatchTokenTtlMs;
|
|
25
|
+
private fastMCP;
|
|
26
|
+
private toolRegistry;
|
|
27
|
+
private httpClient;
|
|
28
|
+
private getAuthConfig;
|
|
29
|
+
private refreshEnvConfigIfChanged;
|
|
30
|
+
private createResponseResourceContent;
|
|
31
|
+
private largeBatchConfirmations;
|
|
32
|
+
constructor(options: ToolRegistrarOptions);
|
|
33
|
+
registerToolsFromSpec(spec: ParsedSpec): void;
|
|
34
|
+
registerBatchDispatcherTool(): void;
|
|
35
|
+
private normalizeToolName;
|
|
36
|
+
private registerTool;
|
|
37
|
+
private issueLargeBatchToken;
|
|
38
|
+
private isLargeBatchConfirmed;
|
|
39
|
+
private buildZodSchema;
|
|
40
|
+
private openAPISchemaToZod;
|
|
41
|
+
}
|
|
42
|
+
export {};
|
|
43
|
+
//# sourceMappingURL=tools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,UAAU,EACV,aAAa,EAGb,UAAU,EACX,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,KAAK,iBAAiB,GAAG;IACvB,IAAI,EAAE,UAAU,CAAC;IAC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
@@ -0,0 +1,249 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ToolRegistrar = void 0;
|
|
4
|
+
const crypto_1 = require("crypto");
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
class ToolRegistrar {
|
|
7
|
+
static largeBatchThreshold = 200;
|
|
8
|
+
static largeBatchTokenTtlMs = 5 * 60 * 1000;
|
|
9
|
+
fastMCP;
|
|
10
|
+
toolRegistry;
|
|
11
|
+
httpClient;
|
|
12
|
+
getAuthConfig;
|
|
13
|
+
refreshEnvConfigIfChanged;
|
|
14
|
+
createResponseResourceContent;
|
|
15
|
+
largeBatchConfirmations;
|
|
16
|
+
constructor(options) {
|
|
17
|
+
this.fastMCP = options.fastMCP;
|
|
18
|
+
this.toolRegistry = options.toolRegistry;
|
|
19
|
+
this.httpClient = options.httpClient;
|
|
20
|
+
this.getAuthConfig = options.getAuthConfig;
|
|
21
|
+
this.refreshEnvConfigIfChanged = options.refreshEnvConfigIfChanged;
|
|
22
|
+
this.createResponseResourceContent = options.createResponseResourceContent;
|
|
23
|
+
this.largeBatchConfirmations = new Map();
|
|
24
|
+
}
|
|
25
|
+
registerToolsFromSpec(spec) {
|
|
26
|
+
for (const tool of spec.tools) {
|
|
27
|
+
this.registerTool(spec, tool);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
registerBatchDispatcherTool() {
|
|
31
|
+
const batchSchema = zod_1.z.object({
|
|
32
|
+
toolName: zod_1.z.string().min(1),
|
|
33
|
+
items: zod_1.z.array(zod_1.z.any()).min(1),
|
|
34
|
+
failFast: zod_1.z.boolean().optional(),
|
|
35
|
+
confirmLargeBatch: zod_1.z.boolean().optional(),
|
|
36
|
+
confirmLargeBatchToken: zod_1.z.string().min(1).optional(),
|
|
37
|
+
});
|
|
38
|
+
this.fastMCP.addTool({
|
|
39
|
+
name: "specrun_batch",
|
|
40
|
+
description: "Run any SpecRun tool in batch with multiple inputs",
|
|
41
|
+
parameters: batchSchema,
|
|
42
|
+
execute: async (args) => {
|
|
43
|
+
this.refreshEnvConfigIfChanged();
|
|
44
|
+
const rawToolName = String(args.toolName || "");
|
|
45
|
+
const toolName = this.normalizeToolName(rawToolName);
|
|
46
|
+
const entry = this.toolRegistry.get(toolName);
|
|
47
|
+
if (!entry) {
|
|
48
|
+
const resource = await this.createResponseResourceContent("SpecRun Batch Error", "Batch execution error", {
|
|
49
|
+
toolName: rawToolName,
|
|
50
|
+
normalizedToolName: toolName,
|
|
51
|
+
error: `Unknown tool: ${toolName}`,
|
|
52
|
+
});
|
|
53
|
+
return {
|
|
54
|
+
content: [resource],
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
const items = Array.isArray(args.items) ? args.items : [];
|
|
58
|
+
const failFast = Boolean(args.failFast);
|
|
59
|
+
const confirmLargeBatch = Boolean(args.confirmLargeBatch);
|
|
60
|
+
const confirmLargeBatchToken = typeof args.confirmLargeBatchToken === "string"
|
|
61
|
+
? args.confirmLargeBatchToken
|
|
62
|
+
: "";
|
|
63
|
+
if (items.length > ToolRegistrar.largeBatchThreshold &&
|
|
64
|
+
!this.isLargeBatchConfirmed(confirmLargeBatch, confirmLargeBatchToken, toolName, items.length)) {
|
|
65
|
+
const token = this.issueLargeBatchToken(toolName, items.length);
|
|
66
|
+
const resource = await this.createResponseResourceContent("SpecRun Batch Confirmation Required", "Batch execution confirmation required", {
|
|
67
|
+
toolName,
|
|
68
|
+
count: items.length,
|
|
69
|
+
threshold: ToolRegistrar.largeBatchThreshold,
|
|
70
|
+
confirmLargeBatchToken: token,
|
|
71
|
+
confirmLargeBatchTokenTtlMs: ToolRegistrar.largeBatchTokenTtlMs,
|
|
72
|
+
message: "Batch execution over 200 items requires user confirmation. Re-run with confirmLargeBatch: true and confirmLargeBatchToken to proceed.",
|
|
73
|
+
});
|
|
74
|
+
return {
|
|
75
|
+
content: [
|
|
76
|
+
{
|
|
77
|
+
type: "text",
|
|
78
|
+
text: "Confirmation required: ask the user to approve this batch, then retry with confirmLargeBatch: true and the provided confirmLargeBatchToken.",
|
|
79
|
+
},
|
|
80
|
+
resource,
|
|
81
|
+
],
|
|
82
|
+
isError: true,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
const results = [];
|
|
86
|
+
for (let index = 0; index < items.length; index += 1) {
|
|
87
|
+
const itemArgs = items[index];
|
|
88
|
+
const parsedArgs = entry.schema.safeParse(itemArgs);
|
|
89
|
+
if (!parsedArgs.success) {
|
|
90
|
+
results.push({
|
|
91
|
+
index,
|
|
92
|
+
error: parsedArgs.error.message,
|
|
93
|
+
});
|
|
94
|
+
if (failFast) {
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
const context = {
|
|
100
|
+
apiName: entry.spec.apiName,
|
|
101
|
+
tool: entry.tool,
|
|
102
|
+
authConfig: this.getAuthConfig()[entry.spec.apiName],
|
|
103
|
+
};
|
|
104
|
+
try {
|
|
105
|
+
const output = await this.httpClient.executeRequest(context, parsedArgs.data);
|
|
106
|
+
results.push({ index, result: output });
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
110
|
+
results.push({ index, error: message });
|
|
111
|
+
if (failFast) {
|
|
112
|
+
break;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const resource = await this.createResponseResourceContent(`SpecRun Batch ${toolName}`, `Batch responses for ${toolName}`, {
|
|
117
|
+
toolName,
|
|
118
|
+
count: items.length,
|
|
119
|
+
results,
|
|
120
|
+
});
|
|
121
|
+
return {
|
|
122
|
+
content: [resource],
|
|
123
|
+
};
|
|
124
|
+
},
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
normalizeToolName(value) {
|
|
128
|
+
const trimmed = value.trim();
|
|
129
|
+
const prefixes = ["mcp_specrun_", "specrun_"];
|
|
130
|
+
for (const prefix of prefixes) {
|
|
131
|
+
if (trimmed.startsWith(prefix)) {
|
|
132
|
+
return trimmed.slice(prefix.length);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return trimmed;
|
|
136
|
+
}
|
|
137
|
+
registerTool(spec, tool) {
|
|
138
|
+
const schema = this.buildZodSchema(tool);
|
|
139
|
+
this.toolRegistry.set(tool.name, { spec, tool, schema });
|
|
140
|
+
this.fastMCP.addTool({
|
|
141
|
+
name: tool.name,
|
|
142
|
+
description: tool.description,
|
|
143
|
+
parameters: schema,
|
|
144
|
+
execute: async (args) => {
|
|
145
|
+
this.refreshEnvConfigIfChanged();
|
|
146
|
+
const context = {
|
|
147
|
+
apiName: spec.apiName,
|
|
148
|
+
tool,
|
|
149
|
+
authConfig: this.getAuthConfig()[spec.apiName],
|
|
150
|
+
};
|
|
151
|
+
const result = await this.httpClient.executeRequest(context, args);
|
|
152
|
+
const resource = await this.createResponseResourceContent(`SpecRun Response ${tool.name}`, `Response for ${tool.name}`, result);
|
|
153
|
+
return {
|
|
154
|
+
content: [resource],
|
|
155
|
+
};
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
issueLargeBatchToken(toolName, count) {
|
|
160
|
+
const token = (0, crypto_1.randomUUID)();
|
|
161
|
+
this.largeBatchConfirmations.set(token, {
|
|
162
|
+
toolName,
|
|
163
|
+
count,
|
|
164
|
+
expiresAt: Date.now() + ToolRegistrar.largeBatchTokenTtlMs,
|
|
165
|
+
});
|
|
166
|
+
return token;
|
|
167
|
+
}
|
|
168
|
+
isLargeBatchConfirmed(confirmLargeBatch, confirmLargeBatchToken, toolName, count) {
|
|
169
|
+
if (!confirmLargeBatch || !confirmLargeBatchToken) {
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
const record = this.largeBatchConfirmations.get(confirmLargeBatchToken);
|
|
173
|
+
if (!record) {
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
if (record.expiresAt <= Date.now()) {
|
|
177
|
+
this.largeBatchConfirmations.delete(confirmLargeBatchToken);
|
|
178
|
+
return false;
|
|
179
|
+
}
|
|
180
|
+
if (record.toolName !== toolName || record.count !== count) {
|
|
181
|
+
return false;
|
|
182
|
+
}
|
|
183
|
+
this.largeBatchConfirmations.delete(confirmLargeBatchToken);
|
|
184
|
+
return true;
|
|
185
|
+
}
|
|
186
|
+
buildZodSchema(tool) {
|
|
187
|
+
const schemaFields = {};
|
|
188
|
+
for (const param of tool.parameters) {
|
|
189
|
+
let fieldSchema = this.openAPISchemaToZod(param.schema);
|
|
190
|
+
if (param.description) {
|
|
191
|
+
fieldSchema = fieldSchema.describe(param.description);
|
|
192
|
+
}
|
|
193
|
+
if (!param.required) {
|
|
194
|
+
fieldSchema = fieldSchema.optional();
|
|
195
|
+
}
|
|
196
|
+
schemaFields[param.name] = fieldSchema;
|
|
197
|
+
}
|
|
198
|
+
if (tool.requestBody) {
|
|
199
|
+
schemaFields.body = zod_1.z.any().optional().describe("Request body data");
|
|
200
|
+
}
|
|
201
|
+
const schema = zod_1.z.object(schemaFields);
|
|
202
|
+
return tool.requestBody ? schema.passthrough() : schema;
|
|
203
|
+
}
|
|
204
|
+
openAPISchemaToZod(schema) {
|
|
205
|
+
if (!schema || typeof schema !== "object") {
|
|
206
|
+
return zod_1.z.any();
|
|
207
|
+
}
|
|
208
|
+
switch (schema.type) {
|
|
209
|
+
case "string":
|
|
210
|
+
return zod_1.z.string();
|
|
211
|
+
case "number":
|
|
212
|
+
return zod_1.z.number();
|
|
213
|
+
case "integer":
|
|
214
|
+
return zod_1.z.number().int();
|
|
215
|
+
case "boolean":
|
|
216
|
+
return zod_1.z.boolean();
|
|
217
|
+
case "array":
|
|
218
|
+
return zod_1.z.array(this.openAPISchemaToZod(schema.items || {}));
|
|
219
|
+
case "object": {
|
|
220
|
+
const properties = schema.properties || {};
|
|
221
|
+
const required = new Set(schema.required || []);
|
|
222
|
+
const shape = {};
|
|
223
|
+
for (const [key, value] of Object.entries(properties)) {
|
|
224
|
+
let propertySchema = this.openAPISchemaToZod(value);
|
|
225
|
+
if (!required.has(key)) {
|
|
226
|
+
propertySchema = propertySchema.optional();
|
|
227
|
+
}
|
|
228
|
+
shape[key] = propertySchema;
|
|
229
|
+
}
|
|
230
|
+
let objectSchema = zod_1.z.object(shape);
|
|
231
|
+
const additional = schema.additionalProperties;
|
|
232
|
+
if (additional === false) {
|
|
233
|
+
objectSchema = objectSchema.strict();
|
|
234
|
+
}
|
|
235
|
+
else if (additional === true || additional === undefined) {
|
|
236
|
+
objectSchema = objectSchema.loose();
|
|
237
|
+
}
|
|
238
|
+
else if (typeof additional === "object") {
|
|
239
|
+
objectSchema = objectSchema.catchall(this.openAPISchemaToZod(additional));
|
|
240
|
+
}
|
|
241
|
+
return objectSchema;
|
|
242
|
+
}
|
|
243
|
+
default:
|
|
244
|
+
return zod_1.z.any();
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
exports.ToolRegistrar = ToolRegistrar;
|
|
249
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":";;;AAAA,mCAAoC;AAEpC,6BAAwB;AA+BxB,MAAa,aAAa;IAChB,MAAM,CAAU,mBAAmB,GAAG,GAAG,CAAC;IAC1C,MAAM,CAAU,oBAAoB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;IACrD,OAAO,CAAU;IACjB,YAAY,CAAe;IAC3B,UAAU,CAAa;IACvB,aAAa,CAAmB;IAChC,yBAAyB,CAAa;IACtC,6BAA6B,CAAwD;IACrF,uBAAuB,CAG7B;IAEF,YAAY,OAA6B;QACvC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;QACzC,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,UAAU,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