Vitest test suite for APIMatic's MCP (Model Context Protocol) server. Tests connection, tool discovery, tool invocations, schema snapshots, and ContextMatic training data health.
| File | What It Tests |
|---|---|
tests/connection.test.ts |
Connects to MCP server, verifies 4 tools are listed, validates each tool has a name/description/schema |
tests/tool-schemas.test.ts |
Snapshot test — compares live tool schemas against saved baseline |
tests/tool-calls.test.ts |
Calls each tool (ask, model_search, endpoint_search, update_activity) with valid and edge-case inputs |
tests/contextmatic-health-check.test.ts |
Fetches the API catalog for 7 languages via fetch_api and verifies training data exists for each entry |
tests/discover.ts |
Utility script — prints all available tools as JSON (not a test) |
-
Install dependencies
npm install
-
Configure environment
Copy
.env.exampleto.envand fill in your values:cp .env.example .env
Variable Used by Description MCP_SERVER_URLmcp-server-tests.yml,connection/tool-calls/tool-schemas testsFull MCP server endpoint URL including language path CONTEXTMATIC_MCP_URLcontextmatic-health-check.test.tsContextMatic plugins MCP endpoint TRAININGDATA_BASE_URLcontextmatic-health-check.test.tsBase URL for the training data health check API
# All tests except contextmatic health check
npx vitest run tests --exclude tests/contextmatic-health-check.test.ts
# ContextMatic health check only
npx vitest run tests/contextmatic-health-check.test.ts
# All tests
npx vitest run tests
# View results in browser
npx vitest run tests --reporter=htmlHTML report is written to mcp-server-tests-report/index.html.
The MCP server uses OAuth 2.0 client credentials. tests/helpers/client.ts handles this automatically:
- Fetches
/.well-known/oauth-protected-resourcefrom the server origin to discover the token endpoint - Exchanges client credentials for a Bearer token
- Attaches the token to all MCP transport requests
No API key or client secret is needed in .env — the server's OAuth metadata is resolved at runtime from the URL itself.
If tool schemas change intentionally, update the snapshot:
npx vitest run tests/tool-schemas.test.ts --update-snapshotsTwo workflows in .github/workflows/:
| Workflow | Trigger | Tests run |
|---|---|---|
mcp-server-tests.yml |
Manual dispatch (dev/prod) | All except contextmatic health check |
contextmatic-health-check.yml |
Manual + daily at 4 PM PKT | contextmatic-health-check.test.ts only |
Required GitHub secrets for mcp-server-tests.yml:
| Secret | Description |
|---|---|
MCP_SERVER_URL_DEV |
Dev MCP server URL |
MCP_SERVER_URL_PROD |
Prod MCP server URL |
The contextmatic health check workflow also requires SLACK_BOT_TOKEN for failure notifications.