@mcp-apps/kusto-mcp-server
Version:
MCP server for interacting with Kusto databases
45 lines • 1.91 kB
JavaScript
import { z } from "zod";
import { KustoService } from "../services/kustoService.js";
// Tool to get schema for a specific table
export const getTableSchemaTool = {
name: "get_table_schema",
description: `This tool retrieves the schema for a specific table in the Kusto database.
The result is a detailed schema information.
Inputs: clusterUrl, database, tableName.`,
parameters: {
clusterUrl: z.string().describe("The Kusto cluster URL (e.g., https://yourcluster.kusto.windows.net)"),
database: z.string().describe("The name of the database in the Kusto cluster"),
tableName: z.string().describe("The name of the table to get schema for"),
isExternal: z.boolean().optional().describe("Whether the table is an external table")
},
handler: async ({ clusterUrl, database, tableName, isExternal }) => {
try {
const schema = await KustoService.getTableSchema(clusterUrl, database, tableName, isExternal);
const columns = schema.OrderedColumns.map((column) => {
return {
name: column.Name,
type: column.CslType
};
});
return {
content: [
{
type: "text",
text: `Schema for ${tableName}: ${JSON.stringify(columns, null, 2)}`
}
]
};
}
catch (error) {
console.error(`Error getting schema for table ${tableName}:`, error);
const errorMessage = error instanceof Error ? error.message : String(error);
return {
content: [{
type: "text",
text: `Error getting table schema: ${errorMessage}`
}]
};
}
}
};
//# sourceMappingURL=get-table-schema.js.map