network-mock-server
Set up request interception to mock API responses: record real responses for baseline, replay them deterministically, modify response fields, add latency per endpoint, simulate errors, and persist mocks across navigation. Supports both Playwright page.route() and CDP Fetch domain for lower-level control.
What this skill does
# Network Mock Server
Create a flexible API mocking layer that intercepts network requests and returns
controlled responses. Record real API responses as a baseline, then replay,
modify, or replace them for testing. Mocks persist across page navigations
within the same browser context.
## When to Use
- Testing frontend behavior against specific API response shapes.
- Reproducing edge cases by modifying real API response fields.
- Simulating slow endpoints to test loading states and timeouts.
- Testing error handling by returning specific HTTP status codes per endpoint.
- Creating deterministic test environments that do not depend on backend availability.
- Recording API responses for offline development or snapshot testing.
## Prerequisites
- **Playwright MCP server** connected and responding (all `mcp__playwright__browser_*` tools available).
- **Chromium-based browser** required for CDP `Fetch.enable` (optional, for lower-level control).
- Target page must make API requests (XHR/fetch) that you want to intercept.
## Workflow
### Step 1 -- Navigate and Record Baseline API Responses
First, load the page normally and capture all API responses as a baseline.
```
browser_navigate({ url: "<target_url>" })
```
```
browser_wait_for({ time: 5 })
```
Capture all network requests made during page load:
```
browser_network_requests({ includeStatic: false })
```
### Step 2 -- Record Detailed API Responses
Install a response recorder that captures full response bodies for API calls.
```javascript
browser_run_code({
code: `async (page) => {
const recorded = [];
// Listen to all responses
page.on('response', async (response) => {
const url = response.url();
// Only record API calls, skip static assets
if (url.includes('/api/') || url.includes('/graphql') ||
response.request().resourceType() === 'xhr' ||
response.request().resourceType() === 'fetch') {
try {
const body = await response.text();
recorded.push({
url: url,
method: response.request().method(),
status: response.status(),
headers: response.headers(),
contentType: response.headers()['content-type'] || null,
body: body.substring(0, 50000),
timestamp: Date.now()
});
} catch (e) {
recorded.push({
url: url,
method: response.request().method(),
status: response.status(),
error: 'Could not read body: ' + e.message,
timestamp: Date.now()
});
}
}
});
// Store reference for later harvest
page.__recordedResponses = recorded;
// Reload to capture from scratch
await page.reload({ waitUntil: 'networkidle' });
return 'Response recorder installed and page reloaded';
}`
})
```
### Step 3 -- Harvest Recorded Responses
```javascript
browser_run_code({
code: `async (page) => {
const recorded = page.__recordedResponses || [];
return {
totalRecorded: recorded.length,
endpoints: recorded.map(r => ({
method: r.method,
url: r.url,
status: r.status,
contentType: r.contentType,
bodySize: r.body ? r.body.length : 0,
bodyPreview: r.body ? r.body.substring(0, 500) : null
}))
};
}`
})
```
### Step 4 -- Set Up Mock Replay (Exact Replay)
Replay recorded responses for deterministic behavior.
```javascript
browser_run_code({
code: `async (page) => {
const recorded = page.__recordedResponses || [];
if (recorded.length === 0) return { error: 'No recorded responses to replay' };
// Build a lookup map: method+url -> response
const mockMap = {};
for (const r of recorded) {
const key = r.method + ' ' + new URL(r.url).pathname;
if (!mockMap[key]) mockMap[key] = r; // First response wins
}
// Clear any existing routes
await page.unrouteAll();
// Install mock routes
await page.route('**/*', (route) => {
const req = route.request();
const key = req.method() + ' ' + new URL(req.url()).pathname;
const mock = mockMap[key];
if (mock) {
route.fulfill({
status: mock.status,
contentType: mock.contentType || 'application/json',
body: mock.body,
headers: { 'x-mocked': 'true' }
});
} else {
// Pass through non-mocked requests
route.continue();
}
});
return {
mockedEndpoints: Object.keys(mockMap).length,
endpoints: Object.keys(mockMap)
};
}`
})
```
### Step 5 -- Mock with Modified Responses
Modify specific fields in recorded responses (e.g., change user name, empty arrays,
alter counts).
```javascript
browser_run_code({
code: `async (page) => {
await page.unrouteAll();
// Example: modify a specific endpoint's response
await page.route('**/api/users**', (route) => {
route.fulfill({
status: 200,
contentType: 'application/json',
headers: { 'x-mocked': 'modified' },
body: JSON.stringify({
users: [
{ id: 1, name: 'Mock User 1', email: '[email protected]', role: 'admin' },
{ id: 2, name: 'Mock User 2', email: '[email protected]', role: 'user' }
],
total: 2,
page: 1
})
});
});
// Example: return empty collection
await page.route('**/api/notifications**', (route) => {
route.fulfill({
status: 200,
contentType: 'application/json',
headers: { 'x-mocked': 'empty' },
body: JSON.stringify({ notifications: [], unread: 0 })
});
});
// Pass through everything else
await page.route('**/*', (route) => {
if (!route.request().url().includes('/api/users') &&
!route.request().url().includes('/api/notifications')) {
route.continue();
}
});
return 'Modified mocks installed for /api/users and /api/notifications';
}`
})
```
Reload and verify:
```javascript
browser_run_code({
code: `async (page) => {
await page.reload({ waitUntil: 'networkidle' });
return 'Page reloaded with modified mocks';
}`
})
```
```
browser_take_screenshot({ type: "png", filename: "mock-modified-response.png" })
```
### Step 6 -- Mock with Latency
Add artificial delay to specific endpoints to test loading states.
```javascript
browser_run_code({
code: `async (page) => {
await page.unrouteAll();
await page.route('**/api/**', async (route) => {
const url = route.request().url();
// Add 3-second delay to specific endpoints
if (url.includes('/api/search') || url.includes('/api/data')) {
await new Promise(resolve => setTimeout(resolve, 3000));
}
// Add 1-second delay to all other API calls
else {
await new Promise(resolve => setTimeout(resolve, 1000));
}
// Continue to real server (with delay applied)
route.continue();
});
return 'Latency mocks installed: 3s for search/data, 1s for other APIs';
}`
})
```
```
browser_take_screenshot({ type: "png", filename: "mock-latency-loading.png" })
```
### Step 7 -- Mock Error Responses Per Endpoint
Return different error codes for different endpoints.
```javascript
browser_run_code({
code: `async (page) => {
await page.unrouteAll();
const errorConfig = {
'/api/auth': { status: 401, body: { error: 'Unauthorized', message: 'Token expired' } },
'/api/users': { status: 500, body: { error: 'Internal Server Error', message: 'Database connection failed' } },
'/api/upload': { status: 413, body: { error: 'Payload Too Large', message: 'File exceeds 10MB limit' } },
'/api/search': { status: 429, body: { error: 'Too Many Requests', message: 'Rate limit exceeded. Retry after 60s', retryAfter: 60 } }
};
await page.route('**/api/**', (route) => {
const pathname = new URL(route.request().url()).pathname;
Related in Backend & APIs
jfrog
IncludedInteract with the JFrog Platform via the JFrog CLI and REST/GraphQL APIs. Use this skill when the user wants to manage Artifactory repositories, upload or download artifacts, manage builds, configure permissions, manage users and groups, work with access tokens, configure JFrog CLI servers, search artifacts, manage properties, set up replication, manage JFrog Projects, run security audits or scans, look up CVE details, query exposures scan results from JFrog Advanced Security, manage release bundles and lifecycle operations, aggregate or export platform data, or perform any JFrog Platform administration task. Also use when the user mentions jf, jfrog, artifactory, xray, distribution, evidence, apptrust, onemodel, graphql, workers, mission control, curation, advanced security, exposures, or any JFrog product name.
cupynumeric-migration-readiness
IncludedPre-migration readiness assessor for porting NumPy to cuPyNumeric. Use BEFORE substantial porting work begins when the user asks whether code will scale on GPU, whether they should migrate to cuPyNumeric, which NumPy patterns transfer cleanly, what must be refactored before porting, or mentions pre-port assessment, scaling analysis, or refactor planning. Inspect the user's source code, look up NumPy usage, cross-reference the cuPyNumeric API support manifest, and distinguish distributed-scaling-friendly patterns from blockers such as unsupported APIs, scalar synchronization, host round-trips, Python/object-heavy control flow, shape/data-dependent branching, and in-place mutation hazards. Produce a verdict of READY, LIGHT REFACTOR, SIGNIFICANT REFACTOR, or NOT RECOMMENDED, with concrete refactor pointers.
alibabacloud-data-agent-skill
IncludedInvoke Alibaba Cloud Apsara Data Agent for Analytics via CLI to perform natural language-driven data analysis on enterprise databases. Data Agent for Analytics is an intelligent data analysis agent developed by Alibaba Cloud Database team for enterprise users. It automatically completes requirement analysis, data understanding, analysis insights, and report generation based on natural language descriptions. This tool supports: discovering data resources (instances/databases/tables) managed in DMS, initiating query or deep analysis sessions, real-time progress tracking, and retrieving analysis conclusions and generated reports. Use this Skill when users need to query databases, analyze data trends, generate data reports, ask questions in natural language, or mention "Data Agent", "data analysis", "database query", "SQL analysis", "data insights".
token-optimizer
IncludedReduce OpenClaw token usage and API costs through smart model routing, heartbeat optimization, budget tracking, and native 2026.2.15 features (session pruning, bootstrap size limits, cache TTL alignment). Use when token costs are high, API rate limits are being hit, or hosting multiple agents at scale. The 4 executable scripts (context_optimizer, model_router, heartbeat_optimizer, token_tracker) are local-only — no network requests, no subprocess calls, no system modifications. Reference files (PROVIDERS.md, config-patches.json) document optional multi-provider strategies that require external API keys and network access if you choose to use them. See SECURITY.md for full breakdown.
resend-cli
IncludedUse this skill when the task is specifically about operating Resend from an AI agent, terminal session, or CI job via the official resend CLI: installing/authenticating the CLI, sending/listing/updating/cancelling emails, batch sends, domains and DNS, webhooks and local listeners, inbound receiving, contacts, topics, segments, broadcasts, templates, API keys, profiles, or debugging Resend CLI/API failures. Trigger on mentions of Resend CLI, `resend`, `resend doctor`, `resend emails send`, `resend domains`, `resend webhooks listen`, `resend emails receiving`, or agent-friendly terminal automation.
alibabacloud-odps-maxframe-coding
IncludedUse this skill for MaxFrame SDK development and documentation navigation on Alibaba Cloud MaxCompute (ODPS). Helps answer MaxFrame API, concept, official example, and supported pandas API questions; create data processing programs; read/write MaxCompute tables; debug jobs (remote or local); and build custom DPE runtime images. Trigger when users mention MaxFrame, MaxCompute with MaxFrame, ODPS table processing, DPE runtime, MaxFrame docs/examples, DataFrame/Tensor operations, or GPU runtime setup. Works for both English and Chinese queries about Alibaba Cloud data processing with MaxFrame.