mikhilv/mcp_server_new
If you are the rightful owner of mcp_server_new and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
This project implements a Model Context Protocol (MCP) server that processes natural language queries, converts them to SQL, executes them on a SnowSQL database, and returns the results in JSON format.
MCP Server for Natural Language SQL Queries
This project implements a Model Context Protocol (MCP) server that accepts natural language queries, converts them to SQL using machine learning, executes them on a SnowSQL database, and returns the results in JSON format.
Setup
- Clone the repository
- Create a virtual environment:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate - Install dependencies:
pip install -r requirements.txt - Configure your SnowSQL connection:
- Copy
.env.exampleto.env - Update the values in
.envwith your SnowSQL credentials
- Copy
Running the Server
To run the server:
uvicorn src.server:app --reload
The server will start on http://localhost:8000
API Usage
POST /query
Send natural language queries to get SQL results.
Request body:
{
"query": "Show me all sales from last month"
}
Response:
{
"sql_query": "SELECT * FROM sales WHERE date >= DATEADD(month, -1, CURRENT_DATE())",
"results": [
{
"sale_id": 1,
"amount": 100.50,
"date": "2023-09-15"
}
// ... more results
]
}
Security Notes
- The server only allows SELECT queries for security reasons
- Make sure to properly configure your SnowSQL user permissions
- Keep your .env file secure and never commit it to version control
Error Handling
The server provides detailed error messages for:
- Invalid natural language queries
- SQL generation failures
- Database connection issues
- Query execution errors