// mssql's tools — mssql's own code (novox/hq ADR 0039), importing mssql's own client. They return // structured data; the mesh serves them through the sdk's tool harness. Both call through // MssqlClient, the module's one pending execution boundary (see client.ts): the tool shapes are // fixed and correct, and surface the work honestly through that boundary. import { registerModuleTools, type ToolDefinition } from "@novox/mesh-sdk/tools"; import { MssqlClient } from "../client.js"; export function getMssqlTools(mssql: MssqlClient): ToolDefinition[] { return [ { name: "mssql_list_databases", description: "List the user databases on the mssql server, with their on-disk size and state.", input: {}, run: async () => ({ databases: await mssql.listDatabases() }), }, { name: "mssql_query", description: "Run a read-only SELECT against a named database (wrapped in a rolled-back transaction).", input: { database: { type: "string", description: "the database to query" }, sql: { type: "string", description: "a single SELECT statement" }, }, run: async (args) => { const database = String(args.database ?? ""); const sql = String(args.sql ?? ""); if (!database) throw new Error("mssql_query: database is required"); if (!sql) throw new Error("mssql_query: sql is required"); const result = await mssql.readOnlyQuery(database, sql); return { database, command: result.command, rows: result.rows }; }, }, ]; } // The tools exist only when the server can be reached from the environment; without it, mssql // contributes none rather than failing the whole tool runtime. registerModuleTools("mssql", (env) => { try { return getMssqlTools(MssqlClient.fromEnv(env)); } catch { return []; } });