MCP-Grounded

MCP-Grounded

Multi-agent pipeline for medical image classification with verification-aware abstention, enabling safer predictions by skipping uncertain cases.

Category
Visit Server

README

MCP-Grounded 🩺

A multi-agent pipeline for medical image classification with verification-aware abstention, coordinated via the Model Context Protocol (MCP).

"Instead of always guessing, the AI says β€” I'm not confident enough, I'll skip this one."


What is this?

MCP-Grounded is a 4-agent AI pipeline that classifies skin lesion images from the HAM10000 dataset. What makes it novel: the final agent can abstain from answering when it isn't confident β€” making it safer for medical use.

All four agents are real MCP tools, not just described as such.


Pipeline

Skin lesion image
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  BiomedCLIP     β”‚  Agent 1: Extract 512-dim embedding
β”‚  (Extract)      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚
         β–Ό  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
            β”‚              MCP Server                  β”‚
            β”‚                                          β”‚
            β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚
            β”‚  β”‚ Retrieve │──────▢│  Rerank  β”‚        β”‚
            β”‚  β”‚ Agent 2  β”‚       β”‚  Agent 3 β”‚        β”‚
            β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜        β”‚
            β”‚                          β”‚               β”‚
            β”‚                 β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
            β”‚                 β”‚  Verify / Abstain  β”‚   β”‚
            β”‚                 β”‚     Agent 4        β”‚   β”‚
            β”‚                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
            └────────────────────────── β”‚ β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                        β”‚
                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                          β”‚                           β”‚
                    conf β‰₯ Ο„                     conf < Ο„
                          β”‚                           β”‚
                       PREDICT                    ABSTAIN

Results

Retrieval Quality

Metric Value
Recall@1 77.9%
Recall@5 93.5%
Recall@10 96.3%
Recall@50 99.2%

Verification-Aware Abstention (key result)

Threshold Ο„ Coverage Selective Accuracy
0.0 (answer all) 100.0% 67.0%
0.5 96.9% 69.0%
0.6 83.4% 77.0%
0.7 52.0% 91.3%
0.8 4.9% 98.6%

At Ο„ = 0.7, selective accuracy improves +24 percentage points over the no-abstention baseline.

Risk–Coverage Curve

Risk-Coverage Curve

As the confidence threshold rises, coverage drops but selective accuracy climbs sharply β€” proving abstention makes the system safer.

Calibration

Metric Value
ECE before temperature scaling 0.191
ECE after temperature scaling 0.185
Learned temperature T 0.944

Dataset

HAM10000 β€” 10,015 dermoscopic images across 7 skin lesion categories:

akiec Β· bcc Β· bkl Β· df Β· mel Β· nv Β· vasc

Split: 70% train / 15% validation / 15% test (stratified).


How to Run

Step 1 β€” Generate embeddings (Google Colab, GPU)

Open notebook1_embeddings.py in Google Colab with a T4 GPU runtime. Run all cells top to bottom. Downloads HAM10000 and produces embeddings.npz.

Step 2 β€” Run experiments (Google Colab)

Open notebook2_experiments.py in a new Colab notebook. Upload embeddings.npz. Run all cells. Produces:

  • All result tables (Recall@K, accuracy, calibration, abstention)
  • risk_coverage.png
  • clf_weights.npz

Step 3 β€” Run the MCP server (local)

pip install "mcp[cli]" numpy torch
python mcp_grounded_server.py

Starts a live MCP server with three callable tools: retrieve, rerank, classify_and_verify.


Requirements

mcp[cli]
numpy
torch
open_clip_torch
scikit-learn
pandas
pillow
tqdm
matplotlib

See requirements.txt.


File Structure

mcp_grounded/
β”œβ”€β”€ notebook1_embeddings.py     # Colab: download HAM10000, extract BiomedCLIP embeddings
β”œβ”€β”€ notebook2_experiments.py    # Colab: retrieval, calibration, abstention experiments
β”œβ”€β”€ mcp_grounded_server.py      # Local: FastMCP server exposing 4 agents as tools
β”œβ”€β”€ risk_coverage.png           # Figure 2: risk-coverage curve
β”œβ”€β”€ requirements.txt
└── README.md

Citation

If you use this work, please cite:

@inproceedings{mcpgrounded2025,
  title     = {MCP-Grounded: A Multi-Agent Pipeline with Verification-Aware Abstention for Medical Image Classification},
  author    = {[Your Name]},
  booktitle = {[Conference Name]},
  year      = {2025}
}

License

MIT License. Dataset (HAM10000) is CC-BY-NC-SA-4.0 β€” see Kaggle for terms.


Built with BiomedCLIP Β· FastMCP Β· HAM10000

Recommended Servers

playwright-mcp

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.

Official
Featured
TypeScript
Magic Component Platform (MCP)

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.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

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.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

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.

Official
Featured
TypeScript
Kagi MCP Server

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.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

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.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured