Skip to content

postgres-execute-sql returns null when result set is empty #3165

@victorivanov

Description

@victorivanov

Prerequisites

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

Toolbox version

1.1.0

Environment

  1. MacOS 26.3.1 (a)
  2. 1.1.0 Binaries via Homebrew (1.1.0+dev.darwin.arm64)

Client

Came up when using Codex (0.128.0), which chokes on the null, verified with manual toolbox CLI use

Tool config:

---
kind: tool
name: query_readonly_sql
type: postgres-execute-sql
source: u1
description: >
  Execute SQL through the read-only PostgreSQL role only. Intended for SELECT,
  WITH SELECT-only queries, EXPLAIN, SHOW, and schema/data inspectio.
annotations:
  readOnlyHint: true
  destructiveHint: false
  idempotentHint: true
  openWorldHint: false

Expected Behavior

A zero-row SQL result from postgres-execute-sql should be represented as an empty list, which would be consistent with other tools (e.g., postgres-list-tables) and allow the client to distinguish empty results from unknown errors

Current Behavior

When a postgres-execute-sql tool returns zero rows, Toolbox returns a null tool result payload over MCP.

Steps to reproduce?

  1. Configure a postgres-execute-sql tool
  2. Run a SELECT query returning no results, e.g. invoke query_readonly_sql '{"sql": "select 1 where false"}'
  3. Observe null in response (and not [])

Additional Details

Similar to #2027

Metadata

Metadata

Assignees

Labels

type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

Type

No fields configured for Bug.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions