MCP Server Monitoring: A cron Script for Uptime and Tool List Changes | MCP Hunter

MCP Server Monitoring: A cron Script for Uptime and Tool List Changes

A short bash script that checks an MCP server on a schedule: initialize, tools/list, response time in ms, and an alert when the call fails or a tool disappears. Run against our own MCP server on 30 November 2026.

MCP Hunter team 8 min read

Monitoring an MCP server means asking it the same questions a client asks, on a schedule, and alerting when the answer changes. An uptime monitor pointed at your homepage answers a different question. A server can return 200 on every page while tools/list comes back empty after a bad deploy, and no client can use it.

This page is the scheduled version of the MCP server health check. That page covers which single request proves a server is healthy and which answers only look broken. This one turns the full check into a script you leave running: it logs the protocol version, the tool count and two response times on every run, and exits non-zero when something a client depends on changed.

TL;DR:

  • Check what a client does: initialize, then tools/list [1][2]. A status route can stay green while both fail.
  • Store the tool names, not only the count. A renamed tool keeps the count and still breaks every prompt that calls the old name.
  • Close the session after each check with an HTTP DELETE [1], or a check every five minutes opens 288 sessions a day.
  • Run it from a machine outside your network. A check from the server's own host passes on problems strangers hit.

What to watch

Signal Why it matters Alert when
initialize answers with protocolVersion The server speaks MCP at all [1] No answer, a non-200, or no protocolVersion
The protocol version Clients negotiate on it, and an upgrade can change the request shape It changes (logged, worth a look)
tools/list returns tools A server with zero tools connects fine and does nothing [2] The list is empty
The tool names Agents and saved prompts call tools by name A name is added or removed
Response time of tools/list The call every client waits on before it can do anything It stays well above your usual figure

A server that declares listChanged should notify connected clients when its tools change [2]. That reaches clients holding an open session. A monitor that connects fresh each time sees the change by comparing lists, which is what the script below does.

The script

It needs bash, curl and jq. It keeps one log and one tool list per URL in ~/.mcp-monitor, and it handles both plain JSON answers and answers sent as an event stream, which a server may always choose [1].

#!/usr/bin/env bash
# mcp-monitor.sh: one MCP check for cron. Exits 1 when the server fails or its tool list changes.
URL=${1:?usage: mcp-monitor.sh <endpoint-url>}
STATE=${STATE_DIR:-$HOME/.mcp-monitor}
mkdir -p "$STATE"
KEY=$(printf '%s' "$URL" | cksum | cut -d' ' -f1)
LOG="$STATE/$KEY.log"
H=(-H 'Content-Type: application/json' -H 'Accept: application/json, text/event-stream')
[ -n "$MCP_TOKEN" ] && H+=(-H "Authorization: Bearer $MCP_TOKEN")
now() { date -u +%Y-%m-%dT%H:%M:%SZ; }
fail() { echo "$(now) FAIL $1" | tee -a "$LOG"; exit 1; }
body() { sed -n 's/^data: //p; /^{/p' "$STATE/b"; }   # plain JSON or an event stream
ms() { awk -v s="$1" 'BEGIN { printf "%d", s * 1000 }'; }

# 1. initialize: proves the server speaks MCP, and hands out a session id if it uses one.
INIT='{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-11-25","capabilities":{},"clientInfo":{"name":"mcp-monitor","version":"1.0.0"}}}'
read -r CODE T1 < <(curl -sS --max-time 10 -D "$STATE/h" -o "$STATE/b" \
  -w '%{http_code} %{time_total}\n' "${H[@]}" -d "$INIT" "$URL" 2>/dev/null)
[ "$CODE" = 000 ] && fail "no answer (timeout, DNS or connection refused)"
[ "$CODE" = 200 ] || fail "initialize returned HTTP $CODE"
VERSION=$(body | jq -r '.result.protocolVersion // empty' | tr -d '\r')
[ -n "$VERSION" ] || fail "initialize answered without protocolVersion"
SESSION=$(grep -i '^mcp-session-id:' "$STATE/h" | cut -d' ' -f2 | tr -d '\r')
S=(-H "MCP-Protocol-Version: $VERSION")
[ -n "$SESSION" ] && S+=(-H "Mcp-Session-Id: $SESSION")

curl -sS --max-time 10 -o /dev/null "${H[@]}" "${S[@]}" \
  -d '{"jsonrpc":"2.0","method":"notifications/initialized"}' "$URL"

# 2. tools/list, timed on its own: this is the call a client waits on.
read -r CODE T2 < <(curl -sS --max-time 10 -o "$STATE/b" -w '%{http_code} %{time_total}\n' \
  "${H[@]}" "${S[@]}" -d '{"jsonrpc":"2.0","id":2,"method":"tools/list","params":{}}' "$URL" 2>/dev/null)

