powerautomate-mcp 0.5.1 → 0.5.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 +83 -46
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -381,6 +381,20 @@ Create the file with your Microsoft Entra app client ID and Power Automate envir
|
|
|
381
381
|
err
|
|
382
382
|
);
|
|
383
383
|
}
|
|
384
|
+
const envClientId = env["PA_MCP_CLIENT_ID"];
|
|
385
|
+
if (envClientId) {
|
|
386
|
+
const UUID_RE3 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
387
|
+
if (!UUID_RE3.test(envClientId)) {
|
|
388
|
+
throw new ConfigurationError(
|
|
389
|
+
`PA_MCP_CLIENT_ID is not a valid UUID: ${envClientId.substring(0, 50)}`
|
|
390
|
+
);
|
|
391
|
+
}
|
|
392
|
+
parsed.auth = {
|
|
393
|
+
...parsed.auth ?? {},
|
|
394
|
+
clientId: envClientId
|
|
395
|
+
};
|
|
396
|
+
logger.info("Using client ID from PA_MCP_CLIENT_ID environment variable");
|
|
397
|
+
}
|
|
384
398
|
try {
|
|
385
399
|
const config = validateConfig(parsed);
|
|
386
400
|
logger.info(
|
|
@@ -14162,7 +14176,7 @@ async function createMcpServer(serverConfig) {
|
|
|
14162
14176
|
const server = new Server(
|
|
14163
14177
|
{
|
|
14164
14178
|
name: "powerautomate-mcp",
|
|
14165
|
-
version: "0.5.
|
|
14179
|
+
version: "0.5.3"
|
|
14166
14180
|
},
|
|
14167
14181
|
{
|
|
14168
14182
|
capabilities: {
|
|
@@ -14519,7 +14533,6 @@ function getDefaultEnvironment(environments) {
|
|
|
14519
14533
|
}
|
|
14520
14534
|
|
|
14521
14535
|
// src/setup/published-app.ts
|
|
14522
|
-
var PUBLISHED_APP_CLIENT_ID = "20ae33ee-6743-4786-9b00-8eb7bfebfd11";
|
|
14523
14536
|
var APP_DISPLAY_NAME = "Power Automate MCP";
|
|
14524
14537
|
var REDIRECT_URI = "https://login.microsoftonline.com/common/oauth2/nativeclient";
|
|
14525
14538
|
var REQUIRED_RESOURCE_ACCESS = [
|
|
@@ -14534,8 +14547,10 @@ var REQUIRED_RESOURCE_ACCESS = [
|
|
|
14534
14547
|
{
|
|
14535
14548
|
resourceAppId: "7df0a125-d3be-4c96-aa54-591f83ff541c",
|
|
14536
14549
|
resourceAccess: [
|
|
14537
|
-
{ id: "
|
|
14538
|
-
{ id: "
|
|
14550
|
+
{ id: "e45c5562-459d-4d1b-8148-83eb1b6dcf83", type: "Scope" },
|
|
14551
|
+
{ id: "30b2d850-00c3-4802-b7ae-ece9af9de5c6", type: "Scope" },
|
|
14552
|
+
{ id: "822a9cde-503a-472d-a530-d1dc9cd0d52b", type: "Scope" },
|
|
14553
|
+
{ id: "d05743e4-fb24-4dff-8a33-0f6c73c964bd", type: "Scope" }
|
|
14539
14554
|
]
|
|
14540
14555
|
},
|
|
14541
14556
|
{
|
|
@@ -14623,6 +14638,8 @@ async function createAppRegistration(displayName) {
|
|
|
14623
14638
|
"false",
|
|
14624
14639
|
"--enable-id-token-issuance",
|
|
14625
14640
|
"false",
|
|
14641
|
+
"--is-fallback-public-client",
|
|
14642
|
+
"true",
|
|
14626
14643
|
"--public-client-redirect-uris",
|
|
14627
14644
|
REDIRECT_URI,
|
|
14628
14645
|
"--required-resource-accesses",
|
|
@@ -14733,56 +14750,69 @@ function readExistingClientId() {
|
|
|
14733
14750
|
return null;
|
|
14734
14751
|
}
|
|
14735
14752
|
}
|
|
14736
|
-
async function
|
|
14753
|
+
async function promptForClientId(askUser) {
|
|
14754
|
+
print("");
|
|
14755
|
+
print(` ${c.yellow}You need a Microsoft Entra app registration for your tenant.${c.reset}`);
|
|
14756
|
+
print(` ${c.dim}Create one in the Azure portal with these delegated permissions:${c.reset}`);
|
|
14757
|
+
print(` ${c.dim}\u2022 Microsoft Graph: User.Read, Sites.ReadWrite.All, Files.ReadWrite.All${c.reset}`);
|
|
14758
|
+
print(` ${c.dim}\u2022 Power Automate: Flows.Read.All, Flows.Manage.All, Activity.Read.All, Approvals.Manage.All${c.reset}`);
|
|
14759
|
+
print(` ${c.dim}\u2022 Dynamics CRM: user_impersonation${c.reset}`);
|
|
14760
|
+
print(` ${c.dim}Enable "Allow public client flows" for device code auth.${c.reset}`);
|
|
14761
|
+
print("");
|
|
14762
|
+
while (true) {
|
|
14763
|
+
const input = await askUser(` ${c.cyan}?${c.reset} Paste your app's ${c.bold}Client ID${c.reset}: `);
|
|
14764
|
+
if (input && UUID_RE2.test(input)) {
|
|
14765
|
+
return input;
|
|
14766
|
+
}
|
|
14767
|
+
print(` ${c.red}Invalid format \u2014 must be a UUID (e.g., 12345678-abcd-1234-abcd-123456789abc)${c.reset}`);
|
|
14768
|
+
}
|
|
14769
|
+
}
|
|
14770
|
+
async function resolveAppRegistration(askUser) {
|
|
14771
|
+
const envClientId = process.env["PA_MCP_CLIENT_ID"];
|
|
14772
|
+
if (envClientId && UUID_RE2.test(envClientId)) {
|
|
14773
|
+
print(` ${icons.check} Using client ID from PA_MCP_CLIENT_ID: ${c.dim}${envClientId}${c.reset}`);
|
|
14774
|
+
return { clientId: envClientId, created: false };
|
|
14775
|
+
}
|
|
14737
14776
|
const existingId = readExistingClientId();
|
|
14738
14777
|
if (existingId) {
|
|
14739
14778
|
print(` ${icons.check} Reusing app from existing config: ${c.dim}${existingId}${c.reset}`);
|
|
14740
14779
|
return { clientId: existingId, created: false };
|
|
14741
14780
|
}
|
|
14742
14781
|
const hasAzCli = await checkAzureCli();
|
|
14743
|
-
if (
|
|
14744
|
-
print(` ${c.dim}Azure CLI
|
|
14745
|
-
print(` ${icons.check} Client ID: ${c.dim}${PUBLISHED_APP_CLIENT_ID}${c.reset}`);
|
|
14746
|
-
return { clientId: PUBLISHED_APP_CLIENT_ID, created: false };
|
|
14747
|
-
}
|
|
14748
|
-
print(` ${c.dim}Azure CLI detected${c.reset}`);
|
|
14749
|
-
try {
|
|
14750
|
-
const azUser = await ensureAzureCliLogin();
|
|
14751
|
-
print(` ${icons.check} Azure CLI signed in as ${c.bold}${azUser}${c.reset}`);
|
|
14752
|
-
} catch (error) {
|
|
14753
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
14754
|
-
print(` ${c.yellow}Azure CLI login failed: ${msg}${c.reset}`);
|
|
14755
|
-
print(` ${c.dim}Falling back to shared app${c.reset}`);
|
|
14756
|
-
print(` ${icons.check} Client ID: ${c.dim}${PUBLISHED_APP_CLIENT_ID}${c.reset}`);
|
|
14757
|
-
return { clientId: PUBLISHED_APP_CLIENT_ID, created: false };
|
|
14758
|
-
}
|
|
14759
|
-
const existingAppId = await findExistingApp(APP_DISPLAY_NAME);
|
|
14760
|
-
if (existingAppId) {
|
|
14761
|
-
print(` ${icons.check} Found existing app: ${c.dim}${existingAppId}${c.reset}`);
|
|
14762
|
-
try {
|
|
14763
|
-
await addWamRedirectUri(existingAppId);
|
|
14764
|
-
} catch {
|
|
14765
|
-
}
|
|
14766
|
-
return { clientId: existingAppId, created: false };
|
|
14767
|
-
}
|
|
14768
|
-
print(` ${c.dim}Creating app registration...${c.reset}`);
|
|
14769
|
-
try {
|
|
14770
|
-
const newId = await createAppRegistration(APP_DISPLAY_NAME);
|
|
14771
|
-
print(` ${icons.check} App created: ${c.dim}${newId}${c.reset}`);
|
|
14782
|
+
if (hasAzCli) {
|
|
14783
|
+
print(` ${c.dim}Azure CLI detected${c.reset}`);
|
|
14772
14784
|
try {
|
|
14773
|
-
await
|
|
14774
|
-
print(` ${icons.check}
|
|
14775
|
-
|
|
14776
|
-
|
|
14785
|
+
const azUser = await ensureAzureCliLogin();
|
|
14786
|
+
print(` ${icons.check} Azure CLI signed in as ${c.bold}${azUser}${c.reset}`);
|
|
14787
|
+
const existingAppId = await findExistingApp(APP_DISPLAY_NAME);
|
|
14788
|
+
if (existingAppId) {
|
|
14789
|
+
print(` ${icons.check} Found existing app: ${c.dim}${existingAppId}${c.reset}`);
|
|
14790
|
+
try {
|
|
14791
|
+
await addWamRedirectUri(existingAppId);
|
|
14792
|
+
} catch {
|
|
14793
|
+
}
|
|
14794
|
+
return { clientId: existingAppId, created: false };
|
|
14795
|
+
}
|
|
14796
|
+
print(` ${c.dim}Creating app registration...${c.reset}`);
|
|
14797
|
+
const newId = await createAppRegistration(APP_DISPLAY_NAME);
|
|
14798
|
+
print(` ${icons.check} App created: ${c.dim}${newId}${c.reset}`);
|
|
14799
|
+
try {
|
|
14800
|
+
await addWamRedirectUri(newId);
|
|
14801
|
+
print(` ${icons.check} WAM redirect URI configured`);
|
|
14802
|
+
} catch {
|
|
14803
|
+
print(` ${c.dim}WAM redirect URI skipped (non-critical)${c.reset}`);
|
|
14804
|
+
}
|
|
14805
|
+
return { clientId: newId, created: true };
|
|
14806
|
+
} catch (error) {
|
|
14807
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
14808
|
+
print(` ${c.yellow}Azure CLI failed: ${msg}${c.reset}`);
|
|
14777
14809
|
}
|
|
14778
|
-
|
|
14779
|
-
}
|
|
14780
|
-
const msg = error instanceof Error ? error.message : String(error);
|
|
14781
|
-
print(` ${c.yellow}App creation failed: ${msg}${c.reset}`);
|
|
14782
|
-
print(` ${c.dim}Falling back to shared app${c.reset}`);
|
|
14783
|
-
print(` ${icons.check} Client ID: ${c.dim}${PUBLISHED_APP_CLIENT_ID}${c.reset}`);
|
|
14784
|
-
return { clientId: PUBLISHED_APP_CLIENT_ID, created: false };
|
|
14810
|
+
} else {
|
|
14811
|
+
print(` ${c.dim}Azure CLI not found \u2014 skipping automatic app creation${c.reset}`);
|
|
14785
14812
|
}
|
|
14813
|
+
const manualId = await promptForClientId(askUser);
|
|
14814
|
+
print(` ${icons.check} Client ID: ${c.dim}${manualId}${c.reset}`);
|
|
14815
|
+
return { clientId: manualId, created: false };
|
|
14786
14816
|
}
|
|
14787
14817
|
async function runSetupWizard() {
|
|
14788
14818
|
const rl = createInterface({
|
|
@@ -14800,7 +14830,7 @@ async function runSetupWizard() {
|
|
|
14800
14830
|
printHeader();
|
|
14801
14831
|
const totalSteps = 5;
|
|
14802
14832
|
printStep(1, totalSteps, "App Registration");
|
|
14803
|
-
const appResult = await resolveAppRegistration();
|
|
14833
|
+
const appResult = await resolveAppRegistration(prompt);
|
|
14804
14834
|
const clientId = appResult.clientId;
|
|
14805
14835
|
printStep(2, totalSteps, "Sign In");
|
|
14806
14836
|
const cacheResult = clearTokenCache();
|
|
@@ -15007,10 +15037,17 @@ Options:
|
|
|
15007
15037
|
--port <N> Port for HTTP transport (default: 3000)
|
|
15008
15038
|
--help, -h Show this help message
|
|
15009
15039
|
|
|
15040
|
+
Environment Variables:
|
|
15041
|
+
PA_MCP_CLIENT_ID Microsoft Entra app client ID (overrides config file)
|
|
15042
|
+
PA_CONFIG_PATH Custom path to config.json
|
|
15043
|
+
|
|
15010
15044
|
First Run:
|
|
15011
15045
|
If no configuration exists, the setup wizard will run automatically.
|
|
15012
15046
|
You can also run it manually with --setup.
|
|
15013
15047
|
|
|
15048
|
+
Each tenant needs its own Microsoft Entra app registration.
|
|
15049
|
+
The wizard can create one via Azure CLI, or you can provide one manually.
|
|
15050
|
+
|
|
15014
15051
|
Configuration:
|
|
15015
15052
|
Config file: ${configPath}
|
|
15016
15053
|
|