Provides access to EdgeLake distributed database through Python-based MCP server implementation with SQL query execution, schema inspection, and resource discovery across EdgeLake nodes
EdgeLake MCP Server
A Model Context Protocol (MCP) server for EdgeLake distributed database, providing AI assistants with access to query and explore distributed data across EdgeLake nodes.
Features
Resource Discovery: List all databases and tables available on EdgeLake nodes
Schema Inspection: Retrieve table schemas with column information
SQL Query Execution: Execute complex SQL queries with:
WHERE clauses with AND/OR operators
GROUP BY aggregations
ORDER BY with ASC/DESC sorting
JOINs across tables and databases
Extended metadata fields (+ip, +hostname, @table_name, etc.)
LIMIT for result pagination
Multi-threaded Execution: Concurrent request handling for optimal performance
Stateless Design: No session management required
Architecture
Installation
Prerequisites
Python 3.10 or higher
Access to an EdgeLake node with REST API enabled
EdgeLake node running on accessible IP:port (default: localhost:32049)
Install Dependencies
Configuration
Configure the server using environment variables:
TODO: Update so that node information can be provided dynamically
Variable | Description | Default |
| EdgeLake node IP/hostname |
|
| EdgeLake REST API port |
|
| HTTP request timeout (seconds) |
|
| Max concurrent threads |
|
| Logging level (DEBUG, INFO, WARNING, ERROR) |
|
Example Configuration
Create a .env file:
Or export environment variables:
Usage
Running the Server
The MCP server runs as a subprocess using stdio transport:
MCP Client Configuration
Add to your MCP client configuration (e.g., Claude Desktop):
macOS/Linux: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
MCP Protocol Implementation
Resources
resources/list
Lists all available databases and tables.
Response Format:
Example:
resources/read
Reads a specific resource (table schema).
URI Format: database://{database}/{table}
Example Request:
Example Response:
Tools
query
Execute SQL queries against EdgeLake with advanced filtering and aggregation.
Parameters:
Parameter | Type | Required | Description |
| string | Yes | Database name |
| string | Yes | Table name |
| array[string] | No | Columns to select (default:
) |
| string | No | WHERE clause conditions |
| array[string] | No | Columns to group by |
| array[object] | No | Sort specifications |
| array[string] | No | Additional tables to JOIN |
| array[string] | No | Metadata fields to add |
| integer | No | Max rows to return (default: 100) |
| string | No | Output format:
or
(default:
) |
Example - Simple Query:
Example - Complex Aggregation:
Example - Cross-Database Join:
Example - Extended Fields:
node_status
Get EdgeLake node status and health information.
Example:
list_databases
List all available databases in EdgeLake. Use this to discover what databases are available before querying.
Example:
Response:
list_tables
List all tables in a specific database. Use this to discover what tables are available in a database before querying.
Parameters:
Parameter | Type | Required | Description |
| string | Yes | Database name to list tables from |
Example:
Response:
get_schema
Get the schema (column definitions) for a specific table. Use this to understand what columns are available before querying.
Parameters:
Parameter | Type | Required | Description |
| string | Yes | Database name |
| string | Yes | Table name |
Example:
Response:
server_info
Get EdgeLake MCP Server version and configuration information.
Example:
Response:
Query Building Rules
WHERE Clause
Add filtering conditions with AND/OR operators:
GROUP BY
Group results by columns (required when using aggregations with non-aggregated columns):
ORDER BY
Order results by columns with optional direction:
Include Tables (JOINs)
Include additional tables using comma-separated syntax. For cross-database tables, use db_name.table_name:
Extended Fields
Add EdgeLake metadata fields using special prefixes:
+ip- Node IP address+overlay_ip- Overlay network IP+hostname- Node hostname@table_name- Source table name
LIMIT
Limit the number of rows returned:
API Examples
Using curl (for testing)
EdgeLake Commands Reference
The MCP server uses EdgeLake's REST API with these commands:
MCP Operation | EdgeLake Command |
List databases |
with header
|
List tables |
with header
|
Get schema |
with header
|
Execute query |
with header
|
Node status |
with header
|
Logging
Logs are written to:
File:
edgelake_mcp.log(in server directory)stderr: Console output for debugging
Set log level via LOG_LEVEL environment variable (DEBUG, INFO, WARNING, ERROR).
Development
Project Structure
Running Tests
Code Style
Troubleshooting
Connection Issues
Problem: Cannot connect to EdgeLake node
Solution:
Verify EdgeLake node is running:
curl http://{host}:{port}Check firewall settings
Verify
EDGELAKE_HOSTandEDGELAKE_PORTare correct
Empty Database List
Problem: No databases returned from resources/list
Solution:
Check EdgeLake node has databases:
curl -H "command: get databases" http://{host}:{port}Verify user has permissions to view databases
Check EdgeLake logs for errors
Query Timeout
Problem: Query takes too long and times out
Solution:
Increase
EDGELAKE_TIMEOUTenvironment variableAdd more specific WHERE clauses to reduce result set
Use LIMIT to restrict rows returned
License
Mozilla Public License 2.0
Support
For issues and questions:
EdgeLake Documentation: https://edgelake.github.io
EdgeLake GitHub: https://github.com/EdgeLake
MCP Specification: https://modelcontextprotocol.io
Contributing
Contributions are welcome! Please ensure:
Code follows PEP 8 style guide
All tests pass
New features include documentation
Type hints are used throughout
This server cannot be installed