From 2192deb14f22b7a1a9f19792dc8729b3f0fea3db Mon Sep 17 00:00:00 2001 From: Anthony Ettinger Date: Mon, 30 Nov 2026 21:15:50 +0000 Subject: [PATCH] fix: ask_dba returns within 12 s and agents poll ask_dba_result (gateway closes long requests) (0.3.1) Co-Authored-By: Claude Opus 5.5 --- package.json | 2 +- src/app.js | 2 +- src/mcp.js | 4 ++-- src/pages.js | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 849242c..9195870 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dbml.db", - "version": "0.3.0", + "version": "0.3.1", "private": true, "description": "DBML as a service for AI agents: validate, parse, review and convert database schemas over an HTTP API, MCP server and CLI.", "type": "module", diff --git a/src/app.js b/src/app.js index 69bf044..3c053eb 100644 --- a/src/app.js +++ b/src/app.js @@ -196,7 +196,7 @@ Inputs up to ${MAX_INPUT_BYTES / 1024} KiB. ${process.env.RATE_LIMIT_PER_MIN || A plain-words answer to a database question, grounded in the engine's exact findings and SQL. ${process.env.ASK_PRICE_CENTS || 5} cents per answer from a prepaid balance; failures are free. Token: get a personal link at ${SITE}ask (token = the part after /ask/), top up there. Send "Authorization: Bearer ". - POST /api/ask {question, schema?} -> 202 {id}; GET /api/ask/ -> {status: working|answered|failed, answer, error} -- MCP: ask_dba {question, schema?, wait_seconds?}, ask_dba_result {id} (same Bearer header on /mcp) +- MCP: ask_dba {question, schema?, wait_seconds? (max 12)} -> {id, status}; poll ask_dba_result {id} every 5-10 s (answers take 30-90 s). Same Bearer header on /mcp. ## Review rules ${RULES.map((r) => `- ${r.id} (${r.severity}): ${r.description}`).join('\n')} diff --git a/src/mcp.js b/src/mcp.js index 2b2f285..c6062f6 100644 --- a/src/mcp.js +++ b/src/mcp.js @@ -104,11 +104,11 @@ export function buildMcpServer({ token = null } = {}) { }, run(() => SYNTAX)); server.registerTool('ask_dba', { - description: `Ask the DBA agent a database question about a schema (DBML or SQL DDL): what is wrong, how to index, how to migrate, SQL for a dialect. The answer is written by an AI model given the review engine's exact findings and SQL, with that exact output appended. Paid: ${PRICE_CENTS()} cents per answer from the token's prepaid balance; failures are free. Waits up to wait_seconds, then returns status "working" and an id for ask_dba_result.`, + description: `Ask the DBA agent a database question about a schema (DBML or SQL DDL): what is wrong, how to index, how to migrate, SQL for a dialect. The answer is written by an AI model given the review engine's exact findings and SQL, with that exact output appended. Paid: ${PRICE_CENTS()} cents per answer from the token's prepaid balance; failures are free. An answer usually takes 30-90 s: this returns within wait_seconds (max 12, the gateway closes longer requests) with status "working" and an id; call ask_dba_result with that id every 5-10 s until status is "answered" or "failed".`, inputSchema: { question: z.string().describe('The question, in plain words'), schema: z.string().optional().describe('DBML or SQL CREATE TABLE statements'), - wait_seconds: z.number().int().min(0).max(170).default(150).describe('How long to wait for the answer'), + wait_seconds: z.number().int().min(0).max(12).default(10).describe('How long to wait before returning (max 12)'), }, }, async ({ question, schema, wait_seconds: wait }) => { const account = accountByToken(token); diff --git a/src/pages.js b/src/pages.js index d9d1d27..5264fa9 100644 --- a/src/pages.js +++ b/src/pages.js @@ -349,7 +349,7 @@ ${endpoint('GET', '/api/v1/syntax', '', 'DBML cheat sheet (text)')}
curl -s ${h(SITE)}api/ask -H "authorization: Bearer $TOKEN" -H 'content-type: application/json' \\
   -d '{"question":"What would you index?","schema":"Table users { id int [pk] }"}'      # {id}
 curl -s ${h(SITE)}api/ask/$ID -H "authorization: Bearer $TOKEN"                        # {status, answer}
-

Over MCP: send the same Authorization: Bearer header on the connection and call ask_dba (waits for the answer) or ask_dba_result.

+

Over MCP: send the same Authorization: Bearer header on the connection and call ask_dba (returns an id within 12 s), then ask_dba_result every 5-10 s until the answer is in (usually 30-90 s).

claude mcp add --transport http dbml ${h(SITE)}mcp --header "Authorization: Bearer $TOKEN"

MCP server