"

MCP Server - Model Context Protocol

Dalineage provides an MCP (Model Context Protocol) server that allows AI assistants and other tools to interact with the SQL parser directly via REST API.

What is MCP?

MCP (Model Context Protocol) is a standard protocol for AI assistants to interact with external tools and services. The Dalineage MCP server exposes parsing capabilities through a simple REST endpoint.

Parser Endpoint

The MCP server provides a parser endpoint that accepts SQL code in various dialects and returns the Abstract Syntax Tree (AST).

Endpoint URL

POST /api/parser/{dialect}

Supported Dialects

Authentication

The endpoint requires HTTP Basic Authentication (same as other API endpoints).

Request

Response

The response is a JSON object with the following structure:

Success response:

{
  "status": "success",
  "data": {
    "type": "Script",
    "statementCount": 2,
    "ast": "Script(\n  statements = List(\n    SelectQuery(...),\n    InsertQuery(...)\n  )\n)"
  }
}

Error response:

{
  "status": "error",
  "data": "Parsing failed: unexpected token at line 5..."
}

Usage Examples

Basic Example - Oracle

curl -X POST http://localhost:8080/api/parser/oracle \
  -u admin:admin \
  -H "Content-Type: text/plain" \
  -d "SELECT * FROM employees WHERE salary > 1000"

T-SQL Example

curl -X POST http://localhost:8080/api/parser/tsql \
  -u admin:admin \
  -H "Content-Type: text/plain" \
  -d "SELECT TOP 10 * FROM customers WHERE country = 'USA'"

BigQuery Example

curl -X POST http://localhost:8080/api/parser/bigquery \
  -u admin:admin \
  -H "Content-Type: text/plain" \
  -d "SELECT * FROM \`project.dataset.table\` WHERE date > '2023-01-01'"

Parse from File

curl -X POST http://localhost:8080/api/parser/snowflake \
  -u admin:admin \
  -H "Content-Type: text/plain" \
  --data-binary @my_script.sql

With jq for Pretty Output

curl -X POST http://localhost:8080/api/parser/oracle \
  -u admin:admin \
  -H "Content-Type: text/plain" \
  -d "SELECT * FROM employees" | jq

Response Format

The AST (Abstract Syntax Tree) is returned as a formatted string representation using the same format as internal Dalineage processing. This representation shows:

Use Cases

1. AI Assistants

AI assistants can use this endpoint to:

2. IDE Integration

Development tools can integrate the parser to:

3. CI/CD Pipelines

Automated pipelines can use the parser to:

4. Code Analysis Tools

Static analysis tools can:

Error Handling

The parser returns detailed error messages when parsing fails:

{
  "status": "error",
  "data": "Parsing failed: Expected identifier:1:8, found \"FROM\""
}

Error messages include:

Configuration

The MCP server uses the same configuration as the main Dalineage application:

Limitations

Related Documentation

Technical Details

The parser endpoint: