- Explore MCP Servers
- MCPTools
Mcptools
What is Mcptools
MCPTools is a Model Context Protocol (MCP) implementation written in C# that facilitates database operations.
Use cases
Use cases include developing backend services that require database connectivity, testing database operations, and managing PostgreSQL databases through a structured protocol.
How to use
To use MCPTools, compile the project using ‘dotnet build’ and run it with ‘dotnet run’. Configure the MCP in a JSON format to set up server connections.
Key features
Key features include database connection management, CRUD operations (Create, Read, Update, Delete), table structure description, table creation/deletion, index management, and schema creation.
Where to use
MCPTools can be used in various fields such as software development, database management, and any application requiring database interactions.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Overview
What is Mcptools
MCPTools is a Model Context Protocol (MCP) implementation written in C# that facilitates database operations.
Use cases
Use cases include developing backend services that require database connectivity, testing database operations, and managing PostgreSQL databases through a structured protocol.
How to use
To use MCPTools, compile the project using ‘dotnet build’ and run it with ‘dotnet run’. Configure the MCP in a JSON format to set up server connections.
Key features
Key features include database connection management, CRUD operations (Create, Read, Update, Delete), table structure description, table creation/deletion, index management, and schema creation.
Where to use
MCPTools can be used in various fields such as software development, database management, and any application requiring database interactions.
Clients Supporting MCP
The following are the main client software that supports the Model Context Protocol. Click the link to visit the official website for more information.
Content
MCPTool
MCPTool 是一个 C#编写的操作数据库的 MCP(Model Context Protocol)实现。
现支持Postgres、MongoDB和MSSQL数据库。
项目结构
Common/interface/IRelationalDB.cs- 关系型数据库接口定义Common/interface/IMongoDB.cs- MongoDB接口定义Common/provider/PostgreSQLProvider.cs- PostgreSQL的实现Common/provider/MongoDBProvider.cs- MongoDB的实现Common/provider/MSSQLProvider.cs- MSSQL的实现Common/DBServerTools.cs- 使用MCP工具包装数据库操作功能DBMCP/Program.cs- Standard IO通信模式的MCP服务器DBMCP_SSE/Program.cs- SSE通信模式的MCP服务器
功能
实现了以下数据库操作功能:
关系型数据库功能 (PostgreSQL & MSSQL)
- 注册/注销数据库连接
- 查询(SELECT)
- 插入(INSERT)
- 更新(UPDATE)
- 删除(DELETE)
- 描述表结构
- 创建/删除表
- 创建/删除索引
- 列出所有表
- 创建类型
- 创建 Schema
MongoDB 功能
- 注册/注销数据库连接
- 查询文档(Find)
- 插入单个/多个文档(InsertOne/InsertMany)
- 更新文档(UpdateMany)
- 删除文档(DeleteMany)
- 创建/删除集合
- 创建/删除索引
- 列出集合
- 获取集合详情
依赖项
- .NET 7.0
- ModelContextProtocol v0.1.0-preview.11
- Npgsql v9.0.3
- MongoDB.Driver v2.24.0
- System.Data.SqlClient v4.9.0
- SQLParser v3.0.22
- xUnit (用于测试)
编译和运行
服务器
Standard IO模式
# 编译
dotnet build
# 运行
cd DBMCP
dotnet run
SSE模式
# 编译
dotnet build
# 运行
cd DBMCP_SSE
dotnet run
测试
dotnet test
使用示例
配置 MCP
{
"servers": {
"dbmcp-stdio": {
"type": "stdio",
"command": "dotnet",
"args": [
"run",
"--project",
"path/to/DBMCP",
"--no-build"
]
},
"dbmcp-sse": {
"type": "sse",
"url": "http://127.0.0.1:5000/sse"
}
}
}
注意事项
- 连接字符串中需要正确配置 PostgreSQL、MSSQL 或 MongoDB 的连接信息
- 客户端测试默认连接到本地数据库服务器(localhost)
- 需要确保测试数据库存在并且有访问权限
- MongoDB 文档操作使用标准 JSON 格式
Dev Tools Supporting MCP
The following are the main code editors that support the Model Context Protocol. Click the link to visit the official website for more information.










