Skip to main content
Glama
README.md
# Frappe Files MCP

A clean, portable, open-source **Frappe v16+** app that encapsulates Frappe's built-in MCP server and adds bidirectional **ChatGPT file exchange**, **Desk-parity private attachment reading** (with native MCP image vision and pure-Python document extraction), and **on-demand Report & Document exports** behind a single OAuth-protected Streamable HTTP endpoint.

## Key Features

- **Unified 21-Tool MCP Endpoint**: Exposes all 13 native `frappe.mcp.tools` alongside 8 file-exchange and report/document export tools at `/api/method/frappe_files_mcp.mcp.gateway.endpoint`.
- **Bidirectional ChatGPT File Exchange**:
  - **Inbound (`openai/fileParams`)**: `upload_and_attach_files` and `create_document_with_files` declare `_meta["openai/fileParams"] = ["files"]` with flattened JSON schemas so ChatGPT can upload user files directly.
  - **SSRF-Hardened Streaming**: HTTPS downloads use DNS-pinned public IP connections (`PinnedHTTPSConnection`), wildcard host allowlists, magic-byte validation, size/timeout budgets, and optional ClamAV scanning.
  - **Outbound Inspection & Vision**: `get_attachment` returns native MCP `image` blocks (including scanned PDF page rendering via `pdftoppm`), pure-Python text extraction for PDF, DOCX, XLSX, CSV, TXT, and JSON, plus `frappe-file://delivery/<token>` resource links and 5-minute single-actor authenticated download URLs.
- **On-Demand Reports & Document PDFs**: `list_reports`, `run_and_export_report` (paginated JSON + `.xlsx` / `.pdf`), and `export_document_pdf` with Desk-parity permissions and optional Print Format allowlists.
- **Zero-Leak Diagnostics & Private Storage**: Uploaded files default to `is_private=1` with `MCP File Proof` SHA-256 metadata. Host allowlist rejections report only the hostname (never full URLs or query tokens).

## Quickstart

```bash
bench get-app https://github.com/ztechnium/frappe_files_mcp.git
bench --site <your-site> install-app frappe_files_mcp
bench --site <your-site> migrate
```

1. Open **System Settings** in Frappe Desk and enable **Enable MCP** (under API/MCP settings).
2. Open **Frappe Files MCP Settings** in Desk, verify **Enable Frappe Files MCP** is checked, and click **Copy MCP URL**.
3. Connect your OAuth client (e.g., ChatGPT) to:
   `https://<your-site>/api/method/frappe_files_mcp.mcp.gateway.endpoint`

## Tool Overview (21 Tools)

- **Frappe Core (13 tools)**: `search_doctypes`, `get_doctype_schema`, `search_methods`, `get_method_schema`, `list_document_methods`, `list_documents`, `get_document`, `count_documents`, `create_document`, `update_document`, `delete_document`, `call_method`, `call_document_method`
- **File Exchange & Exports (8 tools)**: `get_file_capabilities`, `list_attachments`, `get_attachment`, `upload_and_attach_files`, `create_document_with_files`, `list_reports`, `run_and_export_report`, `export_document_pdf`

See [docs/tools-reference.md](docs/tools-reference.md) for full parameter schemas and examples.

## Documentation

- [Architecture & Protocol Design](docs/architecture.md)
- [Deployment, Nginx, Cloudflare & Frappe Setup](docs/deployment-and-proxies.md)
- [Tools Reference (21 Tools)](docs/tools-reference.md)
- [Security & Threat Model](docs/security.md)

## Running Tests

```bash
python -m unittest discover -s frappe_files_mcp/tests -v
```

## License

MIT — see [LICENSE](LICENSE).