Skip to content

Tool Filtering

Chris edited this page Jul 18, 2026 · 130 revisions

Token Optimization: Context-Aware Tooling

Tools Resources Prompts
Code Mode

Value Proposition Conserve context window space and reduce LLM inference costs. Streamline agent tasks with targeted capabilities by systematically filtering irrelevant tools. Read the full value proposition.


Streamline Operations with Context-Aware Tooling

Filter easily using whitelist mode. Specify the desired preset or group. This automatically disables everything else.

Recommended Default:

{
  "mcpServers": {
    "mysql-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@neverinfamous/mysql-mcp",
        "--transport",
        "stdio",
        "--tool-filter",
        "starter"
      ],
      "env": {
        // Local testing requires port 3307 and root/root
        "MYSQL_HOST": "localhost",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "user",
        "MYSQL_PASSWORD": "<YOUR_PASSWORD>",
        "MYSQL_DATABASE": "database",
        "REDIS_URL": "redis://localhost:6379",
        "ALLOWED_IO_ROOTS": "/path/to/allowed/dir"
      }
    }
  }
}

Combine groups using the + prefix to build focused capabilities. For example, to enable core operations alongside text search tools:

Core + Text:

{
  "mcpServers": {
    "mysql-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@neverinfamous/mysql-mcp",
        "--transport",
        "stdio",
        "--tool-filter",
        "core,+text"
      ],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "user",
        "MYSQL_PASSWORD": "<YOUR_PASSWORD>",
        "MYSQL_DATABASE": "database",
        "REDIS_URL": "redis://localhost:6379",
        "ALLOWED_IO_ROOTS": "/path/to/allowed/dir"
      }
    }
  }
}

Docker Default:

{
  "mcpServers": {
    "mysql-mcp": {
      "command": "docker",
      "args": [
        "run",
        "-i",
        "--rm",
        "-e",
        "MYSQL_HOST=host.docker.internal",
        "-e",
        "MYSQL_USER=user",
        "-e",
        "MYSQL_PASSWORD=<YOUR_PASSWORD>",
        "-e",
        "MYSQL_DATABASE=database",
        "-e",
        "REDIS_URL=redis://host.docker.internal:6379",
        "-e",
        "ALLOWED_IO_ROOTS=/tmp/sandbox",
        "writenotenow/mysql-mcp:<VERSION>",
        "--transport",
        "stdio",
        "--tool-filter",
        "starter"
      ]
    }
  }
}

Context Window Optimization

Note

Exclusions (-) CAN be combined with whitelists/presets. This excludes specific tools from a broader group (e.g., --tool-filter "starter,-codemode").

  1. Whitelist Mode (Recommended): Precision control for optimal context window efficiency. Enforce strict capability boundaries by starting with a curated preset or standalone group.

    • group → Specify a group without a preset. Only tools in that group are enabled.
    • starter → Enables core, json, text, and codemode tools.
    • core,+text → Enables core AND text tools.
  2. Legacy/Exclusion Mode: Start with -group.

    • -core → Enables ALL tools, then removes core tools.

Syntax Reference:

Prefix Target Example Effect
+ (or none) Preset starter Base Preset: Enable ONLY this preset as the foundation
(none) Tool mysql_read_query Exclusive Whitelist: Enable ONLY this tool
- Group -json Disable tools in that specific group
(none) Group text Exclusive Whitelist: Enable ONLY tools in this group (when used in isolation)
+ Group +text Context-Aware Modifier: Append tools from this group to the active selection
- Tool -mysql_drop_table Disable one specific tool
+ Tool +mysql_create_index Enable one specific tool

🛠️ Create Custom Toolchains

List individual tool names (without + prefix) to create a fully custom whitelist. This enables only your specified tools:

# Enable specific tools (whitelist mode)
--tool-filter "mysql_read_query,mysql_write_query,mysql_list_tables"

# Mix tools from different groups
--tool-filter "mysql_read_query,mysql_create_index,mysql_json_extract"

# Combine with a preset or group
--tool-filter "core,+mysql_like_search,+mysql_json_stats"

This helps automated clients needing minimal capabilities. Note: codemode is included in the starter preset. It is not globally auto-injected.


📦 Use Curated Presets

Use presets to load relevant tools for specific tasks. Run the server executable with --help for the full, current list of presets.

Prominent Examples:

  • starter: The recommended default (a preset containing multiple groups: core, json, text, and codemode).

Manage Tool Groups

If you need fine-grained control, use individual groups. Run the server executable with --help for the complete current mapping. Note that the mysql_tool_index prompt indexes tools only, not tool groups.

Prominent Categories:

  • Query & Data (core, json, text): Foundational read/write capabilities and formatting.
  • Code Mode (codemode): V8 sandbox for server-side execution.
  • Performance (performance): Query execution plans and optimization tools.
  • ProxySQL (proxysql): Manage routing rules and connection pooling.

Explore Related Topics

MySQL MCP Documentation

Value Proposition Enforce strict execution boundaries and maximize LLM context efficiency for secure, autonomous database interactions. Read the full value proposition

🏠 Home


Launch Your Setup


Connect Ecosystem Tools


Security & Compliance


Scale Your Operations


Explore External Links

Clone this wiki locally