MCP Explained for Developers: Connecting LLMs to Databases and Shells

MCP Explained for Developers: Connecting LLMs to Databases and Shells
One of the largest limitations of using AI coding assistants is their sandboxed isolation. Standard models cannot read your local database tables, look up files, query internal APIs, or verify system CLI outputs without manual copy-paste workflows.
The Model Context Protocol (MCP), developed as an open standard by Anthropic, resolves this limitation. MCP acts as a secure, standardized bridge connecting LLMs directly to local databases, shell workspaces, filesystems, and network endpoints.
1. What is Model Context Protocol?
MCP separates the system architecture into three distinct layers:
┌──────────────────────┐
│ MCP Client │ (e.g. Cline, Cursor, Claude Desktop)
└──────────┬───────────┘
│ (JSON-RPC Protocol)
▼
┌──────────────────────┐
│ MCP Server │ (e.g. Postgres MCP, SQLite, Shell)
└──────────┬───────────┘
│ (Direct Action)
▼
┌──────────────────────┐
│ Local Resource/DB │ (Your PostgreSQL / Filesystem)
└──────────────────────┘- MCP Client: The developer interface (like VS Code's Cline extension or Cursor) that manages model execution.
- MCP Server: A lightweight server (Node.js/Python) that exposes tools, prompts, or resources via a standardized JSON-RPC protocol.
- Local Resource: The actual database, shell command, or local directory being interacted with.
2. Setting Up a PostgreSQL MCP Server in VS Code (Cline)
Let's configure VS Code's Cline extension to read a PostgreSQL database directly using Weavecode endpoints.
Step 2.1: Locate Cline Settings
Open the Cline custom settings file located at:
- Windows:
%APPDATA%\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json - macOS/Linux:
~/.config/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json
Step 2.2: Add the PostgreSQL MCP Server Configurations
Insert the following JSON config:
{
"mcpServers": {
"postgres-mcp": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://user:password@localhost:5432/my_database"
],
"disabled": false,
"autoApprove": []
}
}
}Once saved, Cline automatically starts the server process, registers SQL execution tools, and allows you to prompt the agent: "Audit the user database and generate a list of missing indexes for query optimizations."
3. High-Security Protocol Considerations
Because MCP allows LLMs to run commands and write to local databases, security is paramount:
- Auto-Approval Restrictions: Never add dangerous tools (like shell executables or database deletions) to the
autoApprovelist. Keep the "human-in-the-loop" approval step active. - Read-Only Connections: When connecting database MCP servers to production databases, always use read-only credential strings.