Tool to convert Context7 formatted llms.txt to locally organized markdown library documentation
Project description
Context7 to Markdown (c2md)
A blazing fast tool that converts Context7 to organized markdown documentation with automatic directory structure, multi-language parsing support, and table of contents generation. Supports both local files and direct URLs from Context7.com.
Install with pip
pip install c2md
Install with uv
uv pip install c2md
or
uvx c2md https://context7.com/org/project
Why c2md? 🤔
MCP servers are fairly new and are quite rudimentary. They introduce latency, increase prompt size, consume tokens on every request, and, in the case of Context7, require network calls for each library lookup. Additionally, Context7's MCP server uses natural language search that can miss relevant sections or return results you don't even need.
With c2md, you convert a library once per project and reference it locally. Instead of making MCP calls that cost 4,000-20,000 tokens per search, you attach the generated 000-index.md (typically costs less than Context7's resolve-library-id alone) directly to your agent. The agent gets complete context without network delays or token waste on repeated or bad searches.
This tool excels when dealing with large libraries like Neon, which has around 240 sections (~520,000 tokens). The locally generated index provides instant, inexpensive library context to any section while consuming ~50% fewer tokens than equivalent MCP operations. You can even pass the table of contents or specific sections from the library via a rule in your favorite AI IDE.
If that didn't sell you, c2md:
- ⚓ Converts Context7 to local markdown
- 🧠 Logically organizes the library into sections with sequential file naming
- 🗨️ Consolidates multi-language sections into a single document
- 📜 Generates Table of contents = easy context for your agent
- 🗺️ Maps source URLs to appropriate file paths and names
- 🏎️ Fast as hell
Installation
Using pip
pip install c2md
Using uv
uv pip install c2md
or
uvx c2md https://context7.com/org/project
📋 Requirements
- Python 3.8 or higher
- No external dependencies required unless developing
🛠️ Usage
After installation, use the c2md command:
Basic Usage
From local file - output defaults to ./output/
c2md /path/to/llms.txt
From Context7 standard URL
c2md https://context7.com/org/project
From Context7 raw URL with tokens query
c2md https://context7.com/org/project/llms.txt?tokens=173800
Advanced Usage
# Specify output directory, 001-index.md (ToC) generated in output root
c2md /path/to/llms.txt -d /path/to/output
# From Context7 raw URL with output directory
c2md https://context7.com/org/project/llms.txt -d .docs/neon
# Disable ToC generation
c2md /path/to/llms.txt -nt
# Full example with all options, no table of contents
c2md https://context7.com/context7/supabase/llms.txt?tokens=1000000 -d /path/to/output -nt
Command Line Options
input_file|input_url: Context7 formatted llms.txt or Context7 URL (required)-d, --directory: Output directory (default: current directory)-nt, --no-toc: Disable table of contents generation in documentation root-np, --no-prefix: Disable "000-" prefix file naming-h, --help: Show help message and exit
Bug Reports
If you encounter any issues, please report them on the GitHub Issues page.
Developing locally & contributing
Contributing 🤝
Contributions are welcome! Please feel free to submit a PR if you would like to contribute or have an issue.
Development Installation
# Clone the repository
git clone https://github.com/crisp-sh/context7-to-markdown.git
cd context7-to-markdown
# Install in development mode
pip install -e .
Output Structure
The tool creates an organized directory structure:
output/
├── 001-index.md # Table of contents (if enabled)
├── domain1.com/
│ ├── section1/
│ │ ├── 001-page1.md
│ │ └── 002-page2.md
│ └── section2/
│ └── 001-page3.md
└── domain2.com/
└── docs/
└── 001-guide.md
Context7 Format
The tool processes Context7 format files, which should contain entries with:
- SOURCE: URL or source identifier
- CONTENT: The actual content to be converted
- TITLE: Optional title for the content
- LANGUAGE: Denotes a multi-language document
Architecture
The tool consists of several modular components:
- Parser: Processes Context7 format files
- URL Mapper: Maps source URLs to file paths
- File Organizer: Organizes content into directory structures
- Markdown Writer: Generates clean markdown files
- Index Generator: Creates table of contents
Testing
Run the test suite using Hatch:
# Run tests
hatch run test
# Run tests with coverage
hatch run test-cov
# Run specific test file
hatch run test tests/test_specific.py
Legacy Testing
# Install development dependencies
pip install -e ".[dev]"
# Run tests
python -m unittest discover tests
# Run tests with coverage
python -m unittest discover tests
Releasing
This project uses automated versioned releases with Hatch for version management.
Quick Release
# Create a patch release (0.1.0 → 0.1.1)
hatch run release patch
# Create a minor release (0.1.0 → 0.2.0)
hatch run release minor
# Create a major release (0.1.0 → 1.0.0)
hatch run release major
Development Setup
# Clone the repository
git clone https://github.com/crisp-sh/context7-to-markdown.git
cd context7-to-markdown
# Create a virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install
pip install -e .
Running Tests
# Run all tests with Hatch
hatch run test
# Run specific test file
hatch run test tests/test_specific.py
# Run tests with coverage
hatch run test-cov
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file c2md-1.1.0.tar.gz.
File metadata
- Download URL: c2md-1.1.0.tar.gz
- Upload date:
- Size: 20.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
33d17659240a65cd1203f2c1aa9caba5d9846acee9cb68c24d0a0fc7a51b6143
|
|
| MD5 |
e553f7a2821f6945a57785bb08876574
|
|
| BLAKE2b-256 |
d0e19d8a9d7ba70f06349395d6c1ca96ca55b684e09d2dc92dbbd9175132b72c
|
Provenance
The following attestation bundles were made for c2md-1.1.0.tar.gz:
Publisher:
release.yml on crisp-sh/context7-to-markdown
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
c2md-1.1.0.tar.gz -
Subject digest:
33d17659240a65cd1203f2c1aa9caba5d9846acee9cb68c24d0a0fc7a51b6143 - Sigstore transparency entry: 272670361
- Sigstore integration time:
-
Permalink:
crisp-sh/context7-to-markdown@3826335e322bfd5cf9a48d1a6e0b6fb1e87ecea0 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/crisp-sh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3826335e322bfd5cf9a48d1a6e0b6fb1e87ecea0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file c2md-1.1.0-py3-none-any.whl.
File metadata
- Download URL: c2md-1.1.0-py3-none-any.whl
- Upload date:
- Size: 24.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6bbf66db81c959c2afc12b080b5b159496a879359ae60c309e0436cb1ec7f767
|
|
| MD5 |
967598c2278069a103b1bc62ad42017f
|
|
| BLAKE2b-256 |
2362d30ef3a00b7cdc1e10575492944a675307ac6a03419def7ee2922b5fa810
|
Provenance
The following attestation bundles were made for c2md-1.1.0-py3-none-any.whl:
Publisher:
release.yml on crisp-sh/context7-to-markdown
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
c2md-1.1.0-py3-none-any.whl -
Subject digest:
6bbf66db81c959c2afc12b080b5b159496a879359ae60c309e0436cb1ec7f767 - Sigstore transparency entry: 272670363
- Sigstore integration time:
-
Permalink:
crisp-sh/context7-to-markdown@3826335e322bfd5cf9a48d1a6e0b6fb1e87ecea0 -
Branch / Tag:
refs/tags/v1.1.0 - Owner: https://github.com/crisp-sh
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@3826335e322bfd5cf9a48d1a6e0b6fb1e87ecea0 -
Trigger Event:
push
-
Statement type: