PostgreSQL Explorer MCP Server
mcp-registry
MLflow MCP Server Registry のエンドツーエンドの簡易ウォークスルーです。FastMCP で MCP サーバーを構築し、FastMCP クライアントで呼び出し、MLflow に登録して、バージョン、アクセスエンドポイント、自動検出されたツールと共に検出可能にします。
このリポジトリには 3 つのコンポーネントがあります:
コンポーネント | パス | 説明 |
MCP サーバー |
| 2 つの FastMCP サーバー — おもちゃの挨拶サーバーと実際の PostgreSQL エクスプローラー |
MCP クライアント |
| ストリーミング可能な HTTP 上でツールを呼び出す薄い FastMCP クライアント |
レジストリユーティリティ |
| サーバーを MLflow に登録し、ツールを更新し、アクセスエンドポイントを一覧表示する |
要件
Python ≥ 3.13
ローカルで実行中の MLflow トラッキングサーバー(v3.15+) — レジストリ API はサーバーサイドにあります
PostgreSQL(PostgreSQL サーバーを試す場合)
uv(リポジトリにはuv.lockが同梱されています)
依存関係(pyproject.toml): fastmcp>=3.4.7、mlflow>=3.15.1、psycopg2 + psycopg2-binary、python-dotenv。
uv syncRelated MCP server: postgres-mcp-readonly
設定
PostgreSQL サーバーは、リポジトリルートの .env ファイルから接続設定を読み取ります(python-dotenv 経由で読み込み)。.env は gitignore されています — 自分で作成してください:
PGHOST=localhost
PGPORT=5432
PGUSER=root
PGPASSWORD=root
PGSSLMODE=prefer
PGADMINDB=postgres変数 | デフォルト | 目的 |
|
| サーバーホスト |
|
| サーバーポート |
|
| ログインロール |
|
| パスワード |
|
| libpq SSL モード |
|
| サーバー全体のクエリ( |
src/simple_server.py は設定不要です。
1. MLflow トラッキングサーバーを起動する
mlflow_mcp_registry_util.py は http://127.0.0.1:5000 を指しています。リポジトリにはすでに SQLite バックアップの実行から mlflow.db(gitignore されています)が含まれています:
uv run mlflow server --backend-store-uri sqlite:///mlflow.db --host 127.0.0.1 --port 5000サーバーが別の場所にある場合は、mlflow_mcp_registry_util.py の先頭にある mlflow.set_tracking_uri(...) 呼び出しを編集してください。
2. MCP サーバーを実行する
両方のサーバーは、ストリーミング可能な HTTP(http://localhost:8000/mcp)で ポート 8000 にバインドするため、一度に 1 つずつ実行するか、mcp.run(...) 呼び出しでポートを変更してください。
シンプルな挨拶サーバー — 2 つのツール、Greeting と Sendoff:
uv run python src/simple_server.pyPostgreSQL エクスプローラー — 実行中の PostgreSQL サーバーへの読み取り専用イントロスペクション:
uv run python src/postgresql_mcp.pyまたは FastMCP CLI 経由:
uv run fastmcp run src/postgresql_mcp.py --transport http --port 8000PostgreSQL ツール
ツール | 引数 | 戻り値 |
| — | テンプレート以外のデータベースを所有者と整形されたサイズと共に |
|
| ユーザー定義スキーマ(システムスキーマと一時スキーマを除く) |
|
| スキーマ内のテーブルとビュー、 |
|
| 列名、型、NULL 許容性、デフォルト値 — 順序順 |
|
| 外部キーを |
|
| スキーマ全体のフラットなエッジリスト |
すべてのツールは _query() を経由し、名前付きデータベースへの新しい接続を開き、RealDictCursor を通して単一のパラメータ化された SELECT を実行し、接続を閉じます。書き込みは行いません。
3. クライアントからサーバーを呼び出す
ポート 8000 でサーバーが実行されている状態で:
uv run python clients/postgres_server_client.py # calls ListDatabases, prints each database name
uv run python clients/simple_server_client.py # calls the greeting tool with "Ford"clients/postgres_server_client.py は FastMCP の結果を展開します: result.content の各アイテムには JSON text ペイロードが含まれており、それを解析して database を読み取ります。
注:
clients/simple_server_client.pyはclient.call_tool("greet", ...)を呼び出しますが、src/simple_server.pyのツールはGreetingという名前で登録されています(greetは Python 関数名にすぎません)。呼び出しを解決するには"Greeting"を使用してください。
4. サーバーを MLflow に登録する
mlflow_mcp_registry_util.py には 4 つのコルーチンがあり、それぞれが 1 つのレジストリ API を示しています:
register_postgresql_mcp_server()
リモート サーバー — すでに実行中で HTTP 経由で到達可能なサーバー — を登録します:
mlflow.genai.register_mcp_server(
server_json={
"name": "io.github.pavanjava/postgresql-server",
"version": "0.1.0",
"description": "PostgreSQL FastMCP server exposing DB tools",
"remotes": [{"url": "http://localhost:8000/mcp", "type": "streamable-http"}],
},
status="active",
source="local dev server via fastmcp",
create_access_endpoints_from_remotes=True,
)create_access_endpoints_from_remotes=True により、remotes 内の各エントリが MLflow アクセスエンドポイント に変換され、コンシューマーは接続 URL をハードコーディングする代わりにレジストリから解決できるようになります。
register_qdrant_mcp_server()
代わりに パッケージ化された サーバーを登録します — 実行中のプロセスは不要です。エントリは起動方法(uvx mcp-server-qdrant over stdio)を記述し、環境変数(必要なものと秘密のもの(QDRANT_API_KEY)を含む)を宣言します。
discover_tools()
refresh_mcp_server_version_tools(...) を呼び出します。MLflow は登録されたサーバーバージョンに接続し、そのツールを列挙し、バージョンに永続化します。その後、server_version.tools に検出されたツール名がリストされます。これにはサーバーが実際に到達可能である必要があります。
list_endpoints()
search_mcp_access_endpoints(server_name=...) を呼び出し、各エンドポイントの URL、トランスポートタイプ、および解決されるサーバーバージョンを出力します。
実行方法
__main__ ブロックは一度に 1 つのコルーチンを実行し、残りはコメントアウトされています。必要なコルーチンのコメントを解除してください:
if __name__ == "__main__":
# asyncio.run(register_postgresql_mcp_server())
asyncio.run(register_qdrant_mcp_server())
# asyncio.run(discover_tools())
# asyncio.run(list_endpoints())uv run python mlflow_mcp_registry_util.py登録されたサーバーは、MLflow UI の MCP Servers セクション(http://127.0.0.1:5000)に表示されます。
推奨エンドツーエンドパス
ポート 5000 で MLflow を起動します。
ポート 8000 で PostgreSQL MCP サーバーを起動します。
応答を確認:
uv run python clients/postgres_server_client.py。登録:
register_postgresql_mcp_server()のコメントを解除してユーティリティを実行します。ツールを検出:
discover_tools()に切り替えて再度実行 — 上記の 6 つのツールが表示されるはずです。アクセスエンドポイントを検査:
list_endpoints()に切り替えます。MLflow UI で結果を参照します。
リポジトリレイアウト
.
├── src/
│ ├── simple_server.py # FastMCP "My MCP Server" — Greeting + Sendoff tools
│ └── postgresql_mcp.py # FastMCP "PostgreSQL Explorer" — 6 read-only introspection tools
├── clients/
│ ├── simple_server_client.py # calls a tool on the greeting server
│ └── postgres_server_client.py # calls ListDatabases and prints database names
├── mlflow_mcp_registry_util.py # MLflow MCP registry: register / refresh tools / list endpoints
├── pyproject.toml
└── uv.lockmlflow.db、.env、.venv、および .idea は gitignore されています。
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-qualityDmaintenanceAn open-source MCP server for PostgreSQL schema introspection and guarded read-only queries. It enables MCP clients to discover schemas, tables, columns, indexes, relationships, and safe queryable data from a configured PostgreSQL database.13MIT
- AlicenseAqualityDmaintenanceA secure, read-only PostgreSQL MCP server that provides safe database introspection and querying capabilities.1415MIT
- Alicense-qualityCmaintenanceA Python MCP server that enables schema discovery, read-only SQL queries, table previews, and index/relationship analysis on PostgreSQL databases.1MIT
- AlicenseAqualityBmaintenanceMCP server for PostgreSQL that enables safe read-only database queries, table schema inspection, and query execution planning.634BSD 3-Clause
Related MCP Connectors
MCP server for managing Prisma Postgres.
MCP server for interacting with the Supabase platform
A basic MCP server to operate on the Postman API.
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/pavanjava/mcp_course'
If you have feedback or need assistance with the MCP directory API, please join our Discord server