Skip to content

Parameters do not bind for MySQL custom tools #4084

Closed

Description

@mihai1git

Prerequisites

  • I've searched the current open issues
  • I've updated to the latest version of Toolbox

Toolbox version

toolbox version 1.12.0+binary.windows.amd64.c97ca4d

Environment

  1. OS type and version: Windows 11 v.25H2
  2. How are you running Toolbox:
  • As a downloaded binary (e.g. from curl -o toolbox.exe "https://storage.googleapis.com/mcp-toolbox-for-databases/v%VERSION%/windows/amd64/toolbox.exe")
  1. Database: mysql-8.0.26-winx64

Client

  1. Client: windows command line
  2. Version: Windows 11 command line
  3. Example:
# Windows 11 command line (complex JSON syntax due to error: params must be a valid JSON string):
toolbox --config tools.yaml invoke search-language "{\""language\"": \""en\""}" 
# tools.yaml
kind: source
name: datasets-db
type: mysql
host: 127.0.0.1
port: 3308
database: datasets
user: <user>
password: <pass>
---
kind: tool
name: search-language
type: mysql-sql
source: datasets-db
description: >-
    Retrieves all countries where language as parameter (ex: English) is spoken.
statement: |
  select name , languages from countries_data where languages LIKE CONCAT('%', $1, '%');
parameters:
  - name: language
    type: string
    description: "The searched language code (ex: ps,uz,tk,en,sm )"

Expected Behavior

Replace the positional parameter $1 and execute query from tool: search-language.

Current Behavior

Parameter $1 is not replaced with the given value.
Error: tool execution failed: error processing request: unable to execute query: Error 1054 (42S22): Unknown column '$1' in 'where clause'

Steps to reproduce?

  1. start MySQL on localhost
  2. invoke localhost-tool from command line

Additional Details

No response

Activity

  1. added
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Sep 18, 2026
  2. added theissue type on Sep 18, 2026
  3. UmeshCode1 commented on Sep 28, 2026

    @UmeshCode1

    Hi @mihai1git!

    The error Error 1054 (42S22): Unknown column '$1' in 'where clause' occurs because the mysql-sql tool runner uses MySQL's native prepared statement parameter syntax, which uses ? question mark placeholders rather than PostgreSQL positional placeholders ($1, $2, etc.).

    Because $1 is not a MySQL placeholder syntax, MySQL's SQL parser interprets $1 as an unquoted column identifier in the WHERE clause, which fails because no such column exists.

    Solution

    Change $1 to ? in your statement:

    kind: tool
    name: search-language
    type: mysql-sql
    source: datasets-db
    description: >-
        Retrieves all countries where language as parameter (ex: English) is spoken.
    statement: |
      select name, languages from countries_data where languages LIKE CONCAT('%', ?, '%');
    parameters:
      - name: language
        type: string
        description: "The searched language code (ex: ps,uz,tk,en,sm)"

    Notes on Parameter Mapping:

    • In mysql-sql, parameters defined under parameters: are bound sequentially to each ? in the order they are declared in the YAML file.
    • If you have multiple parameters, ensure their order in the parameters list matches the occurrence order of ? in your statement.
    • If you ever need dynamic substitutions for table or column identifiers (which prepared statements don't allow), use templateParameters with {{.paramName}} syntax instead.
  4. duwenxin99 commented on Sep 29, 2026

    @duwenxin99
    Contributor

    Hi @mihai1git, feel free to refer to our doc for a working MySQL example. Thanks @UmeshCode1 for the answer.

  5. added
    type: questionRequest for information or clarification.
    and removed
    type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.
    on Sep 29, 2026
  6. removed theissue type on Sep 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

type: questionRequest for information or clarification.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions