Defect Vision MCP Agent
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Defect Vision MCP Agentclassify the steel surface defect in data/processed/val/patches/patches_2.jpg"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Defect Vision MCP Agent
Real-time steel surface defect classification system combining a fine-tuned PyTorch computer vision model, a genuine MCP (Model Context Protocol) server, and a LangGraph multi-agent monitoring layer with human-in-the-loop guardrails.
Live Demo: https://defect-vision-mcp-agent-j3eq5p8huviz4hbz495imi.streamlit.app/
Built to close three specific gaps: hands-on PyTorch model training, real MCP protocol integration, and MLOps-style model monitoring — all wired together as one coherent system rather than three disconnected pieces.
Results
Fine-tuned a ResNet18-based classifier (transfer learning, frozen backbone, trained classification head) on the NEU-DET surface defect dataset — 6 classes, 1,800 images (1,440 train / 360 validation, balanced).
Metric | Score |
Validation Accuracy | 98.89% |
Weighted Precision | 0.9892 |
Weighted Recall | 0.9889 |
Weighted F1 | 0.9888 |
Per-class performance:
Class | Precision | Recall | F1 |
crazing | 0.98 | 1.00 | 0.99 |
inclusion | 1.00 | 0.95 | 0.97 |
patches | 1.00 | 0.98 | 0.99 |
pitted_surface | 0.97 | 1.00 | 0.98 |
rolled-in_scale | 1.00 | 1.00 | 1.00 |
scratches | 0.98 | 1.00 | 0.99 |
Related MCP server: Industrial MCP Agent Platform
Architecture
PyTorch Model (
model/) — ResNet18-based transfer-learning classifier. Backbone frozen; only the classification head is fine-tuned, converging in 6 epochs on CPU.MCP Server (
mcp_server/) — a real, protocol-compliant MCP server (built onMCPServerfrom the officialmcpSDK, verified against the MCP Inspector) exposing two tools:classify_image(image_path)— runs inference, logs the predictionget_model_metrics()— returns aggregate stats from the prediction log
Multi-Agent Layer (
agents/) — LangGraph-orchestrated pipeline with three nodes in sequence:Inference agent — calls the MCP tool to classify an image
Guardrail agent — auto-accepts high-confidence predictions; low-confidence predictions are flagged for human review instead of being silently accepted, mirroring a human-in-the-loop pattern rather than blind automation
Drift-monitor agent — tracks the rolling ratio of low-confidence predictions and flags
DRIFT_DETECTEDif it crosses a threshold, signaling the model may need review or retraining
Dashboard (
dashboard/) — Streamlit UI showing live prediction counts, average confidence, low-confidence count, a full prediction log, and a confidence-over-time chart.
Setup
pip install -r requirements.txt
cp .env.example .env # fill in your own GROQ_API_KEYTrain the model
Requires the NEU-DET dataset arranged as:
data/processed/
├── train/<class_name>/*.jpg
└── val/<class_name>/*.jpgpython model/train.py
python model/evaluate.pyRun the MCP server
python mcp_server/server.pyTest it interactively with the MCP Inspector:
npx @modelcontextprotocol/inspector python mcp_server/server.pyRun the agent pipeline
python agents/graph.pyRun the dashboard
streamlit run dashboard/app.pyRun tests
pytest tests/ -vTech Stack
Python · PyTorch · torchvision · MCP SDK · LangGraph · LangChain · Streamlit · scikit-learn · GitHub Actions (CI)
Notes
data/processed/,model/checkpoints/*.pt, and the live prediction log (logs/predictions.jsonl) are gitignored — not included in this repo.logs/predictions_sample.jsonlis committed separately so the deployed dashboard has sample data to display.Deployed on Streamlit Community Cloud (free tier) — expect a brief cold start if the app has been idle.
This server cannot be deployed
Maintenance
Related MCP Connectors
MCP server for building and testing AI agents with multi-model experimentation and insights.
Build and manage AI-native customer support agents from Claude or any MCP client.
Sentiment, toxicity, entity extraction, PII, translation, summary, QA, fraud scoring, safety audit.
Human-in-the-loop for AI agents over MCP: durable approvals with a hosted review page & audit trail
Related MCP Servers
AlicenseNot gradedqualityDmaintenanceAn MCP server that enables automated dataset creation and custom object detection model training through natural language interactions. It integrates foundation models like GroundedSAM for auto-labeling and supports training specialized YOLOv8 models using local or Unsplash images.4MIT- AlicenseNot gradedqualityDmaintenanceMCP server for integrating manufacturing systems (MES/ERP/quality/maintenance) with LLM agents, enabling event ingestion, incident triage, approval workflows, and RAG-based knowledge retrieval.MIT
- AlicenseNot gradedqualityBmaintenanceEnables natural language interaction with complex computer vision workflows such as auto-labeling, class mapping, and embedding selection through an LLM-agnostic MCP orchestration layer.2MIT
- AlicenseAqualityBmaintenanceVision MCP enables text-only agents to understand images through any OpenAI-compatible vision model. It supports local images, URLs, screenshots, documents, charts, and code errors with tools like analyze_image and understand_image.2MIT