Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › FastMCP

A 75-Line MCP PII Preflight Check: What It Catches and What It Misses

By Freedom251 Team · · 5 min read

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A 75-line Python MCP server can scan text for a few PII-shaped strings and a basic prompt-injection phrase before your application sends that text to a model. It is a useful preflight signal, not a privacy filter or a proof that a prompt is safe. The application has to require the scan and stop the send when the result is block or review.

What the tool actually does

The example comes from a September 29, 2026 DEV Community article by AI Dev Hub. It builds a local server with FastMCP and exposes one scan tool. That tool checks an input string against three fixed patterns and returns a structured result.

As an Amazon Associate I earn from qualifying purchases.

The three rules

Rule What it looks for Action returned
Email An email-shaped string review
US SSN A nine-digit SSN-shaped number review
Instruction override A phrase-based attempt to override prior instructions block

What comes back

Each response includes a status (block, review, or no_match), a human-readable reason, the names of the rules that fired, and character offsets for each finding. It also includes a preview in which matched positions are replaced with asterisks. The offsets let your application show a reviewer exactly where the match sits without printing the raw value into a log line.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Limits built into the example

The sample sets two caps: an input limit of 8,192 characters and a findings limit of 48. When either cap is reached, the tool returns review and omits the preview. These are constants chosen in the example code, not measured performance figures. Your own limits should reflect your payload sizes and latency budget.

#1 Best Overall
Yubico - Security Key C NFC - Basic Compatibility - Multi-Factor authentication (MFA) Security Key and passkey, Connect via USB-C or NFC, FIDO Certified
  • POWERFUL SECURITY KEY: The Security Key C NFC is the essential physical passkey for protecting your digital life from phishing attacks. It ensures only you can access your accounts.
  • WORKS WITH 1000+ ACCOUNTS: Compatible with Google, Microsoft, and Apple. A single Security Key C NFC secures 100 of your favorite accounts, including email, password managers, and more.
  • FAST & CONVENIENT LOGIN: Plug in your Security Key C NFC via USB-C and tap it, or tap it against your phone (NFC) to authenticate. No batteries, no internet connection, and no extra fees required.
  • TRUSTED PASSKEY TECHNOLOGY: Uses the latest passkey standards (FIDO2/WebAuthn & FIDO U2F) but does not support One-Time Passwords. For complex needs, check out the YubiKey 5 Series.
  • BUILT TO LAST: Made from tough, waterproof, and crush-resistant materials. Manufactured in Sweden and programmed in the USA with the highest security standards.

What a no_match result does not establish

The author states the central caution directly: the tool “can’t prove that text is safe, and its prompt injection check is only a tripwire.” Each rule has its own blind spots:

  • Email: the pattern is deliberately incomplete and can match strings that are not real mailboxes.
  • SSN: the pattern recognizes a shape. It cannot tell whether a number was ever issued or belongs to a person.
  • Injection: a differently worded attack can evade a phrase match entirely.
  • Everything else: names, street addresses, account numbers, medical identifiers, and any PII format outside the three rules are not checked.

So no_match means only that these three rules found nothing. It should never be logged or displayed as “clean” or “safe.”

Rank #2
Yubico - YubiKey 5C NFC - Multi-Factor authentication (MFA) Security Key and passkey, Connect via USB-C or NFC, FIDO Certified - Protect Your Online Accounts
  • POWERFUL SECURITY KEY: The YubiKey 5C NFC is the most versatile physical passkey, protecting your digital life from phishing attacks. It ensures only you can access your accounts
  • WORKS WITH 1000+ ACCOUNTS: Compatible with popular accounts like Google, Microsoft, and Apple. A single YubiKey 5C NFC secures 100+ of your favorite accounts, including email, password managers, and more
  • FAST & CONVENIENT LOGIN: Plug in your YubiKey 5C NFC via USB and tap it, or tap it against your phone (NFC), to authenticate. No batteries, no internet connection, and no extra fees required
  • MOST SECURE PASSKEY: Supports FIDO2/WebAuthn, FIDO U2F, Yubico OTP, OATH-TOTP/HOTP, Smart card (PIV), and OpenPGP. That means it’s versatile, working almost anywhere you need it
  • PRIMARY & SPARE KEYS: Just like having a spare house key, we recommend buying two YubiKeys - one for daily use and one as a spare. That way you’ll never get locked out of your accounts

Making the gate enforceable

The tutorial’s most important design point is that the host owns the gate. An MCP tool call does not, by itself, stop a later model request. If the agent or calling code can skip the scan, the check is optional, and optional checks tend to be skipped under load or in edge cases.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Place the scan in the application’s required request path, before any transmission to an external model. Then treat the outcomes as follows:

Rank #3
Yubico - YubiKey 5 NFC - Multi-Factor authentication (MFA) Security Key and passkey, Connect via USB-A or NFC, FIDO Certified - Protect Your Online Accounts
  • POWERFUL SECURITY KEY: The YubiKey 5 NFC is the most versatile physical passkey, protecting your digital life from phishing attacks. It ensures only you can access your accounts
  • WORKS WITH 1000+ ACCOUNTS: Compatible with popular accounts like Google, Microsoft, and Apple. A single YubiKey 5 NFC secures 100+ of your favorite accounts, including email, password managers, and more
  • FAST & CONVENIENT LOGIN: Plug in your YubiKey 5 NFC via USB and tap it, or tap it against your phone (NFC), to authenticate. No batteries, no internet connection, and no extra fees required
  • MOST SECURE PASSKEY: Supports FIDO2/WebAuthn, FIDO U2F, Yubico OTP, OATH-TOTP/HOTP, Smart card (PIV), and OpenPGP. That means it’s versatile, working almost anywhere you need it
  • PRIMARY & SPARE KEYS: Just like having a spare house key, we recommend buying two YubiKeys - one for daily use and one as a spare. That way you’ll never get locked out of your accounts
  • no_match: the request may proceed to the model call.
  • review: hold the request. Show the masked preview to a reviewer, or reject it, according to your policy.
  • block: stop the request. Do not offer a send-anyway path in the same flow.

The tutorial treats both block and review as stops. Relaxing review into a warning that users can dismiss turns the check into decoration.

Data handling before you use real text

The walkthrough runs as a local subprocess that communicates over stdio. It needs no model call, no API token, and no paid service. That local design matters, but it does not make the text harmless:

Rank #4
Yubico - Security Key NFC - Basic Compatibility - Multi-Factor Authentication (MFA) Key, Connect via USB-A or NFC, FIDO Certified
  • POWERFUL SECURITY KEY: The Security Key NFC is the essential physical passkey for protecting your digital life from phishing attacks. It ensures only you can access your accounts.
  • WORKS WITH 1000+ ACCOUNTS: Compatible with Google, Microsoft, and Apple. A single Security Key NFC secures 100 of your favorite accounts, including email, password managers, and more.
  • FAST & CONVENIENT LOGIN: Plug in your Security Key NFC via USB-A and tap it, or tap it against your phone (NFC) to authenticate. No batteries, no internet connection, and no extra fees required.
  • TRUSTED PASSKEY TECHNOLOGY: Uses the latest passkey standards (FIDO2/WebAuthn & FIDO U2F) but does not support One-Time Passwords. For complex needs, check out the YubiKey 5 Series.
  • BUILT TO LAST: Made from tough, waterproof, and crush-resistant materials. Manufactured in Sweden and programmed in the USA with the highest security standards.
  • The host process receives the full input text, so anything the host logs is a potential PII leak.
  • Some hosts export tool traces remotely. Check that behavior before sending real customer data through the tool.
  • The masked preview still contains everything the rules missed. Masking is not redaction of unknown PII.

The author’s guidance, which is design advice rather than independently validated testing, includes these practices:

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  1. Keep raw matches out of ordinary debug logs. Log rule names and offsets instead.
  2. Use synthetic fixtures when experimenting with rule changes.
  3. Keep protocol debug output off stdout, because stdio transport uses stdout for protocol messages.
  4. Write tests for the 8,192-character and 48-finding caps, and for overlapping matches.
  5. Add prompt-injection defenses beyond the scan. Restrict tool permissions and require approval for consequential actions.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Compatibility with the current MCP Python SDK

The tutorial’s code uses the v1-era FastMCP import and API. The official MCP Python SDK documentation, as checked for this article, labels v2 as the current stable line and documents MCPServer as the server class. The SDK requires Python 3.10 or later and supports stdio, Streamable HTTP, and SSE transports.

Best Value
FIDO2 U2F Security Key Passkey Two-Factor Authentication (2FA) USB Key PIN+Touch (Non-Biometric) USB-A Type TrustKey T110
  • Security Key : Protect your online accounts against unauthorized access by using FIDO2 and U2F authentication with T110. It's the world's most protective security key that works with windows, Mac OS, Linux as well as Chrome, Firefox, Edge and many other major browsers.
  • Certified with the new FIDO2 standard, T110 provides the benefit of fast login and strong protection against phishing, account takeover as well as many other online attactks.
  • Works with : Bank of America, Github, Google, Microsoft, DUO, Twitter, Facebook, Dropbox, Apple, ebay, BINANCE, mor and more.
  • Fits USB-A port : Insert the T110 security key into the USB-A port of each service and log in conveniently with one touch
  • For the driver download and user guide, please visit TrustKey Solutions Home support page.

Before you copy the tutorial’s code into a project, read the SDK migration guide, then either pin the older SDK version the example expects or port the server to the current API. Do not assume the sample runs unchanged on the latest release.

Choosing how to expose the check

The same scan logic can sit behind three different interfaces. The transport changes how callers reach the check. It does not change scan quality.

Option Good fit Data path and boundary Main cost
Local MCP tool An MCP host needs a named scan tool that other compatible clients can discover Host and subprocess permissions; text passes through a local stdio pipe Host setup and protocol handling
Plain Python function One Python application owns the whole request flow Runs inside the application’s existing permissions and process No tool discovery for other hosts
Operated HTTP endpoint Several applications need one shared rules service Network request; you must implement authentication yourself Deployment, access control, and service operations

For a single caller, a plain function is the simplest starting point. MCP becomes worthwhile when several compatible hosts need the same named tool. An HTTP endpoint makes sense when a shared service must be operated centrally and the network boundary is part of your security design.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

A practical rollout sequence

  1. Run the scan in a test environment with synthetic data only, including inputs at and just above both caps.
  2. Wire the four outcomes (no_match, review, block, and cap-triggered review) into your request path, and confirm that no code path reaches the model without passing the scan.
  3. Audit every logger, trace exporter, and error handler that can receive the input text or the tool response.
  4. Decide who reviews review results and how quickly, since held requests will accumulate.
  5. Only then evaluate real data, under your own privacy and contractual obligations.

The tutorial shows how to build a fast, inspectable preflight check in a few dozen lines. Whether that check is adequate for your data is a separate question that the example cannot answer.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

FastMCPLLM securityMCPPII detectionprompt injectionPython

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.