本项目是一个支持自定义工具的 Modular Command Platform (MCP) 服务器,采用 C# 编写。其一大特色功能是能够在 Firebird 数据库中执行动态查询,同时支持过滤和记录限制。
本项目是一个支持自定义工具的 Modular Command Platform (MCP) 服务器,由 C# 编写而成。借助它,你可以在 Firebird 数据库中执行动态查询,并进行过滤和记录限制。
使用以下命令安装 NuGet 包:
dotnet add package ModelContextProtocol --prerelease
appsettings.json 文件在项目根目录中创建一个 appsettings.json 文件,并添加以下内容:
{
"ConnectionStrings": {
"FirebirdDb": "Database=C:\\你的数据文件名.fdb;User=SYSDBA;Password=masterkey;Dialect=3;Charset=NONE;"
}
}
📝 请根据你的数据库文件的实际路径修改 C:\\你的数据文件名.fdb。
📂 推荐的项目结构如下:
src/
├── MCPServer/
│ ├── Factory/
│ │ └── FbConnectionFactory.cs
│ ├── Tools/
│ │ └── FbQueries.cs
│ ├── Program.cs
│ └── appsettings.json
[McpTool, Description("列出 Firebird 表中的所有记录")]
public Liststring, object>> ListTable(string tableName, string filter = "", int limitRecords = 0)
此工具可以从 Firebird 数据库表中返回记录,支持以下功能:
FIRST){
"tool": "ListTable",
"args": {
"tableName": "CUSTOMERS",
"filter": "STATUS = 'ACTIVE'",
"limitRecords": 10
}
}
Host.CreateApplicationBuilder 实现)appsettings.json 实现)使用以下命令运行 MCP 服务器:
npx @modelcontextprotocol/inspector dotnet run