Skip to main content

SmartBear MCP Server

The @smartbear/mcp package is a Model Context Protocol server that exposes your PactFlow or Pact Broker workspace as a set of contract-testing_* tools. When configured alongside the PactFlow skill, your AI assistant gains structured, programmatic access to your workspace — direct matrix queries and full management of every broker resource. On PactFlow Cloud ☁, it also unlocks AI-assisted test generation and review using your live provider states, BDCT cross-contract verification results, and team metrics.

For the official SmartBear documentation on the MCP server, see the SmartBear MCP contract testing docs.

Without the MCP server, the skill can still interact with your broker via the pact-broker CLI if it is installed and credentials are set in the environment. The CLI covers the core operations — publishing pacts, can-i-deploy, recording deployments, managing environments and webhooks — but does not expose the contract matrix, AI generation tools, or BDCT results. See the comparison table for the full breakdown.

Open-source Pact Broker and PactFlow Cloud

The skill and MCP server work with both the open-source Pact Broker and PactFlow Cloud. Features marked ☁ require a PactFlow Cloud account. All other capabilities work with Pact and any Pact Broker. PactFlow-specific capabilities include: Drift testing, AI test generation and review, bi-directional contract testing, team metrics, the audit log, and all administration tools.

Installation and configuration

If the PactFlow skill is already active, you can ask it to install and configure the MCP server for you:

Set up the SmartBear MCP server

For manual setup, see the PactFlow Skill page for full instructions per tool (Claude Code, Claude Desktop, VS Code, Cursor). The short version:

# Claude Code — plugin install handles this automatically
/plugin install swagger-contract-testing@pactflow-agent-skills

# All other tools — run the MCP server via npx
npx @smartbear/mcp@latest

Required environment variables:

VariableRequired forDescription
PACT_BROKER_BASE_URLAllFull URL to your broker, e.g. https://yourorg.pactflow.io
PACT_BROKER_TOKENPactFlow CloudAPI token from Settings → API Tokens
PACT_BROKER_USERNAMEOpen-source brokerHTTP Basic Auth username
PACT_BROKER_PASSWORDOpen-source brokerHTTP Basic Auth password

Use a token or username/password — not both.


AI tools ☁ Cloud only

contract-testing_generate_pact_tests

Generates a complete, runnable Pact test using PactFlow AI. Accepts any combination of inputs and returns idiomatic test code in the target language with correct matching rules applied.

Inputs:

ParameterDescription
languageTarget language (javascript, typescript, java, kotlin, go, dotnet, ruby, python, php, swift). Inferred if omitted and code files are provided.
request_response.requestRaw HTTP request string or description
request_response.responseRaw HTTP response string or description
codeArray of code files (API client, models, utilities) to generate from
openapi.documentOpenAPI spec content (inline)
openapi.matcherFilter to a specific endpoint, method, or status code within a spec (e.g. GET /orders 200)
openapi.remoteDocumentURL to a remote OpenAPI spec, with optional auth credentials
additional_instructionsExtra constraints — framework version, test runner, naming conventions
test_templateAn existing test file to use as a structural template, so output matches your team's conventions

The pact-generator subagent always calls contract-testing_get_provider_states before invoking this tool, ensuring generated tests reuse existing provider state names from your workspace rather than creating duplicates.

Example:

Generate a consumer test for the POST /orders endpoint.
Use TypeScript with pact-js v13 and Vitest.
Check what provider states already exist for OrderService first.

contract-testing_review_pact_tests

Reviews existing Pact tests against best practices and returns a prioritised list of findings.

Inputs:

ParameterDescription
pact_testsTest files to review — required
codeSupporting files for context (API client, models)
openapi.document / .matcher / .remoteDocumentAPI spec for additional context
user_instructionsAreas to focus on, e.g. "check matching rules" or "focus on provider state naming"
error_messagesOutput from a failing test run or broken provider verification — the review will target the actual failure

The pact-reviewer subagent uses this tool as the core of its review process, passing your files and any error output directly to it.

Example:

Review the Pact tests in src/__tests__/consumer.test.ts.
My provider verification is failing with this error:
[paste error output]

contract-testing_check_pactflow_ai_entitlements

Diagnoses 401 errors or missing-credit issues when the AI generation or review tools fail. Takes no parameters. Returns a plain-language explanation of your account's current AI entitlement state — whether you have credits remaining, whether the feature is enabled on your plan, and what to do if it isn't.

Both pact-generator and pact-reviewer call this automatically when they receive a 401, before falling back to non-AI generation.


Deployment safety

contract-testing_can_i_deploy

