@proxyflow/mcp-server 1.1.0 → 1.1.1
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/README.md +1 -1
- package/dist/index.js +30 -10
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
| `toggle_mock` | 开启/关闭 mock。不传 `method` 时作用于该路径的所有规则;找不到时提示先 `upsert_mock`。 |
|
|
11
11
|
| `list_mocks` | 列出 mock 规则(精简输出:版本列表 + 当前激活版本),`include_body` 可附带激活版本的响应体。 |
|
|
12
12
|
| `switch_mock_version` | 在同一接口的多个场景(成功/空列表/报错…)之间切换激活版本,按 `version_name` 或 `version_id`。 |
|
|
13
|
-
| `delete_mock` |
|
|
13
|
+
| `delete_mock` | 删除某条 mock 规则或单个版本。支持 `rule_id`、`url_pattern`(+ `method`/`condition`/`match_type`)、`version_name`/`version_id`;匹配多条时返回 409 候选列表,需明确 `rule_id`/`condition` 或 `delete_all: true` 才会全删。 |
|
|
14
14
|
| `wait_for_request` | 阻塞等待匹配的真实请求经过代理并返回抓包结果。`lookback_ms` 可回溯已发生的请求,`only_real` 忽略被 mock 命中的请求;返回中 `source` 标明 MOCK/REAL,敏感请求头(Authorization/Cookie 等)自动打码,过大的 body 自动截断。 |
|
|
15
15
|
| `list_recent_requests` | 最近抓到的请求摘要(id/时间/方法/URL/状态/来源),可按 URL、方法、状态(`404` / `5xx`)过滤。 |
|
|
16
16
|
| `get_request` | 按 id 查看单个请求的完整详情(同样打码 + 截断)。 |
|
package/dist/index.js
CHANGED
|
@@ -87,6 +87,11 @@ const WRITE_IDEMPOTENT = { readOnlyHint: false, destructiveHint: false, idempote
|
|
|
87
87
|
const urlPatternField = zod_1.z.string().min(1).describe('Full URL or path of the endpoint, e.g. "/api/users/123" or "https://api.example.com/users/123". ' +
|
|
88
88
|
'Only the pathname is used (host and query string are ignored). Use "*" as a wildcard and ":id" or "{id}" for path parameters, e.g. "/api/users/:id".');
|
|
89
89
|
const methodField = zod_1.z.string().optional().describe('HTTP method, e.g. "GET", "POST" (case-insensitive). Omit to not restrict by method.');
|
|
90
|
+
const conditionField = zod_1.z.object({
|
|
91
|
+
type: zod_1.z.enum(['header', 'query', 'body']),
|
|
92
|
+
key: zod_1.z.string().min(1),
|
|
93
|
+
value: zod_1.z.string().min(1),
|
|
94
|
+
}).optional().describe('Only serve/match this mock when the request has header/query param/JSON body field `key` equal to `value`.');
|
|
90
95
|
const maxBodyField = zod_1.z.number().int().min(200).max(100000).optional()
|
|
91
96
|
.describe(`Max characters of each body to return (default ${format_js_1.DEFAULT_MAX_BODY_CHARS}). Larger bodies are truncated.`);
|
|
92
97
|
server.registerTool('upsert_mock', {
|
|
@@ -112,11 +117,7 @@ server.registerTool('upsert_mock', {
|
|
|
112
117
|
enabled: zod_1.z.boolean().optional().describe('Whether the mock is active. Defaults to true on create; unchanged on update when omitted.'),
|
|
113
118
|
activate: zod_1.z.boolean().optional()
|
|
114
119
|
.describe('Set false to store this response as an alternate version WITHOUT making it the active one. Defaults to true.'),
|
|
115
|
-
condition:
|
|
116
|
-
type: zod_1.z.enum(['header', 'query', 'body']),
|
|
117
|
-
key: zod_1.z.string().min(1),
|
|
118
|
-
value: zod_1.z.string().min(1),
|
|
119
|
-
}).optional().describe('Only serve this mock when the request has header/query param/JSON body field `key` equal to `value`. Lets one endpoint return different mocks per input. Rules with a condition take priority.'),
|
|
120
|
+
condition: conditionField,
|
|
120
121
|
from_request_id: zod_1.z.number().int().optional()
|
|
121
122
|
.describe('Copy status, headers and body from a captured request (request log id from wait_for_request / list_recent_requests). Explicit response_* fields still override.'),
|
|
122
123
|
},
|
|
@@ -247,15 +248,34 @@ server.registerTool('switch_mock_version', {
|
|
|
247
248
|
annotations: WRITE_IDEMPOTENT,
|
|
248
249
|
}, async (args) => respond(await call('/api/mocks/switch-version', { method: 'POST', body: JSON.stringify(args) }), (b) => ({ ...(0, format_js_1.condenseRule)(b), switched_to: b.switched_to })));
|
|
249
250
|
server.registerTool('delete_mock', {
|
|
250
|
-
title: 'Delete a mock',
|
|
251
|
-
description: 'Permanently delete
|
|
252
|
-
'
|
|
251
|
+
title: 'Delete a mock rule or version',
|
|
252
|
+
description: 'Permanently delete a mock rule (or a single stored version if version_id/version_name is given). ' +
|
|
253
|
+
'Target by rule_id (from list_mocks / upsert_mock) OR by url_pattern (+ optional method, condition, match_type). ' +
|
|
254
|
+
'Deletion is strict and guarded: an omitted method means the rule with no method restriction, not every method; ' +
|
|
255
|
+
'if multiple rules match (e.g. different conditions or match_types), it returns a 409 conflict listing candidates instead of wiping them all unless delete_all=true. ' +
|
|
256
|
+
'To merely stop mocking, use toggle_mock enabled=false instead.',
|
|
253
257
|
inputSchema: {
|
|
254
|
-
|
|
258
|
+
rule_id: zod_1.z.number().int().positive().optional()
|
|
259
|
+
.describe('Exact mock rule_id (from list_mocks or upsert_mock). Preferred when multiple rules share a path.'),
|
|
260
|
+
url_pattern: urlPatternField.optional(),
|
|
255
261
|
method: methodField,
|
|
262
|
+
condition: conditionField,
|
|
263
|
+
match_type: zod_1.z.enum(['exact', 'wildcard', 'regex']).optional()
|
|
264
|
+
.describe('Filter by match_type when multiple rules share the same url_pattern.'),
|
|
265
|
+
version_name: zod_1.z.string().min(1).optional()
|
|
266
|
+
.describe('Delete ONLY this stored version/scenario from the matched rule instead of deleting the entire rule.'),
|
|
267
|
+
version_id: zod_1.z.number().int().positive().optional()
|
|
268
|
+
.describe('Delete ONLY this version id from the matched rule instead of deleting the entire rule.'),
|
|
269
|
+
delete_all: zod_1.z.boolean().optional()
|
|
270
|
+
.describe('Set true to delete ALL matching rules when multiple rules match url_pattern (+ method). Defaults to false (returns 409 conflict instead).'),
|
|
256
271
|
},
|
|
257
272
|
annotations: { readOnlyHint: false, destructiveHint: true, idempotentHint: true, openWorldHint: false },
|
|
258
|
-
}, async (args) =>
|
|
273
|
+
}, async (args) => {
|
|
274
|
+
if (args.rule_id === undefined && !args.url_pattern) {
|
|
275
|
+
return { isError: true, content: [{ type: 'text', text: 'Provide either rule_id or url_pattern.' }] };
|
|
276
|
+
}
|
|
277
|
+
return respond(await call('/api/mocks/delete-by-pattern', { method: 'POST', body: JSON.stringify(args) }), (b) => (b?.deleted_version ? { ...(0, format_js_1.condenseRule)(b), deleted_version: b.deleted_version } : b));
|
|
278
|
+
});
|
|
259
279
|
// ── Startup ───────────────────────────────────────────────────────────────
|
|
260
280
|
async function main() {
|
|
261
281
|
const transport = new stdio_js_1.StdioServerTransport();
|