mcpField
P
PowerPlatform MCP Server

PowerPlatform MCP Server

本地服务
github.com/RuniThomsen数据库073 周前更新

关于 PowerPlatform MCP Server

用于访问 PowerPlatform 和 Dataverse 实体及记录的 MCP 服务,面向开发者提供元数据、关系和记录查询,并支持 OData 查询与上下文提示词。

主要功能

  1. 01查询实体元数据与属性
  2. 02使用筛选条件查询 OData 记录
  3. 03映射实体关系
  4. 04查询全局选项集
  5. 05交互式设备代码认证

适用场景

  1. 01检查实体字段与元数据
  2. 02筛选查询 Dataverse 记录
  3. 03了解实体间关系
  4. 04构建 OData 查询模板

MCP 相关

该服务向 MCP 客户端提供工具,用于获取实体元数据、属性、关系、选项集和记录,并支持 OData 筛选查询。它还提供实体概览、属性详情、查询模板和关系图提示词。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"powerplatform-mcp-runithomsen": {
"command": "npx",
"args": [
"-y",
"powerplatform-mcp"
]
}
}
}
启动命令npx -y powerplatform-mcp

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
npmpowerplatform-mcp

工具

还没有获取到工具列表

本地服务需要在你的电脑上运行后才能读取工具,维护者暂未提供工具列表。

详细介绍


title: "README" tags: ["automation", "azure", "cloud", "documentation", "indexing", "markdown", "mcp", "search", "tabular-model", "tom"] project: "General" phase: "Template" updated: "2025-05-29"


title: "PowerPlatform MCP 服务" tags: ["automation", "azure", "cloud", "indexing", "markdown", "script", "search"] project: "General" phase: "Execution" updated: "2025-05-29"

PowerPlatform MCP 服务

一种 Model Context Protocol(MCP)服务,可智能访问 PowerPlatform/Dataverse 实体和记录。此工具提供上下文感知的辅助、实体探索和元数据访问。

主要功能:

  • 丰富的实体元数据探索,提供格式化且能感知上下文的提示词
  • 支持高级 OData 查询和智能筛选
  • 全面的关系映射和可视化
  • 通过 AI Agent 辅助构建查询和数据建模
  • 全面访问实体属性、关系和全局选项集
  • 为无法访问客户端密钥的场景提供交互式身份验证流程

安装

你可以通过以下两种方式安装并运行此工具:

选项 1:全局安装/group/640141a5-f80e-4612-9d12-409154b80395/datasets/140f3c72-1b9c-4a40-9b44-f3761c94c2aa
npm install -g powerplatform-mcp

然后运行:

powerplatform-mcp
选项 2:通过 npx 直接运行

无需安装即可运行:

npx powerplatform-mcp

配置

运行前,请设置以下环境变量:

# PowerPlatform/Dataverse connection details - Interactive Authentication (Recommended)
POWERPLATFORM_URL=https://yourenvironment.crm.dynamics.com
POWERPLATFORM_CLIENT_ID=your-azure-app-client-id
POWERPLATFORM_TENANT_ID=your-azure-tenant-id
POWERPLATFORM_TOKEN_CACHE_PATH=/path/to/token_cache.json  # Optional: defaults to ~/.powerplatform-mcp/token_cache.json
身份验证选项

此 MCP 服务现在主要使用带设备代码流程的交互式身份验证。这在以下情况中特别有用:

  • 你无法创建客户端密钥
  • 你在个人环境中工作
  • 你需要使用个人凭据和 MFA

首次运行服务时,它会显示用于身份验证的设备代码和 URL。在浏览器中打开该 URL,使用 Power Platform 凭据登录,然后输入代码。服务会将身份验证令牌安全地存储在令牌缓存文件中,以供日后使用。

需要身份验证时的输出示例:

To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code ABC123DEF to authenticate.

注意: 之前使用客户端密钥的客户端凭据身份验证方式已弃用,改用这种更安全、更灵活的交互式身份验证方式。

用法

这是一个 MCP 服务,旨在与 Cursor、Claude App 和 GitHub Copilot 等兼容 MCP 的客户端配合使用。运行后,它会提供用于检索 PowerPlatform 实体元数据和记录的工具。

可用工具
  • get-entity-metadata:获取 PowerPlatform 实体的元数据
  • get-entity-attributes:获取 PowerPlatform 实体的属性/字段
  • get-entity-attribute:获取 PowerPlatform 实体的特定属性/字段
  • get-entity-relationships:获取 PowerPlatform 实体的关系
  • get-global-option-set:获取全局选项集定义
  • get-record:按实体名称和 ID 获取特定记录
  • query-records:使用 OData 筛选表达式查询记录
  • use-powerplatform-prompt:使用 PowerPlatform 实体的预定义提示词模板

MCP 提示词

此服务包含提示词功能,可提供格式化且上下文丰富的 PowerPlatform 实体信息。

可用提示词类型

use-powerplatform-prompt 工具支持以下提示词类型:

  1. ENTITY_OVERVIEW:实体的全面概述
  2. ATTRIBUTE_DETAILS:特定实体属性的详细信息
  3. QUERY_TEMPLATE:实体的 OData 查询模板,包含筛选示例
  4. RELATIONSHIP_MAP:实体关系的可视化映射
示例
实体概述提示词
// Example client code
await mcpClient.invoke("use-powerplatform-prompt", {
  promptType: "ENTITY_OVERVIEW",
  entityName: "account"
});

输出:

## Power Platform Entity: account

This is an overview of the 'account' entity in Microsoft Power Platform/Dataverse:

### Entity Details
- Display Name: Account
- Schema Name: Account
- Description: Business that represents a customer or potential customer
- Primary Key: accountid
- Primary Name: name

### Key Attributes
- name: String (Account Name)
- emailaddress1: String (Email)
- telephone1: String (Main Phone)
- address1_city: String (City)
- statecode: Status (Status)
- accountnumber: String (Account Number)
- industrycode: OptionSetValue (Industry)
- revenue: Money (Annual Revenue)
- ownerid: Owner (Owner)
- createdon: DateTime (Created On)

### Relationships
- One-to-Many Relationships: 42
- Many-to-Many Relationships: 8

You can query this entity using OData filters against the plural name.
属性详细信息提示词
await mcpClient.invoke("use-powerplatform-prompt", {
  promptType: "ATTRIBUTE_DETAILS",
  entityName: "account",
  attributeName: "revenue"
});

输出:

## Attribute: revenue

Details for the 'revenue' attribute of the 'account' entity:

- Display Name: Annual Revenue
- Description: Annual revenue for the account
- Type: Money
- Format: Currency
- Is Required: No
- Is Searchable: true

### Usage Notes
- Data Type: Money
- Required: No
- Max Length: N/A
查询模板提示词
await mcpClient.invoke("use-powerplatform-prompt", {
  promptType: "QUERY_TEMPLATE",
  entityName: "account"
});

输出:

## OData Query Template for accounts

Use this template to build queries against the accounts entity:
accounts?$select=name,emailaddress1,telephone1, address1_city,statecode&$filter=name eq 'Example'&$orderby=name asc&$top=50
常见筛选示例
  • 等于:name eq 'Contoso'
  • 包含:contains(name, 'Contoso')
  • 日期大于:createdon gt 2023-01-01T00:00:00Z
  • 多个条件:name eq 'Contoso' and statecode eq 0

#### Relationship Map Prompt

```javascript
await mcpClient.invoke("use-powerplatform-prompt", {
  promptType: "RELATIONSHIP_MAP",
  entityName: "contact"
});

输出:

## Relationship Map for contact

This shows all relationships for the 'contact' entity:

### One-to-Many Relationships (contact as Primary)
- contact_activity_parties: contact (1) → activityparty (N)
- contact_connections1: contact (1) → connection (N)
- contact_connections2: contact (1) → connection (N)
- contact_customer_contacts: contact (1) → contact (N)
- contact_master_contact: contact (1) → contact (N)

### One-to-Many Relationships (contact as Related)
- account_primary_contact: account (1) → contact (N)
- customer_contacts: customer (1) → contact (N)
- system_user_contacts: systemuser (1) → contact (N)

### Many-to-Many Relationships
- contactleads_association: contact (N) ↔ lead (N)
- contactopportunities_association: contact (N) ↔ opportunity (N)
- contactquotes_association: contact (N) ↔ quote (N)

提示词示例

以下是如何使用 PowerPlatform MCP 提示词与助手交互的一些示例:

1. 实体理解

你可以用自然语言向助手询问实体:

User: "Tell me about the Account entity in our PowerPlatform environment"

Response:
[uses ENTITY_OVERVIEW prompt internally]

Here's what I found about the Account entity:
- It's a core business entity representing customers and potential customers
- The primary identifier is 'accountid' and the primary name field is 'name'
- Key fields include:
  * name (Account Name)
  * emailaddress1 (Email)
  * telephone1 (Main Phone)
  * revenue (Annual Revenue)
- It has 42 one-to-many relationships and 8 many-to-many relationships
2. 构建查询

你可以请求帮助来构建查询:

User: "Help me write a query to find active accounts with revenue over $1M in California"

Response:
[uses QUERY_TEMPLATE prompt internally]

Here's the OData query you need:
accounts?$select=name,revenue,statecode,address1_stateorprovince
&$filter=statecode eq 0 
    and revenue gt 1000000 
    and address1_stateorprovince eq 'California'
&$orderby=revenue desc

This query:
1. Selects relevant fields
2. Filters for active accounts (statecode eq 0)
3. Checks revenue > $1M
4. Filters for California location
5. Orders by revenue highest to lowest
3. 理解关系

你可以自然地探索实体关系:

User: "How are Accounts and Contacts related in our system?"

Response:
[uses RELATIONSHIP_MAP prompt for both entities internally]

Here are the key relationships between Accounts and Contacts:

1. Primary Contact (One-to-Many):
   - account_primary_contact: Account (1) → Contact (N)
   - An account can have many contacts, but one designated as primary

2. Customer Relationship:
   - contact_customer_accounts: Contact (N) ← Account (1)
   - Contacts can be associated with customer accounts

3. Additional Relationships:
   - accountleads_association: For lead tracking
   - account_connections: For relationship management
4. 字段/属性调查

你可以询问特定字段:

User: "What kind of field is the revenue field on Account?"

Response:
[uses ATTRIBUTE_DETAILS prompt internally]

The revenue field on Account is:
- Data Type: Money
- Format: Currency
- Not required
- Searchable: Yes
- Used for: Tracking annual revenue for the account
- Can be used in advanced find and filtered views
5. 复杂数据建模

你可以获取数据建模决策方面的帮助:

User: "I need to design a solution for tracking product reviews. Which entities should I relate to?"

Response:
[uses multiple ENTITY_OVERVIEW and RELATIONSHIP_MAP prompts internally]

Based on the existing data model, here's a suggested approach:

1. Product (existing entity):
   - Already has relationships with:
     * Price lists
     * Product categories
     * Inventory units

2. New Review entity should relate to:
   - Product (N:1) - Each review is for one product
   - Contact (N:1) - Reviews are written by contacts
   - Account (N:1) - Optional link to company if B2B review

Here's a sample lookup field structure...
[continues with detailed implementation guidance]
6. 调试协助

你可以获取故障排查方面的帮助:

User: "Why am I getting 'invalid property' when querying account.customertypecode?"

Response:
[uses ATTRIBUTE_DETAILS prompt internally]

I see the issue. The field 'customertypecode' is actually named 'customertype' in your environment. Here's the correct field information:
- Logical Name: customertype
- Type: OptionSetValue
- Valid Values:
  * 1 = Competitor
  * 2 = Consultant
  * 3 = Customer
  * 4 = Investor
  * 5 = Partner
  * 6 = Influencer

Try updating your query to use 'customertype' instead of 'customertypecode'.

这些示例展示了 AI 助手如何利用 MCP 提示词,为 PowerPlatform 开发任务提供上下文感知且准确的协助。AI 能够理解你环境的特定配置,并在简单查询和复杂架构决策方面提供帮助。

许可证

MIT

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。