Skip to content

feat: add FILE_TOOLS_ENABLED env var to conditionally hide file tools#363

Merged
aliasunder merged 8 commits into
mainfrom
worktree-file-tools-enabled
Jul 25, 2026
Merged

feat: add FILE_TOOLS_ENABLED env var to conditionally hide file tools#363
aliasunder merged 8 commits into
mainfrom
worktree-file-tools-enabled

Conversation

@aliasunder

@aliasunder aliasunder commented Jul 22, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds FILE_TOOLS_ENABLED env var (default true) that hides vault_read_file and vault_list_files when set to false
  • Follows the exact MEMORY_ENABLED pattern: config parsing, conditional tool registration, cross-reference stripping from other tool descriptions and server metadata, startup logging
  • Full deploy surface coverage: 4 compose files, 3 .env.example files, CLI env sync, 2 CI workflows, server.json, README, DEPLOY, ARCHITECTURE, deploy guides, DOCKERHUB

Use case: Remote deployments where Obsidian Sync has asset syncing disabled — no files on disk, so the file tools just produce "not found" noise and waste tool-description tokens in the MCP handshake.

What stays unchanged:

  • vault_get_outgoing_links still reports file links (kind: "file") — it indexes from the links table, not the file tools
  • File config vars (MAX_FILE_BYTES, MAX_IMAGE_OUTPUT_BYTES, MAX_PDF_RENDER_PAGES) are still parsed when disabled (same as MEMORY_DIR when MEMORY_ENABLED=false)
  • Internal code keeps "asset" names (registerAssetTools, assetOperations)

Test plan

  • npm test — 2065 tests pass (11 new: 6 config, 3 tool registration, 2 router metadata)
  • npm run lint — 0 errors
  • npm run build — compiles cleanly
  • templates.test.ts — CI drift guard confirms compose ↔ .env.example ↔ CLI consistency
  • Verify FILE_TOOLS_ENABLED=false hides both file tools from the tool list
  • Verify disabled tool names don't appear in any remaining tool description

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added a FILE_TOOLS_ENABLED setting, enabled by default.
    • File tools can now be hidden by setting FILE_TOOLS_ENABLED=false.
    • Server instructions and tool descriptions now reflect whether file tools are available.
    • File links remain available through link-related features when file tools are disabled.
  • Documentation

    • Updated setup, deployment, configuration, and local/remote usage documentation with the new option.

When set to false, vault_read_file and vault_list_files are hidden from
the tool list entirely — useful for remote deployments where Obsidian
Sync has asset syncing disabled and no files exist on disk.

Follows the exact MEMORY_ENABLED pattern: config parsing, conditional
tool registration, cross-reference stripping from other tool
descriptions and server metadata, startup logging, and full deploy
surface coverage (compose files, .env.examples, CI workflows,
server.json, README, DEPLOY, ARCHITECTURE, deploy guides, DOCKERHUB).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@umm-actually

umm-actually Bot commented Jul 22, 2026

Copy link
Copy Markdown

PR Code Suggestions ✨

Explore these optional code suggestions:

CategorySuggestion                                                                                                                                    Impact
General
Fix docs claiming file config vars are ignored when disabled

The README/DOCKERHUB description claims file config vars are ignored when
FILE_TOOLS_ENABLED is false, but the implementation in config.ts still parses
MAX_FILE_BYTES, MAX_IMAGE_OUTPUT_BYTES, and MAX_PDF_RENDER_PAGES unconditionally.
The test "still parses MAX_FILE_BYTES when disabled" and ARCHITECTURE.md both
confirm these are still parsed. Update the docs to state they are still parsed
rather than ignored.

DOCKERHUB.md [147]

-| `FILE_TOOLS_ENABLED`        | —           | `true`                               | Set `false` to hide file tools (`vault_read_file`, `vault_list_files`) — useful for remote deployments where Obsidian Sync has asset syncing disabled. File config vars (`MAX_FILE_BYTES`, etc.) are ignored when `false`.                                     |
+| `FILE_TOOLS_ENABLED`        | —           | `true`                               | Set `false` to hide file tools (`vault_read_file`, `vault_list_files`) — useful for remote deployments where Obsidian Sync has asset syncing disabled. File config vars (`MAX_FILE_BYTES`, etc.) are still parsed when disabled.                             |
Suggestion importance[1-10]: 5

__

Why: The suggestion corrects a documentation inaccuracy in DOCKERHUB.md — the implementation still parses file config vars when FILE_TOOLS_ENABLED is false, so the docs should say "still parsed" instead of "ignored". This is a minor but helpful fix, improving documentation accuracy.

Low

