Skip to main content
Glama
claude-mcp-aws-sqlserver

claude-mcp-aws-sqlserver

by jesseeastern

claude-mcp-aws-sqlserver

MCP Server that gives Claude natural-language access to SQL Server running on a Windows EC2 instance inside an AWS VPC — no public database exposure required.

Python MCP AWS License: MIT


Overview

This project demonstrates how to build an MCP (Model Context Protocol) server that bridges Claude Desktop to an AWS-hosted SQL Server environment. All database traffic flows over the private VPC network — the SQL Server port is never exposed to the public internet.

Claude can use plain English to:

  • Inspect and manage EC2 instances (start, stop, list)

  • Run PowerShell or bash commands on any instance via AWS SSM

  • Query any database on the SQL Server with T-SQL

  • List all databases and their health status


Related MCP server: AWS SSO MCP Server

Architecture

Claude Desktop
     |
     | MCP (streamable-HTTP)
     v
┌─────────────────────────────────┐
│         server.py               │
│         (FastMCP)               │
│                                 │
│  ┌──────────┐  ┌─────────────┐  │
│  │  boto3   │  │   pyodbc    │  │
│  └────┬─────┘  └──────┬──────┘  │
└───────┼───────────────┼─────────┘
        │               │
   AWS API         VPC-internal TCP
        │               │
 ┌──────┴──────┐  ┌─────┴──────────────┐
 │  EC2 + SSM  │  │  Windows EC2       │
 │  (control)  │  │  SQL Server 2019+  │
 └─────────────┘  └────────────────────┘

Key design decisions:

  • SSM is used for remote command execution instead of RDP/SSH — no inbound ports needed on instances.

  • Platform detection automatically selects the correct SSM document (PowerShell vs bash).

  • pyodbc connects to SQL Server via the private VPC IP, keeping the database off the public internet.


MCP Tools

Tool

Description

list_instances

List all EC2 instances with state, type, and public IP

start_instance

Start a stopped EC2 instance by ID

stop_instance

Stop a running EC2 instance by ID

run_command

Run a shell or PowerShell command via SSM (auto-detects OS)

sql_query

Execute any T-SQL query against a named database

list_databases

List all SQL Server databases with state and recovery model


Prerequisites

AWS Side

  • An AWS account with at least one EC2 instance running SQL Server (Windows)

  • SSM Agent installed and running on all managed EC2 instances

  • An IAM role attached to each EC2 instance with the AmazonSSMManagedInstanceCore policy

  • The machine running this server needs AWS credentials with permissions for ec2:Describe*, ec2:StartInstances, ec2:StopInstances, ssm:SendCommand, and ssm:GetCommandInvocation

Local Machine


Setup

1. Clone the repository

git clone https://github.com/jesseeastern/claude-mcp-aws-sqlserver.git
cd claude-mcp-aws-sqlserver

2. Install Python dependencies

pip install -r requirements.txt

3. Configure credentials

Edit server.py and fill in the constants at the top of the file:

WINDOWS_INSTANCE_ID = "i-XXXXXXXXXXXXXXXXX"   # Your Windows EC2 instance ID
SQL_SERVER_IP       = "10.0.0.X"              # Private VPC IP of the SQL Server
SQL_SERVER_PORT     = 1433
SQL_USER            = "sa"
SQL_PASSWORD        = "your-password-here"

Tip: For production use, load these values from environment variables or AWS Secrets Manager instead of hardcoding them.

4. Configure AWS credentials

The server uses the standard boto3 credential chain. The easiest approach:

aws configure
# or set environment variables:
export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
export AWS_DEFAULT_REGION=us-east-2

5. Register with Claude Desktop

Add the following to your claude_desktop_config.json:

{
  "mcpServers": {
    "vpc-mcp": {
      "command": "python",
      "args": ["/absolute/path/to/server.py"],
      "transport": "streamable-http",
      "url": "http://localhost:8000/mcp"
    }
  }
}

6. Start the server

python server.py

Example Prompts

Once connected, you can ask Claude things like:

  • "List all my EC2 instances and tell me which ones are running."

  • "Start instance i-0abc123def456789a and wait for it to be available."

  • "What databases exist on the SQL Server?"

  • "Run this query against AdventureWorks2019: SELECT TOP 10 * FROM Sales.SalesOrderHeader ORDER BY TotalDue DESC"

  • "Check free disk space on the Windows instance using PowerShell."


Security Notes

  • Never commit real passwords or AWS credentials to source control. Use environment variables or a secrets manager.

  • The placeholder values in server.py (i-XXXXXXXXXXXXXXXXX, YOUR_SA_PASSWORD_HERE) are intentional — replace them in your local copy only.

  • Restrict the IAM role to the minimum required permissions using the principle of least privilege.

  • Consider enabling AWS CloudTrail to audit all SSM command executions.


Tech Stack

  • FastMCP — Python MCP server framework

  • boto3 — AWS SDK for Python

  • pyodbc — ODBC database connectivity

  • AWS EC2 — Virtual machines in the cloud

  • AWS Systems Manager (SSM) — Secure remote command execution without open inbound ports


License

This project is licensed under the MIT License.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      Enables Claude to connect to and interact with SQLite, SQL Server, PostgreSQL, and MySQL databases through natural language. Supports executing queries, managing tables, exporting data, and storing business insights with authentication options including AWS IAM.
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Connects AI assistants to AWS infrastructure through AWS IAM Identity Center for secure, natural language management of cloud resources across multiple accounts. It enables users to execute AWS CLI commands, monitor resources, and run remote shell commands on EC2 instances via Systems Manager.
      1,185 npm
      15
      ISC
    • A
      license
      B
      quality
      D
      maintenance
      Enables Claude to interact with core AWS services like S3, EC2, RDS, and CloudWatch, along with a generic SDK wrapper for any AWS operation. It also supports cost monitoring and optional vector store capabilities for document ingestion and search.
      10
      3
      -
    • A
      license
      B
      quality
      D
      maintenance
      Enables Claude Desktop to interact with 57 AWS services using over 200 tools and local machine profiles. It supports multi-profile configurations and features a read-only safe mode by default to manage infrastructure like EC2, S3, and Lambda securely.
      100
      BSD 3-Clause