Skip to main content
Complete API documentation for all @frontmcp/testing exports, types, and methods.

Test Function

test

The main test function with fixture injection.

test.use

Configure fixtures for a test file.

McpTestClient

The primary fixture for testing MCP servers.

Tools API

tools.list

List all available tools.
Returns: Array of tool definitions with name, description, and inputSchema.

tools.call

Call a tool with arguments.
Returns: ToolResult with methods:

Resources API

resources.list

List static resources.
Returns: Array of resources with uri, name, description, and mimeType.

resources.listTemplates

List resource templates.
Returns: Array of templates with uriTemplate, name, and description.

resources.read

Read a resource by URI.
Returns: ResourceContent with methods:

Prompts API

prompts.list

List available prompts.
Returns: Array of prompts with name, description, and arguments.

prompts.get

Get a prompt with arguments.
Returns: PromptResult with:

Session & Connection

isConnected

Check connection status.

sessionId

Get the current session ID.

serverInfo

Get server information.

protocolVersion

Get the MCP protocol version.

capabilities

Get server capabilities.

hasCapability

Check for a specific capability.

authenticate

Authenticate the client with a JWT token.

disconnect

Disconnect from the server.

Raw Protocol API

raw.request

Send a raw JSON-RPC request.

raw.notify

Send a JSON-RPC notification (no response expected).

raw.sendRaw

Send raw string data (for testing parse errors).

Logging & Tracing

logs.all

Get all captured logs.

logs.filter

Filter logs by level.
Search logs by text.

logs.clear

Clear captured logs.

trace.all

Get all request traces.

trace.last

Get the last request trace.

trace.clear

Clear request traces.

Auth Fixture

The auth fixture generates JWT tokens for authentication testing.

createToken

Create a valid JWT token.

createExpiredToken

Create an expired token for testing expiration handling.

createInvalidToken

Create a token with an invalid signature.

users

Pre-built test user configurations.

getJwks

Get the public JWKS for token verification.

getIssuer

Get the token issuer.

getAudience

Get the token audience.

Server Fixture

The server fixture provides server control.

info

Server information.

createClient

Create an additional MCP client.

restart

Restart the server.

getLogs

Get server-side logs.

clearLogs

Clear server logs.

Mock Registry

The mcp.mock API for mocking MCP responses.

mock.add

Add a mock definition.

mock.tool

Convenience method for mocking tool responses.

mock.toolError

Mock a tool error.

mock.resource

Mock a resource response.

mock.clear

Clear all mocks.

Request Interceptors

The mcp.intercept API for intercepting requests and responses.

intercept.request

Intercept outgoing requests.
Returns: Function to remove the interceptor.

intercept.response

Intercept incoming responses.

intercept.delay

Add delay to all requests.
Returns: Function to remove the delay.

intercept.failMethod

Fail requests to a specific method.
Returns: Function to remove the failure.

HTTP Mock API

The httpMock module for mocking external HTTP requests.

httpMock.interceptor

Create an HTTP interceptor.

Interceptor Methods

get, post, put, delete

Create method-specific mocks.

any

Match any HTTP method.

mock

Full mock definition.

allowPassthrough

Allow unmatched requests to reach the network.

assertDone

Assert all one-time mocks were used.

pending

Get unused mocks.

restore

Restore original fetch function.

MockHandle

Returned by mock methods.

Response Helpers

httpResponse

Pre-built HTTP response creators.

mockResponse

Pre-built MCP response creators.

Custom Matchers

All custom Jest matchers added by @frontmcp/testing.

Tool Matchers

Result Matchers

Content Matchers

Resource Matchers

Prompt Matchers

JSON-RPC Matchers


Error Codes

Common MCP error codes for use in tests.

Type Exports

All types are exported for TypeScript usage.