Testing & Mock Server

Testing & Mock Server

Mock Server Overview

The mock server is a full drop-in replacement for the ChainGPT API. It provides:

  • Realistic responses matching the live API schema

  • Simulated latency for real-world behavior

  • Credit tracking (no actual charges)

  • Zero cost for unlimited testing

No API key is required to use the mock server.


Setup

cd mock-server
npm install
npm run dev

The mock server starts on localhost:3001.

Point your environment at the mock server:

export CHAINGPT_BASE_URL=http://localhost:3001

All MCP server tools will automatically route requests to the mock server instead of the live API.


Test Suite

The plugin includes 79 passing tests across two test suites:

Suite
Tests
Coverage

MCP server unit tests

53

All 12 tools, error handling, input validation

Mock server endpoint tests

26

All endpoints, response schemas, edge cases

Running Tests


Validation Script

A structural validation script checks the entire plugin for correctness:

This runs 118 structural checks including:

  • File existence and naming conventions

  • JSON schema validation for plugin.json and .mcp.json

  • Markdown structure and link integrity

  • Template completeness

  • Reference doc cross-references


CI Workflow

All tests run automatically on every push and pull request. The CI workflow:

  1. Installs dependencies

  2. Starts the mock server

  3. Runs the full test suite (79 tests)

  4. Executes the validation script (118 checks)

  5. Reports results


Using the Mock Server in Development

The mock server mirrors every endpoint of the live ChainGPT API:

Responses include the same fields, status codes, and error formats as the production API, making it safe to build and test integrations before going live.

Last updated

Was this helpful?