Skip to content

Fix db_execute_query parameters input type#110

Merged
nathanjcochran merged 1 commit intomainfrom
nathan/fix-parameters-tool-input-type
Nov 19, 2025
Merged

Fix db_execute_query parameters input type#110
nathanjcochran merged 1 commit intomainfrom
nathan/fix-parameters-tool-input-type

Conversation

@nathanjcochran
Copy link
Member

@nathanjcochran nathanjcochran commented Nov 19, 2025

Some AI models/providers (such as Gemini) were choking on the automatically-generated JSON Schema for the db_execute_query tool call.

This is the schema that was previously being generated for the db_execute_query input type:

{
  "type": "object",
  "required": [
    "service_id",
    "query"
  ],
  "properties": {
    "parameters": {
      "type": "array",
      "items": true
    },
    "pooled": {
      "type": "boolean"
    },
    "query": {
      "type": "string"
    },
    "role": {
      "type": "string"
    },
    "service_id": {
      "type": "string"
    },
    "timeout_seconds": {
      "type": "integer"
    }
  },
  "additionalProperties": false
}

It was being auto-generated from this Go type:

type DBExecuteQueryInput struct {
	ServiceID      string `json:"service_id"`
	Query          string `json:"query"`
	Parameters     []any  `json:"parameters,omitempty"`
	TimeoutSeconds int    `json:"timeout_seconds,omitempty"`
	Role           string `json:"role,omitempty"`
	Pooled         bool   `json:"pooled,omitempty"`
}

The problem was that the parameters array didn't specify a type for its elements (because it's []any in the Go code), and some models/providers couldn't handle that.

This PR fixes the issue by changing the type from []any to []string, which causes this JSON Schema to be generated instead:

{
  "type": "object",
  "required": [
    "service_id",
    "query"
  ],
  "properties": {
    "parameters": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "pooled": {
      "type": "boolean"
    },
    "query": {
      "type": "string"
    },
    "role": {
      "type": "string"
    },
    "service_id": {
      "type": "string"
    },
    "timeout_seconds": {
      "type": "integer"
    }
  },
  "additionalProperties": false
}

Notice how the parameters type now specifies "items": {"type": "string"} instead of "items": true. This makes it work correctly with Gemini (and probably some other models/providers that couldn't handle an array without an explicit element type).

Accepting the query parameters as strings doesn't appear to cause any problems for query execution, even when the placeholders in the Postgres query are expecting different types. The underlying pgx driver seems to be able to handle conversions from strings to the correct/expected Postgres types. I asked Claude to test a variety of different queries/parameter types, and they all ran without issue.

Fixes #108.

@nathanjcochran nathanjcochran self-assigned this Nov 19, 2025
@nathanjcochran nathanjcochran merged commit e8c37bb into main Nov 19, 2025
2 checks passed
@nathanjcochran nathanjcochran deleted the nathan/fix-parameters-tool-input-type branch November 19, 2025 21:40
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.

Invalid schema for function 'mcp_tiger_db_execute_query'

2 participants