feat(mcp): configure enabled tool groups
Add OBSIDIAN_MCP_ENABLED_TOOLS as the service config source for MCP tool groups while keeping OBSIDIAN_MCP_ENABLE_INGEST as a legacy fallback. Add mcp_service.sh tools list/enable/disable commands, preserve enabled tools across normal start and token rotation, and let start --enable-ingest/--disable-ingest update the same config file. Teach the MCP runtime to derive file-assets and ingest registration from enabled tool groups so file asset tools can be disabled separately from ingest. Validation: python3 -m unittest discover -v; python3 -m py_compile scripts/manage_mcp_service.py obsidian_wiki/mcp_server.py tests/test_mcp_service.py tests/test_mcp_server_remote.py; CLI tools enable/disable dry run; git diff --check.
This commit is contained in:
@@ -368,7 +368,7 @@ For long-running access from another machine, use the managed user service:
|
||||
bash scripts/mcp_service.sh start
|
||||
```
|
||||
|
||||
`mcp_service.sh start` creates `.runtime/obsidian-wiki-mcp.env` with `0600` permissions if it does not exist, writes `~/.config/systemd/user/obsidian-wiki-mcp.service`, starts the service, and prints the remote URL, `Authorization` header, and client JSON to copy into another agent. It serves the configured `OBSIDIAN_VAULT_PATH` by default; pass `--vault /path/to/vault` to override. The service defaults to `0.0.0.0:8765/mcp` because it is intended for remote clients, but it still requires the bearer token. Prefer SSH tunnel, Tailscale, WireGuard, or another trusted network boundary instead of directly exposing the port to the public internet.
|
||||
`mcp_service.sh start` creates `.runtime/obsidian-wiki-mcp.env` with `0600` permissions if it does not exist, writes `~/.config/systemd/user/obsidian-wiki-mcp.service`, starts the service, and prints the remote URL, `Authorization` header, enabled tool groups, config file path, and client JSON to copy into another agent. It serves the configured `OBSIDIAN_VAULT_PATH` by default; pass `--vault /path/to/vault` to override. The service defaults to `0.0.0.0:8765/mcp` because it is intended for remote clients, but it still requires the bearer token. Prefer SSH tunnel, Tailscale, WireGuard, or another trusted network boundary instead of directly exposing the port to the public internet.
|
||||
|
||||
Customize the first startup if needed:
|
||||
|
||||
@@ -376,12 +376,28 @@ 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:
|
||||
Tool groups are controlled by the same config file:
|
||||
|
||||
```bash
|
||||
OBSIDIAN_MCP_ENABLED_TOOLS=file-assets
|
||||
```
|
||||
|
||||
Edit that line directly, or use the service command:
|
||||
|
||||
```bash
|
||||
bash scripts/mcp_service.sh tools list
|
||||
bash scripts/mcp_service.sh tools enable ingest
|
||||
bash scripts/mcp_service.sh tools disable ingest
|
||||
```
|
||||
|
||||
To let a remote MCP client upload files and ask this machine's local OpenCode to run the normal `wiki-ingest` workflow, enable the `ingest` tool group and restart/start the same service:
|
||||
|
||||
```bash
|
||||
bash scripts/mcp_service.sh start --enable-ingest
|
||||
```
|
||||
|
||||
After `ingest` is enabled once, later `bash scripts/mcp_service.sh start` preserves the config file setting. Use `bash scripts/mcp_service.sh start --disable-ingest` or `bash scripts/mcp_service.sh tools disable ingest` to turn it off.
|
||||
|
||||
This adds write-capable MCP tools to the same `wiki-file-assets` server and bearer token. The server is tool-first: some MCP clients may show empty `resources` or `prompts` lists until a concrete `asset://source/sha256/...` URI is returned by `get_file_asset_metadata`, so use the tool list as the source of truth.
|
||||
|
||||
- `create_ingest_upload` — reserves a controlled runtime staging path for one uploaded file.
|
||||
@@ -405,6 +421,9 @@ Useful service commands:
|
||||
|
||||
```bash
|
||||
bash scripts/mcp_service.sh show-config
|
||||
bash scripts/mcp_service.sh tools list
|
||||
bash scripts/mcp_service.sh tools enable ingest
|
||||
bash scripts/mcp_service.sh tools disable ingest
|
||||
bash scripts/mcp_service.sh stop
|
||||
bash scripts/mcp_service.sh uninstall
|
||||
bash scripts/mcp_service.sh status
|
||||
|
||||
Reference in New Issue
Block a user