Skip to main content
Glama
arjshiv

BlazeSQL MCP Server

by arjshiv

BlazeSQL MCP-Server

Dieses Projekt implementiert einen Model Context Protocol (MCP)-Server mit dem @modelcontextprotocol/sdk der als Proxy für die BlazeSQL Natural Language Query API fungiert. Es ermöglicht MCP-kompatiblen Clients (wie Cursor, Claude 3 mit Tool-Nutzung, dem MCP Inspector usw.) die Interaktion mit BlazeSQL in natürlicher Sprache.

Merkmale

  • Erstellt mit der modernen McpServer Hilfsklasse aus dem MCP SDK.

  • Stellt die BlazeSQL Natural Language Query API als MCP-Tool namens blazesql_query bereit.

  • Verwendet zod zur robusten Validierung der Tool-Eingabeparameter.

  • Behandelt die API-Schlüsselauthentifizierung sicher über Umgebungsvariablen.

  • Kommuniziert mit Clients über den standardmäßigen MCP-Stdio-Transport.

Related MCP server: MySQL MCP Server

Workflow-Diagramm

Dieses Diagramm zeigt die Abfolge der Interaktionen, wenn ein Client das Tool blazesql_query verwendet (Hinweis: Die interne Serverlogik verwendet jetzt McpServer , was die Toolregistrierung im Vergleich zu den im Diagramm gezeigten Low-Level-Handlern vereinfacht):

sequenceDiagram
    participant Client as MCP Client (e.g., Cursor)
    participant Server as BlazeSQL MCP Server (index.ts)
    participant Env as Environment (.env)
    participant BlazeAPI as BlazeSQL API

    Client->>Server: ListTools Request (via stdio)
    Server-->>Client: ListTools Response (tools: [blazesql_query]) (via stdio)

    Client->>Server: CallTool Request (blazesql_query, db_id, nl_request) (via stdio)
    Server->>Env: Read BLAZE_API_KEY
    Env-->>Server: BLAZE_API_KEY
    Server->>BlazeAPI: POST /natural_language_query_api (apiKey, db_id, nl_request)
    BlazeAPI->>BlazeAPI: Process Query (NL->SQL, Execute)
    BlazeAPI-->>Server: HTTPS Response (JSON: agent_response, query, data_result OR error)
    Server->>Server: Format Response (Agent response, SQL, and data into single text block)
    Server-->>Client: CallTool Response (content: [{type: text, text: formattedMarkdown}]) (via stdio)

Voraussetzungen

Aufstellen

  1. Klonen Sie das Repository:

    git clone <repository-url>
    cd blaze-sql-mcp-server
  2. Abhängigkeiten installieren:

    yarn install

    Dadurch werden alle erforderlichen Abhängigkeiten installiert, einschließlich @modelcontextprotocol/sdk , dotenv und zod .

  3. Umgebungsvariablen konfigurieren:

    • Kopieren Sie die Beispielumgebungsdatei:

      cp .env.sample .env
    • Bearbeiten Sie die .env Datei:

      # .env
      BLAZE_API_KEY=YOUR_BLAZESQL_API_KEY_HERE

      Ersetzen Sie YOUR_BLAZESQL_API_KEY_HERE durch Ihren tatsächlichen API-Schlüssel, den Sie aus Ihren BlazeSQL-Kontoeinstellungen erhalten haben.

Ausführen des Servers

  1. Erstellen Sie den Server: Kompilieren Sie den TypeScript-Code in JavaScript:

    yarn build
  2. Führen Sie den Server aus: Führen Sie den kompilierten Code aus:

    node build/index.js

    Der Server startet und protokolliert Meldungen in stderr (möglicherweise wird „API-Schlüssel erfolgreich geladen …“ usw. angezeigt). Er wartet nun über die Standard-Ein-/Ausgabe (stdio) auf eine MCP-Clientverbindung.

Verbinden eines MCP-Clients

Dieser Server verwendet den stdio- Transportmechanismus.

Verwenden des MCP Inspector (zum Testen empfohlen)

  1. Stellen Sie sicher, dass der Server nicht bereits separat ausgeführt wird.

  2. Führen Sie den Inspector aus und weisen Sie ihn an, Ihren Server zu starten:

    npx @modelcontextprotocol/inspector node build/index.js
  3. Die Inspector-Benutzeroberfläche wird gestartet und stellt automatisch eine Verbindung zu Ihrem Server her.

  4. Navigieren Sie zur Registerkarte „Tools“, um mit dem Tool blazesql_query zu interagieren.

Verwendung integrierter Clients (Cursor, Claude 3 usw.)

  1. Starten Sie den Server in einem Terminal:

    node build/index.js
  2. Konfigurieren Sie den Client: In den Einstellungen Ihres MCP-Clients müssen Sie eine benutzerdefinierte Serverkonfiguration hinzufügen.

    • Transport: Wählen Sie stdio aus.

    • Befehl: Geben Sie den genauen Befehl zum Ausführen des Servers an. Sie müssen den absoluten Pfad zum Knoten und den absoluten Pfad zur Datei build/index.js angeben.

      • Beispiel (macOS/Linux – Pfade nach Bedarf anpassen): /usr/local/bin/node /Users/your_username/path/to/blaze-sql-mcp-server/build/index.js

      • Sie können den Pfad zum Knoten mithilfe der Angabe which node in Ihrem Terminal finden.

      • Den Pfad zum Projekt finden Sie mit pwd im Projektverzeichnis.

    • Speichern Sie die Konfiguration.

  3. Der Client sollte jetzt in der Lage sein, eine Verbindung zu Ihrem lokal laufenden Server herzustellen und dessen Tools aufzulisten/verwenden.

