MCP-Python
MCP を使用してデータベースと対話する

このガイドでは、Claude Desktopを使用してPostgreSQLデータベースと連携するためのMCPサーバーの設定と実行方法について説明します。内部でsqlalchemyを使用しているため、MySQL、MariaDB、SQLiteでも動作します。このプロジェクトはhttps://github.com/runekaagaard/mcp-alchemyをベースに構築されています。
**注:**このガイドでは、Docker、環境変数、および CLI の使用に関する基本的な知識があることを前提としています。
前提条件
Docker Compose :インストール手順
Claude Desktop :ここからダウンロード
uv : 最新の高性能Pythonパッケージマネージャー。インストールされていない場合は、以下の手順に従ってください。
Related MCP server: MCP Database Server
1. 環境変数を設定する
環境ファイルのコピーと名前の変更
提供されている.env.exampleファイルを複製し、名前を.envに変更します。cp .env.example .env
2. Claudeデスクトップをセットアップする
Claude Desktop をダウンロードしてインストールする
Claude Desktop のダウンロード ページにアクセスして、アプリケーションをインストールします。
3. ダミーデータでPostgreSQLデータベースを起動する
Docker Composeを実行する
Docker Compose がインストールされ、実行されていることを確認します。docker-compose up -dこのコマンドは
localhost:5432で PostgreSQL データベースを起動し、ダミー データを入力します。
4. uvをインストールする(まだインストールされていない場合)
uvをインストールするuvをインストールするには、次のコマンドを実行します。curl -LsSf https://astral.sh/uv/install.sh | sh
5. MCPサーバーの設定と起動
MCP サーバー構成の作成/更新
次の JSON 構成を MCP サーバー構成ファイルに保存します (必要に応じてパスを調整します)。{ "mcpServers": { "my_database": { "command": "uv", "args": [ "--directory", "/directory/where/this/app/is/located/app/", "run", "server.py" ], "env": { "DB_URL": "postgresql://postgres:password@localhost:5432/mydatabase" } } } }ヒント:
uv標準以外の場所にインストールされている場合は、実行可能ファイルへの完全なパスを反映するように"command"値を更新します。
MCPサーバーを起動する
設定が完了すると、Claude Desktop が起動されるたびに MCP サーバーが自動的に起動します。
6. セットアップを楽しむ
Claude Desktopを開きます。
このツールは自動的に MCP サーバーを呼び出し、データベースとシームレスに対話できるようにします。
まとめ
環境変数を設定する:
.env.exampleを.envにコピーします。Claude Desktop をインストールして実行します。Claude Desktopからダウンロードします。
Docker Compose を使用して PostgreSQL を起動します。docker
docker-compose upを実行して、ダミー データでデータベースを起動します。uvをインストールします。必要に応じて、提供されているインストール コマンドを実行します。MCP サーバーを構成する: 構成ファイルを更新し、パスと環境変数が正しいことを確認します。
起動して楽しむ: Claude Desktop を起動して、MCP 経由でデータベースとのやり取りを開始します。
問題が発生した場合やさらにサポートが必要な場合は、関連ドキュメントを参照するか、サポート チームにお問い合わせください。
楽しいコーディングを!
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityDmaintenanceThis server enables Claude to directly interact with SQLite, SQL Server, PostgreSQL, and MySQL databases through the Model Context Protocol, allowing for query execution, table management, and data export capabilities.MIT
- Alicense-qualityDmaintenanceThis server provides database access capabilities to Claude, supporting SQLite, SQL Server, PostgreSQL, and MySQL databases.853MIT
- Alicense-qualityDmaintenanceThis server provides database access capabilities to Claude, supporting SQLite, SQL Server, PostgreSQL, and MySQL databases.853MIT
- AlicenseAqualityBmaintenanceMCP server for Claude that connects to MySQL, MariaDB, and SQLite databases. Query your databases using natural language.3MIT
Related MCP Connectors
GibsonAI MCP server: manage your databases with natural language
Hosted MCP server connecting claude.ai, ChatGPT and other AI apps to your own computer
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Appeared in Searches
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/rhabraken/mcp-python'
If you have feedback or need assistance with the MCP directory API, please join our Discord server