Bug description
Custom bigquery-sql tools that use templateParameters fail on every invocation with:
unable to extract template params: error getting template params missing parameter <name>
The MCP schema (tools/list) correctly advertises template parameters as required input, but when tools/call is received, the template parameter values are silently dropped before reaching Invoke.
Steps to reproduce
- Define a custom
bigquery-sql tool with templateParameters:
kind: tools
name: list_tables
type: bigquery-sql
source: bigquery-source
description: List all tables in a dataset.
statement: |
SELECT t.table_id, t.row_count
FROM `{{.dataset}}.__TABLES__` t
ORDER BY t.row_count DESC
templateParameters:
- name: dataset
type: string
description: "Project-qualified dataset, e.g. project.dataset_name"
- Start toolbox with
--tools-file pointing to the YAML above.
- Call via MCP JSON-RPC:
{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"list_tables","arguments":{"dataset":"my-project.my_dataset"}}}
- Observe error:
unable to extract template params: error getting template params missing parameter dataset
Root cause
The disconnect is between schema generation and invocation parameter parsing:
Schema generation (bigquerysql.go:78-83) — correct
allParameters, paramManifest, err := parameters.ProcessParameters(cfg.TemplateParameters, cfg.Parameters)
mcpManifest := tools.GetMcpManifest(cfg.Name, cfg.Description, cfg.AuthRequired, allParameters, nil)
allParameters = templateParameters + parameters. The MCP schema correctly advertises all params.
MCP handler (method.go:198) — bug
params, err := parameters.ParseParams(tool.GetParameters(), data, claimsFromAuth)
GetParameters (bigquerysql.go:248-250) — bug
func (t Tool) GetParameters() parameters.Parameters {
return t.Parameters // only regular params, excludes templateParameters
}
ParseParams iterates over the parameter definitions list. Since GetParameters() returns only regular Parameters (not AllParams), any template parameter values present in data are silently ignored. The resulting ParamValues is missing the template param entries.
Invoke (bigquerysql.go:117-121) — fails
paramsMap := params.AsMap() // empty for tools with only templateParameters
newStatement, err := parameters.ResolveTemplateParams(t.TemplateParameters, t.Statement, paramsMap)
// → "missing parameter dataset"
Expected behavior
Template parameter values sent via tools/call should be preserved through ParseParams and available in the paramsMap passed to ResolveTemplateParams.
Suggested fix
GetParameters() should return t.AllParams instead of t.Parameters, so that ParseParams in the MCP handler processes both regular and template parameters. Alternatively, the handler could call ParseParams with all parameters.
Note: this same pattern exists in the REST API handler (api.go:234), and likely affects all tool types that support templateParameters (not just bigquery-sql).
Environment
- Toolbox version: v0.28.0 (commit
81253a0)
- Tool type:
bigquery-sql
- Invocation method: MCP stdio (
tools/call)
- Also tested via REST API (
/api/tool/{name}/invoke) and toolbox invoke CLI — same result
Bug description
Custom
bigquery-sqltools that usetemplateParametersfail on every invocation with:The MCP schema (
tools/list) correctly advertises template parameters as required input, but whentools/callis received, the template parameter values are silently dropped before reachingInvoke.Steps to reproduce
bigquery-sqltool withtemplateParameters:--tools-filepointing to the YAML above.{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"list_tables","arguments":{"dataset":"my-project.my_dataset"}}}unable to extract template params: error getting template params missing parameter datasetRoot cause
The disconnect is between schema generation and invocation parameter parsing:
Schema generation (
bigquerysql.go:78-83) — correctallParameters= templateParameters + parameters. The MCP schema correctly advertises all params.MCP handler (
method.go:198) — bugGetParameters (
bigquerysql.go:248-250) — bugParseParamsiterates over the parameter definitions list. SinceGetParameters()returns only regularParameters(notAllParams), any template parameter values present indataare silently ignored. The resultingParamValuesis missing the template param entries.Invoke (
bigquerysql.go:117-121) — failsExpected behavior
Template parameter values sent via
tools/callshould be preserved throughParseParamsand available in theparamsMappassed toResolveTemplateParams.Suggested fix
GetParameters()should returnt.AllParamsinstead oft.Parameters, so thatParseParamsin the MCP handler processes both regular and template parameters. Alternatively, the handler could callParseParamswith all parameters.Note: this same pattern exists in the REST API handler (
api.go:234), and likely affects all tool types that supporttemplateParameters(not justbigquery-sql).Environment
81253a0)bigquery-sqltools/call)/api/tool/{name}/invoke) andtoolbox invokeCLI — same result