DEV Community

Sam
Sam

Posted on

How to Add Card Fraud Detection to Your AI Agent (in About 5 Minutes)

Last updated: July 2026

Quick question. If your AI agent is touching payment data right now, does it actually know whether a card number is real?

Most don't. They just pass whatever the user typed straight through. No validation, no issuer check, nothing. That's a problem if you're building a support bot, an underwriting assistant, or anything that gets near a card number.

TL;DR: Connect the free BinSearchLookup MCP server to Claude Desktop, Cursor, or any MCP-compatible client. It gives your agent five tools and two ready-made prompts for BIN lookups, offline Luhn validation, and fraud risk scoring, without full card numbers ever touching the LLM's context window. Setup takes about 5 minutes and the free tier needs no credit card. Full steps below.

What Is an MCP Server, and Why Does It Matter for Fraud Checks?

MCP (Model Context Protocol) is the open standard that lets AI agents like Claude Desktop and Cursor call external tools directly, the same way a human developer would call an API. An MCP server is just a small program that exposes a set of tools an agent can invoke on demand.

For fraud detection specifically, that means your agent can validate a card number, identify its issuing bank, and flag risk, all without you writing custom integration code. You wire up the server once, then just talk to your agent in plain English.

I'm going to walk you through the exact setup using the BinSearchLookup MCP server. No fluff, no "hypothetically." Real tools, real config, real commands.

What This Actually Gives Your Agent

Once it's connected, your agent has access to five tools:

  1. local_card_diagnostics(number). Free. Runs completely offline. Identifies the network (Visa, Mastercard, Amex, you name it) and checks the number against the Luhn algorithm before anything touches the internet.
  2. lookup_bin(bin_number). Pulls the full picture on a BIN: issuer, country, card type, brand.
  3. batch_lookup_bins(bins). Feed it a list. It dedupes, chunks into batches of 50, and runs them concurrently. You don't manage pagination.
  4. check_quota(public_user_id). Tells you exactly where you stand against your plan.
  5. check_system_health(). Basic uptime check.

There are also two prompts baked in that do the heavy lifting for you:

  • fraud_analysis runs the offline check first, pulls the live data, and hands back a full risk assessment. One command.
  • bulk_bin_audit takes a comma separated list of BINs and returns a clean markdown table, flagging prepaid cards and high risk countries.

Rate limits get handled automatically with exponential backoff. Repeat lookups in the same session get served from cache instead of burning your quota twice. You don't have to think about any of that. It's already built in.

Step 1: Get Your API Key

Head to binsearchlookup.com and sign up. Free plan gives you 500 requests a month, 20 requests a minute, and no, you don't need a credit card to start.

Once you're in, grab two things from your dashboard:

  • Your API key
  • Your User ID (labeled public_user_id, there's a copy button right next to it)

That's it. Thirty seconds, tops.

Step 2: Wire It Into Your MCP Client

You've got two options here. Pick whichever fits your setup.

Option A: Docker (this is the one most people should use)

Drop this into your claude_desktop_config.json:

{
  "mcpServers": {
    "binsearchlookup": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "-e", "BSL_API_KEY=bsl_your_api_key_here",
        "-e", "BSL_USER_ID=your_user_id_here",
        "python:3.12-slim",
        "sh", "-c", "pip install mcp httpx pydantic tenacity python-dotenv cachetools -q && curl -s https://raw.githubusercontent.com/Bin-Search-Lookup/mcp-binsearchlookup/main/mcp_server.py | python -u"
      ]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

No repo to clone, no Python environment to manage. Restart your client and you're live.

Option B: Local Python

If you'd rather run it yourself:

pip install httpx pydantic tenacity python-dotenv mcp cachetools
Enter fullscreen mode Exit fullscreen mode

Then create a .env file next to mcp_server.py:

BSL_API_KEY=bsl_your_api_key_here
BSL_USER_ID=your_uuid_here
Enter fullscreen mode Exit fullscreen mode

And point your client at it:

{
  "mcpServers": {
    "binsearchlookup": {
      "command": "python3",
      "args": ["/absolute/path/to/mcp_server.py"]
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

You can grab the source, plus a README in ten languages, from the GitHub repo or download it as a tarball directly.

Step 3: Actually Use It

Open your MCP client and just ask, in plain English:

"Run a fraud analysis on 4532015112830366"

That's it. Your agent calls local_card_diagnostics first (instant, offline, free), then lookup_bin for the real issuer data, and gives you back a structured risk read using the fraud_analysis prompt automatically. You didn't write a single line of integration code.

Want to check a whole batch at once? Try this:

"Audit this list of BINs for prepaid or high risk cards: 453201, 542418, 601100, 370000"

That triggers bulk_bin_audit. Concurrent lookups, one clean table back.

Why This Matters More Than You Think

Here's something a lot of people building AI agents overlook. Full card numbers should never end up in an LLM's context window or sitting in a prompt log. That's not a "best practice," that's a compliance issue waiting to happen.

local_card_diagnostics solves this by doing the Luhn check and network ID entirely offline, on your machine, before anything leaves. Only the BIN, six to eight digits, ever gets sent out for the live lookup. The full card number never travels anywhere near an API log or a prompt history.

That's the difference between "we built fraud checks into our agent" and "we built fraud checks into our agent the right way."

What It Costs

Plan Price Rate Limit Monthly Quota
Free $0 20 req/min 500 requests
Starter $29/mo 60 req/min 10,000 requests
Pro $199/mo 280 req/min 78,000 requests
Enterprise $999/mo 768 req/min Unlimited

Start on the free plan. It's more than enough to test this in a real workflow. If your agent starts making serious volume, you'll know it's time to upgrade.

Frequently Asked Questions

What is a BIN number?
BIN stands for Bank Identification Number, the first 6 to 8 digits of a card number. It identifies the issuing bank, card network, and card type without exposing the full card number.

Is it safe to send card numbers through an AI agent?
Full card numbers (PANs) should never be sent to an LLM or a third-party API. The BinSearchLookup MCP server avoids this by validating the full number offline, on your machine, and only sending the BIN (the first 6 to 8 digits) to the live API. The full number never leaves your local process.

Does this work with Claude Desktop, Cursor, and other MCP clients?
Yes. Any MCP-compatible client works, since the setup is just a standard MCP server entry in your client's config file. Claude Desktop and Cursor are the two most common.

Do I need to know Python to set this up?
No. The Docker option needs zero local setup, Docker pulls and runs everything automatically. The local Python option is only needed if you'd rather not use Docker.

How much does it cost to run fraud checks with this MCP server?
The free tier includes 500 requests per month with no credit card required. That's enough for testing and most small projects. Paid plans start at $29/month for 10,000 requests if you need more volume.

What's the difference between local_card_diagnostics and lookup_bin?
local_card_diagnostics runs entirely offline and is free. It checks the Luhn algorithm and identifies the card network. lookup_bin calls the live API and returns full issuer details: bank name, country, and card category.

Grab your free API key and have this running before your coffee gets cold.

Top comments (0)