Skip to content

Fix DISABLE_TOOLS array parsing error #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DanielSinclair
Copy link

@DanielSinclair DanielSinclair commented Jul 9, 2025

Problem

The current implementation expects DISABLE_TOOLS to be an array directly in the Zod schema:

DISABLE_TOOLS: z
  .array(z.string())
  .default(['delete-item'])

However, environment variables are always strings. When users set:

export DISABLE_TOOLS='["delete-item", "update-field"]'

The configuration parsing would fail because the string couldn't be converted to an array.

Solution

Updated the configuration schema to accept a JSON string and parse it into an array:

DISABLE_TOOLS: z
  .string()
  .default('["delete-item"]')
  .transform((val) => JSON.parse(val))
  .pipe(z.array(z.string()))

Changes Made

  1. src/config.ts: Modified DISABLE_TOOLS schema to parse JSON strings
  2. README.md: Updated example configuration to show proper JSON string format:
    - "DISABLE_TOOLS": ["delete-item", "update-field"],
    + "DISABLE_TOOLS": "[\"delete-item\", \"update-field\"]",

Real-world Usage

Users can now properly set this in their environment:

# Shell
export DISABLE_TOOLS='["delete-item", "update-field", "read-users"]'

# .env file
DISABLE_TOOLS=["delete-item", "update-field"]
{
  "mcpServers": {
    "directus": {
      "command": "npx",
      "args": ["@directus/content-mcp@latest"],
      "env": {
        "DIRECTUS_URL": "https://your-directus-instance.com",
        "DIRECTUS_TOKEN": "your_directus_token",
        "DISABLE_TOOLS": "[\"delete-item\", \"update-field\"]"
      }
    }
  }
}

* Initial plan

* Initial commit - no changes yet, planning the fix

Co-authored-by: DanielSinclair <[email protected]>

* Fix DISABLE_TOOLS JSON parsing error

- Add JSON parsing to config schema
- Update docs to use valid JSON format
- Fix mcpServers examples with escaped quotes

Co-authored-by: DanielSinclair <[email protected]>

* Remove package-lock.json and add to .gitignore

Co-authored-by: DanielSinclair <[email protected]>

* Update .gitignore

---------

Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: DanielSinclair <[email protected]>
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.

2 participants