powerplatform-mcp 0.4.2 → 0.4.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -73,7 +73,12 @@ export class PowerPlatformService {
73
73
  * @param entityName The logical name of the entity
74
74
  */
75
75
  async getEntityMetadata(entityName) {
76
- return this.makeRequest(`api/data/v9.2/EntityDefinitions(LogicalName='${entityName}')`);
76
+ const response = await this.makeRequest(`api/data/v9.2/EntityDefinitions(LogicalName='${entityName}')`);
77
+ // Remove Privileges property if it exists
78
+ if (response && typeof response === 'object' && 'Privileges' in response) {
79
+ delete response.Privileges;
80
+ }
81
+ return response;
77
82
  }
78
83
  /**
79
84
  * Get metadata about entity attributes/fields
@@ -81,10 +86,40 @@ export class PowerPlatformService {
81
86
  */
82
87
  async getEntityAttributes(entityName) {
83
88
  const selectProperties = [
84
- 'AttributeType',
85
89
  'LogicalName',
86
90
  ].join(',');
87
- return this.makeRequest(`api/data/v9.2/EntityDefinitions(LogicalName='${entityName}')/Attributes?$select=${selectProperties}&$filter=AttributeType ne 'Virtual'`);
91
+ // Make the request to get attributes
92
+ const response = await this.makeRequest(`api/data/v9.2/EntityDefinitions(LogicalName='${entityName}')/Attributes?$select=${selectProperties}&$filter=AttributeType ne 'Virtual'`);
93
+ if (response && response.value) {
94
+ // First pass: Filter out attributes that end with 'yominame'
95
+ response.value = response.value.filter((attribute) => {
96
+ const logicalName = attribute.LogicalName || '';
97
+ return !logicalName.endsWith('yominame');
98
+ });
99
+ // Filter out attributes that end with 'name' if there is another attribute with the same name without the 'name' suffix
100
+ const baseNames = new Set();
101
+ const namesAttributes = new Map();
102
+ for (const attribute of response.value) {
103
+ const logicalName = attribute.LogicalName || '';
104
+ if (logicalName.endsWith('name') && logicalName.length > 4) {
105
+ const baseName = logicalName.slice(0, -4); // Remove 'name' suffix
106
+ namesAttributes.set(baseName, attribute);
107
+ }
108
+ else {
109
+ // This is a potential base attribute
110
+ baseNames.add(logicalName);
111
+ }
112
+ }
113
+ // Find attributes to remove that match the pattern
114
+ const attributesToRemove = new Set();
115
+ for (const [baseName, nameAttribute] of namesAttributes.entries()) {
116
+ if (baseNames.has(baseName)) {
117
+ attributesToRemove.add(nameAttribute);
118
+ }
119
+ }
120
+ response.value = response.value.filter(attribute => !attributesToRemove.has(attribute));
121
+ }
122
+ return response;
88
123
  }
89
124
  /**
90
125
  * Get metadata about a specific entity attribute/field
package/build/index.js CHANGED
@@ -92,8 +92,10 @@ server.prompt("entity-overview", "Get an overview of a Power Platform entity", {
92
92
  `- Primary Name: ${metadata.PrimaryNameAttribute}`;
93
93
  // Get key attributes
94
94
  const keyAttributes = attributes.value
95
- .filter((attr) => attr.IsValidForRead === true && !attr.AttributeOf)
96
- .map((attr) => `- ${attr.LogicalName}: ${attr.AttributeType} (${attr.DisplayName?.UserLocalizedLabel?.Label || 'No display name'})`)
95
+ .map((attr) => {
96
+ const attrType = attr["@odata.type"] || attr.odata?.type || "Unknown type";
97
+ return `- ${attr.LogicalName}: ${attrType}`;
98
+ })
97
99
  .join('\n');
98
100
  // Get relationships summary
99
101
  const relationships = await service.getEntityRelationships(entityName);
@@ -544,9 +546,11 @@ server.tool("use-powerplatform-prompt", "Use a predefined prompt template for Po
544
546
  `- Primary Name: ${metadata.PrimaryNameAttribute}`;
545
547
  // Get key attributes
546
548
  const keyAttributes = attributes.value
547
- .filter((attr) => attr.IsValidForRead === true && !attr.AttributeOf)
548
549
  //.slice(0, 10) // Limit to first 10 important attributes
549
- .map((attr) => `- ${attr.LogicalName}: ${attr.AttributeType} (${attr.DisplayName?.UserLocalizedLabel?.Label || 'No display name'})`)
550
+ .map((attr) => {
551
+ const attrType = attr["@odata.type"] || attr.odata?.type || "Unknown type";
552
+ return `- ${attr.LogicalName}: ${attrType}`;
553
+ })
550
554
  .join('\n');
551
555
  // Get relationships summary
552
556
  const relationships = await service.getEntityRelationships(entityName);
@@ -591,7 +595,6 @@ server.tool("use-powerplatform-prompt", "Use a predefined prompt template for Po
591
595
  // Get a few important fields for the select example
592
596
  const attributes = await service.getEntityAttributes(entityName);
593
597
  const selectFields = attributes.value
594
- .filter((attr) => attr.IsValidForRead === true && !attr.AttributeOf)
595
598
  .slice(0, 5) // Just take first 5 for example
596
599
  .map((attr) => attr.LogicalName)
597
600
  .join(',');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "powerplatform-mcp",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "description": "PowerPlatform Model Context Protocol server",
5
5
  "main": "build/index.js",
6
6
  "bin": {