Verwenden des blazesql_query -Tools

Sobald die Verbindung hergestellt ist, kann der Client das Tool blazesql_query aufrufen.

  • Toolname: blazesql_query

  • Argumente:

    • db_id (Zeichenfolge, erforderlich): Die ID der Zieldatenbankverbindung in Ihrem BlazeSQL-Konto. Sie finden diese ID in der BlazeSQL-Webanwendung beim Verwalten Ihrer Datenbankverbindungen.

    • natural_language_request (Zeichenfolge, erforderlich): Die Abfrage, die Sie ausführen möchten, in einfachem Englisch (z. B. „Zeige mir die Gesamtzahl der Benutzer“). (Die Eingabe wird mit zod validiert.)

  • Beispielaufruf (zur Veranschaulichung wird mcp test verwendet):

    call-tool blazesql_query --db_id "db_your_actual_db_id" --natural_language_request "What were the total sales last month?"
  • Ausgabe: Bei Erfolg gibt das Tool einen einzelnen text zurück, der Folgendes enthält:

    • Die Antwort des BlazeSQL-Agenten in natürlicher Sprache.

    • Die generierte SQL-Abfrage innerhalb eines Markdown-Code-Zauns ( sql ... ).

    • Die Datenergebnisse werden als JSON innerhalb eines Markdown-Code-Zauns ( json ... ) formatiert.

    Beispielhafte Struktur innerhalb des text :

    **Agent Response:**
    The total sales last month were $12345.67.
    
    **Generated SQL:**
    ```sql
    SELECT sum(sales_amount) FROM sales WHERE sale_date >= date('now', '-1 month');

    Datenergebnis (JSON):

    [
      {
        "sum(sales_amount)": 12345.67
      }
    ]
    
    If unsuccessful, it returns a `text` content block containing the error message from the BlazeSQL API and marks the response as an error (`isError: true`).

Available Tools

1 tool
blazesql_queryB

Executes a natural language query against a specified BlazeSQL database.

ParametersJSON Schema
NameRequiredDescriptionDefault
db_idYesThe ID of the BlazeSQL database connection to query.
natural_language_requestYesThe query expressed in natural language (e.g., 'show me total users per city').

Output Schema

ParametersJSON Schema
NameRequiredDescription
queryYesThe SQL query generated and executed by BlazeSQL.
data_resultYesThe structured data returned by the query, as a map of column names to value arrays.
agent_responseYesNatural language explanation of the results from BlazeSQL.

TDQS

B3.1/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool executes queries but doesn't describe traits like error handling, performance implications, authentication needs, or rate limits. For a query execution tool with zero annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It is front-loaded and appropriately sized, making it easy to understand quickly. Every part of the sentence contributes to clarifying the tool's function.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has an output schema (which handles return values), 100% schema coverage, and no annotations, the description is minimally complete. It covers the basic purpose but lacks behavioral context and usage guidelines. For a query tool with no annotations, it should do more to compensate, but the output schema mitigates some gaps.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema description coverage is 100%, so the schema already documents both parameters (db_id and natural_language_request) with clear descriptions. The description adds no additional meaning beyond what the schema provides, such as examples or constraints. Baseline 3 is appropriate when the schema does the heavy lifting.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with a specific verb ('executes') and resource ('natural language query against a specified BlazeSQL database'). It distinguishes what it does (execute natural language queries) from potential alternatives (like SQL queries), though without sibling tools, differentiation isn't needed. However, it could be more specific about the type of queries or results.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives, prerequisites, or exclusions. It mentions the tool's function but lacks context on appropriate scenarios, such as when natural language queries are supported or if there are limitations. With no sibling tools, this gap is less critical but still present.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 1 tool updatev1.0.0
    • First observedblazesql_query

TDQS

B3.2/5.0

Scored across 1 tool

Disambiguation5/5

With only one tool, there is no possibility of ambiguity or overlap between tools. The single tool has a clearly defined purpose that cannot be confused with any other tool in the set.

Naming Consistency5/5

A single tool inherently has perfect naming consistency as there are no other tools to compare it against. The tool name follows a clear verb_noun pattern (blazesql_query) which would be consistent if more tools existed.

Tool Count2/5

A single tool is generally too few for a database query server, as it lacks basic operations like listing databases, describing schemas, or managing connections. This minimal set limits functionality and forces all interactions through one interface.

Completeness2/5

The tool surface is severely incomplete for a SQL database server. While the query tool covers execution, there are obvious gaps such as no tools for schema exploration, database listing, transaction management, or data manipulation beyond queries, which will cause agent failures in many workflows.

Maintenance

ActivityInactive
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    A Model Context Protocol server that enables Large Language Models to access and interact with database connections, including viewing schemas and performing CRUD operations on connected databases.
    -
  • F
    license
    Not graded
    quality
    D
    maintenance
    A Model Context Protocol server that enables AI models to interact with MySQL databases through natural language, supporting SQL queries, table creation, and schema exploration.
    3
    -
  • A
    license
    Not graded
    quality
    D
    maintenance
    A Model Context Protocol server that enables LLMs like Claude to interact with SQLite and SQL Server databases, allowing for schema inspection and SQL query execution.
    693 npm
    386
    MIT