rtfs
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
rtfs is an asynchronous Python 3.11+ CLI, SDK, and FastMCP server that queries multiple screenplay archives, parses PDF and HTML layouts into a typed Pydantic v2 Abstract Syntax Tree, and exports to JSON, Fountain, or dialogue analytics.
Table of Contents
Related MCP server: starc-mcp
Quick Start
Install via Homebrew or pip / uv:
# Homebrew (macOS & Linux)
brew install AtaCanYmc/tap/rtfs
# PyPI
pip install "pyrtfs[all]"
# Local editable install
uv pip install -e ".[dev]"
rtfs --helpSearch across configured screenplay providers:
rtfs search "The Matrix"Fetch, parse, and export a screenplay to Fountain or JSON:
rtfs get "The Matrix" --format fountain --output matrix.fountain
rtfs get "The Matrix" --format json --output matrix.jsonCompute scene and character dialogue metrics:
rtfs stats "The Matrix"Architecture
rtfs separates upstream HTTP retrieval from structural parsing. Every provider returns a RawScript payload containing raw bytes or strings alongside ScriptMetadata. Specialized parsers transform RawScript into a canonical ScriptDocument AST before handing it to exporters or the progressive-disclosure MCP layer.
flowchart LR
CLI["CLI / SDK / FastMCP"] --> AGG["ScriptAggregator"]
AGG --> P1["ScriptSlugProvider (PDF)"]
AGG --> P2["TVWritingProvider (PDF)"]
AGG --> P3["IMSDbProvider (HTML)"]
AGG --> P4["SubsLikeScriptProvider (Text)"]
P1 & P2 & P3 & P4 --> RAW["RawScript + CacheBackend"]
RAW --> PDF["PdfScreenplayParser"]
RAW --> HTML["HtmlScreenplayParser"]
RAW --> TXT["TranscriptParser"]
PDF & HTML & TXT --> AST["ScriptDocument AST"]
AST --> EXP1["JSON Exporter"]
AST --> EXP2["Fountain Exporter"]
AST --> EXP3["Stats Exporter"]Parsing Mechanics
PDF Coordinate Clustering (
PdfScreenplayParser): Extracts text spans and bounding boxes via PyMuPDFpage.get_text("dict"). Strips headers abovey0 < 50, footers belowy1 > 740, page numbers, revision stamps, and continuation markers. Groups horizontalx0offsets within an 8pt tolerance to classify action margins, dialogue columns, parentheticals, character cues, and right-aligned transitions. Consecutive lines in the same column merge when vertical delta is under1.5xline height.HTML Indentation & Tag Parsing (
HtmlScreenplayParser): Extracts<td class="scrtext"><pre>blocks from IMSDb documents. Handles both<b>-delimited character cues and whitespace-indented scripts through 1D margin clustering.Transcript Normalization (
TranscriptParser): ParsesSPEAKER: linepatterns and bracketed stage directions from HTML or plain-text transcripts intoScriptDocumentscenes.
MCP Server
Full feature-length screenplays typically span 25,000 to 35,000 tokens. The rtfs Model Context Protocol (MCP) server exposes progressive-disclosure tools so AI agents can search titles, inspect the scene heading index, fetch bounded scene ranges (max 10 scenes per call), or filter dialogue by character and keyword without exhausting their context window.
Installation
pip install "pyrtfs[mcp]"
# or install all optional extras (Redis + MCP)
pip install "pyrtfs[all]"Exposed MCP Tools & Resources
Tool / Resource | Parameters | Description |
|
| Searches across active providers and returns concise metadata records. |
|
| Returns metadata, total scene count, top 15 speaking characters, and a full |
|
| Returns a single scene or inclusive range (hard-capped at 10 scenes per call) in Fountain or JSON format. |
|
| Case-insensitive filtering of dialogue turns by character name and/or keyword. |
|
| Returns scene counts, |
|
| MCP resource returning the complete Fountain screenplay when a client explicitly attaches it. |
Client Configuration (claude_desktop_config.json / Cursor)
{
"mcpServers": {
"rtfs": {
"command": "uvx",
"args": ["--from", "pyrtfs[mcp]", "rtfs", "mcp"],
"env": {
"RTFS_CACHE_URL": "disk://~/.cache/rtfs"
}
}
}
}Or if installed directly into an environment:
{
"mcpServers": {
"rtfs": {
"command": "rtfs",
"args": ["mcp", "--transport", "stdio"]
}
}
}Caching
rtfs uses a pluggable async CacheBackend protocol operating strictly on bytes. By default, responses cache locally on disk at ~/.cache/rtfs using DiskCacheBackend.
Supported Cache URIs
URI Pattern | Backend Class | Description |
|
| Default SQLite-backed disk cache offloaded via |
|
| Async Redis cache ( |
|
| Ephemeral in-memory dictionary with monotonic TTL expiration. |
|
| No-op cache backend (equivalent to |
Configuring Cache via Environment or CLI
# Override via environment variable
export RTFS_CACHE_URL="redis://localhost:6379/0"
rtfs search "The Matrix"
# Override per command via --cache-url
rtfs get "The Matrix" --cache-url "disk:///tmp/rtfs-cache"
# Disable caching for a single invocation
rtfs stats "The Matrix" --no-cacheTo use the Redis backend, install the optional redis extra:
pip install "pyrtfs[redis]"Repository Layout
rtfs/
├── .editorconfig
├── .gitattributes
├── .gitignore
├── .markdownlint.json
├── .release-please-manifest.json
├── assets/
│ └── logo.svg
├── CHANGELOG.md
├── CONTRIBUTING.md
├── LICENSE
├── Makefile
├── README.md
├── release-please-config.json
├── ROADMAP.md
├── SECURITY.md
├── pyproject.toml
├── src/
│ └── rtfs/
│ ├── __init__.py
│ ├── cli/
│ │ └── main.py
│ ├── core/
│ │ ├── aggregator.py
│ │ ├── cache/
│ │ │ ├── __init__.py
│ │ │ ├── base.py
│ │ │ ├── disk.py
│ │ │ ├── factory.py
│ │ │ ├── memory.py
│ │ │ ├── null.py
│ │ │ └── redis.py
│ │ ├── http.py
│ │ └── models.py
│ ├── exporters/
│ │ ├── fountain_exp.py
│ │ ├── json_exp.py
│ │ └── stats_exp.py
│ ├── mcp/
│ │ ├── __init__.py
│ │ └── server.py
│ ├── parsers/
│ │ ├── base.py
│ │ ├── html_screenplay.py
│ │ ├── pdf_screenplay.py
│ │ └── transcript.py
│ └── providers/
│ ├── base.py
│ ├── imsdb.py
│ ├── scriptslug.py
│ ├── subslikescript.py
│ └── tvwriting.py
└── tests/
├── fixtures/
│ └── sample_imsdb.html
├── test_aggregator.py
├── test_cache.py
├── test_exporters.py
├── test_mcp.py
├── test_parsers.py
└── test_security.pyCLI Reference
Command | Argument / Flag | Default | Description |
|
| Required | Title query string to match across providers. |
|
|
| Filter by provider: |
|
|
| Include fallback subtitle transcripts from |
|
|
| Cache backend URI ( |
|
|
| Disable caching ( |
|
| Required | Title query string or direct script URL. |
|
|
| Output format: |
|
|
| Destination file path. Writes to |
|
|
| Restrict search to a single provider. |
|
|
| Fall back to transcript sources when screenplay sources miss. |
|
|
| Cache backend URI. Overrides |
|
|
| Disable caching ( |
|
| Required | Title query string or direct script URL to analyze. |
|
|
| Restrict search to a single provider. |
|
|
| Allow transcript sources for statistics calculation. |
|
|
| Cache backend URI. Overrides |
|
|
| Disable caching ( |
|
|
| MCP transport protocol: |
|
|
| Bind host when running SSE transport. |
|
|
| Bind port when running SSE transport. |
|
|
| Cache backend URI. Overrides |
|
|
| Disable caching ( |
Python SDK
import asyncio
from rtfs import (
MemoryCacheBackend,
ScriptAggregator,
compute_stats,
export_fountain,
export_json,
)
async def main() -> None:
# Pass a CacheBackend instance, a URI string ("redis://localhost:6379/0"), or None
cache = MemoryCacheBackend(default_ttl=3600)
async with ScriptAggregator(cache=cache) as agg:
results = await agg.search("The Matrix", allow_transcript=False)
for item in results[:3]:
print(f"{item.title} [{item.source}] score={item.score}")
doc = await agg.get("The Matrix")
fountain_text = export_fountain(doc)
json_payload = export_json(doc)
stats = compute_stats(doc)
print(f"Scenes: {stats.total_scenes} | INT/EXT: {stats.int_ext_ratio}")
for char in stats.top_characters[:5]:
print(f"{char.character}: {char.dialogue_turns} turns, {char.word_count} words")
asyncio.run(main())FAQ
Why are transcripts excluded by default?
Subtitle transcripts lack scene headings, action paragraphs, parentheticals, and character modifiers. rtfs prioritizes shooting scripts and production drafts from scriptslug, tvwriting, and imsdb. Pass --allow-transcript or allow_transcript=True when a transcript is acceptable.
How do I implement a custom cache backend?
Implement the four async methods of CacheBackend (get, set, delete, close) operating on bytes, and pass your instance to ScriptAggregator(cache=MyCustomCache()). All Pydantic serialization uses JSON and base64 encoding at the provider boundary rather than pickle.
Why is rtfs licensed under AGPL-3.0-or-later?
rtfs depends directly on PyMuPDF (pymupdf) for coordinate-based PDF extraction. PyMuPDF is distributed under the GNU Affero General Public License v3.0. Licensing rtfs under AGPL-3.0-or-later maintains full legal compliance with upstream copyleft terms.
Development & Verification
Run the linter and unit test suite via Makefile or directly:
make help
make check
# or directly:
.venv/bin/ruff check .
.venv/bin/pytest -vLicense
Copyright (c) 2026 AtaCanYmc. Distributed under the GNU Affero General Public License v3.0 or later.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
YouTube transcripts, search, channel/playlist listings and upload tracking for AI agents.
Read-only tools for the approved public KOKU SCRIPTS AI Catalog.
Web data for agents: YouTube transcripts, screenshots, Google News, WHOIS, jobs, tech stack, more.
Search ATProto writing, annotations, identity, agents, and forum posts. 12 read-only tools.
Related MCP Servers
- AlicenseAqualityCmaintenanceEnables screenwriters to search for similar scenes, fetch scene details, list indexed movies, find mood reference scenes, and get analysis style guidance, all grounded in real produced scripts.5MIT
- FlicenseBqualityCmaintenanceEnables LLM agents to read and write Story Architect (.starc) project files, including scripts, scenes, statistics, and character/location data.13-
- AlicenseNot gradedqualityCmaintenanceEnables assistants to read and write filmmaking projects: import Final Draft, WriterDuet or Fountain scripts, OCR PDFs and scans, edit scenes and elements, search the script, and create or update storyboard shots with panel cutting and reference images. Connects over remote Streamable HTTP with OAuth sign-in and 22 tools, with versioned script history and confirmation before deletions.MIT
- AlicenseNot gradedqualityBmaintenanceEnables a scriptwriting agent to build and query a persistent, per-project ledger of story propositions and each character's knowledge state, so every proposed line of dialogue is checked before it is written and blocked when it uses information that character cannot yet know. Also supports full-script leak audits, incremental scene ingestion, wiki-style ledger lookups, and waiving false positives with an auditable decision trail.MIT