@hechtcarmel/vertica-mcp
Version:
MCP (Model Context Protocol) server for readonly Vertica database operations
66 lines • 2.03 kB
JavaScript
export function createSuccessResponse(data) {
const response = {
success: true,
data,
executedAt: new Date().toISOString(),
};
return JSON.stringify(response, null, 2);
}
export function createErrorResponse(error) {
let formattedError;
if (typeof error === "string") {
formattedError = { message: error };
}
else if (error instanceof Error) {
formattedError = { message: error.message };
}
else {
formattedError = error;
}
const response = {
success: false,
error: formattedError,
executedAt: new Date().toISOString(),
};
return JSON.stringify(response, null, 2);
}
export function formatQueryResult(result) {
return {
query: result.query,
rowCount: result.rowCount,
fields: result.fields.map((field) => ({
name: field.name,
dataType: field.format,
})),
rows: result.rows,
};
}
export function formatTableStructure(structure) {
return {
table: {
schemaName: structure.schemaName,
tableName: structure.tableName,
tableType: structure.tableType,
owner: structure.owner,
comment: structure.comment,
},
columns: structure.columns.map((col) => ({
name: col.columnName,
dataType: col.dataType,
nullable: col.isNullable,
defaultValue: col.defaultValue,
size: col.columnSize,
decimalDigits: col.decimalDigits,
position: col.ordinalPosition,
comment: col.comment,
})),
constraints: structure.constraints.map((constraint) => ({
name: constraint.constraintName,
type: constraint.constraintType,
column: constraint.columnName,
referencedTable: constraint.referencedTable,
referencedColumn: constraint.referencedColumn,
})),
};
}
//# sourceMappingURL=response-formatter.js.map