MCP Server - Complete Explanation & Setup Guide¶
Created: 2025-11-11 Server: withinearth-sql MCP (SQL Server @ 10.32.8.130:1988)
🤔 WHAT IS MCP SERVER?¶
MCP = Model Context Protocol
Think of it as a "plugin system" for Claude that gives it direct access to external tools and data sources.
📊 DIFFERENCE: Normal Claude vs MCP Server¶
WITHOUT MCP (What We Just Did):¶
YOU → Ask Claude question
CLAUDE → Generates SQL query
CLAUDE → Executes via Bash/sqlcmd
CLAUDE → Parses results manually
CLAUDE → Returns answer
Issues: - ❌ Claude has to manually write SQL every time - ❌ Uses command-line tools (sqlcmd) - ❌ No schema awareness - ❌ Can't explore database structure - ❌ Requires bash commands for every query
WITH MCP (What You Have Now):¶
YOU → Ask Claude question
CLAUDE → Uses MCP "tools" directly
MCP SERVER → Translates to SQL automatically
MCP SERVER → Executes query securely
MCP SERVER → Returns structured data
CLAUDE → Formats answer beautifully
Advantages: - ✅ Schema Awareness: Claude knows your table structure automatically - ✅ Native Integration: No bash commands needed - ✅ Intelligent Tools: Claude can list tables, describe schemas, query data - ✅ Better Context: MCP maintains connection and context - ✅ Type Safety: Structured data instead of text parsing - ✅ Multi-tool: Can use multiple MCP servers simultaneously (SQL + Files + APIs)
🔧 HOW MCP WORKS¶
Architecture:¶
┌─────────────────┐
│ Claude Code │ ← You interact here
└────────┬────────┘
│
▼
┌─────────────────┐
│ MCP Protocol │ ← Standard communication protocol
└────────┬────────┘
│
▼
┌─────────────────┐
│ MCP Server │ ← mssql_mcp_server (running locally)
│ (Tools) │
│ - list_tables │
│ - read_data │
│ - describe_tbl │
└────────┬────────┘
│
▼
┌─────────────────┐
│ SQL Server │ ← Your database (10.32.8.130:1988)
│ withinearthDB │
└─────────────────┘
What Happens When You Ask a Question:¶
Example: "Show me today's revenue"
- Claude receives your question
- Claude decides: "I need database data, I'll use the
withinearth-sqlMCP server" - Claude calls MCP tool:
read_data(table='OnlineHotelBooking', filter='today') - MCP Server:
- Connects to SQL Server
- Generates optimized SQL query
- Executes securely
- Returns structured JSON data
- Claude formats the response → You see beautiful results
🆚 COMPARISON TABLE¶
| Feature | Normal Method | MCP Server |
|---|---|---|
| Query Method | Manual sqlcmd | Automatic via MCP |
| Schema Knowledge | None | Full awareness |
| Connection | Per-query | Persistent |
| Error Handling | Manual parsing | Built-in |
| Security | Command-line exposure | Secure protocol |
| Tools Available | Just queries | list_tables, describe_table, read_data, etc. |
| Performance | Medium | Faster (connection pooling) |
| Team Sharing | Hard | Easy (config file) |
👥 SHARING MCP SERVER WITH OTHERS¶
✅ YES - You Can Share With Your Team!¶
Two Options:
OPTION 1: Direct Config Sharing (Same Machine)¶
Each team member needs to add this to their Claude Desktop config:
Location:
- Windows: %APPDATA%\Claude\claude_desktop_config.json
- Mac: ~/Library/Application Support/Claude/claude_desktop_config.json
- Linux: ~/.config/Claude/claude_desktop_config.json
Config to Share:
{
"mcpServers": {
"withinearth-sql": {
"command": "uvx",
"args": ["mssql_mcp_server"],
"env": {
"MSSQL_HOST": "10.32.8.130,1988",
"MSSQL_DATABASE": "withinearthUpdated",
"MSSQL_USER": "Replica",
"MSSQL_PASSWORD": "Wi@Lo#W$M@!n%6248",
"TrustServerCertificate": "yes",
"Trusted_Connection": "no"
}
}
}
}
Prerequisites for each person:
1. Install uv: curl -LsSf https://astral.sh/uv/install.sh | sh
2. Add config file
3. Restart Claude Desktop
4. Done! They can now query the database
OPTION 2: Remote MCP Server (Recommended for Teams)¶
Host the MCP server on a central machine and everyone connects to it.
Architecture:
Benefits: - ✅ Single point of configuration - ✅ Better security (credentials in one place) - ✅ Access control - ✅ Audit logging
Setup:
- On Central Server (e.g., 10.32.8.130 or monitoring server):
# Install MCP server
curl -LsSf https://astral.sh/uv/install.sh | sh
export PATH="$HOME/.local/bin:$PATH"
# Create MCP config
cat > ~/mcp_server.env << 'EOF'
MSSQL_HOST=10.32.8.130,1988
MSSQL_DATABASE=withinearthUpdated
MSSQL_USER=Replica
MSSQL_PASSWORD=Wi@Lo#W$M@!n%6248
TrustServerCertificate=yes
Trusted_Connection=no
EOF
# Run as service (example with systemd)
sudo tee /etc/systemd/system/mcp-sql.service << 'EOF'
[Unit]
Description=MCP SQL Server
After=network.target
[Service]
Type=simple
User=monitor
EnvironmentFile=/home/monitor/mcp_server.env
ExecStart=/root/.local/bin/uvx mssql_mcp_server
Restart=always
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl enable mcp-sql
sudo systemctl start mcp-sql
- On Each Team Member's Machine:
{
"mcpServers": {
"withinearth-sql": {
"command": "ssh",
"args": ["monitor@10.32.8.130", "uvx", "mssql_mcp_server"],
"env": {
"MSSQL_HOST": "10.32.8.130,1988",
"MSSQL_DATABASE": "withinearthUpdated",
"MSSQL_USER": "Replica",
"MSSQL_PASSWORD": "Wi@Lo#W$M@!n%6248"
}
}
}
}
🔒 SECURITY BEST PRACTICES¶
For Team Sharing:¶
-
Create Read-Only User:
-
Update MCP Config with Read-Only User:
-
Use Environment Variables (Hide Password):
Instead of hardcoding password in config:
{
"mcpServers": {
"withinearth-sql": {
"command": "uvx",
"args": ["mssql_mcp_server"],
"env": {
"MSSQL_HOST": "10.32.8.130,1988",
"MSSQL_DATABASE": "withinearthUpdated",
"MSSQL_USER": "TeamChatbot",
"MSSQL_PASSWORD": "${SQL_PASSWORD}"
}
}
}
}
Then each user sets: export SQL_PASSWORD="SecurePass123!"
📦 SHARING GUIDE FOR YOUR TEAM¶
Step-by-Step for Team Members:¶
Send them this:
🚀 Quick Setup - Join Withinearth SQL Chatbot¶
Time: 5 minutes
Step 1: Install UV
Step 2: Find Your Claude Config
- Windows: Press Win+R, type %APPDATA%\Claude, hit Enter
- Mac: Open Terminal: open ~/Library/Application\ Support/Claude/
- Linux: mkdir -p ~/.config/Claude && cd ~/.config/Claude
Step 3: Create/Edit claude_desktop_config.json
Create the file if it doesn't exist, or add to existing config:
{
"mcpServers": {
"withinearth-sql": {
"command": "uvx",
"args": ["mssql_mcp_server"],
"env": {
"MSSQL_HOST": "10.32.8.130,1988",
"MSSQL_DATABASE": "withinearthUpdated",
"MSSQL_USER": "Replica",
"MSSQL_PASSWORD": "Wi@Lo#W$M@!n%6248",
"TrustServerCertificate": "yes",
"Trusted_Connection": "no"
}
}
}
}
Step 4: Restart Claude Desktop
Step 5: Test It!
Ask Claude: "How many bookings were created today?"
You should get instant results from the database!
🔍 HOW TO VERIFY MCP IS WORKING¶
In Claude Desktop:¶
- Look for 🔌 icon in bottom-right corner
- Should show: "withinearth-sql" with green dot
- Click to see available tools:
list_tablesread_datadescribe_table
In Claude Code (CLI):¶
Just ask database questions naturally: - "Show me today's revenue" - "List all tables in the database" - "What columns are in OnlineHotelBooking table?"
If Claude responds with data, MCP is working!
🎯 EXAMPLE QUESTIONS TO ASK¶
Once MCP is set up, try these:
Database Exploration:¶
- "List all tables in the database"
- "Describe the OnlineHotelBooking table structure"
- "What columns are available in OnlineHotelBookingDetail?"
Business Questions:¶
- "What's our revenue today?"
- "Show me top 10 agents by booking count"
- "Which suppliers have the highest cancellation rate?"
- "How many bookings from Agoda in the last 7 days?"
Data Analysis:¶
- "Compare this week's bookings to last week"
- "Show me hourly booking distribution"
- "Find all bookings with negative margin"
- "Which agents are inactive (no bookings in 30 days)?"
🐛 TROUBLESHOOTING¶
"MCP server not showing up"¶
# Verify uvx is installed
uvx --version
# Test MCP server manually
MSSQL_HOST="10.32.8.130,1988" \
MSSQL_DATABASE="withinearthUpdated" \
MSSQL_USER="Replica" \
MSSQL_PASSWORD="Wi@Lo#W\$M@!n%6248" \
TrustServerCertificate="yes" \
uvx mssql_mcp_server
"Connection failed"¶
# Test SQL connectivity
sqlcmd -S "10.32.8.130,1988" -U "Replica" -P "Wi@Lo#W\$M@!n%6248" -Q "SELECT 1"
"Wrong credentials"¶
- Check password special characters are correct
- Verify user has database access
- Try connecting with SQL Server Management Studio first
📚 ADDITIONAL MCP SERVERS YOU CAN ADD¶
You can add multiple MCP servers to access different systems:
File System:¶
Git:¶
PostgreSQL:¶
"postgres": {
"command": "uvx",
"args": ["mcp-server-postgres"],
"env": {
"POSTGRES_CONNECTION_STRING": "postgresql://user:pass@host:5432/db"
}
}
🎓 LEARN MORE¶
- MCP Documentation: https://modelcontextprotocol.io/
- Available MCP Servers: https://github.com/modelcontextprotocol/servers
- Claude Desktop Docs: https://docs.anthropic.com/claude/docs
✅ YOUR CURRENT STATUS¶
MCP Server: ✅ Installed & Configured
Database: withinearth SQL Server @ 10.32.8.130:1988
Config File: /root/.config/Claude/claude_desktop_config.json
Status: Ready for team sharing!
Questions? Test it now by asking Claude a database question!