LabOps Agent MCP Server
MCP server that enables clinical lab staff to predict reagent stockouts, check inventory, create orders, and update inventory canvases directly from Slack.
README
LabOps Agent π¬
Slack Agent for Good β Slack Agent Builder Challenge 2026 (Salesforce/Devpost)
Predict. Alert. Act. All from Slack.
LabOps Agent is a Slack-native AI agent that predicts reagent stockouts in clinical laboratories before they happen, based on historical demand patterns by test type β and enables lab staff to act directly from Slack without switching to external LIMS systems.
The Problem
Clinical laboratories run on reagents. When a critical reagent runs out mid-operation, testing stops. Current solutions (Quartzy, Scispot) only send passive threshold alerts after stock is already low. No product today predicts stockouts based on test-type demand patterns.
Example: TSH demand spikes every winter in Argentina (JunβAug). A lab with 680 units, at a projected winter demand of ~185 units/day, runs out in ~4 days β inside the 7-day reorder window. Without prediction, they find out when the analyzer throws an error.
What LabOps Agent Does
- Predicts stockouts using Prophet, calibrated with patterns derived from anonymized demand analysis in Argentine clinical labs
- Alerts lab staff in
#labops-alertswith interactive Block Kit messages β before the stockout happens - Acts β staff orders reagents, assigns tasks, and updates inventory without leaving Slack
Why LabOps Agent is Different
No existing product (Quartzy, Scispot, Benchling) combines:
- Prediction by test type β TSH spikes in winter, Hemograma is stable; each reagent gets its own Prophet model
- Native Slack agent β not a webhook or Zapier bridge; Bolt Python with Socket Mode, interactive Block Kit buttons, and modals
- Domain expertise β built by someone with 4 years of B2B KAM experience in clinical diagnostics (Argentina), not a generic inventory template
Technologies Used
| Technology | How It's Used | Platform |
|---|---|---|
| MCP Server | Exposes 4 lab tools: get_inventory, get_forecast, create_order, update_canvas |
Anthropic/Slack |
| Claude Tool-Use Agent | LLM selects and invokes MCP tools via agent_router.py on every @mention |
Anthropic |
| Slack Channel History API | Queries #labops-alerts message history for past reagent incidents (works with the bot token) | Slack |
| Claude API Summarization | Generates natural language summaries of reagent alert history | Anthropic |
Optional add-on (not part of the headline tech): the Slack Search API (
search.messages) surfaces cross-channel mentions, but it requires a workspace user token (xoxp-) β the bot token returns empty results. It is wired up and degrades gracefully when absent; setSLACK_USER_TOKENto enable it.
MCP Server
LabOps Agent exposes a real MCP Server using the official Anthropic MCP Python SDK:
# Run MCP Server (stdio transport)
cd backend
python mcp_server.py
Tools available:
get_inventoryβ Query current reagent stockget_forecastβ Prophet demand forecastcreate_orderβ Create reagent orderupdate_canvasβ Update inventory Canvas
Architecture
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β SLACK WORKSPACE β
β #labops-alerts β Canvas Inventario β App Home β
ββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββ
β Bolt Python (Socket Mode)
ββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββ
β FASTAPI BACKEND β
β βββββββββββββββββββ ββββββββββββββββββββββββββββ β
β β MCP SERVER β β PREDICTION ENGINE β β
β β get_inventory β β Prophet + seasonality β β
β β get_forecast β β calibrated: synthetic β β
β β create_order β β rolling-CV MAPE 8-11% β β
β β update_canvas β ββββββββββββββββββββββββββββ β
β βββββββββββββββββββ β
βββββββββββββββββββββββββββββββββββ¬ββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββΌββββββββββββββββββββ
β SUPABASE β
β inventory β demand_history β orders β alerts_log β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β
βββββββββββββββββββββββββββββββββββΌββββββββββββββββββββ
β CLAUDE API β
β Natural language explanations of predictions β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Demo Flow (3 minutes)
0:00β0:45 β Agent detects TSH will run out in ~4 days (demand forecast exceeds stock)
0:45β1:30 β Alert fires in #labops-alerts with Block Kit buttons:
- π Ver proyecciΓ³n
- π Ordenar reactivo
- π€ Asignar al equipo
1:30β2:15 β User clicks "Ordenar reactivo" β modal opens β one click confirms β Canvas auto-updates
2:15β3:00 β Agent explains WHY TSH is at risk (seasonal demand pattern) β Claude API summarizes past incidents
Try it Live
Demo video (β€3 min): <add YouTube/Vimeo link here once recorded> β this is the canonical proof that the agent runs live in a real Slack sandbox. Sandbox workspace:
https://labopsespacio.slack.com(invite-only sandbox).
Reproduce the live deploy (judge-reachable, chart renders)
Slack fetches forecast-chart images from its own servers, so the backend must be reachable over public HTTPS. Socket Mode also needs a persistent host, so this deploys to Render/Railway/Fly β not Vercel serverless (see Deployment).
- Join the Slack Developer Program and create a Developer Sandbox workspace.
- Create a new app from
slack-manifest.json, install it, and copy the Bot + App tokens. - Deploy with the included
render.yamlblueprint (one persistent web service hosts both the chart endpoint and the Socket Mode websocket). - After the first deploy, set
BACKEND_URL=https://<your-service>.onrender.comand redeploy so the forecast chart renders in Slack.
Local + tunnel (for recording the demo on your machine):
docker-compose up --build # backend + slack client + DB
cloudflared tunnel --url http://localhost:8000 # public HTTPS for the chart
# set BACKEND_URL=https://<random>.trycloudflare.com in .env, restart slack_client
Without a public BACKEND_URL, the forecast still shows as native Block Kit
fields β the chart image is simply omitted, never broken.
Setup Instructions
Prerequisites
- Python 3.11+
- Supabase account
- Slack Developer Sandbox (via Slack Developer Program)
- Anthropic API key
1. Clone and install
git clone https://github.com/Marianooss/labops-agent
cd labops-agent
pip install -r requirements.txt
2. Configure environment
cp .env.example .env
# Fill in your keys:
# SUPABASE_URL, SUPABASE_KEY
# SLACK_BOT_TOKEN, SLACK_APP_TOKEN, SLACK_SIGNING_SECRET
# SLACK_USER_TOKEN (optional β required for search.messages)
# ANTHROPIC_API_KEY
# LABOPS_ALERTS_CHANNEL=#labops-alerts
3. Set up Supabase
# Run in Supabase SQL Editor:
# 1. data/create_tables.sql
# 2. data/seed_data.sql
4. Create Slack App (from manifest)
- Go to api.slack.com/apps β Create New App
- Select From an app manifest
- Choose your Developer Sandbox workspace
- Paste the contents of
slack-manifest.json - Click Create
- Go to OAuth & Permissions β Install to Workspace
- Copy the Bot User OAuth Token and App-Level Token into your
.env
Manifest includes all required scopes: chat:write, channels:read, channels:history, groups:read, groups:history, im:write, users:read, app_mentions:read, canvases:read, canvases:write, search:read.
5. One-Click Docker Setup (recommended for judges)
# Clone and start everything (PostgreSQL + backend + slack client + auto-seed)
git clone https://github.com/Marianooss/labops-agent
cd labops-agent
docker-compose up --build
# Wait ~30s for DB init, then test:
curl "http://localhost:8000/alert/trigger?reagent_name=TSH"
This runs the full stack locally without needing a cloud Supabase account:
dbβ PostgreSQL with auto-created schema and seed databackendβ FastAPI on http://localhost:8000slack_clientβ Bolt Python Socket Mode (waits gracefully if Slack tokens are missing)
To enable Slack integration, copy
.env.exampleto.envand fill inSLACK_BOT_TOKEN,SLACK_APP_TOKEN, andSLACK_SIGNING_SECRETbefore runningdocker-compose up.
6. Local Setup without Docker (one-script)
# Single command β starts backend + Slack client + seeds DB
python scripts/start_local.py
Or manually in separate terminals:
# Terminal 1: FastAPI backend
cd backend && uvicorn main:app --reload --port 8000
# Terminal 2: Slack agent
cd backend && python slack_client.py
Note: Backend commands must be run from the
backend/directory because modules use relative imports.
Deployment (Render / Railway / Fly)
Why not Vercel? The agent uses Slack Socket Mode, which holds a persistent
websocket. Vercel serverless functions are short-lived and cannot keep that
connection open. (If you must use Vercel, you would have to switch to HTTP Events
mode and expose /slack/events β a different integration path this repo does not
use.) Instead, deploy to a persistent host.
The included render.yaml provisions one web service that hosts
both:
- the FastAPI HTTP app (serves the public
/chart/forecast/{reagent}PNG that Slack image blocks fetch β needs public HTTPS), and - the Socket Mode websocket, started in a background thread via
RUN_SOCKET_MODE=1(seebackend/main.pystartup).
Render β New β Blueprint β select this repo β fill the secret env vars
β after first deploy, set BACKEND_URL=https://<service>.onrender.com β redeploy
Railway and Fly.io work identically with the same Dockerfile
(it honors the host-injected $PORT).
Project Structure
labops-agent/
βββ backend/
β βββ main.py # FastAPI entry point
β βββ mcp_server.py # MCP tools (4 lab tools)
β βββ prediction.py # Prophet demand forecasting
β βββ slack_client.py # Bolt Python + event handlers
β βββ database.py # Dual backend: Supabase or PostgreSQL
β βββ claude_client.py # Claude API wrapper
β βββ blocks_loader.py # Block Kit / Canvas template loader
βββ blocks/
β βββ alert.json # Stockout alert Block Kit template
β βββ modal_order.json # Order reagent modal template
β βββ canvas.json # Inventory canvas template
βββ data/
β βββ create_tables.sql # Database schema
β βββ seed_data.sql # Demo data (DEMO badge)
βββ docs/
β βββ architecture.md # Technical architecture
β βββ impact.md # Impact metrics
β βββ demo_script.md # 3-minute demo script
βββ scripts/
β βββ init_db.py # Auto-seed PostgreSQL on Docker startup
β βββ start_local.py # One-script local startup (backend + slack + seed)
β βββ holdout_backtest.py # Monthly hold-out backtest (illustrative)
β βββ cross_validation.py # Rolling-origin CV (headline accuracy metric)
βββ notebooks/
β βββ cv_metrics.json # Rolling-origin CV results (real, reproducible)
β βββ holdout_metrics.json # Monthly hold-out results (caveated)
β βββ prophet_metrics.json # Consolidated metrics summary
βββ tests/
β βββ test_mcp.py # MCP tool unit tests
β βββ test_prediction.py # Prophet engine tests
β βββ test_integration.py # Bolt handler integration tests
βββ models/ # Prophet serialized models (.pkl)
βββ render.yaml # Render Blueprint (persistent host + Socket Mode)
βββ docker-compose.yml # One-click local stack
βββ Dockerfile # Backend container
βββ Makefile # make demo / make local / make test
βββ AGENTS.md # Development operating system
βββ BIBLE.md # Immutable declarations
βββ CLAUDE.md # Claude Code instructions
UiPath Components Used
None β this project uses Slack platform APIs (Channel History API, Canvas API) for messaging and surfaces, Anthropic MCP Server for tool exposure, and Claude API for natural language generation.
Demo Screenshots
Record the β€3-minute demo in your live Slack sandbox and replace these placeholders:
| Timestamp | Screenshot | What to capture |
|---|---|---|
| 0:00-0:45 | docs/demo/01_alert.png |
TSH alert in #labops-alerts with π΄ CRITICAL badge + 3 buttons |
| 0:45-1:30 | docs/demo/02_forecast.png |
Thread reply: 7-day Prophet forecast table + channel history |
| 1:30-2:15 | docs/demo/03_order.png |
Modal "Ordenar reactivo" β confirmation β Canvas update |
| 2:15-3:00 | docs/demo/04_agent.png |
@mention interaction showing agent tool-use (e.g. @LabOps Agent cuΓ‘nto stock hay de TSH?) |
π‘ Tip: Use Slack's built-in screen recording (Cmd+Shift+5 on macOS, Win+Alt+R on Windows) or Loom for the GIF.
Data & Privacy
All data in this project is synthetic and clearly labeled with DEMO badges. No real patient data, no PHI. The prediction model was calibrated with patterns derived from anonymized demand analysis of Argentine clinical laboratories.
License
MIT License β see LICENSE
Builder
Mariano Adrian Oss Β· DevelopOss Β· Buenos Aires, Argentina
B2B KAM in clinical diagnostics (4 years) + AI Builder. This project applies real insider knowledge of clinical laboratory operations to a problem that existing software hasn't solved: uninterrupted diagnostic access for vulnerable patients inside the tools labs already use daily.
LabOps Agent Β· Slack Agent Builder Challenge 2026 Β· Track: Slack Agent for Good
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.