A powerful and intuitive Mock API Server extension for VS Code that helps developers quickly create, manage, and test mock APIs directly within their development environment.
- ๐ YAML-based Configuration - Simple, version-controllable mock API definitions
- ๐ One-Click Server Control - Start/stop MockPilot server from Status Bar
- ๐ Hot Reload - Automatic reload when configuration files change
- ๐ฏ Visual Editor - User-friendly WebView interface for editing mock APIs
- ๐ Real-time Status - Server status display in VS Code Status Bar
- ๐งช Built-in Testing - Test APIs directly from the editor
- ๐ Multiple Response Rules - Support for different response scenarios
- โก Zero Configuration - Works out of the box with sensible defaults
- ๐ค AI-Powered Mock Generation - Generate mock rules using your IDE's AI (Copilot, Cursor, etc.)
- ๐ฏ Claude Skill Auto-Installation - Automatically installs a specialized Claude Skill for generating mock rules
-
Install the extension from VS Code Marketplace
-
Create
.mockdirectory in your project root:- Use Command Palette:
MockPilot: Create .mock Directory - Or manually:
mkdir .mock
- Use Command Palette:
-
Create a mock API configuration (e.g.,
.mock/get_positions.yaml):
name: Get All Positions Info
description: Get all trading positions information
method: GET
endpoint: /v1/positions
rules:
- name: Success
status: 200
headers:
Content-Type: application/json
body:
success: true
timestamp: 1702989203989
data:
current_margin_ratio_with_orders: 1.2385
free_collateral: 450315.09115
total_collateral_value: 489865.71329
rows:
- symbol: PERP_BTC_USDC
position_qty: -5
average_open_price: 27908.14386047
mark_price: 27794.9
unsettled_pnl: 354.858492
leverage: 10
delay: 0-
Start the server:
- Click the Status Bar item:
MockPilot: Stopped - Or use Command Palette:
MockPilot: Start Server
- Click the Status Bar item:
-
Test your API:
curl http://localhost:9527/v1/positionsFor detailed usage instructions, see USAGE.md
Configure the extension in VS Code settings:
{
"mockServer.port": 9527, // Server port (default: 9527)
"mockServer.autoStart": false, // Auto-start server on activation
"mockServer.mockDirectory": ".mock" // Mock configuration directory
}Access via Command Palette (Cmd+Shift+P or Ctrl+Shift+P):
MockPilot: Start Server- Start the mock serverMockPilot: Stop Server- Stop the mock serverMockPilot: Toggle Server- Toggle server on/offMockPilot: Reload Server- Reload all configurationsMockPilot: Create .mock Directory- Create mock config directoryMockPilot: Test Mock API- Test a specific API endpoint
The extension adds a Status Bar item showing the server status:
- Stopped:
$(debug-stop) MockPilot: Stopped(yellow background) - Running:
$(server-process) MockPilot: Running (5)- showing route count
Click the Status Bar item to quickly start/stop the server.
name: API Name
description: API Description
method: GET | POST | PUT | DELETE | PATCH | HEAD | OPTIONS
endpoint: /api/path
rules:
- name: Rule Name
status: 200
headers:
Content-Type: application/json
body:
key: value
delay: 0 # millisecondsThe server automatically reloads when you:
- Modify any
.yamlor.ymlfile in.mockdirectory - Create new mock API files
- Delete mock API files
No manual restart required!
MockPilot is designed to work seamlessly with your IDE's AI capabilities (such as GitHub Copilot, Cursor, Claude in VS Code, etc.) to help you generate mock API configurations using natural language descriptions.
Special Feature: When you install MockPilot, it automatically installs a dedicated Claude Skill that's specifically trained to generate mock API configurations following MockPilot's YAML format standards. This ensures optimal AI-generated outputs when using Claude.
Instead of providing a built-in AI command, MockPilot leverages your existing IDE AI tools. You simply describe your API requirements using a structured prompt template, and your AI assistant will generate the YAML configuration. MockPilot then manages and serves these mock APIs.
- Have an AI assistant enabled in your IDE:
- VS Code: GitHub Copilot, Claude, or other AI extensions
- Cursor: Built-in AI capabilities
- Other IDEs: Any AI coding assistant
- MockPilot extension installed (includes auto-installed Claude Skill for Claude users)
- A project with a
.mockdirectory
If you're using Claude in VS Code, MockPilot automatically installs a specialized Claude Skill on first activation. This skill is optimized for generating MockPilot-compatible YAML configurations.
Simply ask Claude:
Generate a mock API for [your requirement]
The skill understands MockPilot's format and will generate properly structured YAML configurations automatically.
Use this template with your AI assistant to generate mock rules:
Create a mock API YAML configuration with the following requirements:
- Method: [GET/POST/PUT/DELETE/etc.]
- Endpoint: [/api/path]
- Description: [What this API does]
- Response scenarios: [success, error cases, edge cases]
- Data structure: [describe the expected response format]
Format the output as a YAML file following this structure:
name: [API Name]
description: [API Description]
method: [HTTP Method]
endpoint: [API Path]
rules:
- name: [Rule Name]
status: [HTTP Status Code]
headers:
Content-Type: application/json
body:
[response body]
delay: [milliseconds]
Prompt to your AI assistant:
Create a mock API YAML configuration with the following requirements:
- Method: GET
- Endpoint: /v1/positions
- Description: Get all trading positions information
- Response scenarios:
1. Success with positions data
2. Success with empty positions
- Data structure: Include margin ratios, collateral info, and position details with symbol, quantity, price, and PnL
- Ask your AI assistant using the prompt template above
- AI generates the YAML configuration based on your requirements
- Save the file in your
.mockdirectory (e.g.,.mock/get_positions.yaml) - MockPilot automatically detects the new file and reloads
- Test your API immediately using the mock server
Your AI assistant can help you create:
- Complete Mock APIs - From endpoint definition to response bodies
- Multiple Rules - Different scenarios (success, errors, edge cases)
- Realistic Data - Sample user data, product catalogs, financial data, etc.
- Complex Structures - Nested objects, arrays, and relationships
- Headers and Delays - Simulate real-world API behavior
- RESTful Patterns - Follow REST conventions automatically
Your AI assistant will generate:
name: Get All Positions Info
description: Get all trading positions information
method: GET
endpoint: /v1/positions
rules:
- name: Success - With Positions
status: 200
headers:
Content-Type: application/json
body:
success: true
timestamp: 1702989203989
data:
current_margin_ratio_with_orders: 1.2385
free_collateral: 450315.09115
initial_margin_ratio: 0.1
maintenance_margin_ratio: 0.05
margin_ratio: 1.2385
total_collateral_value: 489865.71329
total_pnl_24_h: 0
rows:
- symbol: PERP_BTC_USDC
position_qty: -5
average_open_price: 27908.14386047
mark_price: 27794.9
unsettled_pnl: 354.858492
leverage: 10
imr: 0.1
mmr: 0.05
delay: 100
- name: Success - No Positions
status: 200
headers:
Content-Type: application/json
body:
success: true
timestamp: 1702989203989
data:
current_margin_ratio_with_orders: 0
free_collateral: 0
total_collateral_value: 0
rows: []
delay: 50Then simply:
- Save this as
.mock/get_positions.yaml - MockPilot automatically loads it
- Start testing at
http://localhost:9527/v1/positions
- Be Specific: Provide clear descriptions of expected responses
- Include Scenarios: Mention different cases (success, errors, edge cases)
- Specify Data Types: Indicate if you need numbers, dates, booleans, etc.
- Mention Constraints: Include any validation rules or business logic
- Review Output: Always review AI-generated configs before using
- Iterate: Refine your prompt if the output needs adjustments
- โก Save Time: Generate complex mock rules in seconds
- ๐ฏ Claude Skill Integration: Auto-installed skill ensures optimal results with Claude
- ๐ค Use Your Preferred AI: Works with Copilot, Cursor, Claude, or any AI assistant
- ๐ Best Practices: AI follows YAML and REST conventions
- ๐ฏ Comprehensive: Automatically includes multiple scenarios
- ๐ Iterative: Easily refine by adjusting your prompt
- ๐ Learning Tool: Learn proper mock API structure from examples
- ๐จ Flexibility: Combine AI generation with manual editing as needed
MockPilot focuses on what it does best:
- ๐ Managing your mock configurations
- ๐ Serving mock APIs with hot reload
- ๐ฏ Testing APIs directly from VS Code
- ๐ Monitoring server status and routes
You bring the AI tool you're already comfortable with, and MockPilot handles the rest!
- Node.js >= 16
- pnpm (recommended) or npm
git clone <repository>
cd mock-server
pnpm install# Development build with watch mode
pnpm run watch-web
# Run in browser
pnpm run run-in-browser
# Production build
pnpm run package-web
# Run tests
pnpm testContributions are welcome! Please feel free to submit issues or pull requests.
[] Mock data programmatically [] Mock RPC Server
MIT License
- Frontend Development - Mock backend APIs while frontend is under development
- API Testing - Test different response scenarios (success, errors, edge cases)
- Documentation - Create living API documentation with examples
- Team Collaboration - Share mock configurations via version control
- Offline Development - Work without backend dependencies
Enjoy mocking! ๐
You can author your README using Visual Studio Code. Here are some useful editor keyboard shortcuts:
- Split the editor (
Cmd+\on macOS orCtrl+\on Windows and Linux). - Toggle preview (
Shift+Cmd+Von macOS orShift+Ctrl+Von Windows and Linux). - Press
Ctrl+Space(Windows, Linux, macOS) to see a list of Markdown snippets.
Enjoy!