fix(mcp): stage ingest uploads outside vault

Move remote MCP ingest uploads from the vault inbox to the MCP runtime staging area so uploaded files are not accepted into the vault before wiki-ingest processes them.

Reject ingest runtime roots that resolve inside the vault, and update the generated OpenCode prompt plus docs to describe uploads as temporary staging inputs.

Validation: python3 -m unittest discover -v; python3 -m py_compile obsidian_wiki/mcp_ingest.py tests/test_mcp_ingest.py; git diff --check
This commit is contained in:
Codex
2026-07-05 15:04:16 +00:00
parent 691e5aa8ea
commit e7adfbe9a6
5 changed files with 36 additions and 4 deletions
+2 -2
View File
@@ -384,13 +384,13 @@ bash scripts/mcp_service.sh start --enable-ingest
This adds write-capable MCP tools to the same `wiki-file-assets` server and bearer token:
- `create_ingest_upload` — reserves a controlled inbox path for one uploaded file.
- `create_ingest_upload` — reserves a controlled runtime staging path for one uploaded file.
- `append_ingest_upload_chunk` — appends base64 file chunks; defaults to 4MB decoded chunks.
- `complete_ingest_upload` — verifies declared size and SHA-256.
- `start_ingest_job` — queues a local `opencode run --auto --format json` job with a fixed `/wiki-ingest` prompt for the completed uploads.
- `get_ingest_job_status`, `get_ingest_job_result`, `cancel_ingest_job` — inspect or cancel the local job.
Uploads land under `<vault>/_sources/inbox/mcp-upload/`. Job state and logs live under `.runtime/mcp-ingest/`. The ingest prompt is generated by the MCP service and restricts OpenCode to the uploaded file list; clients cannot pass arbitrary shell commands through this interface. Because enabling ingest gives the remote token write access to the vault through local OpenCode, keep it on a trusted network and rotate the token if it has been shared too broadly.
Uploads land under `.runtime/mcp-ingest/uploads/`, outside the Obsidian vault, and are treated only as temporary source staging. Job state and logs live under `.runtime/mcp-ingest/jobs/`. The MCP server refuses to enable ingest if `OBSIDIAN_MCP_INGEST_RUNTIME_ROOT` points inside the vault; let `wiki-ingest` decide how to archive sources into `_sources/archive/`, update registries, and rebuild the file index. The ingest prompt is generated by the MCP service and restricts OpenCode to the uploaded file list; clients cannot pass arbitrary shell commands through this interface. Because enabling ingest gives the remote token write access to the vault through local OpenCode, keep it on a trusted network and rotate the token if it has been shared too broadly.
Rotate the token later with: