feat(mcp): queue local OpenCode ingest jobs
Add optional write-capable MCP ingest tools for chunked uploads, SHA-verified completion, and asynchronous local OpenCode wiki-ingest jobs. The tools remain disabled by default and are gated by OBSIDIAN_MCP_ENABLE_INGEST or mcp_service.sh start --enable-ingest. Remote clients can upload files into the vault inbox, start a restricted fixed-prompt ingest job, poll job status/result, and cancel queued or running work. The implementation keeps arbitrary prompt and shell execution out of the MCP surface. Validation: python3 -m unittest discover -v; python3 -m py_compile obsidian_wiki/mcp_ingest.py obsidian_wiki/mcp_server.py scripts/manage_mcp_service.py tests/test_mcp_ingest.py tests/test_mcp_server_remote.py tests/test_mcp_service.py; git diff --check.
This commit is contained in:
@@ -376,6 +376,22 @@ Customize the first startup if needed:
|
||||
bash scripts/mcp_service.sh start --vault /path/to/vault --host 0.0.0.0 --port 9876 --path /wiki-mcp
|
||||
```
|
||||
|
||||
To let a remote MCP client upload files and ask this machine's local OpenCode to run the normal `wiki-ingest` workflow, start the same service with ingest tools enabled:
|
||||
|
||||
```bash
|
||||
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.
|
||||
- `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.
|
||||
|
||||
Rotate the token later with:
|
||||
|
||||
```bash
|
||||
|
||||
Reference in New Issue
Block a user