A Sesamcp config, without code of its own¶
Supersedes the module of ADR 0005; its licence stays.
Context and Problem Statement¶
ADR 0005 moved this server onto Sesamcp but kept 890 lines of Python, and Sesamcp had parameters that existed only for them. A tool that turns an API into MCP tools without code should not need code for Paperless.
Decision Outcome¶
The repository is config/sesamcp.yaml, an OpenAPI Overlay, the bundled spec, and tests. The image is FROM ghcr.io/marceltov/sesamcp. Every part of server.py has its replacement or its reason to go:
server.py |
Now |
|---|---|
| spec from the instance, boot wait, bundled fallback | openapi.spec (wait from PAPERLESS_SPEC_WAIT) |
PAPERLESS_API_SPEC |
dropped: mount your own /config/sesamcp.yaml |
API version from info.version in Accept |
openapi.headers with match; a spec without one gives startup_error instead of Paperless's oldest shapes |
PAPERLESS_API_VERSION |
dropped, as above |
| toolsets, never exposed, guides, hints, instructions, permission hint | the same names in the config |
update_version never exposed ("FastMCP can't express the upload") |
now a tool: Sesamcp sends the multipart form |
| JSON where a body is also offered as a form | Sesamcp does it for every API |
fields comma-separated, the notes' second id, the mail account's body |
overlay.yaml |
| boilerplate descriptions replaced by a sentence from the name | overlay.yaml, written out per operation |
| the paging note on every list tool | one line in the instructions |
| download, preview, thumbnail | file answers: an image, text as text, anything else as a file |
upload with content (text) or content_base64 |
content_base64 only; also POST /upload/<tool> |
from_webui left out of the upload |
overlay.yaml |
| waiting up to a minute for a queued bulk task, and failing the call when the task failed | dropped: only Paperless would use it. The answer's task_id is returned; the guide and the instructions say to check tasks_list before reporting success |
| username, password and code traded for the token; Paperless's own reason for a refusal | login.exchange, reason |
a pasted token checked at /api/profile/ |
login.verify; filling in both ways is refused |
| no revoke at Paperless | none |
Token or no scheme in the client's header |
Bearer <token> is what is documented |
token prefix pmcp_, its store salt |
dropped: everyone signs in again |
MCP_AUTH_MODE |
dropped: OAuth, and a raw API token, always. MCP_BASE_URL and MCP_OAUTH_SECRET are required |
MCP_PATH |
dropped: /mcp |
MCP_HOST, MCP_PORT, MCP_ALLOWED_HOSTS, /health |
Sesamcp's, unchanged |
| the error server for a wrong auth configuration | dropped: the container stops with the reason in its log |
| runs as root | runs as user 10001: an existing /data volume needs that owner |
Consequences¶
- Good: an improvement to Sesamcp is a new base image, nothing more.
- Bad: a bulk edit whose task fails answers like one that succeeds, unless the model looks the task up as it is told to. This is the one guarantee the port gives up.
- Bad: a stale
pmcp_token is passed to Paperless as a raw token, so an old connector shows tools whose calls fail until it is reconnected by hand.
Confirmation¶
Built on Sesamcp 0.3.2 (its security release; 0.5.0 is the first release of this form). It adds create_upload, a URL that takes one file for a signed-in client, MCP_PROXY_HOPS for the limit on wrong logins, and a 10 MiB cap on every answer.
49 unit tests on the app production serves, and the whole suite (77) against a throwaway Paperless-ngx with the image: upload, versions, bulk edit, trash, files, sign-in, refresh and revoke. The tools that need an AI backend, a mail server or PDFs are listed as untested in test_coverage.py.