@@ -1160,34 +1160,86 @@ fn handle_cartridge_invoke(app &BojApp, cname string, body string) http.Response
11601160// --- database-mcp: VeriSimDB + general database operations ---
11611161
11621162fn invoke_database (tool string , args string ) http.Response {
1163+ // VeriSimDB endpoint — configurable via VERISIMDB_URL env var
1164+ verisimdb_url := os.getenv_opt ('VERISIMDB_URL' ) or { 'http://localhost:8180' }
1165+
11631166 if tool == 'health' {
1164- result := os.execute ('curl -sf --max-time 3 http://localhost:8080/api/v1 /health 2>/dev/null' )
1167+ result := os.execute ('curl -sf --max-time 3 ${ verisimdb_url } /health 2>/dev/null' )
11651168 if result.exit_code == 0 {
11661169 return json_response (json.encode ({
11671170 'tool' : 'health'
11681171 'status' : 'ok'
1169- 'data' : result.output
1172+ 'data' : result.output. trim_space ()
11701173 }))
11711174 }
11721175 return json_response (json.encode ({
11731176 'tool' : 'health'
11741177 'status' : 'unreachable'
1175- 'error' : 'VeriSimDB not responding at localhost:8080'
1178+ 'error' : 'VeriSimDB not responding at ${verisimdb_url }'
1179+ }))
1180+ }
1181+ if tool == 'list_hexads' {
1182+ result := os.execute ('curl -sf --max-time 5 ${verisimdb_url }/hexads 2>/dev/null' )
1183+ if result.exit_code == 0 {
1184+ return json_response (json.encode ({
1185+ 'tool' : 'list_hexads'
1186+ 'status' : 'ok'
1187+ 'data' : result.output.trim_space ()
1188+ }))
1189+ }
1190+ return json_response (json.encode ({
1191+ 'tool' : 'list_hexads'
1192+ 'status' : 'error'
1193+ 'error' : 'Failed to list hexads: ${result .output .trim_space ()}'
1194+ }))
1195+ }
1196+ if tool == 'create_hexad' {
1197+ params := json.decode (map [string ]string , args) or {
1198+ return error_response (400 , 'create_hexad requires {"name": "...", "type": "service|entity|resource"}' )
1199+ }
1200+ name := params['name' ] or { '' }
1201+ entity_type := params['type' ] or { 'entity' }
1202+ if name == '' {
1203+ return error_response (400 , 'create_hexad requires "name"' )
1204+ }
1205+ body := '{"name":"${name }","type":"${entity_type }"}'
1206+ result := os.execute ("curl -sf --max-time 5 -X POST -H 'Content-Type: application/json' -d '${body }' ${verisimdb_url }/hexads 2>/dev/null" )
1207+ return json_response (json.encode ({
1208+ 'tool' : 'create_hexad'
1209+ 'name' : name
1210+ 'status' : if result.exit_code == 0 { 'created' } else { 'error' }
1211+ 'data' : result.output.trim_space ()
11761212 }))
11771213 }
11781214 if tool == 'query' {
1179- result := os.execute ("curl -sf --max-time 5 -X POST http://localhost:8080/api/v1/query -H 'Content-Type: application/json' -d '${args }' 2>/dev/null" )
1215+ result := os.execute ("curl -sf --max-time 5 -X POST -H 'Content-Type: application/json' -d '${args }' ${ verisimdb_url }/vql/execute 2>/dev/null" )
11801216 if result.exit_code == 0 {
11811217 return json_response (json.encode ({
11821218 'tool' : 'query'
11831219 'status' : 'ok'
1184- 'data' : result.output
1220+ 'data' : result.output. trim_space ()
11851221 }))
11861222 }
11871223 return json_response (json.encode ({
11881224 'tool' : 'query'
11891225 'status' : 'error'
1190- 'error' : 'Query failed: ${result .output }'
1226+ 'error' : 'VQL query failed: ${result .output .trim_space ()}'
1227+ }))
1228+ }
1229+ if tool == 'drift' {
1230+ params := json.decode (map [string ]string , args) or {
1231+ return error_response (400 , 'drift requires {"id": "hexad-id"}' )
1232+ }
1233+ entity_id := params['id' ] or { '' }
1234+ if entity_id == '' {
1235+ return error_response (400 , 'drift requires "id"' )
1236+ }
1237+ result := os.execute ('curl -sf --max-time 5 ${verisimdb_url }/drift/entity/${entity_id } 2>/dev/null' )
1238+ return json_response (json.encode ({
1239+ 'tool' : 'drift'
1240+ 'id' : entity_id
1241+ 'status' : if result.exit_code == 0 { 'ok' } else { 'error' }
1242+ 'data' : result.output.trim_space ()
11911243 }))
11921244 }
11931245 if tool == 'list_backends' {
@@ -1196,7 +1248,7 @@ fn invoke_database(tool string, args string) http.Response {
11961248 'backends' : 'verisimdb,postgresql,sqlite,redis'
11971249 }))
11981250 }
1199- return error_response (400 , 'unknown database-mcp tool: "${tool }" — available: health, query, list_backends' )
1251+ return error_response (400 , 'unknown database-mcp tool: "${tool }" — available: health, list_hexads, create_hexad, query, drift , list_backends' )
12001252}
12011253
12021254// --- ssg-mcp: Static site generation (Zola, Hugo, ddraig) ---
0 commit comments