Running an AI agent 24/7: GitHub Actions, a small server or AWS Lambda

In the first tutorial we built a site doctor: a small AI agent that opens your pages, checks the certificate and DNS, and writes a diagnosis. It works great, as long as my laptop is open. The whole point of a doctor on duty is that it checks the site at 8 AM while I’m still stuck in traffic on the highway.
So here are three ways to run it without a workstation, plus a bonus that lets you call it from any Claude chat on your phone. Pick one. You don’t need all of them.
Before you start
Everything here uses the same site_doctor.py from the first tutorial, unchanged. A script running alone needs a way to tell you something is wrong. The agent’s instructions already end the report with one last line, STATUS: OK or STATUS: PROBLEM. Every option below just looks for that line and only bothers you when it isn’t OK.
One rule for all of them: don’t run the doctor on the same server as the site it watches. If that server goes down, the doctor goes down with it and can’t warn anyone. It’s like keeping the fire alarm’s battery inside the oven.
Option 1: GitHub Actions (easiest, no server)
Put site_doctor.py in a GitHub repository (a private one is fine). Add your key under Settings, then Secrets and variables, then Actions, as a secret called ANTHROPIC_API_KEY. Then add this file as .github/workflows/site-doctor.yml:
# .github/workflows/site-doctor.yml
# Runs the site doctor every morning, and on demand from the Actions tab
# (or the GitHub mobile app) with any site you type in.
# Needs: site_doctor.py in the repo root, and a repository secret ANTHROPIC_API_KEY
# (Settings -> Secrets and variables -> Actions -> New repository secret).
# Alert: if the report says STATUS: PROBLEM the job fails, and GitHub emails you about the failed run.
name: Site doctor
on:
schedule:
- cron: "52 5 * * *" # 05:52 UTC = 07:52 Beirut (GitHub cron is always UTC)
workflow_dispatch:
inputs:
site:
description: "Site to check, e.g. example.com"
required: true
permissions:
contents: read
jobs:
check:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: pip install anthropic
- name: Run the site doctor
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
SITE: ${{ inputs.site || 'https://example.com' }} # scheduled runs check your own site
run: |
python3 site_doctor.py "$SITE" | tee report.txt
echo '```' >> "$GITHUB_STEP_SUMMARY"; cat report.txt >> "$GITHUB_STEP_SUMMARY"; echo '```' >> "$GITHUB_STEP_SUMMARY"
grep -q "STATUS: OK" report.txt # no OK line -> job fails -> GitHub emails you
What you should see: a “Site doctor” workflow in the Actions tab. It runs every morning, and there’s a “Run workflow” button where you can type any site. That button works from the GitHub mobile app too. The report shows on the run’s summary page.
How it alerts you: when the report doesn’t say STATUS: OK, the last line makes the job fail, and GitHub emails you about failed runs. No setup needed.
Option 2: a small Linux server
Any small VPS works. Create a user just for this, copy site_doctor.py, and keep the key in a file only that user can read:
sudo adduser --disabled-password sitedoctor
sudo -iu sitedoctor
mkdir site-doctor && cd site-doctor # copy site_doctor.py here
python3 -m venv .venv && .venv/bin/pip install anthropic
install -m 600 /dev/null key && nano key # paste the key, save
Then a tiny wrapper, check.sh, that stays silent when everything is fine:
#!/bin/sh
# Run the site doctor; print the report only if it found a problem (cron emails anything printed).
cd "$(dirname "$0")"
export ANTHROPIC_API_KEY="$(cat key)"
report="$(.venv/bin/python site_doctor.py "$1" 2>&1)"
echo "$report" | grep -q "STATUS: OK" || echo "$report"
Make it executable with chmod +x check.sh, test it with ./check.sh example.com, then schedule it with crontab -e:
CRON_TZ=Asia/Beirut
MAILTO=you@example.com
52 7 * * * $HOME/site-doctor/check.sh https://example.com
How it alerts you: cron emails whatever a job prints, and check.sh only prints when there’s a problem. That needs mail set up on the server. If you’d rather get a Slack or Telegram message, swap the last echo for a curl to a webhook.
Option 3: AWS Lambda (pay per run)
No server to patch, and one run a day fits inside Lambda’s free tier, so you only pay for the Claude usage. The key lives in Systems Manager Parameter Store as a SecureString called /site-doctor/anthropic-key, never in the code.
"""
Site doctor on AWS Lambda.
- Scheduled: EventBridge Scheduler sends {"site": "https://example.com"} every morning.
- On demand: call the Function URL with ?site=example.com&token=<your token>.
- Alert: if the report has a problem, it is emailed through SNS (topic in ALERT_TOPIC_ARN).
The API key is read from SSM Parameter Store (SecureString /site-doctor/anthropic-key), never stored in code.
"""
import json
import os
import boto3
_ssm = boto3.client("ssm")
os.environ["ANTHROPIC_API_KEY"] = _ssm.get_parameter(Name="/site-doctor/anthropic-key", WithDecryption=True)["Parameter"]["Value"]
import site_doctor # noqa: E402 (imported after the key is set)
def lambda_handler(event, context):
params = event.get("queryStringParameters") or {}
from_url = "requestContext" in event # called through the Function URL
if from_url and params.get("token") != os.environ["ACCESS_TOKEN"]:
return {"statusCode": 403, "body": "forbidden"}
site = params.get("site") or event.get("site")
if not site:
return {"statusCode": 400, "body": "which site? add ?site=example.com"}
if not site.startswith("http"):
site = "https://" + site
report = site_doctor.diagnose(site) # its [step] lines go to CloudWatch logs
if "STATUS: OK" not in report and os.environ.get("ALERT_TOPIC_ARN"):
boto3.client("sns").publish(TopicArn=os.environ["ALERT_TOPIC_ARN"],
Subject=f"Site doctor: problem on {site}"[:100], Message=report)
return {"statusCode": 200, "headers": {"Content-Type": "text/plain; charset=utf-8"}, "body": report}
The setup, in order:
- Package it:
pip install anthropic -t build --platform manylinux2014_x86_64 --only-binary=:all: --python-version 3.12, copy both .py files intobuild, and zip the folder’s contents. - Create a Python 3.12 function and upload the zip. Set the timeout to 5 minutes. The default 3 seconds is far too short for an agent.
- Give its role permission to read that parameter (and decrypt it) and to publish to an SNS topic.
- Create an SNS topic with an email subscription, confirm the email, and put the topic ARN in
ALERT_TOPIC_ARN. - For the daily run, create an EventBridge Scheduler schedule with cron
52 7 * * ? *, time zone Asia/Beirut, and input{"site": "https://example.com"}. - For on-demand runs, add a Function URL and set
ACCESS_TOKENto a long random string. Then from any phone browser:https://your-url/?site=example.com&token=.... It takes about a minute, then shows the report.
How it alerts you: when there’s a problem, SNS emails you the full report.
Which one?
GitHub Actions if you want free and zero maintenance. A server if you want full control, and if you’ll also want the bonus below. Lambda if you’re already on AWS and like the phone link.
What about running it in Claude’s cloud?
You can also ask Claude to run the site doctor on a schedule in a cloud session, so it works even from the Claude mobile app with your computer off. Two things to know. The cloud environment needs internet access to the sites you check: either full access or an allowlist with just the few sites you care about. And there you don’t need an API key at all, because Claude itself is the brain.
Bonus: call it from any Claude chat
This is my favourite. You turn the doctor’s tools into a custom connector (an MCP server), add it once in Claude’s settings, and then in any chat, on your laptop or phone, you just type “run the site doctor on example.com”.
The nice twist: the connector needs no API key. The Claude you’re chatting with is the brain. The connector only gives it the read-only tools: check page, certificate and DNS. Your server is the hands and eyes, nothing more.
The shape is short. You wrap each tool with the MCP library and serve it over HTTPS:
from mcp.server.mcpserver import MCPServer
import site_doctor
mcp = MCPServer("site-doctor", instructions="Website health checker. The tools only look; they change nothing.")
@mcp.tool()
def check_page(url: str) -> dict:
"""Open a URL and report status, final URL, load time and error text."""
return site_doctor.check_page(url)
# ...same for check_certificate and check_dns
Host it on option 2’s server behind HTTPS, then add its URL in Claude under Settings, then Connectors, then Add custom connector. Two safety habits we built in: a long, hard-to-guess URL path as a simple lock, and refusing private or internal addresses so nobody can use your connector to poke around inside a network. If you ever make it public, add a rate limit per visitor too.
Common problems
The Lambda times out: you forgot the 5-minute timeout. An agent takes a minute or more.
GitHub’s schedule runs late: scheduled workflows can start a few minutes after the set time on busy days. For a daily check that’s fine.
No email from cron: the server has no mail set up. Use a webhook instead, it’s simpler.
That’s it. Our doctor now checks the site every morning and stays quiet unless something is actually wrong, which is exactly what you want from anyone on duty.
If you’d like help putting an agent like this to work on your own systems, get in touch.