MCP Server
PostgreSQL API SSH MCP Server
A universal MCP server that enables AI agents to securely manage PostgreSQL databases, make API requests, and execute SSH commands with features for database analysis, schema editing, and data operations.
0
GitHub Stars
8/23/2025
Last Updated
MCP Server Configuration
1{
2 "name": "psql-ssh-api",
3 "command": "node",
4 "args": [
5 "C:\\path\\to\\your\\psql-ssh-api\\simple_openmcp_server.cjs"
6 ],
7 "env": {
8 "NODE_ENV": "production"
9 }
10}
JSON10 lines
README Documentation
🚀 COMPACT PostgreSQL + API + SSH MCP SERVER v4.0.0
English version | Русская версия
Specifically designed for AI agents - Service Layer architecture, maximum security, short names!
🎯 KEY ADVANTAGES v4.0.0
- ✅ Service Layer Architecture - Professional DI-based modular design
- ✅ Maximum Security - Protection against SQL injection, command injection, SSRF
- ✅ Password Encryption - AES-256-CBC, passwords never stored in plain text
- ✅ Optimized Names - 70% shorter tool names (resolves MCP filtering issues)
- ✅ Structured Logging - Detailed logs of all operations
- ✅ Simple Commands - Clear actions without complex parameters
- ✅ Automatic Management - Connections and sessions handled automatically
🏗️ ARCHITECTURE v4.0.0
Service Layer Structure:
simple_openmcp_server.cjs (252 lines) - Main server
src/
├── core/ServiceContainer.cjs # Dependency Injection container
├── services/ # Business services
│ ├── ConnectionService.cjs # Universal connection management
│ ├── QueryService.cjs # Centralized query execution
│ └── ProfileService.cjs # Profile management
├── managers/ # Thin orchestrators
│ ├── PostgreSQLManager.cjs # PostgreSQL operations
│ └── SSHManager.cjs # SSH operations
├── bootstrap/ServiceBootstrap.cjs # Service initialization
├── errors/index.cjs # Error handling
├── constants/index.cjs # Configuration constants
└── api/index.cjs # API client
Improvements from v3.0.0:
- -30% PostgreSQL Manager size (476 → 333 lines)
- -35% SSH Manager size (442 → 286 lines)
- -70% tool name lengths (81 → 27-29 characters)
- +25% throughput improvement
- +20% faster initialization
🔧 INSTALLATION
1. Clone Repository
git clone https://github.com/yourusername/psql-ssh-api.git
cd psql-ssh-api
2. Install Dependencies
npm install
3. Test Server
npm run check
4. Configure Claude Desktop
Add to %APPDATA%\Claude\claude_desktop_config.json
:
{
"mcpServers": {
"psql-ssh-api": {
"command": "node",
"args": ["C:\\path\\to\\your\\psql-ssh-api\\simple_openmcp_server.cjs"],
"env": {
"NODE_ENV": "production"
}
}
}
}
🛡️ SECURITY v4.0.0
Vulnerability Protection:
- SQL Injection - Comprehensive SQL query validation
- Command Injection - SSH command sanitization
- SSRF Attacks - URL validation for API requests
- XSS - Input data sanitization
- Password Security - AES-256-CBC encryption
Validation System:
- All input parameters checked
- Data size and request count limits
- All suspicious operations logged
- Automatic blocking of dangerous patterns
🎮 QUICK START
1. Setup PostgreSQL Profile
{
"action": "setup_profile",
"host": "localhost",
"username": "postgres",
"password": "yourpassword",
"database": "mydb"
}
2. Work with Database (no password needed!)
{
"action": "show_tables"
}
3. Setup SSH Profile
{
"action": "setup_profile",
"host": "myserver.com",
"username": "admin",
"password": "sshpassword"
}
4. Execute Commands (no password needed!)
{
"action": "execute",
"command": "ls -la"
}
🛠️ AVAILABLE TOOLS
📊 PostgreSQL Manager (mcp_psql_manager
)
setup_profile
- Setup connection profile (with encryption)list_profiles
- List saved profilesquick_query
- Execute SQL queries (with injection protection)show_tables
- List tablesdescribe_table
- Table structuresample_data
- Sample datainsert_data
- Insert data (with validation)update_data
- Update data (with validation)delete_data
- Delete data (with protection)database_info
- Database information
🔐 SSH Manager (mcp_ssh_manager
)
setup_profile
- Setup connection profile (with encryption)execute
- Execute commands (with injection protection)system_info
- System informationcheck_host
- Check host availabilitylist_profiles
- List SSH profiles
🌐 API Client (mcp_api_client
)
get
- GET requests (with SSRF protection)post
- POST requests (with data validation)put
- PUT requestsdelete
- DELETE requestspatch
- PATCH requestscheck_api
- Check API availability
📚 DOCUMENTATION
Detailed documentation for AI agents: mcp_config.md
🔄 VERSION HISTORY
v4.0.0 (Compact Names & Architecture Optimization) - CURRENT
- ✅ Compact Names - 70% shorter tool names (resolves MCP filtering)
- ✅ Service Layer Architecture - Professional DI-based design
- ✅ Performance Improvements - 25% throughput increase
- ✅ God Object Elimination - Replaced with specialized services
- ✅ Dependency Injection - Modern development patterns
- ✅ 100% API Compatibility - All commands work unchanged
v3.0.0 (Modular Architecture)
- ✅ Modular Architecture - Breaking God Object into 7 specialized modules
- ✅ Maximum Security - Protection against all injection types
- ✅ AES-256-CBC Encryption - Cryptographically protected passwords
- ✅ Comprehensive Testing - 36 automated security tests
- ✅ Structured Logging - JSON logs with importance levels
- ✅ Centralized Validation - Unified data verification system
v2.0.0 (Simplified Version)
- ✅ Profile system - password only once
- ✅ Simple commands with minimal parameters
- ✅ Automatic connection management
- 🔴 Monolithic architecture (God Object 1505 lines)
- 🔴 Limited security
v1.0.0 (Complex Version)
- 🔴 Password in every request
- 🔴 Complex commands with many parameters
- 🔴 No centralized connection management
🎯 USAGE EXAMPLES
Working with PostgreSQL
// 1. Setup (password encrypted with AES-256-CBC)
{
"action": "setup_profile",
"host": "localhost",
"username": "postgres",
"password": "mypass",
"database": "testdb"
}
// 2. View tables (with security validation)
{
"action": "show_tables"
}
// 3. Execute queries (with SQL injection protection)
{
"action": "quick_query",
"sql": "SELECT * FROM users LIMIT 5"
}
Working with SSH
// 1. Setup SSH profile
{
"action": "setup_profile",
"host": "myserver.com",
"username": "admin",
"password": "sshpass"
}
// 2. Execute commands (with injection protection)
{
"action": "execute",
"command": "df -h"
}
// 3. Get system info
{
"action": "system_info"
}
Working with APIs
// 1. Simple GET request
{
"action": "get",
"url": "https://api.example.com/users"
}
// 2. POST with data
{
"action": "post",
"url": "https://api.example.com/users",
"data": {
"name": "John",
"email": "john@example.com"
}
}
// 3. Authenticated request
{
"action": "get",
"url": "https://api.example.com/protected",
"auth_token": "your_token_here"
}
📊 PERFORMANCE METRICS
- Initialization Time: +20% faster
- Memory Usage: -15% reduction
- Response Time: +10% faster
- Throughput: +25% increase
- Tool Name Length: -70% reduction (81 → 27-29 chars)
🔐 SECURITY FEATURES
- AES-256-CBC Encryption - All passwords encrypted
- SQL Injection Protection - Query validation and sanitization
- Command Injection Protection - SSH command sanitization
- SSRF Protection - URL validation for API requests
- Input Validation - All data validated before processing
- Audit Logging - All operations logged for security
🚀 GETTING STARTED
- Install:
npm install
- Test:
npm run check
- Configure: Add to Claude Desktop config
- Use: Start with
setup_profile
actions
🤝 CONTRIBUTING
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
📄 LICENSE
MIT License - see LICENSE file for details.
🌐 LANGUAGE VERSIONS
- English - This README
- Русский - README_RU.md
🔗 LINKS
🎉 ACKNOWLEDGMENTS
Built with the Model Context Protocol SDK for seamless AI agent integration.
Ready for production use with AI agents! 🚀
Quick Install
Quick Actions
Key Features
Model Context Protocol
Secure Communication
Real-time Updates
Open Source