The deployment safety gate. Checks the contract matrix to determine whether a specific version of a service is safe to deploy to a given environment. Run this in CI before deploying.

Parameters: pacticipant (required), version (required), environment (required — use the environment name, e.g. production)

Returns a success or failure result with a human-readable explanation. When it fails, use contract-testing_matrix to diagnose the root cause.

Example:

Is FrontendApp version abc123 safe to deploy to production?

contract-testing_matrix

Queries the contract verification matrix — the source of truth for what has and hasn't been verified. Use this to diagnose can-i-deploy failures, investigate a specific consumer-provider pair, or get an overview of verification state.

Key parameters:

ParameterDescription
qArray of 1–2 pacticipant selectors. Each selector has pacticipant and one of: version, branch, environment, latest, tag, mainBranch, deployedOrReleased
latestbycvp — latest result per consumer version + provider; cvpv — latest per consumer version + provider version
limitMax rows to return (1–1000, default 100)

Reading the results:

Matrix row stateMeaning
No row existsProvider has never verified this consumer version
Row exists, success: nullVerification is in progress or results weren't published
Row exists, success: falseProvider verified and it failed — genuine contract break
Row exists, success: trueVerified and passing

Diagnosing a can-i-deploy failure:

# Step 1: check what's actually deployed in production
contract-testing_get_currently_deployed_versions → environmentId: <prod-uuid>

# Step 2: query the matrix for this consumer version vs what's in production
contract-testing_matrix
q: [
{ pacticipant: "FrontendApp", version: "abc123" },
{ pacticipant: "OrderService", deployed: true, environment: "production" }
]
latestby: "cvp"
Root causeFix
No matrix row (never verified)Provider is missing { deployedOrReleased: true } in consumerVersionSelectors
success: falseGenuine contract break — fix the failing interaction
Results not publishedProvider CI missing publishVerificationResults: true and providerVersion config
No webhook firingCreate a webhook for contract_requiring_verification_published

Contracts

contract-testing_publish_consumer_contracts

Publishes consumer pact files to the broker. Run in consumer CI after tests pass.

Key parameters:

ParameterDescription
pacticipantNameConsumer name as registered in the broker
pacticipantVersionNumberVersion number — use the git SHA
branchConsumer branch name — use $GIT_BRANCH
contractsArray of pact objects: { consumerName, providerName, content (base64-encoded JSON), contentType: "application/json", specification: "pact" }
buildUrlCI build URL for traceability
Always publish with branch

Publishing without branch means the broker can't use { mainBranch: true } or { matchingBranch: true } selectors for this version.


contract-testing_get_pacts_for_verification

Fetches the pacts a provider should verify in its current CI run. Called by the provider pipeline, not manually.

Key parameters:

ParameterDescription
providerNameProvider name
providerVersionBranchCurrent provider branch — used to resolve matchingBranch selectors
consumerVersionSelectorsArray of selectors controlling which consumer versions are verified
includePendingStatustrue — new consumer interactions won't fail the provider build until first verified
includeWipPactsSinceISO 8601 date — include new consumer pacts automatically for early feedback

Recommended selectors:

[
{ "mainBranch": true },
{ "matchingBranch": true },
{ "deployedOrReleased": true }
]

Missing { "deployedOrReleased": true } is the single most common cause of can-i-deploy failures — without it the provider never verifies the version currently in production.


contract-testing_get_provider_states

Lists all provider states defined for a provider across all published pacts. Always call this before generating new consumer tests — it lets you reuse existing state names and avoid duplication.

Parameter: provider (required)


contract-testing_publish_provider_contract ☁ Cloud only (BDCT)

Publishes a provider OpenAPI spec and self-verification results to PactFlow. Used in the BDCT flow instead of running consumer pact tests on the provider.

Key parameters:

ParameterDescription
providerNameProvider name
pacticipantVersionNumberVersion number — use git SHA
branchProvider branch
contract.contentBase64-encoded OpenAPI spec (YAML or JSON)
contract.contentTypeapplication/yaml or application/json
contract.specificationMust be oas
contract.selfVerificationResults.successtrue or false — whether the provider's own verification tool passed
contract.selfVerificationResults.verifierTool used for self-verification: dredd, schemathesis, postman, curl, etc.

The selfVerificationResults.success boolean is critical. PactFlow will not mark the provider as verified unless this is true.


Pacticipants

Pacticipants are the services registered in your workspace. Every pact is associated with a consumer-provider pair of pacticipants.

ToolWhat it does
contract-testing_list_pacticipantsList all registered services. Optional: pageNumber, pageSize
contract-testing_get_pacticipantGet metadata for a service
contract-testing_create_pacticipantRegister a new service. Set mainBranch on creation so { mainBranch: true } selectors work immediately
contract-testing_patch_pacticipantPartially update a service (only provided fields change). Preferred for targeted changes
contract-testing_update_pacticipantFully replace a service's metadata — clears fields not provided
contract-testing_delete_pacticipantDelete a service and all its data. Irreversible. Check for active deployments first

Registering a new service:

contract-testing_create_pacticipant
name: "PaymentService"
displayName: "Payment Service"
mainBranch: "main"
repositoryUrl: "https://github.com/example/payment-service"

Setting the main branch on an existing service:

contract-testing_patch_pacticipant
pacticipantName: "PaymentService"
mainBranch: "main"

Branches and versions

Branches are a first-class concept in the Pact Broker (from v2.82.0). They supersede tags for tracking which pacts belong to which development line.

ToolWhat it does
contract-testing_list_branchesList branches for a service. Optional: q (name filter)
contract-testing_get_branchGet branch metadata
contract-testing_get_branch_versionsList versions published from a branch
contract-testing_delete_branchDelete a branch and its version associations. Clean up after PRs merge
contract-testing_list_pacticipant_versionsList all versions for a service
contract-testing_get_pacticipant_versionGet metadata for a specific version
contract-testing_get_latest_pacticipant_versionGet the most recent version, optionally filtered by tag
contract-testing_get_deployed_versions_for_versionCheck deployment records for a version in a specific environment
contract-testing_get_released_versions_for_versionCheck release records for a version (mobile/library workflows)
Branch cleanup

Delete merged feature branches with contract-testing_delete_branch to keep the workspace clean. The associated versions are cleaned up automatically. Never delete a branch that has deployed versions without checking first.


Environments and deployments

Environments are named deployment targets (e.g. staging, production). The broker needs to know what is deployed where in order for can-i-deploy to work correctly.

Managing environments

ToolWhat it does
contract-testing_list_environmentsList all environments and their UUIDs
contract-testing_get_environmentGet details for a specific environment
contract-testing_create_environmentCreate an environment. Set production: true for production environments
contract-testing_update_environmentReplace environment config
contract-testing_delete_environmentDelete an environment and all its deployment/release records

Creating environments:

contract-testing_create_environment  name: "staging"     production: false
contract-testing_create_environment name: "production" production: true

Environment UUIDs are needed for recording deployments. Retrieve them with contract-testing_list_environments.

Recording deployments

Use contract-testing_record_deployment for traditional services where one version is active per environment at a time. Recording a new deployment automatically marks the previous version as undeployed.

contract-testing_record_deployment
pacticipantName: "FrontendApp"
versionNumber: "abc1234"
environmentId: "<uuid-of-production>"
applicationInstance: "blue" # optional — for blue/green deployments

Recording releases

Use contract-testing_record_release for mobile apps and shared libraries where multiple versions coexist simultaneously. Unlike record_deployment, this does not mark previous versions as inactive — all released versions remain "supported".

contract-testing_record_release
pacticipantName: "MobileApp"
versionNumber: "3.2.1"
environmentId: "<uuid-of-production>"

Checking what is deployed

# What is currently deployed in production?
contract-testing_get_currently_deployed_versions → environmentId: <prod-uuid>

# What versions are currently supported (mobile/library)?
contract-testing_get_currently_supported_versions → environmentId: <prod-uuid>

Bi-Directional Contract Testing ☁ Cloud only

BDCT removes the need for the provider to run consumer Pact tests. Instead, the provider publishes its OpenAPI spec and the results of a self-verification tool (Dredd, Schemathesis, Postman). PactFlow performs the cross-contract comparison automatically.

See BDCT vs Standard Pact for a comparison of the two approaches.

Investigating a BDCT failure

Work from broad to specific:

1. Overall cross-contract result for a provider version

contract-testing_get_bdct_cross_contract_verification_results
providerName: "OrderService"
providerVersionNumber: "def5678"

Shows the overall pass/fail and which consumer pact interactions failed the spec comparison.

2. Provider self-verification results

contract-testing_get_bdct_provider_contract_verification_results
providerName: "OrderService"
providerVersionNumber: "def5678"

The output of the provider's own spec-verification tool. If success: false, the provider's implementation doesn't match its own spec — fix the implementation or the spec before BDCT can pass.

3. Consumer contracts used in the comparison

contract-testing_get_bdct_consumer_contracts
providerName: "OrderService"
providerVersionNumber: "def5678"

Lists all consumer pact files PactFlow used in the cross-contract verification.

4. Pinpoint a specific consumer-provider version pair

When you know which consumer version is failing:

contract-testing_get_bdct_cross_contract_verification_results_by_consumer_version
providerName: "OrderService"
providerVersionNumber: "def5678"
consumerName: "CheckoutApp"
consumerVersionNumber: "abc1234"

Additional by-consumer-version tools available for: get_bdct_consumer_contract_by_consumer_version, get_bdct_provider_contract_by_consumer_version, get_bdct_provider_contract_verification_results_by_consumer_version, get_bdct_consumer_contract_verification_results_by_consumer_version.

Common BDCT failure patterns

Failure messageRoot causeFix
$.body.X is not defined in the specProvider returns field X but spec doesn't document itUpdate the spec to document it
$.body.X type mismatchSpec type doesn't match implementationFix the spec to match what the provider actually returns
Path /foo not found in specProvider implements the path but spec is missing itAdd the path to the spec
Self-verification failedProvider's implementation doesn't match its own specFix the implementation or the spec
BDCT fails even though self-verification passedSpec is too strict for what the consumer expectsCheck for additionalProperties: false, missing response headers, or overly strict schemas

BDCT vs Standard Pact

Standard PactBDCT
Provider runs consumer testsYesNo
Provider publishesVerification resultsOpenAPI spec + self-verification results
Cross-contract verificationDone by provider test suiteDone by PactFlow automatically
Consumer sideSameSame
AvailabilityCloud, On-Prem, Open SourcePactFlow Cloud only
Best forTight teams with shared test infrastructureLoosely coupled teams; existing spec-based testing

Integrations and network

ToolWhat it does
contract-testing_list_integrationsList all consumer-provider pairings in the workspace
contract-testing_get_pacticipant_networkGet the full integration graph for a service — all consumers that depend on it and all providers it depends on
contract-testing_get_integrations_by_teamList integrations owned by a specific team
contract-testing_delete_integrationDelete a specific consumer-provider pairing and all associated data
contract-testing_delete_all_integrationsDelete every integration in the workspace. Irreversible — use only when decommissioning an entire workspace

contract-testing_get_pacticipant_network is the tool to reach for before making a breaking API change — it shows the blast radius across your entire ecosystem.

Which services depend on UserService?

Labels

Labels are free-form tags you can apply to pacticipants for grouping and filtering.

ToolWhat it does
contract-testing_list_labelsList all labels used in the workspace
contract-testing_get_pacticipant_labelCheck whether a label is applied to a service
contract-testing_list_pacticipants_by_labelList all services with a given label
contract-testing_add_label_to_pacticipantApply a label
contract-testing_remove_label_from_pacticipantRemove a label

Metrics

ToolWhat it does
contract-testing_get_metricsWorkspace-wide usage statistics — total pacticipants, pacts, verifications
contract-testing_get_team_metricsPer-team breakdown of the same metrics

Webhooks

Webhooks trigger actions (typically CI builds) when events occur in the broker. The most important use case is triggering provider verification immediately when a consumer publishes a changed pact, rather than waiting for the next scheduled provider CI run.

Webhook events

EventWhen triggeredTypical use
contract_publishedA pact is published for the first time or content changesTrigger provider verification
contract_requiring_verification_publishedA pact is published and needs verificationRecommended — passes the pact URL directly to the provider build
verification_publishedA provider publishes a verification resultTrigger consumer build to check can-i-deploy
provider_verification_succeededAfter a successful verificationNotify consumer team
provider_verification_failedAfter a failed verificationAlert provider team

Dynamic variables

These can be used in webhook request bodies and URLs:

${pactbroker.consumerName}
${pactbroker.providerName}
${pactbroker.pactUrl}
${pactbroker.verificationResultUrl}
${pactbroker.consumerVersionNumber}
${pactbroker.providerVersionNumber}
${pactbroker.consumerVersionBranch}
${pactbroker.providerVersionBranch}
${pactbroker.githubVerificationStatus}

Managing webhooks

ToolWhat it does
contract-testing_list_webhooksList all webhook configurations
contract-testing_get_webhookGet details for a specific webhook
contract-testing_create_webhookCreate a webhook
contract-testing_update_webhookUpdate a webhook
contract-testing_delete_webhookDelete a webhook
contract-testing_execute_webhookTrigger a webhook manually using the last matching pact event as the test payload
contract-testing_test_execute_webhooksTrigger a webhook with a specific consumer-provider pair as the payload for testing

Example — trigger provider CI via GitHub Actions:

contract-testing_create_webhook
description: "Trigger OrderService verification on pact change"
events: ["contract_requiring_verification_published"]
consumer: "FrontendApp"
provider: "OrderService"
request:
method: POST
url: "https://api.github.com/repos/example/order-service/actions/workflows/pact.yml/dispatches"
headers:
Authorization: "Bearer ${user.bearerToken}"
Content-Type: "application/json"
body:
ref: "main"
inputs:
pact_url: "${pactbroker.pactUrl}"

See the webhook template library for ready-made templates for GitHub Actions, CircleCI, GitLab CI, Jenkins, and Azure DevOps.


Secrets

Secrets store sensitive values (API keys, tokens) for use in webhook configurations. Storing them as secrets means the values aren't exposed in webhook config or logs.

ToolWhat it does
contract-testing_list_secretsList all secrets (names and UUIDs, not values)
contract-testing_get_secretGet secret metadata
contract-testing_create_secretCreate a secret. name and value required
contract-testing_update_secretUpdate a secret's value
contract-testing_delete_secretDelete a secret

Reference secrets in webhook headers using ${user.<secret-name>}.


Audit log ☁ Cloud only

contract-testing_get_audit_log returns an audit trail of actions performed in the workspace — who did what and when. Useful for compliance and debugging unexpected state changes.


Account and authentication

ToolWhat it does
contract-testing_get_current_userGet the identity of the currently authenticated user — name, email, roles
contract-testing_get_system_preferencesRead system-level preferences for the workspace
contract-testing_get_user_preferencesRead preferences for the current user
contract-testing_list_api_tokensList API tokens for the current user
contract-testing_regenerate_api_tokenRegenerate an API token by UUID. The old token is immediately invalidated

Administration ☁ Cloud only

Administration tools manage users, teams, roles, and system accounts in PactFlow Cloud. These are typically used by workspace administrators during onboarding or access control changes.

Users

ToolWhat it does
contract-testing_admin_list_usersList all users in the workspace
contract-testing_admin_get_userGet details for a specific user
contract-testing_admin_create_userCreate a new user
contract-testing_admin_update_userUpdate a user's details
contract-testing_admin_delete_userRemove a user from the workspace
contract-testing_admin_invite_usersSend invitation emails to one or more users

Teams

ToolWhat it does
contract-testing_admin_list_teamsList all teams
contract-testing_admin_get_teamGet details for a specific team
contract-testing_admin_create_teamCreate a team
contract-testing_admin_update_teamUpdate a team's name or settings
contract-testing_admin_delete_teamDelete a team
contract-testing_admin_list_team_usersList users in a team
contract-testing_admin_get_team_userCheck whether a specific user is in a team
contract-testing_admin_set_team_usersReplace the full user list for a team
contract-testing_admin_patch_team_usersAdd or remove specific users from a team
contract-testing_admin_remove_user_from_teamRemove a single user from a team

Roles and permissions

ToolWhat it does
contract-testing_admin_list_rolesList all roles defined in the workspace
contract-testing_admin_get_roleGet details for a specific role
contract-testing_admin_create_roleCreate a custom role
contract-testing_admin_update_roleUpdate a role's permissions
contract-testing_admin_delete_roleDelete a custom role
contract-testing_admin_reset_rolesReset all roles to the system defaults
contract-testing_admin_list_permissionsList all available permissions
contract-testing_admin_add_role_to_userAssign a role to a user
contract-testing_admin_remove_role_from_userRemove a role from a user
contract-testing_admin_set_user_rolesReplace a user's full role assignment

System accounts

ToolWhat it does
contract-testing_admin_create_system_accountCreate a system account (non-human user for CI pipelines)
contract-testing_admin_get_system_account_tokensGet the API tokens for a system account

Troubleshooting

SymptomLikely causeFix
401 UnauthorizedWrong or missing tokenCheck PACT_BROKER_TOKEN matches the value from the API tokens page
404 Not FoundWrong broker URLVerify PACT_BROKER_BASE_URL — no trailing slash, correct subdomain
Tools not appearingMCP server not startingRun npx @smartbear/mcp@latest in a terminal to see startup errors
AI tools return 401Missing PactFlow AI entitlementCall contract-testing_check_pactflow_ai_entitlements to diagnose
can-i-deploy fails unexpectedlyProvider never verified deployed consumer versionAdd { deployedOrReleased: true } to provider's consumerVersionSelectors
Verification results not appearingResults published outside CIpublishVerificationResults should be true only when CI=true
Webhook not firingEvent type mismatchUse contract_requiring_verification_published for triggering provider builds