数据库查询服务

Pagila MCP是一个基于FastMCP开发的只读PostgreSQL数据库查询服务,用于安全地查询Pagila数据库。

  • by lyrken
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 lyrken/pagila_mcp

使用说明

Pagila MCP(只读)

用FASTMCP开发的查询Pagila数据库的MCP服务器(PostgreSQL) 安全(只读)。

要求

  • PostgreSQL 18(兼容)
  • 数据库:Pagila(加载)
  • Python 3.x
  • 紫外线推荐

安装

uv venv
.\.venv\Scripts\activate
uv pip install fastmcp "mcp[cli]" psycopg[binary] sqlparse
v

#VARIABLES DE ENTORNO

$env:PG_HOST="localhost"
$env:PG_PORT="5432"
$env:PG_DB="pagila"
$env:PG_USER="postgres"
$env:PG_PASS="TU_PASSWORD"

# Modelo relacional (Pagila)

La base de datos Pagila contiene 15 tablas principales, entre ellas:
actor, address, category, city, country, customer, film, film_actor, film_category,
inventory, language, payment, rental, staff, store.

Relaciones principales:
- rental se relaciona con inventory mediante inventory_id.
- inventory se relaciona con film mediante film_id.
- payment se relaciona con rental mediante rental_id.
- film_actor es una tabla puente (muchos a muchos) entre film y actor.
- film_category es una tabla puente (muchos a muchos) entre film y category.
- customer se relaciona con rental mediante customer_id.


//Lyrken Calle V.//```