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.1.tar.gz (90.1 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.1-py3-none-any.whl (59.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: papersmith-0.1.1.tar.gz
  • Upload date:
  • Size: 90.1 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.1.tar.gz
Algorithm Hash digest
SHA256 b121ca30881e2c79d24c268776099f83b50f5ee9913d45252bf24806233b39bb
MD5 55b084502e7d274ddb9944fb02f71d29
BLAKE2b-256 46fb610f3b06c94ccf640b4f1fab287bb0a0d7fe40f38ff17eda7d5e901b3c07

See more details on using hashes here.

Provenance

The following attestation bundles were made for papersmith-0.1.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: papersmith-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 59.6 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f140464cbac1cac3bdb93e60bb3961d28b29feabba4da9a9dc1270ebad888d0f
MD5 7630ecafc735f3b8262eac6cd5e1b71a
BLAKE2b-256 e76e544b786aecf58e561bdcb0e579635808c3f56281ac99901815fe4a7de098

See more details on using hashes here.

Provenance

The following attestation bundles were made for papersmith-0.1.1-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