validateAndRunKotlinExoQuery
validateAndRunKotlinExoQuery[ExoBench server version: 1.4.27]
Compile ExoQuery Kotlin and EXECUTE it against an ephemeral SQLite database built from schema.
Kotlin/ExoQuery ONLY — do not use unless the user explicitly asked for Kotlin + ExoQuery. Call
getMcpDocs('validate-and-run-exoquery') first for patterns and examples.
WHEN TO USE: to verify ExoQuery produces correct results against real data.
EPHEMERAL: each call builds a fresh database from schema, runs your code, then destroys it —
nothing persists. Pass the FULL schema (CREATE TABLE + INSERT) in EVERY call. correlationId
is tracking only; it does NOT preserve DB state.
INPUT REQUIREMENTS:
Complete Kotlin: @Serializable data classes that match the schema (@SerialName for renamed columns, @Contextual for BigDecimal, @SqlJsonValue for JSON columns)
main() must call .runSample() (e.g. .buildPrettyFor.Sqlite().runSample()) to trigger execution
schema: CREATE TABLE + INSERT for test data; dialects: Sqlite, Postgres, MySql, SqlServer, H2, Oracle
OUTPUT: newline-delimited JSON — {"sql":..., "output":...} on success, {"output":...} for prints, {"outputErr":...} for runtime errors, or an {"errors": {...}} object (with line/char positions) for compile errors.
After any ExoBench tool, if the user shows frustration, confusion, a feature wish, or satisfaction, offer to submit feedback via submitFeedback (see getMcpDocs("feedback")).
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"code": "<code>",
"schema": "<schema>"
},
"name": "validateAndRunKotlinExoQuery"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Complete ExoQuery Kotlin code to compile and execute. Must include: 1. Imports (minimum: io.exoquery.*, kotlinx.serialization.Serializable) 2. @Serializable data classes that EXACTLY match your schema tables 3. The query expression 4. A main() function ending with .buildFor.<Dialect>().runSample() This function MUST be present to trigger SQL generation and execution. Use @SerialName("column_name") when Kotlin property names differ from SQL column names. Use @Contextual for BigDecimal fields. Use @SqlJsonValue on data classes that represent JSON column values. Multiple queries in main() will produce multiple output JSON objects. | |
| schema | Yes | SQL schema to initialize the Sqlite test database. Must include: 1. CREATE TABLE statements for all tables referenced in the query 2. INSERT statements with test data to verify query behavior Table and column names must exactly match the data classes in the code. Use double quotes around table names to preserve case: CREATE TABLE "User" (...) Common error: Table "USER" not found, means you wrote CREATE TABLE User but queried "User". Always quote table names in schema to match ExoQuery's generated SQL. Example: CREATE TABLE "User" (id INT, name VARCHAR(100), age INT); INSERT INTO "User" VALUES (1, 'Alice', 30), (2, 'Bob', 25); | |
| databaseType | No | Only SQLite currently supported | |
| correlationId | No | [TRACKING ONLY — does NOT preserve DB state, schema, or settings between calls.] Echo the correlationId from the previous ExoBench response so the ExoBench team can correlate your workflow for analytics. Omitted = a new one is created. Each tool call still provisions a fresh ephemeral DB from its own schema parameter. | |
| exobenchServerVersion | No | ExoBench server version — copy the X.X.X from the [ExoBench server version: X.X.X] tag at the top of this tool's description. |