Skip to main content
Glama
herotech101

Enterprise SQL & Postgres C# MCP Server

by herotech101
README.md
# šŸ”Œ Enterprise AI Toolkit (C# MCP Server)

A high-performance C# Model Context Protocol (MCP) server for Microsoft SQL Server and PostgreSQL. Connect **Claude Desktop**, **Cursor IDE**, and custom AI workflows to your production databases and filesystems safely, securely, and in under 5 minutes.

---

## šŸ”“ The Database Access Problem for AI

AI agents like Claude and Cursor are incredibly smart, but they can't see your data. Giving them direct access to your database is extremely risky:
1. **Accidental Deletions/Writes:** The AI might generate `DROP TABLE`, `DELETE`, or `UPDATE` commands that corrupt production data.
2. **Slow Schema Discovery:** Manually copy-pasting tables and structures into prompts is tedious and quickly exceeds context window limits.
3. **Runaway Queries:** An AI writing a raw `SELECT *` on a table with 10 million rows will freeze your database server.
4. **Path Traversal Attacks:** Giving the AI filesystem tools can allow it to escape sandbox limits and read sensitive system files.

---

## 🟢 The Solution: Hardened C# MCP Server

This C# .NET 8.0 server provides a secure, read-only, and sandboxed bridge:
* **Autonomous Schema Crawlers:** The AI discovers tables, row counts, columns, primary keys, and types dynamically on-the-fly.
* **Automatic Transaction Rollbacks:** Every SQL query and stored procedure runs inside an explicit transaction that is **automatically rolled back** (`transaction.Rollback()`). Writes are physically impossible.
* **Command Keyword Filter:** Pre-scans inputs and rejects any command containing modification keywords (`INSERT`, `UPDATE`, `DELETE`, `DROP`, `ALTER`, `TRUNCATE`, `EXEC`).
* **Row Guards:** Automatically caps all query outputs with `TOP 100` (SQL Server) or `LIMIT 100` (PostgreSQL) if no limits are specified.
* **Sandboxed Filesystem:** Traversal-proof file tools (read, write, copy, move, delete) restricted to a configured sandbox workspace.

---

## šŸ“¦ Getting Started (Trial Guide)

This repository contains the **Pre-Compiled Trial Binary** of the server.

### Step 1: Download & Extract
Clone this repository or download it as a ZIP and extract it to a folder (e.g., `C:\Tools\EnterpriseMcpServer`).

### Step 2: Configure appsettings.json
Open `appsettings.json` in the extracted folder and configure your SQL database connection strings and sandbox directory:

```json
{
  "ConnectionStrings": {
    "DefaultConnection": "Server=localhost;Database=HeroERP;Trusted_Connection=True;TrustServerCertificate=True;",
    "PostgresConnection": "Host=localhost;Port=5432;Database=HeroERP;Username=postgres;Password=YOUR_PASSWORD;"
  },
  "McpSettings": {
    "AllowedWorkspace": "./Workspace"
  }
}
```

### Step 3: Integrate with Claude Desktop
Open `%APPDATA%\Claude\claude_desktop_config.json` and register the server:

```json
{
  "mcpServers": {
    "enterprise-sql-filesystem": {
      "command": "dotnet",
      "args": [
        "C:\\Tools\\EnterpriseMcpServer\\bin\\EnterpriseMcpServer.dll"
      ]
    }
  }
}
```
*Note: Make sure to replace `C:\\Tools\\EnterpriseMcpServer` with your actual absolute path.*

Restart Claude. You will see the tools icon (hammer) active, exposing all SQL and sandboxed file tools!

---

## šŸ”’ Trial Version vs Full Version

The pre-compiled DLL in this repository is a **Trial version**. It has a limit of **10 database/file tool calls per session**. If exceeded, it asks you to purchase a license.

To download the **Full, Unprotected C# Source Code, Visual Studio Solution, and Unlimited Production Build**, purchase the toolkit:

šŸ‘‰ **[Purchase Enterprise AI Toolkit on Gumroad](https://nusser6.gumroad.com/)**

*Includes lifetime updates, commercial use license, and full source code (no obfuscation, no limits).*