Building a Natural Language-Powered MCP SSE Server with Node.js

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:

  1. Server loads all table schemas from /src/schemas/*.sql
  2. Your query and schema info are packed into a prompt
  3. The prompt is sent to Gemini API
  4. 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