Skip to main content

Python bindings for Markdown CSV Document packages.

Project description

mcd Python bindings

Rust-backed Python bindings for Markdown CSV Document packages.

Install the PyPI distribution:

pip install mcdee

Released builds include prebuilt wheels for common Windows, macOS, and Linux machines. To require a wheel and avoid local Rust/C compiler builds:

pip install --only-binary=:all: mcdee

The distribution name is mcdee; the Python import package is mcd.

import mcd

doc = mcd.open("report.mcd")
validation = doc.validate()
blocks = doc.blocks()
table = doc.table("revenue")
markdown = doc.markdown(expand_tables=True)
external_data = doc.external_data()
provenance = doc.provenance()
relationships = doc.relationships()

Use query() for SQLite-backed table analysis. Package table IDs are available as SQL table names, and MCD schema metadata is exposed through runtime tables:

doc.query("select table_id, column_name from mcd_primary_keys").rows
doc.query("""
    select table_id, column_name, ref_table_id, ref_column_name
    from mcd_foreign_keys
""").rows
doc.query("select table_id, column_name, unit_code from mcd_units").rows

Use queries() when an agent needs several independent result sets and the package should be loaded only once:

results = doc.queries([
    "select count(*) as rows from revenue",
    "select max(revenue_gbp) as max_revenue from revenue",
])

SQLite PRAGMA introspection works through read-only select queries:

doc.query("select name, pk from pragma_table_info('revenue') where pk > 0").rows

MCP Server

The official MCP server is the Rust mcd-mcp binary in crates/mcd-mcp. Use that for the runtime-neutral published server.

This Python package also provides a convenience MCP server for Python-first environments. Install the optional MCP dependencies when you want an AI agent to call MCD tools through the Python bindings:

pip install "mcdee[mcp]"

Run the server over stdio:

mcd-python-mcp

Equivalent module form:

python -m mcd.mcp_server

The server exposes these tools:

Tool Purpose
mcd_validate Validate a .mcd package and return diagnostics.
mcd_agent_context Return a compact machine-readable document overview.
mcd_markdown Read Markdown, optionally expanding table directives.
mcd_query Run read-only SQL against package tables and metadata.
mcd_queries Run multiple read-only SQL queries against one loaded package.
mcd_table Return table schema and optional row data.
mcd_chart Return chart metadata and optional source rows.
mcd_image Return image metadata.
mcd_annotations Return annotation metadata, optionally filtered.
mcd_relationships Return declared table relationships.
mcd_external_data Return manifest-declared external data references.
mcd_provenance Return package provenance metadata.
mcd_convert_pdf Convert a PDF into an MCD package.

Example MCP client configuration for a local stdio server:

{
  "mcpServers": {
    "mcd": {
      "command": "mcd-python-mcp"
    }
  }
}

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

mcdee-0.1.0a2.tar.gz (113.5 kB view details)

Uploaded Source

Built Distribution

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

mcdee-0.1.0a2-cp39-abi3-win_amd64.whl (4.8 MB view details)

Uploaded CPython 3.9+Windows x86-64

File details

Details for the file mcdee-0.1.0a2.tar.gz.

File metadata

  • Download URL: mcdee-0.1.0a2.tar.gz
  • Upload date:
  • Size: 113.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.13.3

File hashes

Hashes for mcdee-0.1.0a2.tar.gz
Algorithm Hash digest
SHA256 c32e3dc8cc5df24834f86c7cc0bb7874c7e46811403a4ecf6096681fa5db3729
MD5 26356ee72cb95444fd1628cce45b8ded
BLAKE2b-256 bf2ca2a4c1e57eca366e49108629e97fc08b50ba15776a5d11aa1e3a62e98330

See more details on using hashes here.

File details

Details for the file mcdee-0.1.0a2-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: mcdee-0.1.0a2-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 4.8 MB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.13.3

File hashes

Hashes for mcdee-0.1.0a2-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 e8980a65b538aec28b573667db6be7b7b95d6a141e63b34ebf234aa1a80fd464
MD5 54fc4eec54f86b3db457a8097d4cb9ed
BLAKE2b-256 36440ecea83120a8a2d6a9f72b27936c4072af83f315556668c83cf2ff7f2a44

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