Comment thread DOCKERHUB.md Outdated
aliasunder and others added 4 commits July 24, 2026 13:56
README.md and DOCKERHUB.md claimed "File config vars (MAX_FILE_BYTES,
etc.) are ignored when false" but config.ts unconditionally parses and
validates them — an invalid value crashes at startup regardless of
FILE_TOOLS_ENABLED. ARCHITECTURE.md correctly says "still parsed when
disabled." Remove the misleading sentence rather than replace it; the
core description is sufficient without it.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HXbBfT61iG6EwV7ce42xX1
Replace the IIFE in mcp-router.ts instructions construction with plain
const intermediates (matching the existing searchDescription pattern).
Extract two inline ternaries from the outgoing-links tool description
into named clauses (fileReadableClause, fileBytesClause).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HXbBfT61iG6EwV7ce42xX1
Both deploy/local/README.md and deploy/remote/README.md add a
## File Tools section but the Contents navigation line at the top
of each doc was missing the [File Tools](#file-tools) link.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HXbBfT61iG6EwV7ce42xX1
@aliasunder

Copy link
Copy Markdown
Owner Author

@CodeRabbit review

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

File tools feature flag

Layer / File(s) Summary
Configuration contract
src/vault-mcp/config.ts, src/vault-mcp/__tests__/config.test.ts
Adds fileToolsEnabled, parses FILE_TOOLS_ENABLED with a default of true, and validates boolean handling and related limits.
Conditional MCP exposure
src/vault-mcp/mcp-core/..., src/vault-mcp/server.ts
Conditionally registers file tools and removes their references from instructions, prompts, descriptions, and startup logging when disabled.
Feature-flag coverage
src/vault-mcp/mcp-core/__tests__/*
Tests tool registration, initialization instructions, and orientation prompt behavior with file tools disabled.
Environment propagation
.github/workflows/*, cli/src/env.ts, deploy/*, docker-compose*.yml, server.json
Adds the setting to deployment workflows, generated environment files, Compose services, and server configuration metadata.
Configuration documentation
README.md, ARCHITECTURE.md, DEPLOY.md, DOCKERHUB.md, AGENTS.md, deploy/*/README.md, .env.example
Documents the default, opt-out behavior, deployment guidance, and retained outgoing-link reporting.Estimated code review effort: 3 (Moderate)

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding FILE_TOOLS_ENABLED to hide file tools conditionally.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch worktree-file-tools-enabled

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@deploy/local/.env.example`:
- Around line 56-58: Reorder the FILE_TOOLS_ENABLED block before MEMORY_ENABLED
in both deploy/local/.env.example lines 56-58 and deploy/remote/.env.example
lines 70-72, keeping each block’s content unchanged and maintaining consistent
ordering across the deployment templates.

In `@src/vault-mcp/mcp-core/__tests__/mcp-router.test.ts`:
- Around line 297-299: Replace non-null assertions with explicit precondition
checks: in src/vault-mcp/mcp-core/__tests__/mcp-router.test.ts at lines 297-299
and 316-318, verify the first mocked McpServer constructor call exists before
accessing its options; in
src/vault-mcp/mcp-core/__tests__/tool-definitions.test.ts at lines 760-764,
explicitly fail when a non-file tool lacks a description before scanning its
contents.

In `@src/vault-mcp/mcp-core/__tests__/tool-definitions.test.ts`:
- Around line 733-758: The non-file registration test currently checks only the
count, allowing omissions and duplicates to go unnoticed. Update the test around
registerWithDisabledFileTools and NON_FILE_TOOL_COUNT to compare the registered
tool names against the exact ALL_TOOL_NAMES set excluding FILE_TOOLS, and add a
separate assertion that registered names contain no duplicates.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: af7f91ab-a429-4d51-9eca-1792fe02c75f

📥 Commits

Reviewing files that changed from the base of the PR and between 3599efc and 03e3db1.

📒 Files selected for processing (29)
  • .env.example
  • .github/workflows/deploy.yml
  • .github/workflows/test_deploy.yml
  • AGENTS.md
  • ARCHITECTURE.md
  • DEPLOY.md
  • DOCKERHUB.md
  • README.md
  • cli/src/env.ts
  • deploy/local/.env.example
  • deploy/local/README.md
  • deploy/local/docker-compose.yml
  • deploy/remote/.env.example
  • deploy/remote/README.md
  • deploy/remote/docker-compose.yml
  • docker-compose.local.yml
  • docker-compose.yml
  • server.json
  • src/vault-mcp/__tests__/config.test.ts
  • src/vault-mcp/config.ts
  • src/vault-mcp/mcp-core/__tests__/mcp-router.test.ts
  • src/vault-mcp/mcp-core/__tests__/tool-definitions.test.ts
  • src/vault-mcp/mcp-core/__tests__/vault-orientation-prompt.test.ts
  • src/vault-mcp/mcp-core/mcp-router.ts
  • src/vault-mcp/mcp-core/prompts/vault-orientation-prompt.ts
  • src/vault-mcp/mcp-core/tool-definitions.ts
  • src/vault-mcp/mcp-core/tools/search-tools.ts
  • src/vault-mcp/mcp-core/tools/vault-crud-tools.ts
  • src/vault-mcp/server.ts

Comment thread deploy/local/.env.example
Comment thread src/vault-mcp/mcp-core/__tests__/mcp-router.test.ts Outdated
Comment thread src/vault-mcp/mcp-core/__tests__/tool-definitions.test.ts Outdated
aliasunder and others added 3 commits July 24, 2026 14:55
…ertion

- mcp-router.test.ts: replace `!` with `?.` + `toHaveLength(1)` precondition
- tool-definitions.test.ts: replace count-only assertion with exact set
  comparison (catches omission+duplication); add `toBeDefined()` guard
  replacing `!` on description access

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HXbBfT61iG6EwV7ce42xX1
Obsidian calls non-markdown files "attachments" — "asset" is internal
code vocabulary that doesn't match what users see in their Sync settings.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HXbBfT61iG6EwV7ce42xX1
@aliasunder
aliasunder merged commit ee5dd09 into main Jul 25, 2026
15 checks passed
@aliasunder
aliasunder deleted the worktree-file-tools-enabled branch July 25, 2026 17:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant