FtMocks is a Node.js application that will simplify your maintainance of mock data.
- Easy maintanance of mock data for test cases
- Default mock data for all test cases
- Mock server for the test case
To quickly set up a new mock project, install Playwright, and clone & start the ftmocks-server, run:
npx ftmocks init-playwright-allTo quickly set up ftmocks-server, run:
npx ftmocks setup- Please visit FtMocks(www.ftmocks.com)
To run this project, ensure you have the following installed on your machine:
-
Clone the repository:
git clone https://github.com/SodhanaLibrary/ftmocks-server.git
-
Navigate into the project directory:
cd ftmocks-server -
Install dependencies:
npm i
-
Install playwright:
npx playwright install
-
Create my-project.env file for your project
-
Create a my-project.env file in the project root.
MOCK_DIR=./example/my-project/testMockData PORT=5000 PREFERRED_SERVER_PORTS=[4051]
To start the project, use:
npm start my-projectThis repository ships an MCP server (mcp/index.js) that exposes tools mapped to the same HTTP API defined in server.js. Any MCP-capable client (for example Cursor) can drive FtMocks programmatically while your FtMocks process is running.
For agent-oriented usage (workflows, quirks, examples), see the Cursor skill at .cursor/skills/ftmocks-mcp/SKILL.md.
- Node.js 20 or later and
npm installcompleted in this repo. - The FtMocks HTTP API must be reachable (typically
npm start <path-to-envfile>). The MCP server only forwards HTTP requests; it does not replaceserver.js.
The MCP process resolves the API base URL in this order:
FTMOCKS_API_BASE_URL— full origin, e.g.http://localhost:5000FTMOCKS_SERVER_URL— same meaning as above (alternate name)- Fallback:
http://localhost:${PORT}whenPORTis set, otherwisehttp://localhost:5000
Set FTMOCKS_API_BASE_URL (or FTMOCKS_SERVER_URL) in your MCP client config so it matches the host and port where FtMocks listens.
From the repository root:
npm run mcpThis starts a stdio MCP server (protocol messages on stdin/stdout). Integrations should not write unrelated data to stdout.
Adjust paths and port to match your setup:
{
"mcpServers": {
"ftmocks": {
"command": "node",
"args": ["/absolute/path/to/ftmocks-server/mcp/index.js"],
"env": {
"FTMOCKS_API_BASE_URL": "http://localhost:5000"
}
}
}
}Tools are registered in mcp/tools.js and named with an ftmocks_ prefix. Each tool corresponds to one or more /api/v1/… routes, including:
| Area | Examples |
|---|---|
| Tests | List/create/update/delete/duplicate tests; mock list CRUD; per-mock update/delete; variants; reset; reorder tests; move mocks to default mocks |
| File uploads | HAR, Postman export, Playwright trace — for a specific test or for default mocks. MCP accepts base64 file content plus an optional filename (see tool descriptions). |
| Default mocks | List/create/update/delete mocks and variants; move defaults into tests |
| Environment / projects | Current env snapshot (/env/project); projects list; switch/add/remove project; ignoreForAll |
| Recorded flow | Recorded events CRUD, reorder, screenshots (responses may be base64 for files) |
| Code | Save generated files under Playwright dir; run test (response can be long streamed-style text) |
| Mock server | Start, restart, or stop the auxiliary mock HTTP server bound to a test |
| API specs | List/get/create/update/delete files under {MOCK_DIR}/api_specs |
| Versions | Compare versions; optional server-side git pull via /versions |
| Browser recording | Endpoints that launch Playwright/browser on the machine running FtMocks |
| Crypto / AI | Encrypt/decrypt/list keys; AI-assisted mock editing when configured |
The built-in FtMocks request logger (/api/v1/logs via LogRoutes) and recorded logs APIs (/api/v1/recordedLogs, deleteAllLogs) are intentionally not exposed as MCP tools. Use the REST API or UI for those.
| File | Role |
|---|---|
mcp/index.js |
MCP stdio entry; wires registerFtMocksTools |
mcp/tools.js |
Tool definitions and HTTP mapping |
mcp/http.js |
Shared fetch, multipart/base64 helpers, response formatting |
Refer to the ftmocks-utils for detailed API documentation, usage examples, and advanced configuration. This package is essential for wrighting testcases.
Contributions are welcome! Please fork this repository and create a pull request.
- Fork the Project
- Create your Feature Branch (git checkout -b feature/AmazingFeature)
- Commit your Changes (git commit -m 'Add some AmazingFeature')
- Push to the Branch (git push origin feature/AmazingFeature)
- Open a Pull Request