MCP Server for PostgreSQL
MCP-сервер для PostgreSQL
Реализация сервера Model Context Protocol (MCP) для PostgreSQL, предоставляющая простой интерфейс для взаимодействия с базами данных PostgreSQL через MCP.
Функции
Выполнение SQL-запросов с параметризованными входными данными
Выполнение операций INSERT/UPDATE/DELETE
Создать новые базы данных
Создание или обновление схем таблиц
Отладка соединений PostgreSQL
Контейнеризация с Docker для простоты развертывания
Конфигурация на основе среды
Related MCP server: MCP PostgreSQL Server
Предпосылки
Питон 3.8+
PostgreSQL 10+
Docker (опционально, для контейнерного развертывания)
Docker Compose (опционально, для разработки)
Установка
Использование Docker (рекомендуется)
Клонируйте репозиторий:
git clone https://github.com/asadudin/mcp-server-postgres.git cd mcp-server-postgresСкопируйте пример файла среды:
cp .env.example .envОбновите файл
.env, указав свои учетные данные PostgreSQL:PG_HOST=postgres PG_PORT=5432 PG_USER=postgres PG_PASSWORD=your_password PG_DATABASE=your_database HOST=0.0.0.0 PORT=8056Запустите службу с помощью Docker Compose:
docker-compose up -d
Ручная установка
Клонируйте репозиторий:
git clone https://github.com/asadudin/mcp-server-postgres.git cd mcp-server-postgresСоздайте и активируйте виртуальную среду:
python -m venv venv source venv/bin/activate # On Windows: .\venv\Scripts\activateУстановить зависимости:
pip install -r requirements.txtСкопируйте пример файла среды и обновите его:
cp .env.example .env # Edit .env with your configurationЗапускаем сервер:
python mcp_server_postgres.py
Использование
Сервер MCP предоставляет следующие конечные точки:
sql_query
Выполнить запрос SELECT и вернуть результаты в формате JSON.
Параметры:
query: строка запроса SQLparams: Необязательная строка JSON параметров запроса (список или словарь)
Пример:
{
"query": "SELECT * FROM users WHERE id = $1",
"params": [1]
}sql_execute
Выполните оператор INSERT/UPDATE/DELETE.
Параметры:
query: SQL-выражениеparams: Необязательная строка JSON параметров запроса (список или словарь)
Пример:
{
"query": "INSERT INTO users (name, email) VALUES ($1, $2)",
"params": ["John Doe", "john@example.com"]
}create_database
Создайте новую базу данных PostgreSQL.
Параметры:
database_name: Имя создаваемой базы данных
create_or_update_table
Создайте или обновите схему таблицы.
Параметры:
sql: SQL-оператор CREATE TABLE или ALTER TABLE
debug_postgres_connection
Отладка соединения PostgreSQL.
Переменные среды
Переменная | По умолчанию | Описание |
PG_HOST | локальный хост | Хост PostgreSQL |
PG_PORT | 5432 | Порт PostgreSQL |
PG_USER | постгрес | Имя пользователя PostgreSQL |
PG_ПАРОЛЬ | Пароль PostgreSQL | |
PG_DATABASE | постгрес | Имя базы данных по умолчанию |
ХОЗЯИН | 0.0.0.0 | Хост для привязки сервера MCP |
ПОРТ | 8056 | Порт для запуска сервера MCP |
Разработка
Проведение тестов
# Install test dependencies
pip install -r requirements-dev.txt
# Run tests
pytestСоздание образа Docker
docker build -t mcp-server-postgres .API-документация
Подробную документацию по API можно найти в спецификации OpenAPI .
Внося вклад
Вклады приветствуются! Пожалуйста, не стесняйтесь отправлять запрос на включение.
Лицензия
Данный проект лицензирован по лицензии MIT — подробности см. в файле LICENSE .
Благодарности
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
- AlicenseBqualityBmaintenanceA Model Context Protocol server that enables powerful PostgreSQL database management capabilities including analysis, schema management, data migration, and monitoring through natural language interactions.182,467198AGPL 3.0
- Alicense-qualityDmaintenanceA Model Context Protocol server that enables performing PostgreSQL database operations (create, read, update, delete) on User and Post entities through MCP tools.764MIT
- Alicense-qualityCmaintenanceA Model Context Protocol server that enables interaction with PostgreSQL databases to list tables, retrieve schemas, and execute read-only SQL queries.22MIT
- Flicense-qualityDmaintenanceAn MCP server that enables AI assistants to interact with PostgreSQL databases by executing SQL queries and inspecting database schemas. It provides tools for standardized database exploration and management through the Model Context Protocol.
Related MCP Connectors
MCP server for managing Prisma Postgres.
MCP server for interacting with the Supabase platform
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
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/asadudin/mcp-server-postgres'
If you have feedback or need assistance with the MCP directory API, please join our Discord server