<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/"
    xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
    <channel>
        
        <title>
            <![CDATA[ Claude Desktop - freeCodeCamp.org ]]>
        </title>
        <description>
            <![CDATA[ Browse thousands of programming tutorials written by experts. Learn Web Development, Data Science, DevOps, Security, and get developer career advice. ]]>
        </description>
        <link>https://www.freecodecamp.org/news/</link>
        <image>
            <url>https://cdn.freecodecamp.org/universal/favicons/favicon.png</url>
            <title>
                <![CDATA[ Claude Desktop - freeCodeCamp.org ]]>
            </title>
            <link>https://www.freecodecamp.org/news/</link>
        </image>
        <generator>Eleventy</generator>
        <lastBuildDate>Tue, 25 Aug 2026 22:03:41 +0000</lastBuildDate>
        <atom:link href="https://www.freecodecamp.org/news/tag/claude-desktop/rss.xml" rel="self" type="application/rss+xml" />
        <ttl>60</ttl>
        
            <item>
                <title>
                    <![CDATA[ How to Build a Privacy-First Medical Image De-Identification Agent with Claude and MCP ]]>
                </title>
                <description>
                    <![CDATA[ Imagine asking an AI assistant to de-identify thousands of medical images. It runs the pipeline, tracks progress, summarizes every decision, and tells you which files need human review, all without ev ]]>
                </description>
                <link>https://www.freecodecamp.org/news/build-a-privacy-first-medical-image-de-identification-agent/</link>
                <guid isPermaLink="false">6a7450ad88b91c86871fa9de</guid>
                
                    <category>
                        <![CDATA[ Healthcare AI ]]>
                    </category>
                
                    <category>
                        <![CDATA[ ai agents ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Claude Desktop ]]>
                    </category>
                
                    <category>
                        <![CDATA[ mcp ]]>
                    </category>
                
                    <category>
                        <![CDATA[ Medical Imaging ]]>
                    </category>
                
                <dc:creator>
                    <![CDATA[ Lakshmi Mahabaleshwara ]]>
                </dc:creator>
                <pubDate>Thu, 06 Aug 2026 09:15:25 +0000</pubDate>
                <media:content url="https://cdn.hashnode.com/uploads/covers/5fc16e412cae9c5b190b6cdd/93b0e883-87c6-4e07-97ca-4024da3e45e3.png" medium="image" />
                <content:encoded>
                    <![CDATA[ <p>Imagine asking an AI assistant to de-identify thousands of medical images. It runs the pipeline, tracks progress, summarizes every decision, and tells you which files need human review, all without ever seeing a single pixel of patient data.</p>
<p>That sounds impossible at first. AI assistants typically need access to the data they are helping you process.</p>
<p>In this tutorial, you'll build an AI agent that doesn’t inspect sensitive medical images. Instead, it orchestrates a local de-identification pipeline through carefully designed tools, keeping the patient data entirely on your machine.</p>
<p>The technology that makes this possible is the Model Context Protocol (MCP), an open standard that lets AI models call external tools instead of relying only on their built-in capabilities.</p>
<p>In my previous article, <a href="https://www.freecodecamp.org/news/build-ai-image-de-identification-for-clinical-research/">How to Build an AI-Powered Medical Image De-Identification Pipeline for Clinical Research</a>, we already saw how to build the de-identification tool - <em><strong>Aegis</strong></em>, an open-source tool built using a MONAI (PyTorch) pipeline that removes PHI from both DICOM metadata and image pixels using OCR and NER.</p>
<p>I have since extended it with local MCP (Model Context Protocol) server support, and in this article we'll build that server from scratch with FastMCP. Then we'll connect it to Claude Desktop, turning Claude into an AI agent that can run, monitor, and audit de-identification jobs through natural conversation.</p>
<p>One note before we start: while Aegis is the example throughout, the pattern in this tutorial applies to any Python tool you want to give an AI agent access to. If you have your own pipeline, CLI, or library, you can follow along and wrap that instead.</p>
<h2 id="heading-table-of-contents">Table of Contents</h2>
<ul>
<li><p><a href="#heading-what-youll-build">What You'll Build</a></p>
</li>
<li><p><a href="#heading-prerequisites">Prerequisites</a></p>
</li>
<li><p><a href="#heading-what-aegis-does">What Aegis Does</a></p>
</li>
<li><p><a href="#heading-how-to-set-up-aegis">How to Set Up Aegis</a></p>
</li>
<li><p><a href="#heading-what-is-mcp-and-why-use-it">What Is MCP, and Why Use It?</a></p>
</li>
<li><p><a href="#heading-how-the-architecture-works">How the Architecture Works</a></p>
</li>
<li><p><a href="#heading-step-1-design-the-tool-surface">Step 1: Design the Tool Surface</a></p>
</li>
<li><p><a href="#heading-step-2-build-the-mcp-server-with-fastmcp">Step 2: Build the MCP Server with FastMCP</a></p>
</li>
<li><p><a href="#heading-step-3-test-with-mcp-inspector-before-any-ai-is-involved">Step 3: Test with MCP Inspector — Before Any AI Is Involved</a></p>
</li>
<li><p><a href="#heading-step-4-connect-claude-desktop">Step 4: Connect Claude Desktop</a></p>
</li>
<li><p><a href="#heading-step-5-talk-to-your-agent">Step 5: Talk to Your Agent</a></p>
</li>
<li><p><a href="#heading-verification">Verification</a></p>
</li>
<li><p><a href="#heading-does-the-ai-ever-see-patient-data">Does the AI Ever See Patient Data?</a></p>
</li>
<li><p><a href="#heading-security-considerations">Security Considerations</a></p>
</li>
<li><p><a href="#heading-a-note-on-the-word-de-identification">A Note on the Word "De-identification"</a></p>
</li>
<li><p><a href="#heading-where-this-fits-and-whats-next">Where This Fits, and What's Next</a></p>
</li>
<li><p><a href="#heading-conclusion">Conclusion</a></p>
</li>
<li><p><a href="#heading-references">References</a></p>
</li>
</ul>
<h2 id="heading-what-youll-build">What You'll Build</h2>
<p>By the end of this tutorial, you'll have:</p>
<ul>
<li><p>A local MCP server that exposes the Aegis de-identification pipeline as six tools.</p>
</li>
<li><p>Claude Desktop connected to that server, with human-in-the-loop approval for each action.</p>
</li>
<li><p>An agent you can talk to in plain English: <em>"De-identify this folder and tell me if anything needs manual review."</em></p>
</li>
<li><p>A verifiable audit trail on disk that you can check against everything the agent reports.</p>
</li>
</ul>
<h2 id="heading-prerequisites">Prerequisites</h2>
<p>To follow this tutorial, you should have:</p>
<ul>
<li><p>Intermediate Python experience</p>
</li>
<li><p>The Aegis repository (or your own Python tool to wrap): <a href="https://github.com/lakshmi-mahabaleshwara/aegis">https://github.com/lakshmi-mahabaleshwara/aegis</a></p>
</li>
<li><p>Python 3.10 or later</p>
</li>
<li><p>Claude Desktop installed (macOS or Windows); a free Claude account works for local MCP servers</p>
</li>
<li><p>Node.js (only used for a testing tool, not for the server itself)</p>
</li>
</ul>
<p>We'll use:</p>
<ul>
<li><p>The MCP Python SDK (<code>mcp</code>)</p>
</li>
<li><p>FastMCP (included in the SDK)</p>
</li>
<li><p>MCP Inspector for testing</p>
</li>
<li><p>Claude Desktop as the MCP host</p>
</li>
</ul>
<p>If you haven't read the previous article, you don't need to rebuild the pipeline from scratch. Cloning the Aegis repository is enough, but the earlier article explains what the pipeline is actually doing under the hood.</p>
<h2 id="heading-what-aegis-does">What Aegis Does</h2>
<p>Aegis is a medical image de-identification pipeline that removes PHI from DICOM metadata and image pixels, records every action in audit reports, and routes uncertain cases for manual review.</p>
<h2 id="heading-how-to-set-up-aegis">How to Set Up Aegis</h2>
<p>Before we build the server, get Aegis installed. The server we write in the next step imports this package, so this has to be in place first.</p>
<pre><code class="language-python"># Get the code
git clone https://github.com/lakshmi-mahabaleshwara/aegis.git
cd aegis

# Create and activate a virtual environment
python3 -m venv venv
source venv/bin/activate
# On Windows: venv\Scripts\activate

# Install Aegis (editable) plus the MCP server in one step.
# The [mcp] pulls in the MCP SDK; it also installs the
# `aegis-mcp` console command you'll point Claude Desktop at.
pip install -e ".[mcp]"

# One-time: download the OCR and NER model weights
python scripts/prefetch_models.py
</code></pre>
<p>The editable install (<code>pip install -e</code>) makes the <code>monai_aegis</code> package importable from any directory and puts the <code>aegis-mcp</code> console command on your PATH (inside the venv). The MCP server depends on this, because Claude Desktop launches it from its own working directory, not from the repository root.</p>
<p>With the package installed, we can start building the server that exposes it.</p>
<h2 id="heading-what-is-mcp-and-why-use-it">What Is MCP, and Why Use It?</h2>
<p>The Model Context Protocol (MCP) is an open standard that lets AI applications call external tools. Instead of trying to solve everything from the information already in its context, an AI model can invoke functions exposed by an external program.</p>
<p>Three roles are involved:</p>
<ul>
<li><p>Host – the AI application (Claude Desktop in our case)</p>
</li>
<li><p>Server – a small program you write that exposes tools</p>
</li>
<li><p>Tools – Python functions with names, parameters, and descriptions that the AI can call</p>
</li>
</ul>
<p>When Claude Desktop starts, it launches your MCP server and discovers the tools it exposes. It sees only each tool’s name, parameter schema, and docstring, not your implementation code. In practice, <strong>your docstrings become the prompt</strong> that helps Claude decide when to call a tool.</p>
<p><em><strong>Why use MCP at all?</strong></em> If you’re comfortable with Python, you could call the Aegis library directly from your own scripts. MCP becomes valuable when you want an AI assistant to operate that pipeline through natural conversation. Instead of writing scripts or remembering command-line options, you can simply ask:</p>
<ul>
<li><p>“De-identify this folder.”</p>
</li>
<li><p>“Is the batch finished?”</p>
</li>
<li><p>“Which files need manual review?”</p>
</li>
<li><p>“Summarize today’s run.”</p>
</li>
</ul>
<p>The underlying pipeline never changes. MCP simply provides a safe interface between the AI and your software, allowing the model to orchestrate the workflow while the actual processing remains in your local Python application.</p>
<p>We’ll use Claude Desktop as the host because it supports MCP natively. There are no bridges, extra services, or network ports to configure the server communicates with Claude Desktop over standard input/output as a local subprocess, and the entire setup is configured through a single JSON file.</p>
<h2 id="heading-how-the-architecture-works">How the Architecture Works</h2>
<img src="https://cdn.hashnode.com/uploads/covers/69fd77e89f93a850a46d376f/1dfe474b-d9a0-4256-9dd7-302beecef935.png" alt="Architecture diagram showing Claude Desktop communicating with a local MCP server, which invokes the Aegis de-identification pipeline. Medical images are processed locally, and only summary results such as counts, decisions, and file paths are returned to the AI model." style="display:block;margin:0 auto" width="2720" height="1880" loading="lazy">

<p>Claude Desktop communicates with the MCP server, which invokes the Aegis pipeline locally. The pipeline processes the medical images on your machine, while only summaries such as counts, decisions, and file paths are returned to Claude.</p>
<h2 id="heading-step-1-design-the-tool-surface">Step 1: Design the Tool Surface</h2>
<p>Before writing code, decide what the agent can do. Our server exposes six tools:</p>
<table>
<thead>
<tr>
<th>Tool</th>
<th>Purpose</th>
</tr>
</thead>
<tbody><tr>
<td><code>warm_up</code></td>
<td>Preload the OCR and NER models in Aegis so the first real call is fast</td>
</tr>
<tr>
<td><code>deidentify_file</code></td>
<td>De-identify a single DICOM/JPEG/PNG file using Aegis pipeline</td>
</tr>
<tr>
<td><code>start_batch_job</code></td>
<td>Discover and process all DICOM/image files in a directory, in the background</td>
</tr>
<tr>
<td><code>get_job_status</code></td>
<td>Check the progress of a batch job initiated previously</td>
</tr>
<tr>
<td><code>summarize_run</code></td>
<td>Audit a completed run from its report files</td>
</tr>
<tr>
<td><code>list_review_queue</code></td>
<td>List files routed to manual human review</td>
</tr>
</tbody></table>
<p><strong>We designed these tools around three simple principles:</strong></p>
<ul>
<li><p>Return summaries instead of sensitive data.</p>
</li>
<li><p>Use background jobs for long-running tasks.</p>
</li>
<li><p>Keep the tool surface small and focused.</p>
</li>
</ul>
<h2 id="heading-step-2-build-the-mcp-server-with-fastmcp">Step 2: Build the MCP Server with FastMCP</h2>
<p>Now let’s turn that design into a working MCP server. We will build it one piece at a time so you can reuse the same pattern for your own Python tools. The complete implementation lives in <code>src/monai_aegis/mcp_server.py</code>; the sections below show how it comes together.</p>
<h3 id="heading-1-the-server-instance">1. The Server Instance</h3>
<p>FastMCP (bundled with the MCP Python SDK) turns a decorated Python function into a tool.</p>
<pre><code class="language-python">from mcp.server.fastmcp import FastMCP

# creates a FastMCP server instance
mcp = FastMCP("aegis-mcp")
</code></pre>
<p>The string <code>"aegis-mcp"</code> is just the server's name. It's what Claude Desktop shows in its tool list. Every tool we add from here is a function decorated with <code>@mcp.tool()</code>.</p>
<h3 id="heading-2-your-first-tool">2. Your First Tool</h3>
<p>A tool is a decorator, a typed signature, and a docstring. Here's the one that does the real work, de-identifying a single file:</p>
<pre><code class="language-python">@mcp.tool()
def deidentify_file(input_path: str, output_dir: str = "") -&gt; dict:
    """De-identify a single medical image (DICOM, JPEG, or PNG).

    Scrubs DICOM header PHI and redacts burned-in pixel PHI using
    OCR and NER. Returns summary statistics and the output location
    only, never the redacted text or any pixel data.
    """
    ...
    return {
        "status": "success",
        "source_file": src.name,
        "output_dir": str(out),
        "pixel_regions_detected": len(pixel_rows),
        "pixel_decisions": decisions,   # e.g. {"redacted": 4, "safelisted": 10}
        "header_tags_scrubbed": tags_scrubbed,
        "needs_manual_review": decisions.get("low_confidence", 0) &gt; 0,
    }
</code></pre>
<p>Notice that Claude only sees the docstring, while the tool returns summary statistics rather than image data or extracted text.</p>
<h3 id="heading-3-never-print-to-stdout">3. Never Print to <code>stdout</code></h3>
<p>Do not use <code>print()</code> in an MCP server because <code>stdout</code> is reserved for JSON-RPC. Send logs to <code>stderr</code> instead.</p>
<h3 id="heading-4-long-jobs-need-the-async-pattern">4. Long Jobs Need the Async Pattern</h3>
<p>Processing an entire directory can take several minutes, which is longer than an MCP tool call should block. Instead of waiting synchronously, <code>start_batch_job</code> creates a background thread, immediately returns a <code>job_id</code>, and lets Claude poll the progress using <code>get_job_status()</code>.</p>
<pre><code class="language-python">import threading, uuid

_jobs = {}

@mcp.tool()
def start_batch_job(input_dir: str, output_dir: str = "", mode: str = "auto") -&gt; dict:
    """Start a background job that de-identifies all DICOM/image files
    in a directory. Returns immediately with a job_id. Use get_job_status
    to check progress, do not wait synchronously.
    """
    job_id = uuid.uuid4().hex[:8]
    _jobs[job_id] = {"job_id": job_id, "state": "queued",
                     "processed": 0, "total": None,
                     "decisions": {}, "errors": []}
    threading.Thread(
        target=_batch_worker, args=(job_id, input_dir, output_dir),
        daemon=True,
    ).start()
    return {"status": "started", "job_id": job_id,
            "next_step": f"Call get_job_status with job_id '{job_id}'."}
</code></pre>
<p>The worker thread updates <code>_jobs[job_id]</code> as it processes each file, and the polling tool just reads it back:</p>
<pre><code class="language-python">@mcp.tool()
def get_job_status(job_id: str) -&gt; dict:
    """Return the current state, progress, and decision counts for a job."""
    return _jobs.get(job_id, {"status": "unknown", "job_id": job_id})
</code></pre>
<p>Since the MCP server is a long-running process, it can keep the job registry in memory throughout the conversation. If the server restarts, active job IDs are lost, but the de-identified files and audit reports remain safely on disk.</p>
<h3 id="heading-5-heavy-models-need-a-warm-up"><strong>5. Heavy Models Need a Warm-Up</strong></h3>
<p>Aegis loads EasyOCR and a Stanford NER model, which takes time. The server builds the pipeline lazily and caches it, so it pays that cost once, and exposes a <code>warm_up</code> tool so the first <em>real</em> call doesn't run into a timeout while models load:</p>
<pre><code class="language-python">@mcp.tool()
def warm_up() -&gt; dict:
    """Preload the OCR and NER models so the first real call is fast."""
    _get_pipeline()   # builds and caches the pipeline on first use
    return {"status": "ready"}
</code></pre>
<h3 id="heading-6-the-audit-tools-read-the-records-not-the-images">6. The Audit Tools Read the Records, Not the Images</h3>
<p>The remaining tools read the reports and review folders that Aegis already produces. Because they summarize existing audit records rather than reprocessing images, Claude can answer questions about completed runs without accessing the underlying medical images.</p>
<pre><code class="language-python">@mcp.tool()
def summarize_run(run_dir: str) -&gt; dict:
    """Audit a run from its CSV reports. Returns counts only — never text or tag values."""
    run = Path(run_dir).expanduser().resolve()
    pixels = _read_csv_rows(run / "aegis_pixel_detections.csv")
    tags = _read_csv_rows(run / "aegis_tag_actions.csv")
    return {
        "pixel_decisions": Counter(r["decision"] for r in pixels),  # redacted / safelisted / low_confidence
        "tag_actions": Counter(r["action"] for r in tags),          # REMOVE / REMAP / ZERO / DUMMY / ATTEST
</code></pre>
<pre><code class="language-python">@mcp.tool()
def list_review_queue() -&gt; dict:
    """List files quarantined for manual review — names only, never contents."""
    names = sorted(f for _, _, fs in os.walk(REVIEW_DIR) for f in fs if not f.startswith("."))
    return {"count": len(names), "files": names[:50]}
</code></pre>
<h2 id="heading-step-3-test-with-mcp-inspector-before-any-ai-is-involved">Step 3: Test with MCP Inspector — Before Any AI Is Involved</h2>
<p>If you are skeptical about all of this (I was), this step is for you. MCP Inspector is a debug UI that connects to your server and lets <em>you</em> click the tools manually.</p>
<pre><code class="language-shell">npx @modelcontextprotocol/inspector /&lt;ABSOLUTE PATH&gt;/aegis/venv/bin/aegis-mcp
</code></pre>
<p>The Inspector opens on the <strong>Servers</strong> screen with your <code>aegis-mcp</code> server listed. Click the toggle to connect, it turns green when the server is running.</p>
<img src="https://cdn.hashnode.com/uploads/covers/69fd77e89f93a850a46d376f/7e952989-9e3e-4f45-9a08-579821699963.png" alt="MCP Inspector showing the Aegis MCP server connected over STDIO, with the server status active and ready for testing." style="display:block;margin:0 auto" width="2513" height="983" loading="lazy">

<p>Next, open the <strong>Tools</strong> tab. You’ll see the six tools exposed by your MCP server. Run <code>warm_up</code> first, and watch the terminal where you started the Inspector to see the OCR and NER models load.</p>
<p>Next, run <code>deidentify_file</code> with the path to a test image. The <strong>Results</strong> panel shows the tool’s JSON response, while <strong>Messages</strong> shows the request and response exchanged with the server.</p>
<img src="https://cdn.hashnode.com/uploads/covers/69fd77e89f93a850a46d376f/a3d0ee93-165f-4093-bb38-70a6776d6f03.png" alt="MCP Inspector displaying the deidentify_file tool with its input fields and the JSON response returned after processing a test medical image." style="display:block;margin:0 auto" width="2544" height="1129" loading="lazy">

<h2 id="heading-step-4-connect-claude-desktop">Step 4: Connect Claude Desktop</h2>
<p>Open <strong>Claude Desktop</strong> and go to <strong>Settings → Developer → Edit Config</strong>. This opens (or creates) the MCP configuration file. On macOS it’s located at <code>~/Library/Application Support/Claude/claude_desktop_config.json</code>, and on Windows at <code>%APPDATA%\Claude\claude_desktop_config.json</code>.</p>
<p>Add the following <code>aegis</code> entry under <code>mcpServers</code>:</p>
<pre><code class="language-json">{
  "mcpServers": {
    "aegis": {
      "command": "/&lt;PATH TO AEGIS&gt;/aegis/venv/bin/aegis-mcp",
      "args": [],
      "env": {
        "AEGIS_OUTPUT_DIR": "/&lt;PATH TO AEGIS&gt;/aegis/staging_output",
        "AEGIS_REVIEW_DIR": "/&lt;PATH TO AEGIS&gt;/aegis/staging_not_processed",
        "AEGIS_DEVICE": "mps"
      }
    }
  }
}
</code></pre>
<p>Configuration for Claude Desktop to connect to the Aegis MCP server.</p>
<p>A few things to check before saving:</p>
<ul>
<li><p>Use absolute paths for command, <code>AEGIS_OUTPUT_DIR</code>, and <code>AEGIS_REVIEW_DIR</code>.</p>
</li>
<li><p>Point command to the aegis-mcp executable inside your virtual environment so Claude uses the correct Python installation and dependencies.</p>
</li>
<li><p>Set <code>AEGIS_DEVICE</code> to <code>mps</code> for Apple Silicon, <code>cpu</code> for Intel Macs or Linux, or <code>cuda</code> if you have an NVIDIA GPU.</p>
</li>
</ul>
<p>Save the file, <strong>fully quit and restart Claude Desktop</strong> (closing the window isn’t enough). In a new chat, open the <strong>Search &amp; Tools</strong> menu, you should now see the <strong>Aegis</strong> MCP server with its six available tools.</p>
<img src="https://cdn.hashnode.com/uploads/covers/69fd77e89f93a850a46d376f/d3ec5a5e-80db-48f8-8521-ce56ada47e4c.png" alt="Claude Desktop Search &amp; Tools menu showing the Aegis MCP server and its available tools, including warm_up, deidentify_file, start_batch_job, get_job_status, summarize_run, and list_review_queue." style="display:block;margin:0 auto" width="868" height="776" loading="lazy">

<h2 id="heading-step-5-talk-to-your-agent">Step 5: Talk to Your Agent</h2>
<p>Time for the first conversation. Send:</p>
<blockquote>
<p>Warm up the Aegis de-identification server.</p>
</blockquote>
<p>Claude will ask for permission before calling the tool. This prompt is a feature, every capability you have given the agent requires your explicit approval, and you can grant it per call or per tool.</p>
<p>Once approved, the models load and Claude reports back with the elapsed time.</p>
<p>De-identify a single file:</p>
<blockquote>
<p>De-identify the file &lt;/test_ultrasound.dcm.&gt;</p>
</blockquote>
<p>Claude calls <code>deidentify_file</code> and answers with the counts: how many text regions were detected, how many were redacted versus safe listed as clinical text, how many DICOM tags were scrubbed, and whether anything needs review. It narrates all of this without ever having seen the image.</p>
<img src="https://cdn.hashnode.com/uploads/covers/69fd77e89f93a850a46d376f/68139acd-4fc7-4ad9-9199-4d419a0062f0.png" alt="Claude Desktop conversation where the user asks the Aegis MCP server to de-identify a medical image, and Claude reports summary statistics such as detected text regions, redactions, and whether manual review is required." style="display:block;margin:0 auto" width="1124" height="360" loading="lazy">

<p>Next, a batch:</p>
<blockquote>
<p>Now start a batch de-identification job for &lt;/test_ultrasound&gt;</p>
</blockquote>
<p>The tool returns instantly with a job ID, and the processing continues in the background. Ask about it a moment later:</p>
<blockquote>
<p>How's that job going?</p>
</blockquote>
<p>Claude remembers the job ID across turns and polls <code>get_job_status</code>, reporting files processed, running decision counts, and any errors.</p>
<p>Once the job finishes, you can ask Claude to summarize the run, list files requiring manual review, or generate a report for your review meeting, all from the pipeline’s audit records.</p>
<blockquote>
<p>Summarize the completed run. Does anything need manual review?</p>
</blockquote>
<blockquote>
<p>What exactly was done to test_ultrasound.dcm, which header tags were touched?</p>
</blockquote>
<blockquote>
<p>Draft a short de-identification summary for this run, suitable for a review meeting. Include totals, the decision breakdown, and files pending human review.</p>
</blockquote>
<p>Everything in the below summary came from tool results, counts and decisions read from the pipeline's own records.</p>
<img src="https://cdn.hashnode.com/uploads/covers/69fd77e89f93a850a46d376f/70353644-c512-470c-a32e-72794d644343.png" alt="Claude Desktop conversation showing the progress of a batch de-identification job, including processed files, decision counts, and current job status returned by the MCP server." style="display:block;margin:0 auto" width="907" height="963" loading="lazy">

<img src="https://cdn.hashnode.com/uploads/covers/69fd77e89f93a850a46d376f/1b5f583c-224c-4f89-bf09-3208332beafb.png" alt="Claude Desktop generating a summary report of a completed de-identification run, including totals, decision breakdowns, and files requiring manual review based on Aegis audit records." style="display:block;margin:0 auto" width="903" height="1077" loading="lazy">

<h2 id="heading-verification">Verification</h2>
<p>Compare Claude’s summary with the CSV reports and <code>job_summary_&lt;job_id&gt;.json</code>. The numbers should match, giving you a simple way to verify everything the agent reports.</p>
<h2 id="heading-does-the-ai-ever-see-patient-data">Does the AI Ever See Patient Data?</h2>
<p>No. The tools never return image pixels, OCR-extracted text, or DICOM tag values, so Claude cannot access the underlying PHI.</p>
<p>For example, if you ask:</p>
<blockquote>
<p>Show me the patient name detected in that file.</p>
</blockquote>
<p>Claude cannot answer because that information is never exposed by the MCP tools.</p>
<p>However, conversation metadata does reach the model. File names, directory paths, counts, and tool outputs are processed by Claude just like any other chat. Keep these points in mind:</p>
<ul>
<li><p><strong>Avoid PHI in file names.</strong> Rename files if they contain patient names or identifiers.</p>
</li>
<li><p><strong>Keep error messages clean.</strong> Don’t include sensitive DICOM values in exceptions returned by your tools.</p>
</li>
<li><p><strong>Use synthetic data while developing.</strong> This tutorial uses fake PHI. Before working with real patient data, follow your organization’s security and compliance requirements.</p>
</li>
</ul>
<h2 id="heading-security-considerations">Security Considerations</h2>
<p>If you adapt this pattern for your own tools, consider these best practices:</p>
<ul>
<li><p><strong>Restrict file access.</strong> Limit tools to approved directories instead of allowing any readable path.</p>
</li>
<li><p><strong>Review tool permissions.</strong> It’s reasonable to always allow read-only tools like <code>get_job_status</code>, but keep approval prompts for tools that modify files.</p>
</li>
<li><p><strong>Return structured results.</strong> Prefer counts and categories over raw text to reduce the chance of exposing sensitive information.</p>
</li>
<li><p><strong>Pin model versions.</strong> Using fixed OCR and NER model versions makes your pipeline more reproducible and predictable.</p>
</li>
</ul>
<h2 id="heading-a-note-on-the-word-de-identification">A Note on the Word "De-identification"</h2>
<p>In regulations such as HIPAA, <strong>de-identification</strong> has a specific legal meaning with defined requirements. This tutorial shows how to build an AI agent interface for a de-identification pipeline, not how to certify regulatory compliance. The pipeline intentionally routes uncertain cases for human review, and any real-world deployment should be validated against your organization’s policies and applicable regulations.</p>
<h2 id="heading-where-this-fits-and-whats-next">Where This Fits, and What's Next</h2>
<p>MCP doesn’t change how well Aegis detects PHI, it changes <strong>how people interact with it</strong>. Instead of using the command line, users can run jobs, review results, and ask questions in natural language.</p>
<p>For automated workflows such as nightly batch processing, the CLI is still the better choice. MCP is best for interactive, human-in-the-loop tasks, while the CLI remains ideal for scheduled jobs. In both cases, the files and audit reports on disk remain the source of truth.</p>
<p><strong>Here are a few directions you can explore next:</strong></p>
<ul>
<li><p><strong>Run everything locally.</strong> Pair the same MCP server with Ollama and Open WebUI so both the pipeline and the AI model stay on your machine.</p>
</li>
<li><p><strong>Strengthen security</strong>. Restrict tools to approved directories before deploying in a shared environment.</p>
</li>
<li><p><strong>Build dataset preparation workflows</strong>. Use the agent to de-identify data, summarize results, and prepare datasets for machine learning.</p>
</li>
<li><p><strong>Add downstream analysis.</strong> Run vision models on the de-identified outputs instead of the original images.</p>
</li>
<li><p><strong>Reuse the pattern elsewhere</strong>. The same architecture can orchestrate pipelines that remove sensitive information from legal documents, logs, financial records, or other confidential data.</p>
</li>
</ul>
<h2 id="heading-conclusion">Conclusion</h2>
<p>We turned an existing Python pipeline into an AI-accessible tool using MCP. The key design principle is <strong>the model orchestrates the workflow but never sees the sensitive data.</strong></p>
<p>This pattern extends beyond medical imaging. Any pipeline that handles sensitive information: such as legal documents, financial records, or personal photos can expose safe, structured tools while keeping the underlying data private.</p>
<p>You can find the complete implementation in the <strong>Aegis</strong> repository: <a href="https://github.com/lakshmi-mahabaleshwara/aegis">https://github.com/lakshmi-mahabaleshwara/aegis</a>. If you found this tutorial useful, <em><strong>consider starring the repository to help others discover it.</strong></em></p>
<h2 id="heading-references">References</h2>
<ul>
<li><p><a href="https://modelcontextprotocol.io/">Model Context Protocol documentation</a></p>
</li>
<li><p><a href="https://github.com/modelcontextprotocol/python-sdk">MCP Python SDK</a></p>
</li>
<li><p><a href="https://support.claude.com/en/articles/10949351-getting-started-with-local-mcp-servers-on-claude-desktop">Getting started with local MCP servers on Claude Desktop</a></p>
</li>
<li><p><a href="https://www.freecodecamp.org/news/build-ai-image-de-identification-for-clinical-research/">How to Build an AI-Powered Medical Image De-Identification Pipeline for Clinical Research</a></p>
</li>
<li><p><a href="https://github.com/lakshmi-mahabaleshwara/aegis">Aegis on GitHub</a></p>
</li>
</ul>
 ]]>
                </content:encoded>
            </item>
        
    </channel>
</rss>
