Skip to main content
Canary testing validates that Golf Gateway is healthy, can connect to MCP servers, and has security features active. This guide provides a playbook for creating automated canary tests.

Prerequisites

  • Golf Gateway deployed
  • Access token for authentication (M2M or user token)
  • Python 3.10+ with mcp and httpx packages

What to test

A comprehensive canary test covers three areas:

Test 1: Health check

The gateway exposes a /health endpoint that verifies internal components. Endpoint: GET /health
Expected response (HTTP 200):
Failure (HTTP 503) indicates an unhealthy component—check logs for details.

Python implementation

Test 2: MCP connectivity

This test verifies you can establish an authenticated MCP session through the gateway.

Authentication

Step 1: Discover DCR endpoint

Find the registration endpoint from OAuth metadata:

Step 2: Dynamic Client Registration (one-time per execution of the canary script)

Register your canary test client per RFC 7591:

Step 3: Token provider with refresh

Create a token provider that handles acquisition of the M2M token from your IDP.

Connecting with the Python MCP SDK

Use the official MCP Python SDK to establish a connection. Key concepts:
  1. MCP URL format: {gateway_url}/{server_name}/mcp
  2. Token injection: Pass token via Authorization header to streamable_http_client
  3. Transport: Use streamable_http_client for HTTP-based MCP
  4. Initialization: Call session.initialize() to establish the session

Python implementation

Validating the upstream server

A successful initialize confirms the gateway can reach the upstream, but doesn’t verify the upstream is fully functional. For deeper validation, call a tool that returns a known output:
Choose a lightweight, read-only tool for canary tests. Avoid tools that modify data or have side effects.

Test 3: Security firewall

This test verifies that Golf Gateway’s threat detection is active and blocking prompt injection attacks. When a prompt injection is detected, the gateway blocks the request—either returning an HTTP 403 or an MCP error depending on when in the request lifecycle the threat is detected.

Test payloads

Use known prompt injection patterns that should trigger the firewall:

Python implementation

Use the MCP SDK to call a tool with a malicious payload and verify the firewall blocks it: