NS

netanelbollag/simple-psql-mcp

Developer tools

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。 原文を見る

32 stars 7 forks 品質 66 トレンド 12MIT

PostgreSQL コネクタをクリーンでわかりやすくした、初心者向け MCP サーバーテンプレートです.

概要

独自のMCPサーバーを構築したいというテンプレートプロジェクトです。 私は理解し、適応するのは簡単です死にるように設計しました - コードは、MCP ドキュメントを添付して簡単ですので、迅速にスピードを上げることができます。 TL;DR - AI用のプラグインを書く方法です モデルコンテキストプロトコル (MCP) は、LM が外部ツールやデータとやり取りするための標準的な方法です。 ナットシェル: - LLM がコマンドを実行できるように(データベースクエリを実行するような) - 会話に添付できるデータ(ファイルをプロンプトに添付するなど) - 一貫性のある LLM 命令を生成するテンプレート 1. - execute query - データベースに対してSQLクエリを実行 - test connection - データベースの接続を検証する 2. - db://tables - スキーマ内のすべてのテーブルのリスト - db://tables/{table name} - 特定のテーブルのスキーマ情報 - db://schema - データベース内のすべてのテーブルの完全なスキーマ情報 3.

概要(AI 翻訳)

独自のMCPサーバーを構築したいというテンプレートプロジェクトです。 私は理解し、適応するのは簡単です死にるように設計しました - コードは、MCP ドキュメントを添付して簡単ですので、迅速にスピードを上げることができます。

MCPとは?

TL;DR - AI用のプラグインを書く方法

モデルコンテキストプロトコル (MCP) は、LM が外部ツールやデータとやり取りするための標準的な方法です。 ナットシェル:

  • Tools は LLM がコマンドを実行できるようにします(データベースクエリを実行するような) -Resourcesは、会話に添付できるデータ(ファイルをプロンプトに添付するような)です。 -Promptsは、一貫性のあるLM命令を生成するテンプレートです

##特徴

このPostgreSQL MCPサーバーは、以下の機能を実行します。

  1. ツール**
  • [execute_query - データベースに対してSQLクエリを実行
  • [test_connection - データベースの接続が動作していることを確認します

2.リソース

  • [db://tables - スキーマ内のすべてのテーブルのリスト
  • [db://tables/{table_name} - 特定のテーブルのスキーマ情報
  • [db://schema - データベース内のすべてのテーブルのスキーマ情報の完全な

3。 プロンプト

  • クエリ生成テンプレート
  • 分析クエリビルダー
  • このリポジトリのテンプレートに基づく

前提条件

  • Python 3.8+

このページは AI により自動翻訳されています。技術的な詳細は原文をご確認ください。

README

以下は原文 README の抜粋です。原文を見る。

Simple PostgreSQL MCP Server

This is a template project for those looking to build their own MCP servers. I designed it to be dead simple to understand and adapt - the code is straightforward with MCP docs attached so you can quickly get up to speed.

What is MCP?

TL;DR - It’s a way to write plugins for AI

Model Context Protocol (MCP) is a standard way for LLMs to interact with external tools and data. In a nutshell:

  • Tools allow the LLM to execute commands (like running a database query)
  • Resources are data you can attach to conversations (like attaching a file to a prompt)
  • Prompts are templates that generate consistent LLM instructions

Features

This PostgreSQL MCP server implements:

  1. Tools

    • execute_query - Run SQL queries against your database
    • test_connection - Verify the database connection is working
  2. Resources

    • db://tables - List of all tables in the schema
    • db://tables/{table_name} - Schema information for a specific table
    • db://schema - Complete schema information for all tables in the database
  3. Prompts

    • Query generation templates
    • Analytical query builders
    • Based on the templates in this repo

Prerequisites

  • Python 3.8+
  • uv - Modern Python package manager and installer
  • npx (included with Node.js)
  • PostgreSQL database you can connect to

Quick Setup

  1. Create a virtual environment and install dependencies:

    # Create a virtual environment with uv
    uv venv
    
    # Activate the virtual environment
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
    
    # Install dependencies
    uv pip install -r requirements.txt
    
  2. Run the server with the MCP Inspector:

    # Replace with YOUR actual database credentials
    npx @modelcontextprotocol/inspector uv --directory . run postgres -e DSN=postgresql://username:password@hostname:port/database -e SCHEMA=public
    

    Note: If this is your first time running npx, you’ll be prompted to approve the installation. Type ‘y’ to proceed.

    After running this command, you’ll see the MCP Inspector interface launched in your browser. You should see a message like:

    MCP Inspector is up and running at http://localhost:5173
    

    If the browser doesn’t open automatically, copy and paste the URL into your browser. You should see something like this:

  3. Using the Inspector:

    • Click the “Connect” button in the interface (unless there’s an error message in the console on the bottom left)
    • Explore the “Tools”, “Resources”, and “Prompts” tabs to see available functionality
    • Try clicking on listed commands or typing resource names to retrieve resources and prompts
    • The interface allows you to test queries and see how the MCP server responds
  4. Take a look at the official docs

GitHub で README 全文を見る

インストール

npx @modelcontextprotocol/inspector uv --directory . run postgres -e DSN=postgresql://username:password@hostname:port/database -e SCHEMA=public
MCP 初心者?mcpskill.org のガイドから始めましょう →

設定

{ "mcpServers": { "postgres": { "command": "/path/to/uv", "args": [ "--directory", "/path/to/simple-psql-mcp", "run", "postgres" ], "env": { "DSN": "postgresql://username:password@localhost:5432/my-db", "SCHEMA": "public" } } } }