数据传输元数据MCP服务器
一个MCP(模型上下文协议)服务器,提供查询Microsoft Ruby/Power Platform元数据的工具。该服务器允许像GitHub Copilot这样的AI助手与WAX环境交互,以检索实体和属性元数据。
概述
此MCP服务器通过标准化协议公开了元数据,使AI驱动的工具能够:
- 列出LOX环境中的所有实体
- 检索特定实体的详细元数据,包括属性、类型和选项集
- 访问查找关系和选择列表值
先决条件
- .NET 8.0 SDK 或更高版本(用于从源代码构建)
- BLOB环境 具有适当的访问凭据
- BLOB连接字符串 -请参阅 Microsoft文档 用于连接字符串格式
建设项目
从源代码构建
# Clone the repository
git clone https://github.com/WycliffeAssociates/DataverseMetadataMCPServer.git
cd DataverseMetadataMCPServer
# Build the project
dotnet build
# Build for release
dotnet build -c Release创建NuGet包
# Pack the project (creates .nupkg file in bin/Release)
dotnet pack -c Release该项目配置为为多个平台构建自包含的可执行文件:
win-x64-Windows 64位win-arm64-Windows ARM64osx-arm64-macOS ARM64(苹果硅)linux-x64-Linux 64位linux-arm64-Linux ARM64linux-musl-x64-基于Linux的musl(Alpine等)
运行服务器
环境变量
服务器需要设置一个作为环境变量的BLOCK连接字符串:
# Set the connection string environment variable
export DATAVERSE_CONNECTION_STRING="AuthType=OAuth;Username=youruser@yourdomain.com;Password=yourpassword;Url=https://yourorg.crm.dynamics.com;AppId=your-app-id-guid;RedirectUri=app://your-redirect-uri-guid;LoginPrompt=Auto"连接字符串组件:
AuthType-身份验证类型(OAuth、Office365等)Url-您的Webex环境URLUsername/Password-凭据(如果使用Office365身份验证)AppId-Azure AD应用程序IDRedirectUri-OAuth重定向类型- 身份验证方法所需的其他参数
从源代码运行
# Run the server directly
dotnet run --project DataverseMetadataMCPServer/DataverseMetadataMCPServer.csproj在VS代码中配置
创建或更新 .vscode/mcp.json 在您的工作空间中:
{
"servers": {
"DataverseMetadataMCPServer": {
"type": "stdio",
"command": "dotnet",
"args": [
"run",
"--project",
"/absolute/path/to/DataverseMetadataMCPServer/DataverseMetadataMCPServer.csproj"
],
"env": {
"DATAVERSE_CONNECTION_STRING": "AuthType=OAuth;Username=youruser@yourdomain.com;..."
}
}
}
}在Visual Studio中配置
创建 .mcp.json 在您的解决方案目录中:
{
"servers": {
"DataverseMetadataMCPServer": {
"type": "stdio",
"command": "dotnet",
"args": [
"run",
"--project",
"C:\\path\\to\\DataverseMetadataMCPServer\\DataverseMetadataMCPServer.csproj"
],
"env": {
"DATAVERSE_CONNECTION_STRING": "AuthType=OAuth;Username=youruser@yourdomain.com;..."
}
}
}
}可用工具
服务器提供以下MCP工具:
1.获取实体异步列表
说明: 获取一个包含所有实体及其显示名称的列表。
参数: 无
退货: 将实体逻辑名称映射到其显示名称的字典。
示例用法:
User: "Show me all the entities in the Dataverse environment"
AI: Uses GetListOfEntitiesAsync to retrieve and display the list样本输出:
{
"account": "Account",
"contact": "Contact",
"opportunity": "Opportunity",
"lead": "Lead"
}2.获取实体数据异步
说明: 获取指定实体的所有属性的详细元数据。
参数:
logicalEntityName(string,必填)-要检索元数据的实体的逻辑名称
退货: 列表 AttributeMetadataInfo 对象包含:
LogicalName-属性的逻辑名称DisplayName-用户友好的显示名称AttributeType-属性的数据类型(字符串、整数、查找、选择列表等)LookupTargetEntity-对于查找字段,目标实体OptionSetValues-对于选择列表/多选字段,标签的选项值字典
示例用法:
User: "What are the attributes of the account entity?"
AI: Uses GetEntityMetadataAsync with logicalEntityName="account"样本输出:
[
{
"LogicalName": "accountid",
"DisplayName": "Account",
"AttributeType": "Uniqueidentifier",
"LookupTargetEntity": null,
"OptionSetValues": null
},
{
"LogicalName": "name",
"DisplayName": "Account Name",
"AttributeType": "String",
"LookupTargetEntity": null,
"OptionSetValues": null
},
{
"LogicalName": "primarycontactid",
"DisplayName": "Primary Contact",
"AttributeType": "Lookup",
"LookupTargetEntity": "contact",
"OptionSetValues": null
},
{
"LogicalName": "accountcategorycode",
"DisplayName": "Category",
"AttributeType": "Picklist",
"LookupTargetEntity": null,
"OptionSetValues": {
"1": "Preferred Customer",
"2": "Standard"
}
}
]发布到NuGet.org
- 更新包元数据 在
DataverseMetadataMCPServer.csproj:
- 集 到一个唯一的名称 - 更新 - 添加 `, `等等。
- 打包项目:
dotnet pack -c Release- 发布到NuGet.org:
dotnet nuget push bin/Release/*.nupkg --api-key --source https://api.nuget.org/v3/index.json- 配置客户端以使用已发布的包:
{
"servers": {
"DataverseMetadataMCPServer": {
"type": "stdio",
"command": "dnx",
"args": [
"DataverseMetadataMCPServer",
"--version",
"0.1.0-beta",
"--yes"
],
"env": {
"DATAVERSE_CONNECTION_STRING": "..."
}
}
}
}建筑
服务器是使用以下方式构建的:
- .NET 8.0 -现代跨平台运行时
- 模型上下文协议。服务器。标准输入输出 -MCP SDK。网
- 微软。PowerPlatform。网络。客户端 -官方数据库
- 微软。扩展。托管 -用于应用程序托管和DI
服务器使用标准输入/输出(stdio)进行通信,使其与任何符合MCP的客户端兼容。
故障排除
连接问题
如果遇到连接错误:
- 验证您的连接字符串是否正确
- 确保您在Webex环境中具有适当的权限
- 检查是否可以访问网络
- 验证AppId和RedirectUri是否已在Azure AD中注册(用于OAuth)
缺少环境变量
如果服务器无法启动“DATAVERSE_CONNECTION_STRING环境变量未设置”:
- 确保在shell或IDE配置中设置了环境变量
- 该变量必须对运行服务器的进程可用
额外资源
许可证
看 许可证 文件以获取详细信息。
