Skip to main content

A Model Context Protocol (MCP) server that implements the famous Chico and Dico card magic trick algorithm. This server enables AI assistants to perform mathematical card magic by encoding and decoding card sequences based on combinatorial principles. The magic works by using the first 4 cards to predict the 5th card from any randomly selected 5-card hand, leveraging factorial number systems and permutation mathematics.

Project description

card-magic-mcp

License PyPI GitHub CI Downloads

中文文档

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.

📦 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

Can be called through Qwen Agent, supporting two calling methods: stdio and sse. See examples/usage_remote.py for usage examples.

1. 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"
      ]
    }
  }
}

2. sse Remote Call

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

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

card_magic_mcp-1.0.7.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

card_magic_mcp-1.0.7-py3-none-any.whl (11.8 kB view details)

Uploaded Python 3

File details

Details for the file card_magic_mcp-1.0.7.tar.gz.

File metadata

  • Download URL: card_magic_mcp-1.0.7.tar.gz
  • Upload date:
  • Size: 15.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.14

File hashes

Hashes for card_magic_mcp-1.0.7.tar.gz
Algorithm Hash digest
SHA256 315a43ab5c1bf79938195a0fbe46eb80b6ade5bc17eda4d4219dc3f675a0c87c
MD5 927ab6ea32ef639e1709548540ac7e2a
BLAKE2b-256 95e341a455b8dce8212263177e426f5d8245017925b01eda2ab987fefcbceaff

See more details on using hashes here.

File details

Details for the file card_magic_mcp-1.0.7-py3-none-any.whl.

File metadata

  • Download URL: card_magic_mcp-1.0.7-py3-none-any.whl
  • Upload date:
  • Size: 11.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.14

File hashes

Hashes for card_magic_mcp-1.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 8f199537f0b79f5c2fc3af61b9485ef962ed2e967f241ecafff394cf9778e2a0
MD5 bb4bca97b51e0c7d42a34fa80ffbf6bc
BLAKE2b-256 8cb5ef8b71d6dc9502df93f0b37339e6a2c5633bb2b23f098ba036724194dbee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page