Commit Graph

9 Commits

Author SHA1 Message Date
Stefan Lohmaier 936ebc2f56 feat(pdf): gemeinsames pdfutil — Scan-PDFs als Bild + OCR (Files & Mail)
Scan-/bildbasierte PDFs werden jetzt von Files-MCP (read_file) UND Mail-MCP
(read_attachment) ueber das gemeinsame Modul pdfutil.py verarbeitet: Seiten via
PyMuPDF als PNG (150dpi, max 20) + OCR-Text (tesseract deu+eng). Verschluesselte/
kaputte PDFs bleiben graceful. Deps: pymupdf, pytesseract (+ system tesseract-ocr).
76 Tests gruen.
2026-06-19 08:46:00 +02:00
Stefan Lohmaier b555a2e19d security: redirect_uri-Allowlist + mail Path-Traversal-Schutz
- common.py /authorize: redirect_uri muss https://claude.ai/ oder https://claude.com/ sein
  (verhindert offenen Redirect / Code-Abfluss an fremde URIs).
- mail/server.py _open_folder: realpath-Check, Ordner muss im Account-Verzeichnis
  bleiben (Path-Traversal verhindert).
- tests: get_token_pkce auf sicheren Flow aktualisiert (erlaubte redirect_uri +
  client_secret). 54/54 Tests gruen.
test-Client bleibt (Test-Suite braucht ihn, Secret 600-geschuetzt).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-18 10:09:23 +02:00
Stefan Lohmaier 37a24bc5b5 mail: malloc_trim nach search_mail/read_attachment gegen RSS-Bloat
search_mail dekodiert bei breiten Queries den Body jeder Mail; CPython/glibc
gibt den Peak-RSS nicht ans OS zurueck -> Prozess wuchs auf 6.2 GB und hat
zusammen mit einem 2-TB-Restic-Lauf den Server-RAM/Swap gesprengt (restic OOM).
Fix: gc.collect()+malloc_trim(0) nach den speicherintensiven Tools.
Zusaetzlich systemd MemoryMax=2G/MemoryHigh=1.5G als Sicherheitsnetz (Drop-In, nicht im Repo).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-18 08:54:33 +02:00
root bced937a24 mail: PDF-Anhaenge als extrahierten Text zurueckgeben
read_attachment extrahiert PDF-Text serverseitig via pdfplumber und liefert
ihn als TextContent (statt EmbeddedResource-Blob, den claude.ai nicht lesen
kann). Bei Scan-/Bild-PDFs ohne Text: Hinweis + Blob-Fallback.
Loest 'Connector kann PDF nicht lesen' bei Buchungsbestaetigungen etc.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 09:39:01 +02:00
root 56d92c153b mail: robustes Decoding gegen unbekannte Charsets (x-unknown); OAuth-Token 30 Tage
- _safe_decode() faengt LookupError bei unbekannten/kaputten Mail-Charsets
  (z.B. 'x-unknown') ab, Fallback utf-8 -> latin-1. Verhindert Crash der
  Mail-Suche/Read bei einzelnen kaputt-kodierten Mails.
- common.py: OAuth access_token Lifetime 24h -> 30 Tage (weniger Re-Auth in claude.ai)
- .gitignore: *.before-* Backups ausschliessen

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-17 09:37:15 +02:00
Stefan Lohmaier c06e6d6b4c Joplin via Data API + Mail attachments
Notes server rewritten to use Joplin CLI Data API (joplin-cli sync
clients on host, ports 41184/41185). Clean fast search, proper
resource handling. New tools: list_note_resources, read_resource
(attachments as inline image/document/text).

Mail server: read_mail now lists attachments; new read_attachment
tool returns images inline, PDFs/docs as EmbeddedResource, text directly.

Tests: 54 total. Notes now real (notebooks, list, create+read).
Mail attachment listing + fetch tested.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-12 12:26:26 +02:00
Stefan Lohmaier ef37d1e467 Fix Mail Maildir paths and oCIS auth
Mail: INBOX is a subfolder (INBOX/cur), not the account root.
Removed special-case mapping that pointed INBOX to root dir.

Files: oCIS user may differ from MCP user (e.g. stefan -> admin).
Added _ocis_user() mapping for WebDAV paths and auth.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-12 10:22:27 +02:00
Stefan Lohmaier 1f98695821 Add create_draft tool to Mail server
Creates email drafts via IMAP APPEND to the Drafts folder.
Supports Stefan (1blu, Drafts folder) and Kati (Gmail, Entwürfe).
Draft can be reviewed and sent from Roundcube or phone.

IMAP credentials externalized to config.json.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-12 08:16:53 +02:00
Stefan Lohmaier fb642e47c8 Initial commit: 5 MCP servers for Mail, Calendar, Contacts, Files, Notes
Self-hosted MCP servers with OAuth client_credentials auth.
Each server connects to a different backend:
- Mail: reads Maildir IMAP backups
- Calendar/Tasks: CalDAV against Radicale
- Contacts: CardDAV against Radicale
- Files: WebDAV against oCIS
- Notes: Joplin REST API

Credentials externalized to config.json (not in repo).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-06-12 06:22:42 +02:00