Skip to content

Add cronitor monitor mcp to create and update MCP checks, with OAuth sign-in - #96

Draft
aflanagan wants to merge 3 commits into
masterfrom
agent/mcp-checks
Draft

aflanagan wants to merge 3 commits into
masterfrom
agent/mcp-checks

Conversation

@aflanagan

Copy link
Copy Markdown
Contributor

Merge and release after cronitorio/cronitor#767 is deployed. --oauth uses server endpoints that PR adds. Until then the command stops with "OAuth start did not return authorize_url and connection". Header auth works against any server that has MCP checks.

What it does

cronitor monitor mcp creates or updates an MCP check: a Cronitor uptime check that connects to a remote MCP server, lists its tools, and alerts when the connection, the auth, the tools or the speed change.

cronitor monitor mcp https://mcp.example.com/mcp --key docs-mcp --header "Authorization: Bearer $TOKEN"
cronitor monitor mcp https://mcp.example.com/mcp --key docs-mcp --oauth
cronitor monitor mcp https://mcp.example.com/mcp --tools search,fetch --include-descriptions
cronitor monitor mcp --key docs-mcp --accept-baseline
  • Create or update: with --key, the command updates the check if it exists (GET then PUT /monitors/<key>) and creates it otherwise. Without --key it creates a new check. --tools and --include-descriptions are only sent when given, so an update doesn't reset them.

  • --header: repeatable, "Name: value". Values are stored write-only on the server and never printed. They are also redacted from -v and --log output through the existing rememberSecret.

  • --oauth:

    1. Calls POST /monitors/mcp/oauth/start.
    2. Prints the sign-in URL and opens the browser. If the browser can't open, it only prints a message.
    3. Polls GET /monitors/mcp/oauth/connections/<id> every 2 s until the status is ready, failed or expired, or until expires_in runs out. Ctrl-C stops it.
    4. When ready, saves the check with mcp.oauth_connection.

    The CLI never sees the OAuth tokens; Cronitor keeps them. The user signs in to the MCP server's provider in a browser where they are logged in to Cronitor, and lands on a page that says they can return to the terminal.

  • Output: the check key, protocol version, auth (header names or the OAuth issuer), watched tools and baseline tools. A server 400 prints its message, for example Auth failed: server returned 401 or header values are required.

  • --header and --oauth are exclusive.

Changes

  • lib/api_client.go: a new APIClient.APIVersion field, so these requests can send Cronitor-Version: 2025-11-28 without changing the global setting.

  • cmd/monitor_mcp.go (new): the command. It reuses the browser and polling helpers from cmd/connect.go and cmd/integrations_common.go.

  • cmd/monitor_mcp_test.go (new): 4 tests against an httptest server.

    • header create, with no header value in verbose output;
    • the OAuth path: start, pending, ready, then create with oauth_connection;
    • a failed sign-in: exit 1 and no monitor write;
    • --header with --oauth is rejected.

    Each test also checks the Cronitor-Version header.

  • README.md: an "MCP server checks" section with one header example and one OAuth example.

Tests

  • go test ./cmd ./lib passes, including the existing README-examples test.
  • go test ./... can't build the root package locally, because web/static is gitignored and CI builds it first.
  • Not run against a live server yet: the OAuth endpoints exist only on #767.

Generated by Claude Code

APIClient.APIVersion, when set, is sent instead of the configured
CRONITOR_API_VERSION, for endpoints that need a minimum API version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B4Z4DjjwWh9BgvdzdFoMnc
Creates a check with type "check", platform "mcp" for a remote MCP
server URL, or updates the check named by --key when it exists.
Auth is --header "Name: value" (repeatable; values are sent write-only
and redacted from verbose logs) or --oauth, which starts a sign-in at
/monitors/mcp/oauth/start, prints the authorize URL, opens the browser
and polls the connection every 2s until it is ready, failed or expired,
then saves the monitor with mcp.oauth_connection. Also --tools,
--include-descriptions and --accept-baseline. Requests send
Cronitor-Version 2025-11-28. Prints the key, protocol version, auth,
watched tools and baseline tools; 400s show the server's mcp messages.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B4Z4DjjwWh9BgvdzdFoMnc
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01B4Z4DjjwWh9BgvdzdFoMnc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants