MCP cover image
See in Github
2025-03-19

1

Github Watches

1

Github Forks

0

Github Stars

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

配置

  1. 复制 .env.example 文件为 .env:
cp .env.example .env
  1. 编辑 .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 查询

使用示例

  1. 列出所有表:

    • MCP 请求: list_resources
    • 响应: 以 URI 形式返回所有表的列表
  2. 获取表结构:

    • MCP 请求: read_resource 使用特定表的 URI
    • 响应: 返回表的列信息
  3. 执行查询:

    • MCP 请求: call_tool 使用 db_query 工具和 SQL 查询
    • 响应: 返回查询结果

许可证

MIT

相关推荐

  • NiKole Maxwell
  • I craft unique cereal names, stories, and ridiculously cute Cereal Baby images.

  • https://suefel.com
  • Latest advice and best practices for custom GPT development.

  • Yusuf Emre Yeşilyurt
  • I find academic articles and books for research and literature reviews.

  • https://maiplestudio.com
  • Find Exhibitors, Speakers and more

  • Carlos Ferrin
  • Encuentra películas y series en plataformas de streaming.

  • Joshua Armstrong
  • Confidential guide on numerology and astrology, based of GG33 Public information

  • Contraband Interactive
  • Emulating Dr. Jordan B. Peterson's style in providing life advice and insights.

  • rustassistant.com
  • Your go-to expert in the Rust ecosystem, specializing in precise code interpretation, up-to-date crate version checking, and in-depth source code analysis. I offer accurate, context-aware insights for all your Rust programming questions.

  • Elijah Ng Shi Yi
  • Advanced software engineer GPT that excels through nailing the basics.

  • Emmet Halm
  • Converts Figma frames into front-end code for various mobile frameworks.

  • apappascs
  • Découvrez la collection la plus complète et la plus à jour de serveurs MCP sur le marché. Ce référentiel sert de centre centralisé, offrant un vaste catalogue de serveurs MCP open-source et propriétaires, avec des fonctionnalités, des liens de documentation et des contributeurs.

  • modelcontextprotocol
  • Serveurs de protocole de contexte modèle

  • Mintplex-Labs
  • L'application tout-en-un desktop et Docker AI avec chiffon intégré, agents AI, constructeur d'agent sans code, compatibilité MCP, etc.

  • ShrimpingIt
  • Manipulation basée sur Micropython I2C de l'exposition GPIO de la série MCP, dérivée d'Adafruit_MCP230XX

  • OffchainLabs
  • Aller la mise en œuvre de la preuve de la participation Ethereum

  • n8n-io
  • Plateforme d'automatisation de workflow à code équitable avec des capacités d'IA natives. Combinez le bâtiment visuel avec du code personnalisé, de l'auto-hôte ou du cloud, 400+ intégrations.

  • huahuayu
  • Une passerelle API unifiée pour intégrer plusieurs API d'explorateur de blockchain de type étherscan avec la prise en charge du protocole de contexte modèle (MCP) pour les assistants d'IA.

    Reviews

    1 (1)
    Avatar
    user_huIkDQQW
    2025-04-15

    I've been using the Hevy MCP Server by VReippainen for a while now, and it has completely transformed my gaming experience. The setup process was seamless, and the performance is outstanding, with minimal lag and superb stability. The welcoming features make it feel like a community right from the start. Highly recommended for any serious MCP user! Check it out here: https://mcp.so/server/hevy-mcp-server/VReippainen