@north7/entraaware 0.0.3 → 0.0.5
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/build/index.js +47 -21
- package/package.json +1 -1
package/build/index.js
CHANGED
@@ -11,7 +11,7 @@ let azureCredential = null;
|
|
11
11
|
// Create server instance
|
12
12
|
const server = new McpServer({
|
13
13
|
name: "EntraAware",
|
14
|
-
version: "0.0.
|
14
|
+
version: "0.0.5",
|
15
15
|
capabilities: {
|
16
16
|
resources: {},
|
17
17
|
tools: {},
|
@@ -30,15 +30,22 @@ function getCredentials() {
|
|
30
30
|
function getAzureCredential() {
|
31
31
|
if (!azureCredential) {
|
32
32
|
try {
|
33
|
-
//
|
33
|
+
// Try DefaultAzureCredential which includes CLI credentials
|
34
|
+
console.error("Attempting to use DefaultAzureCredential (will try Azure CLI if environment variables not set)");
|
34
35
|
azureCredential = new DefaultAzureCredential();
|
35
|
-
console.error("Using DefaultAzureCredential - will try Azure CLI if environment variables not set");
|
36
36
|
}
|
37
37
|
catch (error) {
|
38
|
-
// Fall back to ClientSecretCredential
|
39
|
-
console.error(
|
40
|
-
|
41
|
-
|
38
|
+
// Fall back to ClientSecretCredential
|
39
|
+
console.error(`DefaultAzureCredential failed: ${error instanceof Error ? error.message : String(error)}`);
|
40
|
+
console.error("Falling back to ClientSecretCredential");
|
41
|
+
try {
|
42
|
+
const { tenantId, clientId, clientSecret } = getCredentials();
|
43
|
+
azureCredential = new ClientSecretCredential(tenantId, clientId, clientSecret);
|
44
|
+
}
|
45
|
+
catch (secretError) {
|
46
|
+
console.error(`ClientSecretCredential failed: ${secretError instanceof Error ? secretError.message : String(secretError)}`);
|
47
|
+
throw new Error("Failed to initialize any Azure credential. Please ensure you are logged in with 'az login' or have set environment variables.");
|
48
|
+
}
|
42
49
|
}
|
43
50
|
}
|
44
51
|
return azureCredential;
|
@@ -73,6 +80,23 @@ function formatErrorResponse(err, apiType) {
|
|
73
80
|
],
|
74
81
|
};
|
75
82
|
}
|
83
|
+
// Process OData parameters for Graph API
|
84
|
+
function processODataParams({ queryParams = {}, select, filter, expand, orderBy, top, count }) {
|
85
|
+
const processedParams = { ...queryParams };
|
86
|
+
if (select)
|
87
|
+
processedParams['$select'] = select;
|
88
|
+
if (filter)
|
89
|
+
processedParams['$filter'] = filter;
|
90
|
+
if (expand)
|
91
|
+
processedParams['$expand'] = expand;
|
92
|
+
if (orderBy)
|
93
|
+
processedParams['$orderby'] = orderBy;
|
94
|
+
if (top !== undefined)
|
95
|
+
processedParams['$top'] = top.toString();
|
96
|
+
if (count)
|
97
|
+
processedParams['$count'] = 'true';
|
98
|
+
return processedParams;
|
99
|
+
}
|
76
100
|
// MICROSOFT GRAPH API TOOL
|
77
101
|
server.tool("askEntra", "Direct access to Microsoft Graph API for accurate Entra (Azure AD) data", {
|
78
102
|
path: z.string().describe("The Graph API URL path (e.g. '/users/{id}/memberOf', '/directoryRoles')"),
|
@@ -92,20 +116,16 @@ server.tool("askEntra", "Direct access to Microsoft Graph API for accurate Entra
|
|
92
116
|
}, async ({ path, method, queryParams = {}, body, apiVersion, fetchAllPages, consistencyLevel, select, filter, expand, orderBy, top, count }) => {
|
93
117
|
try {
|
94
118
|
// Process shorthand query parameters
|
95
|
-
const processedParams = {
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
processedParams['$top'] = top.toString();
|
106
|
-
if (count)
|
107
|
-
processedParams['$count'] = 'true';
|
108
|
-
// Initialize or get Graph client
|
119
|
+
const processedParams = processODataParams({
|
120
|
+
queryParams,
|
121
|
+
select,
|
122
|
+
filter,
|
123
|
+
expand,
|
124
|
+
orderBy,
|
125
|
+
top,
|
126
|
+
count
|
127
|
+
});
|
128
|
+
// Initialize client on demand
|
109
129
|
if (!graphClient) {
|
110
130
|
const credential = getAzureCredential();
|
111
131
|
const authProvider = new TokenCredentialAuthenticationProvider(credential, {
|
@@ -210,6 +230,12 @@ server.tool("askAzure", "Direct access to Azure Resource Management API for mana
|
|
210
230
|
'Microsoft.Network/virtualNetworks': '2023-04-01',
|
211
231
|
'Microsoft.KeyVault/vaults': '2023-02-01'
|
212
232
|
};
|
233
|
+
// Set default API version for common paths if not provided
|
234
|
+
if (!apiVersion && !queryParams['api-version']) {
|
235
|
+
if (path === '/subscriptions') {
|
236
|
+
apiVersion = '2022-12-01'; // Default API version for listing subscriptions
|
237
|
+
}
|
238
|
+
}
|
213
239
|
// Handle predefined operations
|
214
240
|
if (operation !== "custom") {
|
215
241
|
const requiredSubscriptionId = !['listResourceProviders', 'getResourceProvider', 'registerResourceProvider'].includes(operation);
|