sidinurhalim.dev/projects/ops-bot
WIB
OB

Ops Bot

Sidi Nurhalim July 2026 6 tools

Telegram bot that lets on-call engineers triage incidents and review PRs with Claude.

A Claude-powered Telegram bot for incident triage, PR review, and infra ops. It blends local Bitbucket tools with five MCP servers (Grafana, AWS, SonarQube, Jenkins, Git) behind one unified tool registry, so Claude can check incidents, review or fix pull requests, and report back in chat, with AWS access enforced read-only and a small FastAPI admin panel to toggle tool groups per Telegram chat.

O
Ops Botbot
@procal_ops_bot checkout-service alert just escalated from warning to critical, what's going on?
🔍 p99 latency crossed the critical threshold: 340ms → 2.1s over the last 5 min. Checked Loki + Tempo: traced it to a slow DB query introduced by commit a3f21c9, which dropped an index.
Recommended fix: revert a3f21c9, or re-add the index on orders.customer_id. Want me to open a PR for either?
open a PR to re-add the index
✅ Opened PR #491: re-add index on orders.customer_id
Case study

This bot lives in a Telegram group topic and responds when mentioned or replied to, giving the cohort a conversational way to ask about incidents, review pull requests, and check on the procal infrastructure without leaving chat. It was built as a personal deep-dive alongside the DevOps Institute program, exploring how Claude and the Model Context Protocol (MCP) can support day-to-day operations work on top of the same procal stack described in the other case studies.

Architecture

Telegram Grouptopic thread, @mention or reply
bot.pyEC2, private subnet + NAT Gateway
claude_clientClaude API + tool loop
mcp_clientGrafana / AWS / SonarQube / Jenkins / Git
admin_panelFastAPI :8080, chat & tool config
pollingauto PR review, every 5 min, to Bitbucket

Claude receives one unified tool list built from local Bitbucket tools plus whatever the connected MCP servers expose; the bot doesn't need to know which is which.

Tech stack

Bot & App
PythonTelegramFastAPI
AI
Claude API
Integrations
BitbucketGrafanaSonarQubeJenkinsGit
Cloud
AWS S3AWS Secrets Manager

What it does

  1. 1

    Incident triage

    Mention the bot about a service error and it checks active Grafana incidents, queries Loki error logs and Prometheus metrics, checks slow Tempo traces, and cross-references recent commits, then returns what happened, probable cause, and a recommended fix.

  2. 2

    PR review, on request

    Ask it to review, approve, request changes on, or comment on a Bitbucket PR, and it acts directly through the Bitbucket API.

  3. 3

    Auto PR review (polling)

    A background loop watches the infra repo's PRs every 5 minutes, runs a Terraform-focused review on any new PR or commit, posts it as a Bitbucket comment, and notifies the Telegram group, tracking which PRs/commits it already reviewed so it never double-reviews on restart.

  4. 4

    Code fixes without cloning

    For simple fixes, it creates a branch off the PR's source branch, commits the fix via the Bitbucket source API, and opens a PR back to the author, with no local clone involved.

  5. 5

    Audit trail

    Every write action (approvals, comments, branch commits, new PRs) is logged and sent as a Telegram notification to a configured audit chat.

Highlights

  • A unified tool registry blends local Python tools (Bitbucket) with five separate MCP servers (Grafana, AWS, SonarQube, Jenkins, Git), some over stdio and one over HTTP, behind a single interface Claude calls into.
  • AWS access is read-only by design, enforced twice: a `READ_OPERATIONS_ONLY` flag on the MCP server itself, plus a read-only IAM policy on the instance role, belt and suspenders on a bot that can act autonomously.
  • A small FastAPI admin panel lets you toggle which tool groups (AWS, Bitbucket, Grafana, SonarQube, Jenkins, per-repo Git) are enabled per Telegram chat, without redeploying the bot.
  • Credentials flow through the EC2 instance role via IMDS rather than static keys in `.env`, matching the same 'no long-lived credentials on disk' pattern used elsewhere in the program's infra work.
  • PR-review polling state is persisted to disk, so a bot restart mid-cycle doesn't cause it to re-review PRs it already commented on.
Terminalzsh
sidi@portfolio:projects$
main✓ aws saa-c03 / aif-c01utf-8