Files
obsidian-wiki/.env.example
T
Codex d3bd7f0c08 feat(mcp): issue upload tickets for ingest
Add short-lived single-use HTTP upload tickets that authenticated MCP clients can request before uploading files to /mcp-ingest/uploads. This lets remote agents use curl without needing to read or expose the main MCP bearer token, avoiding oversized base64 tool arguments for larger files.

The upload endpoint now accepts either the normal bearer token or X-Obsidian-Wiki-Upload-Token. Ticket defaults can carry project, doc_type_hint, note, start_job, and file-count limits while uploads still stage outside the vault.

Validation: python3 -m unittest discover -v; python3 -m py_compile obsidian_wiki/mcp_ingest.py obsidian_wiki/mcp_server.py tests/test_mcp_ingest.py tests/test_mcp_server_remote.py; git diff --check
2026-07-05 16:45:37 +00:00

135 lines
5.4 KiB
Bash

# =============================================================================
# Obsidian Wiki — Environment Configuration
# Copy this to .env and set your vault path
# =============================================================================
# --- Required ---
# Absolute path to your Obsidian vault
OBSIDIAN_VAULT_PATH=
# --- Optional ---
# Comma-separated source directories to ingest documents from
# Leave empty to skip document ingestion
OBSIDIAN_SOURCES_DIR=
# Copy file-based sources into the vault before ingest so citations survive
# machine moves and Linux/Web deployment. Archived files are immutable and
# tracked in _meta/source-registry.jsonl.
WIKI_ARCHIVE_SOURCES=true
OBSIDIAN_SOURCE_ARCHIVE_DIR=_sources/archive
# Maintain content-based source catalog pages that link to archived originals
# without copying the same file into multiple folders.
WIKI_SOURCE_CATALOG=true
OBSIDIAN_SOURCE_CATALOG_DIR=_sources/catalog
# SQLite source-file locator. Leave empty to use _meta/file-assets.sqlite.
OBSIDIAN_FILE_ASSET_DB=
# --- Source File MCP Server (optional) ---
#
# Run with: obsidian-wiki-mcp
# Install extra: pip install "obsidian-wiki[mcp]"
# The MCP server serves only safe engineering source files by default.
OBSIDIAN_MCP_BOT_PROFILE=bjd-general-bot
OBSIDIAN_MCP_MAX_FILE_BYTES=26214400
OBSIDIAN_MCP_EXPOSE_PATHS=false
# Optional remote Streamable HTTP MCP mode.
# Run locally:
# OBSIDIAN_MCP_TOKEN='<long-random-token>' obsidian-wiki-mcp --transport streamable-http
# Or manage a user-level service:
# bash scripts/mcp_service.sh start
# Rotate token later with:
# bash scripts/mcp_service.sh new-token
OBSIDIAN_MCP_TOKEN=
OBSIDIAN_MCP_HOST=127.0.0.1
OBSIDIAN_MCP_PORT=8765
OBSIDIAN_MCP_PATH=/mcp
OBSIDIAN_MCP_ENABLED_TOOLS=file-assets
# 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.
# 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.
# Preferred remote file upload path: POST multipart/form-data to
# /mcp-ingest/uploads. Agents that cannot read the main MCP bearer token should
# call `create_ingest_upload_ticket` first and send the returned
# X-Obsidian-Wiki-Upload-Token header. `get_ingest_upload_instructions` returns
# exact fields/examples.
# Keep this runtime root outside OBSIDIAN_VAULT_PATH; uploads are staging inputs,
# and wiki-ingest decides how sources are archived into the vault.
# 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
OBSIDIAN_MCP_INGEST_MAX_FILE_BYTES=104857600
OBSIDIAN_MCP_INGEST_MAX_CHUNK_BYTES=4194304
OBSIDIAN_MCP_INGEST_MAX_FILES_PER_JOB=10
OBSIDIAN_MCP_INGEST_OPENCODE_PATH=opencode
OBSIDIAN_MCP_INGEST_RUNTIME_ROOT=.runtime/mcp-ingest
# Wiki categories (directories created in the vault)
OBSIDIAN_CATEGORIES=concepts,entities,skills,references,synthesis,journal
# Max pages to create/update per ingest operation
OBSIDIAN_MAX_PAGES_PER_INGEST=15
# Claude conversation history path (auto-discovered from ~/.claude if empty)
CLAUDE_HISTORY_PATH=
# Codex history path (defaults to ~/.codex if empty)
CODEX_HISTORY_PATH=
# Pi agent session history path (defaults to ~/.pi/agent/sessions if empty)
PI_HISTORY_PATH=
# Lint schedule: daily | weekly | manual
LINT_SCHEDULE=weekly
# Internal link format for generated/updated pages
# wikilink (default) → [[concepts/foo]] or [[concepts/foo|display text]]
# markdown → [display text](relative/path.md)
# Only affects future writes — existing vault content is never migrated automatically.
OBSIDIAN_LINK_FORMAT=wikilink
# --- QMD Semantic Search (optional) ---
#
# QMD indexes your wiki and sources for fast semantic search.
# Install: https://github.com/tobi/qmd
# After installing, point these at your QMD collection names (set when you ran `qmd index`).
#
# Without QMD: wiki-ingest and wiki-query fall back to Grep/Glob — fully functional, just slower.
# With QMD: semantic search replaces grep passes, enabling concept-level matches and cross-collection queries.
# Name of the QMD collection indexing your compiled wiki pages (OBSIDIAN_VAULT_PATH)
QMD_WIKI_COLLECTION=
# Name of the QMD collection indexing your raw source documents (OBSIDIAN_SOURCES_DIR or _raw/)
QMD_PAPERS_COLLECTION=
# QMD integration transport: mcp | cli
# mcp preserves the original behavior and uses an agent-configured QMD MCP server.
# cli runs the local qmd command directly; useful for agents without QMD MCP support.
QMD_TRANSPORT=mcp
# CLI search quality mode: quality | balanced | fast
# quality: qmd query with reranking (best relevance, slowest on CPU)
# balanced: qmd query --no-rerank (good hybrid results, faster)
# fast: qmd vsearch (semantic only) or qmd search when exact terms matter
QMD_CLI_SEARCH_MODE=quality
# Optional qmd binary override if qmd is not on PATH.
QMD_CLI=qmd
# --- Raw Staging Directory (optional) ---
#
# A directory inside OBSIDIAN_VAULT_PATH for unprocessed draft pages.
# Drop rough notes, clipboard pastes, or quick captures here.
# wiki-ingest will promote them to proper wiki pages when you run it.
# Promoted files are deleted from _raw/ after processing.
OBSIDIAN_RAW_DIR=_raw