powerautomate-mcp 0.9.1 → 0.9.3
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.
- package/dist/index.js +115 -16
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3837,6 +3837,7 @@ var DataverseApi = class {
|
|
|
3837
3837
|
*/
|
|
3838
3838
|
static getDataverseUrl(environmentId, region = "crm") {
|
|
3839
3839
|
const regionMap = {
|
|
3840
|
+
// Power Platform region names
|
|
3840
3841
|
unitedstates: "crm",
|
|
3841
3842
|
europe: "crm4",
|
|
3842
3843
|
uk: "crm11",
|
|
@@ -3853,7 +3854,35 @@ var DataverseApi = class {
|
|
|
3853
3854
|
government: "crm9",
|
|
3854
3855
|
gcc: "crm9",
|
|
3855
3856
|
gcchigh: "crm.microsoft.us",
|
|
3856
|
-
dod: "crm.appsplatform.us"
|
|
3857
|
+
dod: "crm.appsplatform.us",
|
|
3858
|
+
// Azure region names (map to same CRM domains)
|
|
3859
|
+
westus: "crm",
|
|
3860
|
+
eastus: "crm",
|
|
3861
|
+
centralus: "crm",
|
|
3862
|
+
westus2: "crm",
|
|
3863
|
+
eastus2: "crm",
|
|
3864
|
+
southcentralus: "crm",
|
|
3865
|
+
northcentralus: "crm",
|
|
3866
|
+
westeurope: "crm4",
|
|
3867
|
+
northeurope: "crm4",
|
|
3868
|
+
uksouth: "crm11",
|
|
3869
|
+
ukwest: "crm11",
|
|
3870
|
+
eastasia: "crm5",
|
|
3871
|
+
southeastasia: "crm5",
|
|
3872
|
+
australiaeast: "crm6",
|
|
3873
|
+
australiasoutheast: "crm6",
|
|
3874
|
+
japaneast: "crm7",
|
|
3875
|
+
japanwest: "crm7",
|
|
3876
|
+
centralindia: "crm8",
|
|
3877
|
+
southindia: "crm8",
|
|
3878
|
+
canadacentral: "crm3",
|
|
3879
|
+
canadaeast: "crm3",
|
|
3880
|
+
brazilsouth: "crm2",
|
|
3881
|
+
francecentral: "crm12",
|
|
3882
|
+
francesouth: "crm12",
|
|
3883
|
+
switzerlandnorth: "crm17",
|
|
3884
|
+
germanywestcentral: "crm16",
|
|
3885
|
+
uaenorth: "crm15"
|
|
3857
3886
|
};
|
|
3858
3887
|
const crmDomain = regionMap[region.toLowerCase()] || region;
|
|
3859
3888
|
return `${environmentId}.${crmDomain}.dynamics.com`;
|
|
@@ -8635,9 +8664,10 @@ async function handleDiagnoseFlow(api, input) {
|
|
|
8635
8664
|
try {
|
|
8636
8665
|
const actions = await api.getFlowRunActions(parsed.flowId, failedRun.name, parsed.environment);
|
|
8637
8666
|
const failedActions = actions.filter((a) => a.properties.status === "Failed");
|
|
8667
|
+
const ioFetches = [];
|
|
8638
8668
|
for (const action of failedActions) {
|
|
8639
8669
|
const errorCode = action.properties.error?.code || "Unknown";
|
|
8640
|
-
|
|
8670
|
+
let errorMessage = action.properties.error?.message || "Unknown error";
|
|
8641
8671
|
let category2 = "Unknown Error";
|
|
8642
8672
|
let suggestedFixes2 = ["Review the error message and action inputs"];
|
|
8643
8673
|
for (const pattern of ERROR_PATTERNS) {
|
|
@@ -8647,13 +8677,56 @@ async function handleDiagnoseFlow(api, input) {
|
|
|
8647
8677
|
break;
|
|
8648
8678
|
}
|
|
8649
8679
|
}
|
|
8650
|
-
|
|
8680
|
+
const info = {
|
|
8651
8681
|
name: action.name,
|
|
8652
8682
|
errorCode,
|
|
8653
8683
|
errorMessage,
|
|
8654
8684
|
category: category2,
|
|
8655
8685
|
suggestedFixes: suggestedFixes2
|
|
8656
|
-
}
|
|
8686
|
+
};
|
|
8687
|
+
failedActionsInfo.push(info);
|
|
8688
|
+
if (action.properties.outputsLink?.uri) {
|
|
8689
|
+
ioFetches.push(
|
|
8690
|
+
api.fetchResourceLink(action.properties.outputsLink.uri).then(
|
|
8691
|
+
(data) => {
|
|
8692
|
+
const d = data;
|
|
8693
|
+
if (d.statusCode) info.httpStatus = Number(d.statusCode);
|
|
8694
|
+
const body = d.body;
|
|
8695
|
+
if (body) {
|
|
8696
|
+
const bodyStr = typeof body === "object" ? JSON.stringify(body) : String(body);
|
|
8697
|
+
info.outputs = bodyStr.length > 800 ? bodyStr.slice(0, 800) + "\u2026" : bodyStr;
|
|
8698
|
+
if ((errorMessage === "Unknown error" || errorMessage.includes("An action failed")) && bodyStr.length > 5) {
|
|
8699
|
+
info.errorMessage = bodyStr.slice(0, 300);
|
|
8700
|
+
for (const pattern of ERROR_PATTERNS) {
|
|
8701
|
+
if (pattern.pattern.test(bodyStr)) {
|
|
8702
|
+
info.category = pattern.category;
|
|
8703
|
+
info.suggestedFixes = pattern.fixes;
|
|
8704
|
+
break;
|
|
8705
|
+
}
|
|
8706
|
+
}
|
|
8707
|
+
}
|
|
8708
|
+
}
|
|
8709
|
+
},
|
|
8710
|
+
() => {
|
|
8711
|
+
}
|
|
8712
|
+
)
|
|
8713
|
+
);
|
|
8714
|
+
}
|
|
8715
|
+
if (action.properties.inputsLink?.uri) {
|
|
8716
|
+
ioFetches.push(
|
|
8717
|
+
api.fetchResourceLink(action.properties.inputsLink.uri).then(
|
|
8718
|
+
(data) => {
|
|
8719
|
+
const str = typeof data === "object" ? JSON.stringify(data) : String(data);
|
|
8720
|
+
info.inputs = str.length > 800 ? str.slice(0, 800) + "\u2026" : str;
|
|
8721
|
+
},
|
|
8722
|
+
() => {
|
|
8723
|
+
}
|
|
8724
|
+
)
|
|
8725
|
+
);
|
|
8726
|
+
}
|
|
8727
|
+
}
|
|
8728
|
+
if (ioFetches.length > 0) {
|
|
8729
|
+
await Promise.all(ioFetches);
|
|
8657
8730
|
}
|
|
8658
8731
|
if (failedActionsInfo.length > 0) {
|
|
8659
8732
|
primaryErrorCode = failedActionsInfo[0].errorCode;
|
|
@@ -8750,10 +8823,20 @@ async function handleDiagnoseFlow(api, input) {
|
|
|
8750
8823
|
output += `**Failed Actions (${result.failedRun.failedActions.length}):**
|
|
8751
8824
|
`;
|
|
8752
8825
|
for (const action of result.failedRun.failedActions) {
|
|
8753
|
-
output += ` \u274C **${action.name}** - ${action.category}
|
|
8826
|
+
output += ` \u274C **${action.name}** - ${action.category}`;
|
|
8827
|
+
if (action.httpStatus) output += ` (HTTP ${action.httpStatus})`;
|
|
8828
|
+
output += `
|
|
8829
|
+
`;
|
|
8830
|
+
output += ` Error: ${action.errorMessage.slice(0, 300)}${action.errorMessage.length > 300 ? "..." : ""}
|
|
8754
8831
|
`;
|
|
8755
|
-
|
|
8832
|
+
if (action.outputs && action.outputs !== action.errorMessage.slice(0, 300)) {
|
|
8833
|
+
output += ` Response: ${action.outputs.slice(0, 500)}${action.outputs.length > 500 ? "..." : ""}
|
|
8756
8834
|
`;
|
|
8835
|
+
}
|
|
8836
|
+
if (action.inputs) {
|
|
8837
|
+
output += ` Request: ${action.inputs.slice(0, 300)}${action.inputs.length > 300 ? "..." : ""}
|
|
8838
|
+
`;
|
|
8839
|
+
}
|
|
8757
8840
|
output += ` Fix: ${action.suggestedFixes[0]}
|
|
8758
8841
|
`;
|
|
8759
8842
|
}
|
|
@@ -15083,9 +15166,11 @@ async function createMcpServer(serverConfig) {
|
|
|
15083
15166
|
source = "bap";
|
|
15084
15167
|
}
|
|
15085
15168
|
} catch (err) {
|
|
15169
|
+
const errMsg = err instanceof Error ? err.message : String(err);
|
|
15170
|
+
const isAuthError = errMsg.includes("cached credentials") || errMsg.includes("authenticate");
|
|
15086
15171
|
logger.warn(
|
|
15087
|
-
{ err:
|
|
15088
|
-
"BAP admin API did not return a Dataverse instanceUrl \u2014 falling back to region guess (may fail DNS)"
|
|
15172
|
+
{ err: errMsg },
|
|
15173
|
+
isAuthError ? "BAP admin API token not cached \u2014 run --setup again or add dataverseUrl to your environment config" : "BAP admin API did not return a Dataverse instanceUrl \u2014 falling back to region guess (may fail DNS)"
|
|
15089
15174
|
);
|
|
15090
15175
|
}
|
|
15091
15176
|
}
|
|
@@ -15883,15 +15968,29 @@ async function runSetupWizard() {
|
|
|
15883
15968
|
print(` ${icons.check} ${c.green}Signed in${c.reset}`);
|
|
15884
15969
|
}
|
|
15885
15970
|
const additionalResources = [
|
|
15886
|
-
{ url: "https://service.powerapps.com", label: "PowerApps (connections)" },
|
|
15887
|
-
{ url: "https://api.bap.microsoft.com", label: "Admin API (environments)" }
|
|
15971
|
+
{ url: "https://service.powerapps.com", label: "PowerApps (connections)", critical: false },
|
|
15972
|
+
{ url: "https://api.bap.microsoft.com", label: "Admin API (environments/Dataverse)", critical: true }
|
|
15888
15973
|
];
|
|
15889
|
-
for (const { url, label } of additionalResources) {
|
|
15890
|
-
|
|
15891
|
-
|
|
15892
|
-
|
|
15893
|
-
|
|
15894
|
-
|
|
15974
|
+
for (const { url, label, critical } of additionalResources) {
|
|
15975
|
+
try {
|
|
15976
|
+
let token = null;
|
|
15977
|
+
if (authProvider.tryGetTokenForResourceSilent) {
|
|
15978
|
+
token = await authProvider.tryGetTokenForResourceSilent(url);
|
|
15979
|
+
}
|
|
15980
|
+
if (token) {
|
|
15981
|
+
print(` ${icons.check} ${c.dim}${label}: authorized${c.reset}`);
|
|
15982
|
+
} else {
|
|
15983
|
+
print(` ${c.dim}Authorizing ${label}...${c.reset}`);
|
|
15984
|
+
await authProvider.getTokenForResource(url);
|
|
15985
|
+
print(` ${icons.check} ${c.dim}${label}: authorized (interactive)${c.reset}`);
|
|
15986
|
+
}
|
|
15987
|
+
} catch (err) {
|
|
15988
|
+
if (critical) {
|
|
15989
|
+
print(` ${c.yellow || ""}${icons.warn} ${label}: not authorized \u2014 Dataverse tools may not work.${c.reset}`);
|
|
15990
|
+
print(` ${c.dim} Add dataverseUrl to your environment config as a workaround.${c.reset}`);
|
|
15991
|
+
} else {
|
|
15992
|
+
print(` ${c.dim}${icons.info || "-"} ${label}: not authorized (non-critical)${c.reset}`);
|
|
15993
|
+
}
|
|
15895
15994
|
}
|
|
15896
15995
|
}
|
|
15897
15996
|
} catch (error) {
|