MCP server that scores Shelem (شلم) card game hands with deterministic integer arithmetic.
pip install shelem-scorekeeping-mcp Copy PIP instructions
A local Model Context Protocol server that scores hands of Shelem (شلم), the Persian trick-taking card game. An AI assistant reads the bids and results from conversation, and this server does every score change with deterministic integer arithmetic. The assistant never has to do the maths itself.
The server runs on your machine over STDIO. It has no network access, no database, and no state. It needs nothing hosted.
The full specification, including the contradictions found in the source rules and how each one is resolved, is in docs/scoring-rules.md. The same document in Persian is docs/scoring-rules.fa.md.
The package name is shelem-scorekeeping-mcp, and the command it installs has the same name. Python 3.10 or newer is required.
uv downloads and runs the server in an isolated environment, so there is nothing to install by hand:
uvx shelem-scorekeeping-mcp --version With pip pip install shelem-scorekeeping-mcp shelem-scorekeeping-mcp --version python -m shelem_mcp also starts the server.
git clone https://github.com/khaleghika/shelem-mcp cd shelem-mcp uvx --from . shelem-scorekeeping-mcp --version Run without arguments, the command starts the MCP server on STDIO and waits for a client. You do not normally run it yourself. Your MCP client launches it.
Edit claude_desktop_config.json. On macOS it is at ~/Library/Application Support/Claude/claude_desktop_config.json. On Windows it is at %APPDATA%\Claude\claude_desktop_config.json.
{ "mcpServers": { "shelem-scorekeeping": { "command": "uvx", "args": ["shelem-scorekeeping-mcp"] } } } Restart Claude Desktop afterwards. If you installed with pip instead, use "command": "shelem-scorekeeping-mcp" with "args": [].
claude mcp add shelem-scorekeeping -- uvx shelem-scorekeeping-mcp Add --scope user to make it available in every project. Alternatively, commit a project-level .mcp.json:
{ "mcpServers": { "shelem-scorekeeping": { "type": "stdio", "command": "uvx", "args": ["shelem-scorekeeping-mcp"] } } } Cursor and other clients Any client that launches STDIO servers takes the same command and args. In Cursor, add the Claude Desktop block above to ~/.cursor/mcp.json or to .cursor/mcp.json in a project.
Tell your assistant about the game in your own words, for example: "We're both on 1000. Team 1 is Hakem, bid 20, and made it exactly (مک)." The assistant expands the spoken bid "20" to 120 and calls the tool:
{ "team1_score": 1000, "team2_score": 1000, "hakem_team": 1, "bidding_team": 1, "bid": 120, "outcome": "mak" } The server returns this structured result:
{ "updated_team1_score": 1120, "updated_team2_score": 1000, "game_finished": false, "winner": null, "score_changes": { "team1": 120, "team2": 0 }, "explanation": "Team 1 (Hakem) declared a normal bid of 120. Team 1 captured 120 points and Team 2 captured 45. Team 1 captured exactly its bid (Mak), which is a made bid: +120. Team 2 had 1000 before the hand (1000 or more) and the bid was made, so its 45 captured points are withheld: +0. New totals: Team 1 1120, Team 2 1000. Neither team has reached 1165, so the game continues.", "hand": { "bid": 120, "contract": "normal", "bidding_team": 1, "hakem_team": 1, "defending_team": 2, "declarer_points": 120, "defending_points": 45, "bid_successful": true, "scoring_rule": "bid_made", "thousand_point_rule_applied": true, "scoring_note": null } } The server is stateless. The assistant keeps the running totals and passes the totals from before each hand. To correct an earlier hand, it re-scores every hand from that point on.
"One of the two" and "one of the three" mean at least one field from that group is required. When several are given, they must agree.
bid_successful alone cannot score a hand. The Hakem's award depends on whether the defenders captured nothing or 85 or more, and the defenders' award is the points they captured. The tool therefore needs the captured points, or outcome, as well.
scoring_rule is one of sweep_double, bid_made, bid_failed, heavy_failure, shelem_made, shelem_failed, or shelem_heavy_failure.
Invalid input returns an MCP tool result with isError: true and a message that ends in (field: ), for example:
bid must be from 100 through 165 in steps of 5. Abbreviated spoken bids are not accepted. (field: bid) No score is returned with an error. The tool refuses to score a hand when either team is already at 1165 or more, because that game is over.
from shelem_mcp.scoring import calculate, explain result = calculate({"team1_score": 0, "team2_score": 0, "bidding_team": 2, "bid": 135, "defending_points": 35}) print(result["team1_score"], result["team2_score"]) # 35 -135 print(explain(result)) python -m shelem_mcp.scoring < hand.json scores one hand from JSON on the command line.
uv venv uv pip install -e ".[dev]" uv run pytest The tests cover the following:
uv build uvx twine check dist/* Publishing server.json uses the current registry schema, https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json. It is a local PyPI package on STDIO. There is no remote endpoint. The mcp-name comment at the top of this file is the ownership proof PyPI publishing checks.
Pushing a tag such as v0.1.0 runs .github/workflows/publish-mcp.yml. The tag, the package version, and both version fields in server.json must be the same number. The workflow tests, builds, publishes shelem-scorekeeping-mcp to PyPI with a repository secret named PYPI_API_TOKEN, then publishes this repository's server.json with mcp-publisher v1.8.6. The binary is verified with its Sigstore bundle before it runs, and it authenticates with GitHub OIDC (login github-oidc). No registry token is stored in the repository.
Create the PyPI token at pypi.org/manage/account/token. Use scope Entire account until the project exists, then add it as the GitHub Actions secret PYPI_API_TOKEN.
git tag v0.1.0 git push origin v0.1.0 Confirm the release:
curl "https://registry.modelcontextprotocol.io/v0.1/servers?search=io.github.khaleghika/shelem-scorekeeping" Manual publish Install mcp-publisher from the quickstart, publish the package to PyPI first, then:
mcp-publisher validate mcp-publisher login github mcp-publisher publish validate checks server.json against the live registry and does not publish it.
card-game mcp model-context-protocol scorekeeping shelem
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
None of the files in this release were uploaded with provenance metadata.
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.




