Token导航 LogoToken导航TokenDH.com
Amazon Q Postgresql MCP Server logo
数据服务未说明官方级别未说明来源级核验

Amazon Q Postgresql MCP Server

MCP Server

一个基于Rust的模块化能力提供者(MCP)服务器,使Amazon Q能够通过聊天界面查询PostgreSQL数据库结构并执行只读查询。

工具数

3

提示词数

0

GitHub Stars

0

资源数

0
数据分析PostgreSQLAPI集成

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

qthanh04

提供方

qthanh04

最后核验

2026/5/17 20:21

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

用于Amazon Q的PostgreSQL MCP服务器

一个基于Rust的模块化能力提供者(MCP)服务器,支持Amazon Q交互PostgreSQL数据库。服务器允许用户通过Amazon Q聊天界面查询数据库结构的只读查询。

概述

此项目实现了一个遵循Amazon Q CLI使用的MCP协议的PostgreSQL服务器

  1. 列出PostgreSQL数据库中的所有表
  2. 获取特定表的架构信息
  3. 执行只读SQL查询,结果返回为JSON

先决条件

  • 锈蚀1.70
  • 货物包装经理
cargo new postgresql_server
  • PostgreSQL数据库
  • 亚马逊Q CLI

安装

  1. 克隆存储库:
git clone ...
cd postgresql-mcp-server
  1. 构建项目:
cargo build --release --bin postgresql_server

用法

运行服务器

  • 服务器需要PostgreSQL连接字符串作为命令行参数:
./target/release/postgresql_server "postgresql://username:password@hostname:port/database"

与Amazo Q CLI集成

  1. 创建或编辑MCP
vim ~/.aws/amazonq/mcp.json
  1. 将PosgreSQL服务器配置添加到文件
{
  "mcpServers": {
    "calculator": {
      "command": "/home/ec2-user/sample-building-mcp-servers-with-rust/target/release/calculator_server",
      "args": []
    },
    "rds": {
      "command": "/home/ec2-user/sample-building-mcp-servers-with-rust/target/release/rds_server",
      "args": []
    },
    "s3": {
      "command": "/home/ec2-user/sample-building-mcp-servers-with-rust/target/release/s3_server",
      "args": []
    },
    "postgres": {
      "command": "/home/ec2-user/sample-building-mcp-servers-with-rust/target/release/postgresql_server",
      "args": [
        "postgresql://postgres:@.com:5432/demo"
      ]
    }
  }
}
  1. 测试Q Amanzon服务器
  • 开始Q亚马逊
qchat
  • 要求Amazon Q列出数据库中的表

Can you list all tables in my PostgreSQL database using the postgres operator?

  • 尝试询问特定表的架构:

What columns are in the student table?

  • 执行SQL查询:

List 100 students sorted by name.

项目结构

  • src/main.rs:命令行参数、日志设置和服务器初始化的入口点
  • src/operator.rs 使用数据库交互工具实现PostgreSQL。

工具实施 operator.rs

服务器使用RMCP框架中的工具artribute实现了三个主要工具:

  1. 列表表格:
#[tool(description = "List tables in the PostgreSQL database")]
async fn list_tables(&self) -> String {
    // Implementation that queries information_schema.tables
    // and returns a JSON string of table names
}
  1. 获取表架构:
#[tool(description = "Get schema for a specific table")]
async fn get_table_schema(
    &self,
    #[tool(param)]
    #[schemars(description = "Name of the table to get schema for")]
    table_name: String,
) -> String {
    // Implementation that queries information_schema.columns
    // and returns a JSON string of column names and data types
}
  1. 执行SQL查询:
#[tool(description = "Run a read-only SQL query")]
async fn query(
    &self,
    #[tool(param)]
    #[schemars(description = "SQL query to execute (read-only)")]
    sql: String,
) -> String {
    // Implementation that executes the SQL query
    // and returns a JSON string of the results
}

目录标签

目录标签

数据分析PostgreSQLAPI集成Makefile本地部署数据库查询只读操作AmazonQ集成Rust开发

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

none

工具数量(toolCount,工具数)

3

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明none部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP