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.2.tar.gz (69.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.2-py3-none-any.whl (59.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: papersmith-0.1.2.tar.gz
  • Upload date:
  • Size: 69.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.2.tar.gz
Algorithm Hash digest
SHA256 2496851e34870d2df338e0e61914c97b679e740d7c82c38ac65b84dba1a979f2
MD5 c47df6610439a37447094bb84f592b26
BLAKE2b-256 851160dfa75d96caeb04b147f5651085a333565e52328a76e8656f932f21f884

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: papersmith-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 59.3 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dd560ded57f10f6f0f014ed9235f998e6a140fd20a345d9962cce7cf12a886b2
MD5 28a2de78d53d209482dff03419eb711b
BLAKE2b-256 d91629da1df1c10f49b5819fedec2634e0b37769a09c4eb7b686a035b0c66373

See more details on using hashes here.

Provenance

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