
mcp server db ts
未知
Repository Info
About This Server
未知
Model Context Protocol (MCP) - This server can be integrated with AI applications to provide additional context and capabilities, enabling enhanced AI interactions and functionality.
Documentation
MCP 数据库服务器 (TypeScript)
这是一个基于 Model Context Protocol (MCP) 的数据库查询服务器,用 TypeScript 实现。它允许 AI 模型安全地查询关系型数据库,如 MySQL 和 PostgreSQL。
功能特性
- 支持 MySQL 和 PostgreSQL 数据库
- 提供表结构信息作为资源
- 支持只读 SQL 查询执行
- 使用事务确保查询安全性
安装
使用 cnpm 进行安装:
git clone <repository-url>
cd mcp-server-db-ts
cnpm install
配置
- 复制
.env.example文件为.env:
cp .env.example .env
- 编辑
.env文件,设置您的数据库连接信息:
# 数据库连接配置
# 数据库类型: mysql 或 postgres
DB_TYPE=mysql
# MySQL 配置
MYSQL_HOST=127.0.0.1
MYSQL_PORT=3306
MYSQL_USER=root
MYSQL_PASS=your_password
MYSQL_DB=your_database
# PostgreSQL 配置
PG_HOST=127.0.0.1
PG_PORT=5432
PG_USER=postgres
PG_PASS=your_password
PG_DB=your_database
# 服务器配置
SERVER_NAME=mcp-server-db-ts
SERVER_VERSION=1.0.0
构建
cnpm run build
运行
cnpm start
开发模式
cnpm run dev
支持的 MCP 功能
资源
list_resources: 列出数据库中的所有表read_resource: 获取指定表的结构信息
工具
db_query: 执行只读 SQL 查询
使用示例
-
列出所有表:
- MCP 请求:
list_resources - 响应: 以 URI 形式返回所有表的列表
- MCP 请求:
-
获取表结构:
- MCP 请求:
read_resource使用特定表的 URI - 响应: 返回表的列信息
- MCP 请求:
-
执行查询:
- MCP 请求:
call_tool使用db_query工具和 SQL 查询 - 响应: 返回查询结果
- MCP 请求:
许可证
MIT
Quick Start
Clone the repository
git clone https://github.com/cherl/mcp-server-db-tsInstall dependencies
cd mcp-server-db-ts
npm installFollow the documentation
Check the repository's README.md file for specific installation and usage instructions.
Repository Details
Recommended MCP Servers
Discord MCP
Enable AI assistants to seamlessly interact with Discord servers, channels, and messages.
Knit MCP
Connect AI agents to 200+ SaaS applications and automate workflows.
Apify MCP Server
Deploy and interact with Apify actors for web scraping and data extraction.
BrowserStack MCP
BrowserStack MCP Server for automated testing across multiple browsers.
Zapier MCP
A Zapier server that provides automation capabilities for various apps.