Card Spy

A smartcard and NFC IDE

Card Spy works with smartcards and NFC tags through any PC/SC reader. Send APDUs, explore cards, write scripts in TypeScript, and record a card to replay without it.

macOS, Windows and Linux · free and open source (MIT)

Card Spy exploring a payment card: its applications and records in a tree, one record decoded in the inspector, and the APDU trace below.

Card explorer

Explore a card

Explore reads the ATR, the payment applications with their records, counters and transaction log, and the memory and NDEF messages of NFC tags. It also checks for common applications such as PIV, OpenPGP and FIDO.

Values are shown with their names and decoded where the format is known: dates, amounts, currencies, country codes, CVM lists and ISO 7816-4 file control parameters.

An NFC tag explored: UID, capability container, and an NDEF message with a URI and a text record.

APDU console

Send APDUs and read the responses

Type a command in hex, or a shortcut such as select 1PAY.SYS.DDF01. The trace lists the exchanges from the console, the explorer and scripts, with the command name, status word and timing. Select one to see the header fields, what the status word means and the response as a TLV tree. Hovering over a tag highlights its bytes in the hex dump.

On T=0 cards, Card Spy sends GET RESPONSE after 61xx and retries with the right length after 6Cxx. Both show up in the trace.

The inspector decoding a GET RESPONSE: command header, status word, hex dump and the File Control Information as a TLV tree.

Scripts

Scripts in TypeScript

Scripts use a small card API, with type checking and completion in the editor. Run one against any reader, or step through it with F10: Card Spy stops before each APDU and highlights the line that sends it.

const fci = (await card.select('A0000000031010')).expectOk();
log(fci.tlv());
A script paused before a READ RECORD command, with its line highlighted and output so far below.

AI agents

Let an agent use your readers

Card Spy has a Model Context Protocol server. Turn it on, and an agent such as Claude Code can list your readers, send APDUs, explore a card, run scripts and work with virtual cards.

Everything it sends appears in the trace beside your own commands, tagged mcp, so you can see what it did and pick up where it left off.

In Card Spy 3.1 and later.

A card explored by hand, then commands from an agent in the same trace, tagged mcp, with one of them decoded in the inspector.

What's on the card in the reader?

It's a Visa debit card with one payment application, A0000000031010, labelled VISA DEBIT, listed in the contact payment directory.

The records give the card number 4761 7390 0101 0010 in the name TEST/CARDHOLDER, valid from January 2024 to December 2029, issued in the UK in pounds. It prefers an offline plaintext PIN, then online PIN, then signature.

The PIN has 3 tries left. The transaction counter is at 42, and the card's own log holds its last three transactions, the latest for £12.50.

An example, from the demo Visa card that comes with Card Spy.

Things to ask

  1. What's on this card?
  2. Which applications does it have, and how do their records differ?
  3. Write a script that reads every record and lists the tags it finds, and run it.
  4. Why did my last SELECT come back 6A82?
  5. Record this card, so I can carry on without the reader.
  6. Make a virtual card that answers like a PIV card, and test my script against it.

Set it up

  1. Turn it on. Click MCP in the status bar and tick Let agents on this computer connect.
  2. Tell your agent. The dialog shows a command that adds Card Spy to Claude Code. Copy it and run it in a terminal. Any other client that speaks MCP over HTTP needs the same URL and Authorization header.
  3. Ask. Start a new session, put a card in a reader or insert a virtual one, and ask what's on it.

Card Spy has to be running for the agent to reach it.

The MCP dialog: a tick box to let agents connect, another to allow commands that can change a real card, and the command that adds Card Spy to Claude Code.

Real cards are read-only

An agent can read a card in a hardware reader, but a command that could change it, such as a PIN try or a write, isn't sent unless you allow it. Virtual cards take anything. Exploring a payment card does advance its transaction counter, as it does when you do it.

Only on your computer

The server is off until you turn it on. It listens on this computer alone, needs a token that Card Spy makes for you, and turns web pages away.

What leaves your computer

What an agent reads from a card, such as a card number or a name, goes to the company that runs its model. A PIN you typed yourself is hidden from an agent reading the trace.

Virtual cards

Save a session with a real card as a virtual card and replay it without the card. Virtual cards are JSON files you can edit and keep in version control. Two demo cards are included.

Readers

Works with contact and contactless PC/SC readers, such as the ACR122U. NFC tags like NTAG and MIFARE Ultralight are read with the reader's storage card commands.

Decoding

EMV and ISO 7816 tag dictionaries, NDEF, a list of known AIDs and status word meanings, including Java Card's. When a card rejects a command, Card Spy suggests the likely reason.

Download

The latest release is on GitHub.

macOS

For Apple Silicon and Intel Macs. Signed and notarised by Apple.

Windows

Windows 10 or 11, 64-bit. Uses the Windows smart card service.

Linux

64-bit. Needs pcscd running: sudo apt install pcscd.

To build from source, clone https://github.com/tomkp/card-spy and run npm install then npm run dev. The README has more.