feat(mcp): add simplified ingest uploads

Add a one-shot IngestManager upload path, an ingest_file_base64 MCP tool, and an authenticated /mcp-ingest/uploads multipart HTTP endpoint so remote agents can transfer files without manual chunk orchestration.

Keep uploaded files in runtime staging outside the vault and let wiki-ingest/OpenCode decide archival, registry updates, and index rebuilds.

Update service output, docs, and agent rules to make the preferred upload path discoverable while preserving chunked tools as a fallback.

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:
Codex
2026-07-05 16:32:33 +00:00
parent ef2e44656d
commit d7daf2f210
9 changed files with 493 additions and 15 deletions
+18
View File
@@ -28,6 +28,7 @@ MCP_CLIENT_NAME = "wiki-file-assets"
DEFAULT_HOST = "0.0.0.0"
DEFAULT_PORT = 8765
DEFAULT_PATH = "/mcp"
DEFAULT_INGEST_UPLOAD_PATH = "/mcp-ingest/uploads"
DEFAULT_TOKEN_BYTES = 32
DEFAULT_UV_CACHE_DIR = "/tmp/uv-cache"
DEFAULT_OPENCODE_PATH = "opencode"
@@ -340,6 +341,22 @@ def render_remote_config(
enabled_section = ""
if enabled_tools is not None:
enabled_section = f"\nEnabled tool groups:\n{format_enabled_tools(enabled_tools) or 'none'}\n"
ingest_upload_section = ""
if enabled_tools is not None and TOOL_INGEST in normalize_enabled_tools(enabled_tools):
upload_url = f"http://{host}:{port}{DEFAULT_INGEST_UPLOAD_PATH}"
upload_alternatives = "\n".join(
f"- http://{candidate}:{port}{DEFAULT_INGEST_UPLOAD_PATH}" for candidate in hosts[1:]
)
upload_alternatives_section = (
f"\nOther ingest upload addresses:\n{upload_alternatives}\n" if upload_alternatives else ""
)
ingest_upload_section = (
"\n"
"Ingest file upload endpoint:\n"
f"{upload_url}\n"
f"{upload_alternatives_section}"
"Use the same Authorization header. POST multipart/form-data with one or more `files` fields.\n"
)
return (
"MCP service is running.\n"
"\n"
@@ -348,6 +365,7 @@ def render_remote_config(
f"{alternatives_section}"
f"{config_section}"
f"{enabled_section}"
f"{ingest_upload_section}"
"\n"
"Use this header:\n"
f"Authorization: Bearer {token}\n"