Skip to main content
Use Database Query when you want the assistant to translate natural language into SQL over a configured database connection.

Prerequisites

Requirements

  • Tool spec: { "name": "database_query", "type": "database_query_v1" }
  • tool_context: one sql_database context with connection_string

Basic request and response

This example validates a request that enables database query. For validation, it sets tool_choice to none so the validator doesn’t try to connect.
Example response:
To run the request, send the same body to POST /messages and set tool_choice to { \"type\": \"auto\" }.

Response blocks

Zylon runs this tool on the server. The response contains a server_tool_use block with the call, followed by a server_tool_result block with the result. The call ID starts with srvtoolu_. Don’t send a tool_result back for it.
Error:
is_error is true when the tool fails, and content holds the error message. See Migrating from 1.57 to 1.58 for the full list of server tool blocks.

Tips

  • Use a read-only database user.
  • Limit schemas to reduce inspection time.

Next steps

  • Learn how messages return tool blocks: Messages