Skip to content

Commit 6c824fc

Browse files
cuongmxclaude
andcommitted
feat: add list_mock_captures tool (v0.3.0)
The mock toolset shipped in v0.2.0 covered create/configure/deploy but had no way for an agent to verify the integration was actually calling the mock URL. This adds list_mock_captures so an agent can close the loop: deploy → trigger from app under test → list captures → confirm method/path/status match expectations. Wraps the existing GET /api/mock-endpoints/:id/interactions endpoint. Returns id, method, path, statusCode, matchedRuleId, occurredAt, remoteAddress per capture, with a count + total summary. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent dd6aad6 commit 6c824fc

4 files changed

Lines changed: 44 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ Add to `~/.windsurf/mcp_config.json`:
114114
| `create_mock_endpoint` | Create a mock endpoint (returns live `{slug}.rbmock.dev` URL) |
115115
| `add_mock_rule` | Append a routing rule (match method/path → status + headers + body) |
116116
| `deploy_mock` | Publish the current rule set so the live mock server picks it up |
117+
| `list_mock_captures` | List recent requests that hit a mock endpoint — verify your integration is actually calling the mock URL |
117118

118119
## Example Workflow
119120

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@requestbin/mcp-server",
3-
"version": "0.2.0",
3+
"version": "0.3.0",
44
"description": "MCP server for RequestBin — test webhooks from Claude Code, Cursor, and Windsurf",
55
"license": "MIT",
66
"homepage": "https://github.com/requestbin/mcp-server",

src/api-client.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,4 +159,9 @@ export class RequestBinClient {
159159
method: 'POST',
160160
});
161161
}
162+
163+
async listMockCaptures(endpointId: string, opts: { limit?: number } = {}): Promise<any> {
164+
const limit = Math.max(1, Math.min(200, opts.limit ?? 50));
165+
return this.request(`/api/mock-endpoints/${endpointId}/interactions?limit=${limit}`);
166+
}
162167
}

src/index.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,43 @@ server.tool(
418418
},
419419
);
420420

421+
// ── Tool: list_mock_captures ──
422+
423+
server.tool(
424+
'list_mock_captures',
425+
'List recent captured requests that hit a mock endpoint. Use this to verify your integration is actually calling the mock URL — shows method, path, status, and time for each capture. Returns up to 50 by default.',
426+
{
427+
endpointId: z.string().describe('The mock endpoint ID (from list_mock_endpoints)'),
428+
limit: z.number().int().min(1).max(200).optional().describe('Max captures to return (1-200, default 50)'),
429+
},
430+
async ({ endpointId, limit }) => {
431+
try {
432+
const result = await client.listMockCaptures(endpointId, { limit });
433+
const captures = (result.interactions || []).map((i: any) => ({
434+
id: i.id,
435+
method: i.method,
436+
path: i.path,
437+
statusCode: i.statusCode,
438+
matchedRuleId: i.matchedRuleId,
439+
occurredAt: i.occurredAt,
440+
remoteAddress: i.remoteAddress,
441+
}));
442+
return {
443+
content: [{
444+
type: 'text' as const,
445+
text: JSON.stringify({
446+
count: captures.length,
447+
total: result.total ?? captures.length,
448+
captures,
449+
}, null, 2),
450+
}],
451+
};
452+
} catch (e: any) {
453+
return { content: [{ type: 'text' as const, text: `Error: ${e.message}` }], isError: true };
454+
}
455+
},
456+
);
457+
421458
// ── Start server ──
422459

423460
async function main() {

0 commit comments

Comments
 (0)