feat(mcp): harden remote assets and job execution

Gate source-file downloads and verify registry paths and content hashes. Stream multipart uploads with bounded limits, supervise OpenCode jobs with explicit result markers and timeouts, and preserve managed endpoint security settings. Document the trusted-client boundary and add focused regression coverage.

Validation: PYTHONPATH=<staged-tree> python -m unittest discover -s tests (182 tests)
This commit is contained in:
Codex
2026-07-09 21:44:48 +00:00
parent d47bb2c549
commit 7eb9b987ab
16 changed files with 3709 additions and 500 deletions
+23 -1
View File
@@ -40,10 +40,13 @@ OBSIDIAN_BUSINESS_FACTS_DB=
#
# Run with: obsidian-wiki-mcp
# Install extra: pip install "obsidian-wiki[mcp]"
# The MCP server serves only safe engineering source files by default.
# Metadata/search is limited to safe engineering source files. Downloading the
# underlying source bytes is a separate opt-in and defaults off for new managed
# installs; metadata tools remain available when it is disabled.
OBSIDIAN_MCP_BOT_PROFILE=bjd-general-bot
OBSIDIAN_MCP_MAX_FILE_BYTES=26214400
OBSIDIAN_MCP_EXPOSE_PATHS=false
OBSIDIAN_MCP_ALLOW_SOURCE_FILES=false
# Optional remote Streamable HTTP MCP mode.
# Run locally:
@@ -57,10 +60,22 @@ OBSIDIAN_MCP_HOST=127.0.0.1
OBSIDIAN_MCP_PORT=8765
OBSIDIAN_MCP_PATH=/mcp
OBSIDIAN_MCP_ENABLED_TOOLS=file-assets
# Optional public URLs shown to remote agents in capabilities/config output.
# Set PUBLIC_BASE_URL when /mcp is behind DNS/tunnel/reverse proxy.
OBSIDIAN_MCP_PUBLIC_BASE_URL=
# Set only when the ingest upload endpoint has a different public URL.
OBSIDIAN_MCP_INGEST_PUBLIC_UPLOAD_URL=
# Comma-separated HTTP Host and Origin allowlists. Managed service installs
# derive these from their bind/public URLs; set them explicitly for manual HTTP
# deployments, especially behind a tunnel or reverse proxy.
OBSIDIAN_MCP_ALLOWED_HOSTS=
OBSIDIAN_MCP_ALLOWED_ORIGINS=
# Optional write-capable MCP ingest tools. Default is disabled.
# When enabled, remote MCP clients sharing this token can upload files and
# trigger a local `opencode run --auto` wiki-ingest job for those uploads.
# The prompt entrypoint is fixed, but `--auto` has no enforced shell sandbox.
# Enable ingest/query only for trusted clients behind a trusted network boundary.
# After enabling, call the MCP tool `check_ingest_opencode_readiness` before
# the first upload; set run_smoke_test=true to verify OpenCode can load the
# project wiki-ingest skill without editing files.
@@ -74,9 +89,15 @@ OBSIDIAN_MCP_ENABLED_TOOLS=file-assets
# Prefer OBSIDIAN_MCP_ENABLED_TOOLS=file-assets,ingest for new configs. This
# legacy flag is still read when OBSIDIAN_MCP_ENABLED_TOOLS is absent.
OBSIDIAN_MCP_ENABLE_INGEST=0
# Multipart files are streamed to spooled storage. The parser enforces the
# per-file cap while consuming each part.
OBSIDIAN_MCP_INGEST_MAX_FILE_BYTES=104857600
OBSIDIAN_MCP_INGEST_MAX_CHUNK_BYTES=4194304
OBSIDIAN_MCP_INGEST_MAX_FILES_PER_JOB=10
# 0 derives the total request cap from max-file-bytes * max-files plus multipart
# overhead. A positive value sets an additional, stricter total request cap.
OBSIDIAN_MCP_INGEST_MAX_REQUEST_BYTES=0
OBSIDIAN_MCP_INGEST_JOB_TIMEOUT_SECONDS=1800
OBSIDIAN_MCP_OPENCODE_PATH=opencode
OBSIDIAN_MCP_INGEST_OPENCODE_PATH=opencode
OBSIDIAN_MCP_INGEST_OPENCODE_MODEL=openai/gpt-5.5
@@ -94,6 +115,7 @@ OBSIDIAN_MCP_INGEST_RUNTIME_ROOT=.runtime/mcp-ingest
OBSIDIAN_MCP_QUERY_OPENCODE_MODEL=openai/gpt-5.5
OBSIDIAN_MCP_QUERY_OPENCODE_VARIANT=minimal
OBSIDIAN_MCP_QUERY_MAX_CHARS=8000
OBSIDIAN_MCP_QUERY_JOB_TIMEOUT_SECONDS=300
OBSIDIAN_MCP_QUERY_RUNTIME_ROOT=.runtime/mcp-query
# Wiki categories (directories created in the vault)