内容
# Postgres MCP 代理
## 概述
Postgres MCP 代理是一个模型上下文协议(MCP)服务器,旨在与 PostgreSQL 数据库交互。它允许使用 MCP 框架查询和管理数据库资源。
## 安装
### 前置条件
- Node.js(v16 或更高版本)
- PostgreSQL
### 通过 NPM 安装
要通过 npm 安装 Postgres MCP 代理,请运行:
```bash
npm install -g postgres-mcp-agent
```
## 从源代码构建
### 克隆仓库
要从源代码构建 Postgres MCP 代理,首先克隆仓库:
```bash
git clone https://github.com/your-repo/postgres-mcp-agent.git
cd postgres-mcp-agent
```
### 安装依赖项
安装所需的依赖项:
```bash
npm install
```
### 构建项目
使用 TypeScript 构建项目:
```bash
npm run build
```
这将把 TypeScript 文件编译成 JavaScript,并生成包含编译文件的 `dist` 文件夹。
## 使用
### 运行 MCP 服务器
要启动 MCP 服务器,请使用以下命令:
```bash
node dist/index.js postgres://<username>:<password>@<host>:<port>/<database>
```
用您的 PostgreSQL 凭证替换 `<username>`、`<password>`、`<host>`、`<port>` 和 `<database>`。
### 安装到 MCP 客户端
要将 Postgres MCP 代理集成到 MCP 客户端,请在您的 MCP 客户端设置中添加以下配置:
```json
{
"postgres-local": {
"command": "node",
"args": [
"/path/to/postgres-mcp-agent/dist/index.js",
"postgres://<username>:<password>@<host>:<port>/<database>"
]
}
}
```
用构建的 MCP 代理的路径替换 `/path/to/postgres-mcp-agent/dist/index.js`,并用您的 PostgreSQL 凭证替换 `<username>`、`<password>`、`<host>`、`<port>` 和 `<database>`。
## 贡献
欢迎贡献!请为任何错误或功能请求提交拉取请求或打开问题。
## 许可证
该项目在 MIT 许可证下获得许可。