@hoststack.dev/mcp 0.7.0 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hoststack-mcp.js +39 -0
- package/dist/hoststack-mcp.js.map +1 -1
- package/dist/index.js +39 -0
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/hoststack-mcp.js
CHANGED
|
@@ -680,6 +680,45 @@ defineTool({
|
|
|
680
680
|
return respond({ summary: `Database ${args2.database_id} (${type}) is ${status}.`, data });
|
|
681
681
|
}
|
|
682
682
|
});
|
|
683
|
+
defineTool({
|
|
684
|
+
name: "query_database",
|
|
685
|
+
category: "databases",
|
|
686
|
+
description: [
|
|
687
|
+
"Run a single READ-ONLY SQL statement against a managed Postgres database.",
|
|
688
|
+
"",
|
|
689
|
+
"When to use: ad-hoc data inspection \u2014 checking row counts, sampling rows, debugging a constraint. For schema changes or seed data, ship a Drizzle migration instead.",
|
|
690
|
+
"",
|
|
691
|
+
"Safety model (server-side, not bypassable):",
|
|
692
|
+
' - Wrapped in `BEGIN TRANSACTION READ ONLY` \u2014 INSERT/UPDATE/DELETE/DDL fail with a clear "cannot execute \u2026 in a read-only transaction" error.',
|
|
693
|
+
" - 30s statement_timeout \u2014 runaway queries are killed.",
|
|
694
|
+
" - 1000-row cap; result CSV is also size-capped at 1 MiB. Both surface via `truncated: true`.",
|
|
695
|
+
" - Postgres engine only (v1). Other engines return a 400.",
|
|
696
|
+
" - Single statement only; no embedded `;` and no psql meta-commands (`\\\u2026`).",
|
|
697
|
+
' - Every call is audit-logged (success or failure) as `database.query` so an admin can answer "who queried this DB, when, with what SQL".',
|
|
698
|
+
"",
|
|
699
|
+
"Inputs:",
|
|
700
|
+
` - database_id: publicId of the postgres database (e.g. "db_\u2026"). Resolved via the SDK's publicId helper.`,
|
|
701
|
+
" - sql: a single SELECT/WITH/SHOW/EXPLAIN statement, no trailing `;`. Max 16 KiB.",
|
|
702
|
+
"",
|
|
703
|
+
"Returns: { columns: string[], rows: string[][], rowCount: number, truncated: boolean, durationMs: number }. Values come back as strings (psql --csv); cast on the caller side when needed.",
|
|
704
|
+
"",
|
|
705
|
+
"Examples:",
|
|
706
|
+
' - query_database({ database_id: "db_abc", sql: "SELECT count(*) FROM users" }) \u2192 { columns: ["count"], rows: [["1234"]], \u2026 }',
|
|
707
|
+
` - query_database({ database_id: "db_abc", sql: "SELECT id, email FROM users WHERE created_at > now() - interval '1 day' LIMIT 50" })`
|
|
708
|
+
].join("\n"),
|
|
709
|
+
input: {
|
|
710
|
+
database_id: z5.string().describe("Database publicId (e.g. db_abc)."),
|
|
711
|
+
sql: z5.string().min(1).max(16384).describe(
|
|
712
|
+
"A single READ-ONLY SQL statement. No trailing `;`, no embedded `;`, no psql meta-commands."
|
|
713
|
+
)
|
|
714
|
+
},
|
|
715
|
+
handler: async (args2, ctx) => {
|
|
716
|
+
const teamId = await ctx.resolveTeamId();
|
|
717
|
+
const result = await ctx.hoststack.databases.query(teamId, args2.database_id, args2.sql);
|
|
718
|
+
const summary = result.truncated ? `Query returned ${result.rowCount} row${result.rowCount === 1 ? "" : "s"} (truncated; raise LIMIT if needed) in ${result.durationMs}ms.` : `Query returned ${result.rowCount} row${result.rowCount === 1 ? "" : "s"} in ${result.durationMs}ms.`;
|
|
719
|
+
return respond({ summary, data: result });
|
|
720
|
+
}
|
|
721
|
+
});
|
|
683
722
|
|
|
684
723
|
// src/tools/deploys.ts
|
|
685
724
|
import { z as z6 } from "zod";
|