Skip to content

Commit 64e9cd5

Browse files
aprimakinaclaude
andcommitted
refactor(mcp): trim duplicative truncation docs, simplify result drain
Drop the db_execute_query-specific truncation sentence from the top-level server instructions and the redundant cap/truncation mechanics from the tool description; the truncated and notice output field descriptions already cover them. In processResultSet, close rows and check rows.Err() unconditionally so errors that surface after scanning some rows aren't missed. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent acebe3d commit 64e9cd5

2 files changed

Lines changed: 6 additions & 10 deletions

File tree

internal/tiger/mcp/db_tools.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ Connects to a PostgreSQL database service in Tiger Cloud and executes the provid
157157
158158
Multi-statement queries (semicolon-separated) are supported when no parameters are provided. All result sets are returned. By default, statements execute in an implicit transaction that automatically commits on success or rolls back on error. Explicit transactions (opened with BEGIN) must be explicitly committed with COMMIT, or they roll back when the connection closes.
159159
160-
Process data in the database, not in your context: aggregate, filter, sort/limit, and join in SQL rather than fetching raw rows. Results are capped per result set (default 100 rows, configurable via mcp_max_rows) and by total size; a truncated response sets "truncated": true with a "notice" on how to refine the query.
160+
Process data in the database, not in your context: aggregate, filter, sort/limit, and join in SQL rather than fetching raw rows.
161161
162162
WARNING: Can execute any SQL statement including INSERT, UPDATE, DELETE, and DDL commands. Always review queries before execution.`,
163163
InputSchema: DBExecuteQueryInput{}.Schema(),
@@ -385,15 +385,13 @@ func processResultSet(conn *pgx.Conn, rows pgx.Rows, maxRows int, remainingBytes
385385
resultRows = append(resultRows, values)
386386
}
387387

388-
if truncated {
389-
// Drain so the command tag (and true row count) is available.
390-
rows.Close()
391-
} else if err := rows.Err(); err != nil {
388+
// Drain so the command tag reports the true row count even when truncated.
389+
rows.Close()
390+
391+
if err := rows.Err(); err != nil {
392392
return ResultSet{}, err
393393
}
394394

395-
// After a full drain the command tag reports the true row count, even when
396-
// we returned fewer.
397395
commandTag := rows.CommandTag()
398396

399397
return ResultSet{

internal/tiger/mcp/server.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,7 @@ type Server struct {
3737
// gate itself stays correct because handlers reload config per call.
3838
func buildServerInstructions(cfg *config.Config) string {
3939
base := "Tiger MCP provides tools for creating, managing, and querying Tiger Cloud database services (managed TimescaleDB/PostgreSQL). " +
40-
"Use it to provision and fork services, start/stop/resize instances, rotate credentials, fetch service logs, execute SQL queries, and search Tiger documentation. " +
41-
"When working with data, do the work in the database: push aggregation, filtering, sorting, and joins into SQL rather than fetching raw rows and computing locally. " +
42-
"db_execute_query caps the rows and total size it returns; if a result is truncated, refine the query (aggregate, filter, or paginate with LIMIT/OFFSET) instead of re-running it to pull everything."
40+
"Use it to provision and fork services, start/stop/resize instances, rotate credentials, fetch service logs, execute SQL queries, and search Tiger documentation."
4341

4442
if cfg == nil || !cfg.ReadOnly {
4543
return base

0 commit comments

Comments
 (0)