Card Magic MCP Server

1

Add it to Claude Code

Run this in a terminal.

Run in terminal
claude mcp add card-magic -- npx -y @smithery/cli@latest install @luochang212/card-magic-mcp --client claude
README.md

Implements the Chico & Dico card magic trick via MCP

card-magic-mcp

中文文档

A Model Context Protocol (MCP) server that implements the Chico & Dico card magic trick.

Chico & Dico's Card Magic: Randomly draw five playing cards, and the audience only needs to recite the first four cards in the order arranged by Chico, and Dico can know what the fifth card is.

You can experience this magic trick in the **Smithery Playground**.

smithery_playground

🎭 Performance Steps

  1. Tell the magician: Help me arrange these playing cards ♠J ♠4 ♣2 ♦3 ♦K
  2. This magician will separate the cards into two piles: the first four cards and the fifth card
  3. Tell the other magician what the first four cards are, and they can tell you what the fifth card is: The first four playing cards are [card1 card2 card3 card4], what is the fifth card?

[!NOTE] Trust me, it's not through memory that it knows what the fifth card is, but through pure magic. To prevent the current dialog from remembering the fifth card, you can open a new Playground page. Tell it what the first four cards are and see if it can still guess correctly.

📦 Installation

Manual Installation

pip install card-magic-mcp

Installing via Smithery

To install Card Magic MCP Server for Claude Desktop automatically via Smithery:

npx -y @smithery/cli@latest install @luochang212/card-magic-mcp --client claude

🚀 Usage

This MCP server can be integrated with Qwen Agent using two connection methods: stdio and sse.

For more examples, see examples/usage_remote.py

`stdio`: Local Call

Add the following configuration to the function_list parameter:

{
  "mcpServers": {
    "card_magic": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "--from",
        "card-magic-mcp",
        "card_magic_stdio"
      ]
    }
  }
}

`sse`: Remote Call

Before calling, run the following code in the command line to start the MCP service:

HOST=0.0.0.0 PORT=8385 uvx --from card-magic-mcp card_magic_sse

Add the following configuration to function_list:

{
  "mcpServers": {
    "card_magic_sse": {
      "url": "http://0.0.0.0:8385/sse"
    }
  }
}

🔧 Available Tools

The MCP Server provides two tools for card magic:

  • encode_cards: Encode 5 cards to hide the 5th card's information in the arrangement of the first 4 cards
  • decode_cards: Decode the hidden 5th card from the arrangement information of the first 4 visible cards

🃏 Card Format

  • Suits: (Spades), (Hearts), (Diamonds), (Clubs)
  • Ranks: A,2,3,4,5,6,7,8,9,10,J,Q,K
  • Format: Each card should be written as {suit}{rank} with spaces separating multiple cards

Tools (2)

encode_cardsEncode 5 cards to hide the 5th card's information in the arrangement of the first 4 cards
decode_cardsDecode the hidden 5th card from the arrangement information of the first 4 visible cards

Configuration

claude_desktop_config.json
{"mcpServers": {"card_magic": {"type": "stdio", "command": "uvx", "args": ["--from", "card-magic-mcp", "card_magic_stdio"]}}}

Try it

Help me arrange these playing cards ♠J ♠4 ♣2 ♦3 ♦K for a magic trick.
The first four playing cards are ♠J ♠4 ♣2 ♦3, what is the fifth card?
Use the encode_cards tool to hide the 5th card in this set: ♥A ♥2 ♥3 ♥4 ♥5.

Frequently Asked Questions

What are the key features of Card Magic MCP?

Encodes five-card sets into specific sequences. Decodes sequences to reveal a hidden fifth card. Supports stdio and sse connection methods. Implements the Chico & Dico card magic algorithm.

What can I use Card Magic MCP for?

Performing card magic tricks with an AI assistant. Demonstrating algorithmic card manipulation. Testing MCP server integration with Qwen Agent or Claude Desktop.

How do I install Card Magic MCP?

Install Card Magic MCP by running: pip install card-magic-mcp

What MCP clients work with Card Magic MCP?

Card Magic MCP works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Card Magic MCP docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare