Skip to main content

Programmatic Word document generation with LaTeX equations, style presets, citations, charts, and MCP server

Project description

🔨 papersmith

CI

PyPI version

Python 3.10+

License: MIT

Typed

Programmatic Word document generation with LaTeX equations, academic formatting, citations, charts, and MCP server.

papersmith wraps python-docx into a fluent, high-level API that handles all the boilerplate for professional document generation. It bundles its own LaTeX-to-OMML equation pipeline, citation management with multiple styles, chart generation, metadata scrubbing, and exposes an MCP server so any LLM can generate documents directly.


✨ Features

  • 📝 Fluent Document API — Create professional Word documents with a clean, chainable API

  • 📐 LaTeX Equations — Inline $...$ and display $$...$$ equations rendered as native OMML (editable in Word)

  • 🎨 Style Presets — Academic, modern, report, formal, minimal — or define your own

  • 📚 Citations & Bibliography — APA, IEEE, Harvard, MLA, Chicago styles with BibTeX import

  • 📊 Charts & Infographics — Bar, line, pie, scatter charts via matplotlib, embedded as high-res images

  • 🔍 Live Editing — Open, navigate, find/replace, and modify existing documents

  • 💬 Review Support — Comments, footnotes, endnotes, and tracked changes

  • 📋 Metadata Management — Set or scrub author, dates, revision info — leave no generation fingerprints

  • 🤖 MCP Server — 25+ tools for LLM-powered document generation (works with Claude Desktop, Cursor, etc.)

  • ⌨️ CLI Interface — Generate documents from the command line

  • 🔌 LLM Provider Abstraction — Swap between OpenAI, Anthropic, Google with a config change

🚀 Quick Start

Installation

# Full install (all features included)

pip install papersmith

Create Your First Document

from papersmith import SmithDocument



doc = SmithDocument(preset="academic")

doc.add_cover_page(

    title="Advanced Algorithms: Lab Solutions",

    author="Jane Smith",

    institution="MIT"

)

doc.add_heading("Question 1: Merge Sort Analysis", level=2)

doc.add_text("The time complexity of merge sort is $O(n \\log n)$.")

doc.add_equation(r"T(n) = 2T\left(\frac{n}{2}\right) + \Theta(n)")

doc.add_table(

    headers=["Algorithm", "Best", "Average", "Worst"],

    rows=[

        ["Merge Sort", "$O(n \\log n)$", "$O(n \\log n)$", "$O(n \\log n)$"],

        ["Quick Sort", "$O(n \\log n)$", "$O(n \\log n)$", "$O(n^2)$"],

    ]

)

doc.set_metadata(author="Jane Smith", scrub=True)

doc.save("solutions.docx")

Citations

from papersmith import SmithDocument



doc = SmithDocument(preset="academic")

doc.citations.style = "ieee"



doc.citations.add_source("knuth1997",

    author="Donald E. Knuth",

    title="The Art of Computer Programming",

    year=1997,

    publisher="Addison-Wesley",

)



doc.add_heading("Literature Review")

doc.add_text("Sorting algorithms are well studied {cite:knuth1997}.")

doc.add_bibliography()

doc.save("paper.docx")

MCP Server (for LLM Integration)

# Start MCP server for Claude Desktop / Cursor

papersmith mcp-server --transport stdio

Claude Desktop config (claude_desktop_config.json):

{

  "mcpServers": {

    "papersmith": {

      "command": "papersmith",

      "args": ["mcp", "--transport", "stdio"]

    }

  }

}

VS Code workspace MCP config: put the same server definition in .vscode/mcp.json.

This repository includes a working example at examples/mcp_quickstart.py.

📦 Installation

pip install papersmith installs the full runtime feature set: documents, equations, citations, charts, PDF export, MCP, CLI, and LLM provider support.

For development tools only, install pip install -e ".[dev]".

🛠️ CLI Usage

# Generate a document from markdown

papersmith convert notes.md -o notes.docx --preset academic



# Generate with LLM assistance

papersmith generate questions.md -o solutions.docx --provider openai



# Scrub metadata from a document

papersmith scrub report.docx --author "John Doe"



# List available presets

papersmith presets



# Start MCP server

papersmith mcp-server --transport stdio

📖 Documentation

Full documentation is available at imnb57.github.io/papersmith.

🤝 Contributing

We welcome contributions! See CONTRIBUTING.md for guidelines.

# Clone and install for development

git clone https://github.com/imnb57/papersmith.git

cd papersmith

pip install -e ".[dev]"



# Run tests

pytest



# Lint and format

ruff check src/ tests/

ruff format src/ tests/



# Type check

mypy src/papersmith/

🚀 Releasing

This repository already includes a GitHub Actions release workflow at .github/workflows/release.yml.

To publish without Twine, tag a release and push it:

git tag v0.1.1

git push origin v0.1.1

The workflow uses PyPI trusted publishing, so no local Twine account or API token is needed once the PyPI project is configured for this GitHub repository.

Claiming papersmith on PyPI

  1. Sign in to your PyPI account.

  2. Open the papersmith project page on PyPI, or create the project by publishing the first release.

  3. In the project settings, add a trusted publisher for this repository: imnb57/papersmith.

  4. Keep the GitHub Actions workflow environment name as pypi to match the PyPI trusted publisher entry.

  5. Tag v0.1.1 and push it once the trusted publisher is saved.

📄 License

MIT License. See LICENSE for details.

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

papersmith-0.1.3.tar.gz (70.2 kB view details)

Uploaded Source

Built Distribution

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

papersmith-0.1.3-py3-none-any.whl (58.8 kB view details)

Uploaded Python 3

File details

Details for the file papersmith-0.1.3.tar.gz.

File metadata

  • Download URL: papersmith-0.1.3.tar.gz
  • Upload date:
  • Size: 70.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for papersmith-0.1.3.tar.gz
Algorithm Hash digest
SHA256 6ba0296cae4ff460c6556ed228f57e77c0bc61b76ed842d319620fe9c24ed890
MD5 da8474aa061e3b79fc2aa87414b1d0f3
BLAKE2b-256 ec50c8c6fd7b6294186d75d0eca141771924b0fc5581e93bd3070213040d82f0

See more details on using hashes here.

Provenance

The following attestation bundles were made for papersmith-0.1.3.tar.gz:

Publisher: release.yml on imnb57/papersmith

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file papersmith-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: papersmith-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 58.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for papersmith-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 6a45cefc0fc3e54283c4bad2a09606607e085a4caf53d9d8a3ab5a9c7f9a2c51
MD5 dfaa574e44cf50904eb34950b7dbb9f4
BLAKE2b-256 d78ebb409e7074086668d808592ffc02281f51aa13decd59442ff75efd14f558

See more details on using hashes here.

Provenance

The following attestation bundles were made for papersmith-0.1.3-py3-none-any.whl:

Publisher: release.yml on imnb57/papersmith

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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