# 3. End the session, so a check every few minutes does not leave hundreds open.
[ -n "$SESSION" ] && curl -sS --max-time 10 -o /dev/null -X DELETE "${S[@]}" "$URL"

[ "$CODE" = 200 ] || fail "tools/list returned HTTP $CODE"
TOOLS=$(body | jq -r '.result.tools[]?.name' | tr -d '\r' | sort)
COUNT=$(printf '%s\n' "$TOOLS" | grep -c .)
[ "$COUNT" -gt 0 ] || fail "tools/list returned no tools"

# 4. Compare with the last run that passed.
LAST="$STATE/$KEY.tools"
if [ -f "$LAST" ] && [ "$(cat "$LAST")" != "$TOOLS" ]; then
  GONE=$(comm -23 "$LAST" <(printf '%s\n' "$TOOLS") | paste -sd, -)
  NEW=$(comm -13 "$LAST" <(printf '%s\n' "$TOOLS") | paste -sd, -)
  printf '%s\n' "$TOOLS" > "$LAST"
  fail "tool list changed: removed [$GONE] added [$NEW]"
fi
printf '%s\n' "$TOOLS" > "$LAST"
echo "$(now) OK $VERSION $COUNT tools initialize=$(ms "$T1")ms tools/list=$(ms "$T2")ms" | tee -a "$LOG"

Save it as mcp-monitor.sh, then chmod +x mcp-monitor.sh. If your server needs a token, set MCP_TOKEN and the script sends it as a bearer header on every request.

The requests are the same three calls described step by step in testing an MCP server with curl, plus the DELETE at the end. The spec says a client that no longer needs a session should send one, and a server may refuse it with 405 when it does not let clients end sessions [1]. Ours refuses it, so on our server that call is a no-op. Ending the session is still the polite default, because each initialize on a server that keeps sessions opens a new one.

What it printed

We ran it against our own MCP server at https://mcp-hunter.com/mcp on 30 November 2026. Two normal runs:

2026-11-30T07:46:20Z OK 2025-11-25 9 tools initialize=214ms tools/list=279ms
2026-11-30T07:46:26Z OK 2025-11-25 9 tools initialize=200ms tools/list=136ms

To see the change alert, we deleted weekly_leaderboard from the stored list and ran it again. The server still had nine tools, so the script reported the difference and exited 1:

2026-11-30T07:45:32Z FAIL tool list changed: removed [] added [weekly_leaderboard]

And the two failures you most want to hear about, our homepage (a web page, not an MCP endpoint) and a host that does not exist:

2026-11-30T07:45:37Z FAIL initialize returned HTTP 405
2026-11-30T07:45:38Z FAIL no answer (timeout, DNS or connection refused)

Response times on the same server moved between 130 and 313 ms across nine runs that morning, so alert on a run of slow checks, never on one.

Put it on a schedule

Every five minutes, with the log and the tool list in the default place:

*/5 * * * * /home/you/bin/mcp-monitor.sh https://your-server.example.com/mcp >/dev/null || /home/you/bin/notify.sh "MCP check failed"

The script exits 0 on a pass and 1 on anything else, so the alert is whatever runs after ||: a mail command, a webhook to Slack or Discord, or a push to a phone. The reason is the last line of the log, tail -n1 ~/.mcp-monitor/*.log.

A scheduled CI job works as well as cron, and it runs from someone else's network. In GitHub Actions, a workflow with on: schedule and a cron: line runs the script on a hosted runner, and a non-zero exit marks the run as failed.

Two adjustments for real servers:

  • A guarded server answers 401 until you give it a token, and the script reports that as a failure. Set MCP_TOKEN, or treat a 401 with a WWW-Authenticate header as up, as the health check page explains. A 401 proves the auth layer answered, not what sits behind it.
  • A 2026-07-28 server has no initialize. Swap step 1 for the server/discover request in the curl guide and drop the session lines. Of 694 registry servers that completed a handshake in our census on 20 August 2026, 3 negotiated that revision, so most servers need the script as written.

Where MCP Hunter fits

MCP Hunter connects to a listed server once, at submission, and a maker may ask for a re-test once every 7 days, so a listing shows a dated measurement, not a live status. Makers with a listed remote server see a $9 a month monitoring offer on their submission page: a daily check and an email the morning the server stops answering or its tool list changes. It is not built yet. Pressing the button there tells us you would pay for it, and nothing is charged.

For a one-off check from outside your own network, our MCP connection test sends the same requests and saves the result at a dated URL. Every field tools/list can return is in the tools/list reference.

Sources

  1. Transports, MCP specification 2025-11-25
  2. Tools, MCP specification 2025-11-25