MCP PostgreSQLサーバー
次の機能を備えたモデル コントローラー プロバイダー (MCP) サーバー:
PostgreSQLデータベースに接続する
テーブルスキーマをリソースとして公開する
読み取り専用SQLクエリを実行するためのツールを提供します
一般的なデータ分析タスクのプロンプトが含まれています
特徴
スキーマ探索: データベースのスキーマ、テーブル、列を参照します
読み取り専用クエリ実行: データベースに対してSQLクエリを安全に実行します
データ分析プロンプト: 一般的な分析タスク用の事前構築された SQL テンプレート
データの可視化: 可視化のためのデータを生成する
関係探索: テーブルの関係と外部キーを視覚化する
APIドキュメント: 自動生成されたOpenAPI仕様
Related MCP server: PostgreSQL MCP Server
建築
このアプリケーションは、モデル - コントローラー - プロバイダー (MCP) パターンに従います。
モデル層: データベースとの直接的なやり取り
プロバイダー層: ビジネスロジックとデータ処理
コントローラー層: APIエンドポイントとリクエスト処理
セキュリティ機能
読み取り専用クエリ検証
SQLインジェクション保護
レート制限
パラメータ化されたクエリ
認証サポート
CORS設定
インストール
リポジトリをクローンします。
git clone <repository-url> cd mcp-postgres-server依存関係をインストールします:
npm install.env.templateに基づいて.envファイルを作成します。cp .env.template .envPostgreSQL データベースの資格情報を使用して
.envファイルを更新します。サーバーを起動します。
npm start
構成
すべての構成は環境変数を通じて管理されます。
サーバー: ポート、環境、CORS設定
データベース: 接続の詳細、プールの設定
セキュリティ: JWT設定、レート制限
クエリ: 実行制限、結果サイズ制限
APIエンドポイント
スキーマエンドポイント
GET /api/schemas- すべてのスキーマを一覧表示するGET /api/schemas/:schema/tables- スキーマ内のテーブルを一覧表示するGET /api/schemas/:schema/tables/:table- テーブルスキーマの詳細を取得するGET /api/schemas/:schema/relationships- テーブルの関係を取得するGET /api/structure- 完全なデータベース構造を取得するGET /api/search?q=term- テーブルと列を検索
クエリエンドポイント
POST /api/query- SQLクエリを実行するPOST /api/query/explain- クエリ実行プランを取得するGET /api/schemas/:schema/tables/:table/sample- サンプルデータを取得するGET /api/schemas/:schema/tables/:table/stats- テーブル統計を取得する
分析プロンプトエンドポイント
GET /api/prompts- 分析プロンプトテンプレートの一覧を取得するGET /api/prompts/:templateId- プロンプトテンプレートの詳細を取得するPOST /api/prompts/:templateId/generate- テンプレートからSQLを生成するGET /api/schemas/:schema/tables/:table/analysis/suggest- 分析の提案を取得する
クエリの例
基本的なテーブルクエリ
// API request
fetch('/api/query', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
sql: 'SELECT * FROM users LIMIT 10'
})
})
.then(response => response.json())
.then(data => console.log(data));分析プロンプトの使用
// Get suggested analysis for a table
fetch('/api/schemas/public/tables/orders/analysis/suggest')
.then(response => response.json())
.then(suggestions => {
// Use a suggestion
const suggestionId = suggestions.data[0].templateId;
const params = suggestions.data[0].params;
// Generate SQL from the template
return fetch(`/api/prompts/${suggestionId}/generate`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ params })
});
})
.then(response => response.json())
.then(data => {
// Execute the generated SQL
return fetch('/api/query', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ sql: data.data.sql })
});
})
.then(response => response.json())
.then(results => console.log(results));発達
開発モードで実行:
npm run devテストを実行:
npm testリントコード:
npm run lint
ライセンス
マサチューセッツ工科大学
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Appeared in Searches
- A database for searching medical and scientific research articles
- PostgreSQL MCP (Multi-Version Concurrency Control or specific usage)
- Information about PostgreSQL MCP (Managed Cloud Provider or other related concepts)
- Search for information about 'rag'
- Overview and Resources for PostgreSQL Database System
Latest Blog Posts
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/Maxim2324/mcp-server-test'
If you have feedback or need assistance with the MCP directory API, please join our Discord server
