diff --git a/src/mysql/index.ts b/src/mysql/index.ts index 82f0e4d..d5c3285 100644 --- a/src/mysql/index.ts +++ b/src/mysql/index.ts @@ -21,6 +21,14 @@ interface ColumnRow { data_type: string; } +interface QueryResult { + content: Array<{ + type: string; + text: string; + }>; + isError: boolean; +} + const config = { server: { name: "example-servers/mysql", @@ -39,11 +47,11 @@ const config = { }, }; -const mysqlQuery = ( +const mysqlQuery = ( connection: PoolConnection, sql: string, params: any[] = [], -): Promise => { +): Promise => { return new Promise((resolve, reject) => { connection.query(sql, params, (error: MySQLErrorType, results: any) => { if (error) reject(error); @@ -91,17 +99,17 @@ const server = new Server(config.server, { }, }); -async function executeQuery(sql: string, params: any[] = []): Promise { +async function executeQuery(sql: string, params: any[] = []): Promise { const connection = await mysqlGetConnection(pool); try { - const results = await mysqlQuery(connection, sql, params); + const results = await mysqlQuery(connection, sql, params); return results; } finally { connection.release(); } } -async function executeReadOnlyQuery(sql: string): Promise { +async function executeReadOnlyQuery(sql: string): Promise { const connection = await mysqlGetConnection(pool); try { @@ -120,7 +128,7 @@ async function executeReadOnlyQuery(sql: string): Promise { // Reset to read-write mode await mysqlQuery(connection, "SET SESSION TRANSACTION READ WRITE"); - return { + return { content: [ { type: "text",