Recently, I built a custom MCP (Model Context Protocol) server using Node.js that supports Server-Sent Events (SSE) and an array of practical tools β including a powerful Natural Language to SQL (NL2SQL) converter. The final result was a lightweight yet extensible backend service that can be integrated with Claude Desktop, Windsurf AI, or any other MCP-compatible interface.
π Full source code available on GitHub
π§ Why I Built This
I started off with some open-source examples for MCP servers (mainly focused on calculator tools), but many didnβt work out of the box. After trial and error, I landed on a minimal structure that worked and then began extending it. The most exciting addition? A tool that transforms natural language questions into executable SQL queries using Googleβs Gemini API.
βοΈ What the MCP Server Can Do
Once set up, the server provides the following capabilities out of the box:
- π Mathematical Expression Evaluation: Simple calculator that evaluates expressions like
2 + 2 * 3
- π Unit Conversion: Temperature, distance, and weight conversions between common units
- π Date Formatting: Format dates using flexible patterns
- π§ Natural Language to SQL: Describe what data you want, and it returns a SQL query
π Endpoints
Type | URL | Description |
---|---|---|
REST | /mcp |
Main entrypoint for MCP protocol traffic |
SSE | /sse |
Server-Sent Events endpoint (MCP over SSE) |
π§ Natural Language to SQL with Gemini
One of the key tools in this project is nl-to-sql
. You describe your query in plain English, and it generates valid SQL based on pre-loaded schemas.
π§ͺ Example:
const result = await nlToSql({
query: "Find all employees in the IT department with salary greater than 70000"
});
Under the hood:
- Server loads all table schemas from
/src/schemas/*.sql
- Your query and schema info are packed into a prompt
- The prompt is sent to Gemini API
- The resulting SQL is parsed and returned
β Supported Tables
employees
departments
projects
employee_projects
This tool is especially handy for building AI interfaces that connect natural language to real data.
π₯οΈ Claude Desktop Integration
You can connect this server to Claude Desktop by editing your configuration like this:
{
"mcpServers": {
"RustamMCP-Server": {
"command": "npx",
"args": ["mcp-remote", "http://localhost:3000/mcp"]
}
}
}
After restarting Claude, your tools (like calculate
, convert
, nl-to-sql
) will show up.
β Tested with Windsurf AI, which recognized and used the tools successfully
π οΈ Local Setup
Clone the repo and run:
npm install
cp .env.example .env
# Add your GEMINI_API_KEY in the .env file
npm run dev
Server starts on http://localhost:3000
.
π‘ Whatβs Next?
Some next steps or ideas:
- β More schemas and domain-specific NL2SQL patterns
- π Logging and analytics of tool usage
- π Rate limiting and authentication for hosted setups
- π§© Adding custom AI model backends (e.g. Claude or local LLMs)
π Final Thoughts
Building this project helped me appreciate the modularity of MCP and the power of Geminiβs generative models. What started as a calculator became an AI-powered backend for natural language interfaces.
Feel free to fork the GitHub repo, experiment with your own tools, or deploy a custom version.
Stay tuned for more features and real-world integrations.
π Built with Node.js, Express, Gemini API, and the MCP SDK