Skip to content

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]>
archawat added a commit to archawat/mcp-directus that referenced this pull request Dec 1, 2025
- Add unique constraint warnings for resolve/reject fields
- Document correct workflow for inserting operations into chains
- Add data reference patterns ($last.field, {{key.field}})
- Update system prompt with operation chaining section
- Add common mistakes directus#11-13 for operation errors
- Improve create-operation and update-operation descriptions
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