@apicircle/mcp-server 1.0.8 → 1.0.9
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/bin/mcp-server.cjs +232 -93
- package/dist/bin/mcp-server.cjs.map +1 -1
- package/dist/index.cjs +223 -91
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +222 -90
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/bin/mcp-server.cjs
CHANGED
|
@@ -36,7 +36,7 @@ var init_package = __esm({
|
|
|
36
36
|
"package.json"() {
|
|
37
37
|
package_default = {
|
|
38
38
|
name: "@apicircle/mcp-server",
|
|
39
|
-
version: "1.0.
|
|
39
|
+
version: "1.0.9",
|
|
40
40
|
private: false,
|
|
41
41
|
type: "module",
|
|
42
42
|
description: "Model Context Protocol server exposing API Circle Studio's workspace as a tool catalog. Used by Claude Desktop, ChatGPT, Cursor, GitHub Copilot, and any other MCP-compatible AI client.",
|
|
@@ -2205,12 +2205,146 @@ var init_prompt = __esm({
|
|
|
2205
2205
|
}
|
|
2206
2206
|
});
|
|
2207
2207
|
|
|
2208
|
+
// src/tools/globalAssets.ts
|
|
2209
|
+
function deriveState(asset, hasPendingUpload) {
|
|
2210
|
+
const w = asset.workingBranchRef ?? null;
|
|
2211
|
+
const b = asset.baseBranchRef ?? null;
|
|
2212
|
+
if (w && b) {
|
|
2213
|
+
if (w.blobSha && b.blobSha && w.blobSha !== b.blobSha) return "diverged";
|
|
2214
|
+
return "merged";
|
|
2215
|
+
}
|
|
2216
|
+
if (w && !b) return "workingOnly";
|
|
2217
|
+
if (!w && b) return "baseOnly";
|
|
2218
|
+
if (hasPendingUpload) return "uploading";
|
|
2219
|
+
return "missing";
|
|
2220
|
+
}
|
|
2221
|
+
var import_zod10, import_shared4, globalAssetsFilesListTool, globalAssetsFilesCreateTool, globalAssetsFilesUpdateTool, globalAssetsFilesDeleteTool;
|
|
2222
|
+
var init_globalAssets = __esm({
|
|
2223
|
+
"src/tools/globalAssets.ts"() {
|
|
2224
|
+
"use strict";
|
|
2225
|
+
import_zod10 = require("zod");
|
|
2226
|
+
import_shared4 = require("@apicircle/shared");
|
|
2227
|
+
globalAssetsFilesListTool = {
|
|
2228
|
+
name: "assets.list_files",
|
|
2229
|
+
description: "List every Global File Asset with its provenance state and reference count. Each entry includes id, name, filename, size, mimeType, sha256, state (uploading | workingOnly | merged | baseOnly | missing | diverged), workingBranchRef, baseBranchRef, and usage { requests, mockEndpoints, total }.",
|
|
2230
|
+
inputSchema: import_zod10.z.object({}).strict(),
|
|
2231
|
+
async handler(_input, ctx) {
|
|
2232
|
+
const state = await ctx.workspace.read();
|
|
2233
|
+
const files = state.synced.globalAssets.files ?? {};
|
|
2234
|
+
const pending = state.local.pendingFileUploads ?? {};
|
|
2235
|
+
const usage = state.local.assetUsageIndex ?? {};
|
|
2236
|
+
const items = Object.values(files).map((asset) => {
|
|
2237
|
+
const hasPending = Boolean(pending[asset.id]);
|
|
2238
|
+
const u = usage[asset.id] ?? { requests: [], mockEndpoints: [], total: 0 };
|
|
2239
|
+
return {
|
|
2240
|
+
id: asset.id,
|
|
2241
|
+
name: asset.name,
|
|
2242
|
+
description: asset.description ?? null,
|
|
2243
|
+
filename: asset.filename,
|
|
2244
|
+
size: asset.size,
|
|
2245
|
+
mimeType: asset.mimeType,
|
|
2246
|
+
sha256: asset.sha256 ?? null,
|
|
2247
|
+
state: deriveState(asset, hasPending),
|
|
2248
|
+
workingBranchRef: asset.workingBranchRef ?? null,
|
|
2249
|
+
baseBranchRef: asset.baseBranchRef ?? null,
|
|
2250
|
+
usage: { ...u }
|
|
2251
|
+
};
|
|
2252
|
+
});
|
|
2253
|
+
return { count: items.length, files: items };
|
|
2254
|
+
}
|
|
2255
|
+
};
|
|
2256
|
+
globalAssetsFilesCreateTool = {
|
|
2257
|
+
name: "assets.create_file",
|
|
2258
|
+
description: 'Register a Global File Asset entry. Bytes are NOT carried \u2014 MCP returns the new asset id and the asset enters the "missing" state. The user fills the bytes from the Global Assets panel (a "Fill bytes" button surfaces on missing-state assets) which preserves the slot id and queues the bytes for the next push. Use this when an AI client wants to claim an asset slot for a file the user will provide later.',
|
|
2259
|
+
inputSchema: import_zod10.z.object({
|
|
2260
|
+
name: import_zod10.z.string().min(1, "name is required"),
|
|
2261
|
+
description: import_zod10.z.string().optional(),
|
|
2262
|
+
filename: import_zod10.z.string().min(1, "filename is required"),
|
|
2263
|
+
size: import_zod10.z.number().int().nonnegative(),
|
|
2264
|
+
mimeType: import_zod10.z.string().default("application/octet-stream"),
|
|
2265
|
+
sha256: import_zod10.z.string().optional()
|
|
2266
|
+
}).strict(),
|
|
2267
|
+
async handler(input, ctx) {
|
|
2268
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
2269
|
+
const file = {
|
|
2270
|
+
id: (0, import_shared4.generateId)(),
|
|
2271
|
+
name: input.name,
|
|
2272
|
+
description: input.description,
|
|
2273
|
+
slotId: (0, import_shared4.generateId)(),
|
|
2274
|
+
filename: input.filename,
|
|
2275
|
+
size: input.size,
|
|
2276
|
+
mimeType: input.mimeType,
|
|
2277
|
+
sha256: input.sha256,
|
|
2278
|
+
createdAt: now,
|
|
2279
|
+
updatedAt: now
|
|
2280
|
+
};
|
|
2281
|
+
const out = await ctx.workspace.apply({ kind: "globalAsset.upsertFile", file });
|
|
2282
|
+
return { id: file.id, slotId: file.slotId, changedIds: out.changedIds };
|
|
2283
|
+
}
|
|
2284
|
+
};
|
|
2285
|
+
globalAssetsFilesUpdateTool = {
|
|
2286
|
+
name: "assets.update_file",
|
|
2287
|
+
description: "Rename or re-describe a Global File Asset. Provenance refs (workingBranchRef, baseBranchRef) and binary metadata (slotId, sha256, size, mimeType) are preserved verbatim.",
|
|
2288
|
+
inputSchema: import_zod10.z.object({
|
|
2289
|
+
id: import_zod10.z.string().min(1),
|
|
2290
|
+
patch: import_zod10.z.object({
|
|
2291
|
+
name: import_zod10.z.string().optional(),
|
|
2292
|
+
description: import_zod10.z.string().nullable().optional()
|
|
2293
|
+
}).strict()
|
|
2294
|
+
}).strict(),
|
|
2295
|
+
async handler(input, ctx) {
|
|
2296
|
+
const state = await ctx.workspace.read();
|
|
2297
|
+
const existing = state.synced.globalAssets.files?.[input.id];
|
|
2298
|
+
if (!existing) {
|
|
2299
|
+
return { found: false, changedIds: [] };
|
|
2300
|
+
}
|
|
2301
|
+
const next = {
|
|
2302
|
+
...existing,
|
|
2303
|
+
name: input.patch.name ?? existing.name,
|
|
2304
|
+
description: input.patch.description === null ? void 0 : input.patch.description ?? existing.description
|
|
2305
|
+
};
|
|
2306
|
+
const out = await ctx.workspace.apply({ kind: "globalAsset.upsertFile", file: next });
|
|
2307
|
+
return { found: true, id: next.id, changedIds: out.changedIds };
|
|
2308
|
+
}
|
|
2309
|
+
};
|
|
2310
|
+
globalAssetsFilesDeleteTool = {
|
|
2311
|
+
name: "assets.delete_file",
|
|
2312
|
+
description: "Delete a Global File Asset. Cascades \u2014 every request body and mock-response body that referenced the asset is unbound in the same mutation. The result envelope includes the consumer list that was cleared so the caller can report what changed.",
|
|
2313
|
+
inputSchema: import_zod10.z.object({ id: import_zod10.z.string().min(1) }).strict(),
|
|
2314
|
+
async handler(input, ctx) {
|
|
2315
|
+
const before = await ctx.workspace.read();
|
|
2316
|
+
const usage = before.local.assetUsageIndex?.[input.id] ?? {
|
|
2317
|
+
requests: [],
|
|
2318
|
+
mockEndpoints: [],
|
|
2319
|
+
total: 0
|
|
2320
|
+
};
|
|
2321
|
+
const existing = before.synced.globalAssets.files?.[input.id];
|
|
2322
|
+
if (!existing) {
|
|
2323
|
+
return { found: false, changedIds: [] };
|
|
2324
|
+
}
|
|
2325
|
+
const out = await ctx.workspace.apply({ kind: "globalAsset.removeFile", id: input.id });
|
|
2326
|
+
return {
|
|
2327
|
+
found: true,
|
|
2328
|
+
id: input.id,
|
|
2329
|
+
filename: existing.filename,
|
|
2330
|
+
unbound: {
|
|
2331
|
+
requests: usage.requests,
|
|
2332
|
+
mockEndpoints: usage.mockEndpoints,
|
|
2333
|
+
total: usage.total
|
|
2334
|
+
},
|
|
2335
|
+
changedIds: out.changedIds
|
|
2336
|
+
};
|
|
2337
|
+
}
|
|
2338
|
+
};
|
|
2339
|
+
}
|
|
2340
|
+
});
|
|
2341
|
+
|
|
2208
2342
|
// src/tools/mocks.ts
|
|
2209
2343
|
async function ingestSource(source, name) {
|
|
2210
2344
|
const { endpoints, warnings } = await (0, import_mock_server_core2.parseSourceToEndpoints)(source);
|
|
2211
2345
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
2212
2346
|
const mock = {
|
|
2213
|
-
id: (0,
|
|
2347
|
+
id: (0, import_shared5.generateId)(),
|
|
2214
2348
|
name,
|
|
2215
2349
|
source,
|
|
2216
2350
|
endpoints,
|
|
@@ -2231,16 +2365,16 @@ function buildDefaultEndpoint(args) {
|
|
|
2231
2365
|
};
|
|
2232
2366
|
const headers = [{ key: "Content-Type", value: response.contentType, enabled: true }];
|
|
2233
2367
|
return {
|
|
2234
|
-
id: (0,
|
|
2368
|
+
id: (0, import_shared5.generateId)(),
|
|
2235
2369
|
name: args.name ?? `${args.method} ${args.pathPattern}`,
|
|
2236
2370
|
method: args.method,
|
|
2237
2371
|
pathPattern: args.pathPattern,
|
|
2238
2372
|
description: args.description,
|
|
2239
|
-
requestSchema: (0,
|
|
2373
|
+
requestSchema: (0, import_shared5.makeDefaultRequestSchema)(),
|
|
2240
2374
|
requestValidation: [],
|
|
2241
2375
|
responseRules: [],
|
|
2242
2376
|
defaultResponse: {
|
|
2243
|
-
...(0,
|
|
2377
|
+
...(0, import_shared5.makeDefaultMockResponse)(),
|
|
2244
2378
|
status: response.status,
|
|
2245
2379
|
headers,
|
|
2246
2380
|
body: { type: "json", content: response.jsonBody }
|
|
@@ -2267,20 +2401,20 @@ function patchEndpoint2(mock, endpointId, patcher) {
|
|
|
2267
2401
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
2268
2402
|
};
|
|
2269
2403
|
}
|
|
2270
|
-
var
|
|
2404
|
+
var import_zod11, import_shared5, import_mock_server_core2, mockCreateFromOpenApiTool, mockCreateFromPostmanTool, mockCreateFromInsomniaTool, mockImportPostmanMockCollectionTool, mockListTool, mockStartTool, mockStopTool, mockDeleteTool, HTTP_METHOD3, mockCreateManualTool, mockListEndpointsTool, ENDPOINT_RESPONSE2, mockAddEndpointTool, mockUpdateEndpointTool, mockDeleteEndpointTool, VALIDATION_RULE, CONDITION_CLAUSE, RESPONSE_RULE, MULTIPLIER, mockSetValidationRulesTool, mockSetResponseRulesTool, mockSetMultipliersTool;
|
|
2271
2405
|
var init_mocks = __esm({
|
|
2272
2406
|
"src/tools/mocks.ts"() {
|
|
2273
2407
|
"use strict";
|
|
2274
|
-
|
|
2275
|
-
|
|
2408
|
+
import_zod11 = require("zod");
|
|
2409
|
+
import_shared5 = require("@apicircle/shared");
|
|
2276
2410
|
import_mock_server_core2 = require("@apicircle/mock-server-core");
|
|
2277
2411
|
mockCreateFromOpenApiTool = {
|
|
2278
2412
|
name: "mock.create_from_openapi",
|
|
2279
2413
|
description: "Create a mock server from an OpenAPI / Swagger spec (YAML or JSON).",
|
|
2280
|
-
inputSchema:
|
|
2281
|
-
name:
|
|
2282
|
-
spec:
|
|
2283
|
-
format:
|
|
2414
|
+
inputSchema: import_zod11.z.object({
|
|
2415
|
+
name: import_zod11.z.string(),
|
|
2416
|
+
spec: import_zod11.z.string().min(1),
|
|
2417
|
+
format: import_zod11.z.enum(["json", "yaml"]).default("json")
|
|
2284
2418
|
}),
|
|
2285
2419
|
async handler(input, ctx) {
|
|
2286
2420
|
const { mock, warnings } = await ingestSource(
|
|
@@ -2299,7 +2433,7 @@ var init_mocks = __esm({
|
|
|
2299
2433
|
mockCreateFromPostmanTool = {
|
|
2300
2434
|
name: "mock.create_from_postman",
|
|
2301
2435
|
description: "Create a mock server from a Postman v2/v2.1 collection.",
|
|
2302
|
-
inputSchema:
|
|
2436
|
+
inputSchema: import_zod11.z.object({ name: import_zod11.z.string(), collection: import_zod11.z.string().min(1) }),
|
|
2303
2437
|
async handler(input, ctx) {
|
|
2304
2438
|
const { mock, warnings } = await ingestSource(
|
|
2305
2439
|
{ kind: "postman", collection: input.collection },
|
|
@@ -2317,7 +2451,7 @@ var init_mocks = __esm({
|
|
|
2317
2451
|
mockCreateFromInsomniaTool = {
|
|
2318
2452
|
name: "mock.create_from_insomnia",
|
|
2319
2453
|
description: "Create a mock server from an Insomnia v4 export.",
|
|
2320
|
-
inputSchema:
|
|
2454
|
+
inputSchema: import_zod11.z.object({ name: import_zod11.z.string(), export: import_zod11.z.string().min(1) }),
|
|
2321
2455
|
async handler(input, ctx) {
|
|
2322
2456
|
const { mock, warnings } = await ingestSource(
|
|
2323
2457
|
{ kind: "insomnia", export: input.export },
|
|
@@ -2335,7 +2469,7 @@ var init_mocks = __esm({
|
|
|
2335
2469
|
mockImportPostmanMockCollectionTool = {
|
|
2336
2470
|
name: "mock.import_postman_mock_collection",
|
|
2337
2471
|
description: "Import a Postman Mock Collection (collections previously hosted on Postman's mock service). Same parser as a regular Postman collection but marked as a mock import.",
|
|
2338
|
-
inputSchema:
|
|
2472
|
+
inputSchema: import_zod11.z.object({ name: import_zod11.z.string(), collection: import_zod11.z.string().min(1) }),
|
|
2339
2473
|
async handler(input, ctx) {
|
|
2340
2474
|
const { mock, warnings } = await ingestSource(
|
|
2341
2475
|
{ kind: "postman", collection: input.collection },
|
|
@@ -2353,7 +2487,7 @@ var init_mocks = __esm({
|
|
|
2353
2487
|
mockListTool = {
|
|
2354
2488
|
name: "mock.list",
|
|
2355
2489
|
description: "List all mock servers in the workspace plus their runtime status (running / stopped, port).",
|
|
2356
|
-
inputSchema:
|
|
2490
|
+
inputSchema: import_zod11.z.object({}),
|
|
2357
2491
|
async handler(_input, ctx) {
|
|
2358
2492
|
const state = await ctx.workspace.read();
|
|
2359
2493
|
const running = await ctx.mock.list();
|
|
@@ -2375,9 +2509,9 @@ var init_mocks = __esm({
|
|
|
2375
2509
|
mockStartTool = {
|
|
2376
2510
|
name: "mock.start",
|
|
2377
2511
|
description: "Start a mock server by id. Returns the bound port. Errors if the mock is already running or the requested port is in use.",
|
|
2378
|
-
inputSchema:
|
|
2379
|
-
id:
|
|
2380
|
-
port:
|
|
2512
|
+
inputSchema: import_zod11.z.object({
|
|
2513
|
+
id: import_zod11.z.string(),
|
|
2514
|
+
port: import_zod11.z.number().int().positive().optional()
|
|
2381
2515
|
}),
|
|
2382
2516
|
async handler(input, ctx) {
|
|
2383
2517
|
const state = await ctx.workspace.read();
|
|
@@ -2394,7 +2528,7 @@ var init_mocks = __esm({
|
|
|
2394
2528
|
mockStopTool = {
|
|
2395
2529
|
name: "mock.stop",
|
|
2396
2530
|
description: "Stop a running mock server by id (no-op if not running).",
|
|
2397
|
-
inputSchema:
|
|
2531
|
+
inputSchema: import_zod11.z.object({ id: import_zod11.z.string() }),
|
|
2398
2532
|
async handler(input, ctx) {
|
|
2399
2533
|
try {
|
|
2400
2534
|
await ctx.mock.stop(input.id);
|
|
@@ -2407,7 +2541,7 @@ var init_mocks = __esm({
|
|
|
2407
2541
|
mockDeleteTool = {
|
|
2408
2542
|
name: "mock.delete",
|
|
2409
2543
|
description: "Delete a mock server definition. Stops it first if it's running.",
|
|
2410
|
-
inputSchema:
|
|
2544
|
+
inputSchema: import_zod11.z.object({ id: import_zod11.z.string() }),
|
|
2411
2545
|
async handler(input, ctx) {
|
|
2412
2546
|
try {
|
|
2413
2547
|
await ctx.mock.stop(input.id);
|
|
@@ -2417,18 +2551,18 @@ var init_mocks = __esm({
|
|
|
2417
2551
|
return { ok: true, changedIds: out.changedIds };
|
|
2418
2552
|
}
|
|
2419
2553
|
};
|
|
2420
|
-
HTTP_METHOD3 =
|
|
2554
|
+
HTTP_METHOD3 = import_zod11.z.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]);
|
|
2421
2555
|
mockCreateManualTool = {
|
|
2422
2556
|
name: "mock.create_manual",
|
|
2423
2557
|
description: "Create an empty manual-mode mock server. Use `mock.add_endpoint` afterward to populate it. CORS defaults to off (same-origin only); enable + list explicit origins via `mock.update_cors` if cross-origin access is needed.",
|
|
2424
|
-
inputSchema:
|
|
2425
|
-
name:
|
|
2426
|
-
defaultPort:
|
|
2558
|
+
inputSchema: import_zod11.z.object({
|
|
2559
|
+
name: import_zod11.z.string().min(1),
|
|
2560
|
+
defaultPort: import_zod11.z.number().int().positive().nullable().optional()
|
|
2427
2561
|
}),
|
|
2428
2562
|
async handler(input, ctx) {
|
|
2429
2563
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
2430
2564
|
const mock = {
|
|
2431
|
-
id: (0,
|
|
2565
|
+
id: (0, import_shared5.generateId)(),
|
|
2432
2566
|
name: input.name,
|
|
2433
2567
|
source: { kind: "manual", endpoints: [] },
|
|
2434
2568
|
endpoints: [],
|
|
@@ -2446,7 +2580,7 @@ var init_mocks = __esm({
|
|
|
2446
2580
|
mockListEndpointsTool = {
|
|
2447
2581
|
name: "mock.list_endpoints",
|
|
2448
2582
|
description: "List endpoints for a mock server (id, method, path, name).",
|
|
2449
|
-
inputSchema:
|
|
2583
|
+
inputSchema: import_zod11.z.object({ mockId: import_zod11.z.string() }),
|
|
2450
2584
|
async handler(input, ctx) {
|
|
2451
2585
|
const state = await ctx.workspace.read();
|
|
2452
2586
|
const mock = state.synced.mockServers[input.mockId];
|
|
@@ -2465,20 +2599,20 @@ var init_mocks = __esm({
|
|
|
2465
2599
|
};
|
|
2466
2600
|
}
|
|
2467
2601
|
};
|
|
2468
|
-
ENDPOINT_RESPONSE2 =
|
|
2469
|
-
status:
|
|
2470
|
-
jsonBody:
|
|
2471
|
-
contentType:
|
|
2602
|
+
ENDPOINT_RESPONSE2 = import_zod11.z.object({
|
|
2603
|
+
status: import_zod11.z.number().int().min(100).max(599).default(200),
|
|
2604
|
+
jsonBody: import_zod11.z.string().default("{}"),
|
|
2605
|
+
contentType: import_zod11.z.string().default("application/json")
|
|
2472
2606
|
});
|
|
2473
2607
|
mockAddEndpointTool = {
|
|
2474
2608
|
name: "mock.add_endpoint",
|
|
2475
2609
|
description: "Append a new endpoint to a mock server. Defaults to a 200 JSON response of `{}`. Returns the new endpoint id.",
|
|
2476
|
-
inputSchema:
|
|
2477
|
-
mockId:
|
|
2610
|
+
inputSchema: import_zod11.z.object({
|
|
2611
|
+
mockId: import_zod11.z.string(),
|
|
2478
2612
|
method: HTTP_METHOD3,
|
|
2479
|
-
pathPattern:
|
|
2480
|
-
name:
|
|
2481
|
-
description:
|
|
2613
|
+
pathPattern: import_zod11.z.string().min(1),
|
|
2614
|
+
name: import_zod11.z.string().optional(),
|
|
2615
|
+
description: import_zod11.z.string().optional(),
|
|
2482
2616
|
response: ENDPOINT_RESPONSE2.optional()
|
|
2483
2617
|
}),
|
|
2484
2618
|
async handler(input, ctx) {
|
|
@@ -2501,13 +2635,13 @@ var init_mocks = __esm({
|
|
|
2501
2635
|
mockUpdateEndpointTool = {
|
|
2502
2636
|
name: "mock.update_endpoint",
|
|
2503
2637
|
description: "Patch fields on a single mock endpoint (method, pathPattern, name, description, defaultResponse status / contentType / json body). Pass only the fields you want to change.",
|
|
2504
|
-
inputSchema:
|
|
2505
|
-
mockId:
|
|
2506
|
-
endpointId:
|
|
2638
|
+
inputSchema: import_zod11.z.object({
|
|
2639
|
+
mockId: import_zod11.z.string(),
|
|
2640
|
+
endpointId: import_zod11.z.string(),
|
|
2507
2641
|
method: HTTP_METHOD3.optional(),
|
|
2508
|
-
pathPattern:
|
|
2509
|
-
name:
|
|
2510
|
-
description:
|
|
2642
|
+
pathPattern: import_zod11.z.string().optional(),
|
|
2643
|
+
name: import_zod11.z.string().optional(),
|
|
2644
|
+
description: import_zod11.z.string().optional(),
|
|
2511
2645
|
response: ENDPOINT_RESPONSE2.partial().optional()
|
|
2512
2646
|
}),
|
|
2513
2647
|
async handler(input, ctx) {
|
|
@@ -2548,7 +2682,7 @@ var init_mocks = __esm({
|
|
|
2548
2682
|
mockDeleteEndpointTool = {
|
|
2549
2683
|
name: "mock.delete_endpoint",
|
|
2550
2684
|
description: "Remove an endpoint from a mock server.",
|
|
2551
|
-
inputSchema:
|
|
2685
|
+
inputSchema: import_zod11.z.object({ mockId: import_zod11.z.string(), endpointId: import_zod11.z.string() }),
|
|
2552
2686
|
async handler(input, ctx) {
|
|
2553
2687
|
const state = await ctx.workspace.read();
|
|
2554
2688
|
const mock = state.synced.mockServers[input.mockId];
|
|
@@ -2568,9 +2702,9 @@ var init_mocks = __esm({
|
|
|
2568
2702
|
return { ok: true, changedIds: out.changedIds };
|
|
2569
2703
|
}
|
|
2570
2704
|
};
|
|
2571
|
-
VALIDATION_RULE =
|
|
2572
|
-
id:
|
|
2573
|
-
kind:
|
|
2705
|
+
VALIDATION_RULE = import_zod11.z.object({
|
|
2706
|
+
id: import_zod11.z.string().optional(),
|
|
2707
|
+
kind: import_zod11.z.enum([
|
|
2574
2708
|
"header-required",
|
|
2575
2709
|
"header-equals",
|
|
2576
2710
|
"header-matches",
|
|
@@ -2581,51 +2715,51 @@ var init_mocks = __esm({
|
|
|
2581
2715
|
"body-required",
|
|
2582
2716
|
"content-type-equals"
|
|
2583
2717
|
]),
|
|
2584
|
-
target:
|
|
2585
|
-
expected:
|
|
2586
|
-
message:
|
|
2587
|
-
enabled:
|
|
2588
|
-
failResponse:
|
|
2589
|
-
status:
|
|
2590
|
-
jsonBody:
|
|
2718
|
+
target: import_zod11.z.string().default(""),
|
|
2719
|
+
expected: import_zod11.z.string().optional(),
|
|
2720
|
+
message: import_zod11.z.string().optional(),
|
|
2721
|
+
enabled: import_zod11.z.boolean().default(true),
|
|
2722
|
+
failResponse: import_zod11.z.object({
|
|
2723
|
+
status: import_zod11.z.number().int().min(100).max(599).default(400),
|
|
2724
|
+
jsonBody: import_zod11.z.string().default('{"error":"validation failed"}')
|
|
2591
2725
|
}).default({})
|
|
2592
2726
|
});
|
|
2593
|
-
CONDITION_CLAUSE =
|
|
2594
|
-
id:
|
|
2595
|
-
scope:
|
|
2596
|
-
target:
|
|
2597
|
-
op:
|
|
2598
|
-
value:
|
|
2727
|
+
CONDITION_CLAUSE = import_zod11.z.object({
|
|
2728
|
+
id: import_zod11.z.string().optional(),
|
|
2729
|
+
scope: import_zod11.z.enum(["query", "pathParam", "header", "cookie", "body-json-path"]),
|
|
2730
|
+
target: import_zod11.z.string(),
|
|
2731
|
+
op: import_zod11.z.enum(["equals", "not-equals", "matches", "gt", "lt", "gte", "lte", "present", "absent"]),
|
|
2732
|
+
value: import_zod11.z.string().optional()
|
|
2599
2733
|
});
|
|
2600
|
-
RESPONSE_RULE =
|
|
2601
|
-
id:
|
|
2602
|
-
name:
|
|
2603
|
-
enabled:
|
|
2604
|
-
when:
|
|
2605
|
-
response:
|
|
2606
|
-
status:
|
|
2607
|
-
jsonBody:
|
|
2734
|
+
RESPONSE_RULE = import_zod11.z.object({
|
|
2735
|
+
id: import_zod11.z.string().optional(),
|
|
2736
|
+
name: import_zod11.z.string(),
|
|
2737
|
+
enabled: import_zod11.z.boolean().default(true),
|
|
2738
|
+
when: import_zod11.z.array(CONDITION_CLAUSE).default([]),
|
|
2739
|
+
response: import_zod11.z.object({
|
|
2740
|
+
status: import_zod11.z.number().int().min(100).max(599).default(200),
|
|
2741
|
+
jsonBody: import_zod11.z.string().default("{}")
|
|
2608
2742
|
}).default({})
|
|
2609
2743
|
});
|
|
2610
|
-
MULTIPLIER =
|
|
2611
|
-
id:
|
|
2612
|
-
name:
|
|
2613
|
-
source:
|
|
2614
|
-
kind:
|
|
2615
|
-
key:
|
|
2744
|
+
MULTIPLIER = import_zod11.z.object({
|
|
2745
|
+
id: import_zod11.z.string().optional(),
|
|
2746
|
+
name: import_zod11.z.string().optional(),
|
|
2747
|
+
source: import_zod11.z.object({
|
|
2748
|
+
kind: import_zod11.z.enum(["query", "pathParam", "header", "body-json-path"]),
|
|
2749
|
+
key: import_zod11.z.string()
|
|
2616
2750
|
}),
|
|
2617
|
-
targetJsonPath:
|
|
2618
|
-
defaultCount:
|
|
2619
|
-
min:
|
|
2620
|
-
max:
|
|
2751
|
+
targetJsonPath: import_zod11.z.string(),
|
|
2752
|
+
defaultCount: import_zod11.z.number().int().nonnegative().default(0),
|
|
2753
|
+
min: import_zod11.z.number().int().nonnegative().optional(),
|
|
2754
|
+
max: import_zod11.z.number().int().nonnegative().optional()
|
|
2621
2755
|
});
|
|
2622
2756
|
mockSetValidationRulesTool = {
|
|
2623
2757
|
name: "mock.set_validation_rules",
|
|
2624
2758
|
description: "Replace an endpoint's validation rules. Rules without an `id` get a fresh one; existing rules can keep theirs to preserve client-side selection state. Empty array clears all rules.",
|
|
2625
|
-
inputSchema:
|
|
2626
|
-
mockId:
|
|
2627
|
-
endpointId:
|
|
2628
|
-
rules:
|
|
2759
|
+
inputSchema: import_zod11.z.object({
|
|
2760
|
+
mockId: import_zod11.z.string(),
|
|
2761
|
+
endpointId: import_zod11.z.string(),
|
|
2762
|
+
rules: import_zod11.z.array(VALIDATION_RULE)
|
|
2629
2763
|
}),
|
|
2630
2764
|
async handler(input, ctx) {
|
|
2631
2765
|
const state = await ctx.workspace.read();
|
|
@@ -2635,7 +2769,7 @@ var init_mocks = __esm({
|
|
|
2635
2769
|
const next = patchEndpoint2(mock, input.endpointId, (e) => ({
|
|
2636
2770
|
...e,
|
|
2637
2771
|
requestValidation: rules.map((r) => ({
|
|
2638
|
-
id: r.id ?? (0,
|
|
2772
|
+
id: r.id ?? (0, import_shared5.generateId)(),
|
|
2639
2773
|
kind: r.kind,
|
|
2640
2774
|
target: r.target,
|
|
2641
2775
|
expected: r.expected,
|
|
@@ -2652,10 +2786,10 @@ var init_mocks = __esm({
|
|
|
2652
2786
|
mockSetResponseRulesTool = {
|
|
2653
2787
|
name: "mock.set_response_rules",
|
|
2654
2788
|
description: "Replace an endpoint's conditional response rules. Rules fire in order; the first whose every clause matches wins. Disabled rules are skipped. Empty array falls back to defaultResponse.",
|
|
2655
|
-
inputSchema:
|
|
2656
|
-
mockId:
|
|
2657
|
-
endpointId:
|
|
2658
|
-
rules:
|
|
2789
|
+
inputSchema: import_zod11.z.object({
|
|
2790
|
+
mockId: import_zod11.z.string(),
|
|
2791
|
+
endpointId: import_zod11.z.string(),
|
|
2792
|
+
rules: import_zod11.z.array(RESPONSE_RULE)
|
|
2659
2793
|
}),
|
|
2660
2794
|
async handler(input, ctx) {
|
|
2661
2795
|
const state = await ctx.workspace.read();
|
|
@@ -2665,11 +2799,11 @@ var init_mocks = __esm({
|
|
|
2665
2799
|
const next = patchEndpoint2(mock, input.endpointId, (e) => ({
|
|
2666
2800
|
...e,
|
|
2667
2801
|
responseRules: rules.map((r) => ({
|
|
2668
|
-
id: r.id ?? (0,
|
|
2802
|
+
id: r.id ?? (0, import_shared5.generateId)(),
|
|
2669
2803
|
name: r.name,
|
|
2670
2804
|
enabled: r.enabled,
|
|
2671
2805
|
when: r.when.map((c) => ({
|
|
2672
|
-
id: c.id ?? (0,
|
|
2806
|
+
id: c.id ?? (0, import_shared5.generateId)(),
|
|
2673
2807
|
scope: c.scope,
|
|
2674
2808
|
target: c.target,
|
|
2675
2809
|
op: c.op,
|
|
@@ -2686,10 +2820,10 @@ var init_mocks = __esm({
|
|
|
2686
2820
|
mockSetMultipliersTool = {
|
|
2687
2821
|
name: "mock.set_multipliers",
|
|
2688
2822
|
description: "Replace the response multipliers on an endpoint's defaultResponse. Multipliers expand an array at `targetJsonPath` to a count derived from a request value. Empty array clears all multipliers.",
|
|
2689
|
-
inputSchema:
|
|
2690
|
-
mockId:
|
|
2691
|
-
endpointId:
|
|
2692
|
-
multipliers:
|
|
2823
|
+
inputSchema: import_zod11.z.object({
|
|
2824
|
+
mockId: import_zod11.z.string(),
|
|
2825
|
+
endpointId: import_zod11.z.string(),
|
|
2826
|
+
multipliers: import_zod11.z.array(MULTIPLIER)
|
|
2693
2827
|
}),
|
|
2694
2828
|
async handler(input, ctx) {
|
|
2695
2829
|
const state = await ctx.workspace.read();
|
|
@@ -2701,7 +2835,7 @@ var init_mocks = __esm({
|
|
|
2701
2835
|
defaultResponse: {
|
|
2702
2836
|
...e.defaultResponse,
|
|
2703
2837
|
multipliers: multipliers.length === 0 ? void 0 : multipliers.map((m) => ({
|
|
2704
|
-
id: m.id ?? (0,
|
|
2838
|
+
id: m.id ?? (0, import_shared5.generateId)(),
|
|
2705
2839
|
name: m.name,
|
|
2706
2840
|
source: { kind: m.source.kind, key: m.source.key },
|
|
2707
2841
|
targetJsonPath: m.targetJsonPath,
|
|
@@ -2735,6 +2869,7 @@ var init_registry = __esm({
|
|
|
2735
2869
|
init_history();
|
|
2736
2870
|
init_codebase();
|
|
2737
2871
|
init_prompt();
|
|
2872
|
+
init_globalAssets();
|
|
2738
2873
|
init_mocks();
|
|
2739
2874
|
TOOL_REGISTRY = [
|
|
2740
2875
|
importCurlTool,
|
|
@@ -2795,6 +2930,10 @@ var init_registry = __esm({
|
|
|
2795
2930
|
promptSetEndpointValidationRulesTool,
|
|
2796
2931
|
promptSetEndpointResponseRulesTool,
|
|
2797
2932
|
promptSetEndpointMultipliersTool,
|
|
2933
|
+
globalAssetsFilesListTool,
|
|
2934
|
+
globalAssetsFilesCreateTool,
|
|
2935
|
+
globalAssetsFilesUpdateTool,
|
|
2936
|
+
globalAssetsFilesDeleteTool,
|
|
2798
2937
|
mockCreateFromOpenApiTool,
|
|
2799
2938
|
mockCreateFromPostmanTool,
|
|
2800
2939
|
mockCreateFromInsomniaTool,
|