UNPKG

@bilims/mcp-sqlserver

Version:

MCP Server for Microsoft SQL Server with CRUD operations and data analysis capabilities

197 lines (196 loc) 6.72 kB
import { z } from 'zod'; import { DatabaseConnection } from '../database/connection.js'; export declare const BulkInsertSchema: z.ZodObject<{ table: z.ZodString; data: z.ZodArray<z.ZodRecord<z.ZodString, z.ZodAny>, "many">; batchSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>; timeout: z.ZodDefault<z.ZodOptional<z.ZodNumber>>; }, "strip", z.ZodTypeAny, { timeout: number; table: string; data: Record<string, any>[]; batchSize: number; }, { table: string; data: Record<string, any>[]; timeout?: number | undefined; batchSize?: number | undefined; }>; export declare const BatchUpdateSchema: z.ZodObject<{ table: z.ZodString; updates: z.ZodArray<z.ZodObject<{ data: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodAny>, Record<string, any>, Record<string, any>>; where: z.ZodArray<z.ZodObject<{ column: z.ZodString; operator: z.ZodEnum<["=", "!=", ">", "<", ">=", "<=", "LIKE", "IN", "NOT IN", "IS NULL", "IS NOT NULL"]>; value: z.ZodOptional<z.ZodAny>; }, "strip", z.ZodTypeAny, { column: string; operator: "=" | "!=" | ">" | "<" | ">=" | "<=" | "LIKE" | "IN" | "NOT IN" | "IS NULL" | "IS NOT NULL"; value?: any; }, { column: string; operator: "=" | "!=" | ">" | "<" | ">=" | "<=" | "LIKE" | "IN" | "NOT IN" | "IS NULL" | "IS NOT NULL"; value?: any; }>, "many">; }, "strip", z.ZodTypeAny, { where: { column: string; operator: "=" | "!=" | ">" | "<" | ">=" | "<=" | "LIKE" | "IN" | "NOT IN" | "IS NULL" | "IS NOT NULL"; value?: any; }[]; data: Record<string, any>; }, { where: { column: string; operator: "=" | "!=" | ">" | "<" | ">=" | "<=" | "LIKE" | "IN" | "NOT IN" | "IS NULL" | "IS NOT NULL"; value?: any; }[]; data: Record<string, any>; }>, "many">; batchSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>; }, "strip", z.ZodTypeAny, { table: string; batchSize: number; updates: { where: { column: string; operator: "=" | "!=" | ">" | "<" | ">=" | "<=" | "LIKE" | "IN" | "NOT IN" | "IS NULL" | "IS NOT NULL"; value?: any; }[]; data: Record<string, any>; }[]; }, { table: string; updates: { where: { column: string; operator: "=" | "!=" | ">" | "<" | ">=" | "<=" | "LIKE" | "IN" | "NOT IN" | "IS NULL" | "IS NOT NULL"; value?: any; }[]; data: Record<string, any>; }[]; batchSize?: number | undefined; }>; export declare const BatchDeleteSchema: z.ZodObject<{ table: z.ZodString; conditions: z.ZodArray<z.ZodObject<{ where: z.ZodArray<z.ZodObject<{ column: z.ZodString; operator: z.ZodEnum<["=", "!=", ">", "<", ">=", "<=", "LIKE", "IN", "NOT IN", "IS NULL", "IS NOT NULL"]>; value: z.ZodOptional<z.ZodAny>; }, "strip", z.ZodTypeAny, { column: string; operator: "=" | "!=" | ">" | "<" | ">=" | "<=" | "LIKE" | "IN" | "NOT IN" | "IS NULL" | "IS NOT NULL"; value?: any; }, { column: string; operator: "=" | "!=" | ">" | "<" | ">=" | "<=" | "LIKE" | "IN" | "NOT IN" | "IS NULL" | "IS NOT NULL"; value?: any; }>, "many">; }, "strip", z.ZodTypeAny, { where: { column: string; operator: "=" | "!=" | ">" | "<" | ">=" | "<=" | "LIKE" | "IN" | "NOT IN" | "IS NULL" | "IS NOT NULL"; value?: any; }[]; }, { where: { column: string; operator: "=" | "!=" | ">" | "<" | ">=" | "<=" | "LIKE" | "IN" | "NOT IN" | "IS NULL" | "IS NOT NULL"; value?: any; }[]; }>, "many">; batchSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>; }, "strip", z.ZodTypeAny, { table: string; batchSize: number; conditions: { where: { column: string; operator: "=" | "!=" | ">" | "<" | ">=" | "<=" | "LIKE" | "IN" | "NOT IN" | "IS NULL" | "IS NOT NULL"; value?: any; }[]; }[]; }, { table: string; conditions: { where: { column: string; operator: "=" | "!=" | ">" | "<" | ">=" | "<=" | "LIKE" | "IN" | "NOT IN" | "IS NULL" | "IS NOT NULL"; value?: any; }[]; }[]; batchSize?: number | undefined; }>; export declare const ImportDataSchema: z.ZodObject<{ table: z.ZodString; data: z.ZodString; format: z.ZodEnum<["csv", "json"]>; hasHeaders: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>; delimiter: z.ZodDefault<z.ZodOptional<z.ZodString>>; batchSize: z.ZodDefault<z.ZodOptional<z.ZodNumber>>; skipRows: z.ZodDefault<z.ZodOptional<z.ZodNumber>>; }, "strip", z.ZodTypeAny, { table: string; data: string; batchSize: number; format: "csv" | "json"; hasHeaders: boolean; delimiter: string; skipRows: number; }, { table: string; data: string; format: "csv" | "json"; batchSize?: number | undefined; hasHeaders?: boolean | undefined; delimiter?: string | undefined; skipRows?: number | undefined; }>; export declare class BulkTools { private db; constructor(db: DatabaseConnection); bulkInsert(params: z.infer<typeof BulkInsertSchema>): Promise<{ success: boolean; totalRowsAffected: number; batchCount: number; batchSize: number; errors: string[] | undefined; }>; batchUpdate(params: z.infer<typeof BatchUpdateSchema>): Promise<{ success: boolean; totalRowsAffected: number; batchCount: number; batchSize: number; errors: string[] | undefined; }>; batchDelete(params: z.infer<typeof BatchDeleteSchema>): Promise<{ success: boolean; totalRowsAffected: number; batchCount: number; batchSize: number; errors: string[] | undefined; }>; importData(params: z.infer<typeof ImportDataSchema>): Promise<{ success: boolean; format: "csv" | "json"; recordsProcessed: number; recordsInserted: number; batchCount: number; batchSize: number; errors: string[] | undefined; error?: undefined; } | { success: boolean; format: "csv" | "json"; recordsProcessed: number; recordsInserted: number; error: string; batchCount?: undefined; batchSize?: undefined; errors?: undefined; }>; private parseCsv; private parseCsvLine; }