feat: add binary file attachment and import tools for Outline LTM system (#1)
Build and Push Outline MCP Docker Image / build (push) Successful in 14s

Implement 3 new MCP tools:
- attach_file_to_document(document_id, file_path)
- upload_image_to_document(image_path, document_id, alt_text)
- import_file_to_outline(file_path, collection_id, parent_document_id)

Security:
- Restrict file access to /tmp via _validate_file_path with realpath
- 50MB max file size enforced client-side
- Symlink traversal blocked

Technical:
- Extract shared _upload_attachment() helper
- Stream files to presigned URLs instead of loading into memory
- Add combined lifespan to close OutlineClient on shutdown
- Update CI workflow with modern action versions and PR triggers

Tests:
- Add 28 tests covering path validation, size limits, upload flow,
  error handling, symlink traversal, and multipart imports
This commit is contained in:
2026-05-25 00:36:54 +00:00
parent d152162dbf
commit 950a8fc441
6 changed files with 751 additions and 4 deletions
+41
View File
@@ -46,6 +46,27 @@ Params: method (required), params (JSON string)
Returns: Raw API response as JSON string
```
### attach_file_to_document
Upload a local file as an attachment to an existing Outline document.
```
Params: document_id (required), file_path (required — must be under /tmp)
Returns: JSON with attachment_url, markdown embed string, name, size, content_type
```
### upload_image_to_document
Upload an image file as an attachment and return Markdown image embed syntax.
```
Params: image_path (required — must be under /tmp), document_id (required), alt_text (optional)
Returns: JSON with attachment_url, markdown image embed, name, size, content_type
```
### import_file_to_outline
Import a local file (Markdown, text, JSON, CSV) as a new Outline document.
```
Params: file_path (required — must be under /tmp), collection_id (required), parent_document_id (optional)
Returns: JSON with newly created document metadata
```
---
## Outline API Reference
@@ -384,3 +405,23 @@ params: {"invites": [{"email": "user@example.com", "name": "User Name", "role":
method: "collections.create"
params: {"name": "Engineering", "description": "Engineering documentation", "permission": "read_write"}
```
### Attach a file to a document
```
document_id: "document-uuid"
file_path: "/tmp/report.pdf"
```
### Upload an image to a document
```
image_path: "/tmp/screenshot.png"
document_id: "document-uuid"
alt_text: "System architecture diagram"
```
### Import a Markdown file as a new document
```
file_path: "/tmp/notes.md"
collection_id: "collection-uuid"
parent_document_id: "parent-document-uuid" # optional
```