@mcp-consultant-tools/azure-b2c 27.0.0 → 28.0.0-beta.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/b2c-client.d.ts +30 -0
- package/build/b2c-client.d.ts.map +1 -0
- package/build/b2c-client.js +112 -0
- package/build/b2c-client.js.map +1 -0
- package/build/index.d.ts +11 -18
- package/build/index.d.ts.map +1 -1
- package/build/index.js +51 -529
- package/build/index.js.map +1 -1
- package/build/models/api-types.d.ts +106 -0
- package/build/models/api-types.d.ts.map +1 -0
- package/build/models/api-types.js +5 -0
- package/build/models/api-types.js.map +1 -0
- package/build/models/index.d.ts +5 -0
- package/build/models/index.d.ts.map +1 -0
- package/build/models/index.js +2 -0
- package/build/models/index.js.map +1 -0
- package/build/prompts/index.d.ts +7 -0
- package/build/prompts/index.d.ts.map +1 -0
- package/build/prompts/index.js +6 -0
- package/build/prompts/index.js.map +1 -0
- package/build/prompts/templates.d.ts +3 -0
- package/build/prompts/templates.d.ts.map +1 -0
- package/build/prompts/templates.js +74 -0
- package/build/prompts/templates.js.map +1 -0
- package/build/services/group-service.d.ts +43 -0
- package/build/services/group-service.d.ts.map +1 -0
- package/build/services/group-service.js +280 -0
- package/build/services/group-service.js.map +1 -0
- package/build/services/index.d.ts +6 -0
- package/build/services/index.d.ts.map +1 -0
- package/build/services/index.js +6 -0
- package/build/services/index.js.map +1 -0
- package/build/services/user-service.d.ts +55 -0
- package/build/services/user-service.d.ts.map +1 -0
- package/build/services/user-service.js +415 -0
- package/build/services/user-service.js.map +1 -0
- package/build/tools/group-tools.d.ts +8 -0
- package/build/tools/group-tools.d.ts.map +1 -0
- package/build/tools/group-tools.js +90 -0
- package/build/tools/group-tools.js.map +1 -0
- package/build/tools/index.d.ts +8 -0
- package/build/tools/index.d.ts.map +1 -0
- package/build/tools/index.js +9 -0
- package/build/tools/index.js.map +1 -0
- package/build/tools/user-tools.d.ts +9 -0
- package/build/tools/user-tools.d.ts.map +1 -0
- package/build/tools/user-tools.js +346 -0
- package/build/tools/user-tools.js.map +1 -0
- package/build/types.d.ts +12 -0
- package/build/types.d.ts.map +1 -0
- package/build/types.js +2 -0
- package/build/types.js.map +1 -0
- package/build/utils/formatters.d.ts +1 -1
- package/build/utils/formatters.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Azure B2C Graph API client
|
|
3
|
+
*
|
|
4
|
+
* Handles authentication, client setup, response mapping, and error enhancement.
|
|
5
|
+
*/
|
|
6
|
+
import { Client } from '@microsoft/microsoft-graph-client';
|
|
7
|
+
import type { AzureB2CConfig, B2CUser, B2CGroup } from './models/index.js';
|
|
8
|
+
export declare class B2CClient {
|
|
9
|
+
private config;
|
|
10
|
+
private graphClient;
|
|
11
|
+
private credential;
|
|
12
|
+
constructor(config: AzureB2CConfig);
|
|
13
|
+
/** Get the resolved config */
|
|
14
|
+
getConfig(): AzureB2CConfig;
|
|
15
|
+
/** Get or create the Microsoft Graph client */
|
|
16
|
+
getClient(): Client;
|
|
17
|
+
/** Check if operation is permitted */
|
|
18
|
+
checkPermission(operation: string, enabled: boolean): void;
|
|
19
|
+
/** Map Graph API user response to B2CUser */
|
|
20
|
+
mapUserResponse(response: any): B2CUser;
|
|
21
|
+
/** Map array of Graph API user responses */
|
|
22
|
+
mapUsersResponse(responses: any[]): B2CUser[];
|
|
23
|
+
/** Map Graph API group response to B2CGroup */
|
|
24
|
+
mapGroupResponse(response: any): B2CGroup;
|
|
25
|
+
/** Map array of Graph API group responses */
|
|
26
|
+
mapGroupsResponse(responses: any[]): B2CGroup[];
|
|
27
|
+
/** Enhance error with helpful context */
|
|
28
|
+
enhanceError(error: any, operation: string): Error;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=b2c-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"b2c-client.d.ts","sourceRoot":"","sources":["../src/b2c-client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAE3D,OAAO,KAAK,EAAE,cAAc,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE3E,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,WAAW,CAAuB;IAC1C,OAAO,CAAC,UAAU,CAAuC;gBAE7C,MAAM,EAAE,cAAc;IAclC,8BAA8B;IAC9B,SAAS,IAAI,cAAc;IAI3B,+CAA+C;IAC/C,SAAS,IAAI,MAAM;IAoBnB,sCAAsC;IACtC,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAS1D,6CAA6C;IAC7C,eAAe,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO;IAoBvC,4CAA4C;IAC5C,gBAAgB,CAAC,SAAS,EAAE,GAAG,EAAE,GAAG,OAAO,EAAE;IAI7C,+CAA+C;IAC/C,gBAAgB,CAAC,QAAQ,EAAE,GAAG,GAAG,QAAQ;IAUzC,6CAA6C;IAC7C,iBAAiB,CAAC,SAAS,EAAE,GAAG,EAAE,GAAG,QAAQ,EAAE;IAI/C,yCAAyC;IACzC,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,GAAG,KAAK;CAsCnD"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Azure B2C Graph API client
|
|
3
|
+
*
|
|
4
|
+
* Handles authentication, client setup, response mapping, and error enhancement.
|
|
5
|
+
*/
|
|
6
|
+
import { ClientSecretCredential } from '@azure/identity';
|
|
7
|
+
import { Client } from '@microsoft/microsoft-graph-client';
|
|
8
|
+
import { TokenCredentialAuthenticationProvider } from '@microsoft/microsoft-graph-client/authProviders/azureTokenCredentials/index.js';
|
|
9
|
+
export class B2CClient {
|
|
10
|
+
config;
|
|
11
|
+
graphClient = null;
|
|
12
|
+
credential = null;
|
|
13
|
+
constructor(config) {
|
|
14
|
+
this.config = {
|
|
15
|
+
maxResults: 100,
|
|
16
|
+
cacheUsersTTL: 300,
|
|
17
|
+
...config,
|
|
18
|
+
};
|
|
19
|
+
if (!this.config.tenantId || !this.config.clientId || !this.config.clientSecret) {
|
|
20
|
+
throw new Error('Azure B2C requires tenantId, clientId, and clientSecret configuration');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/** Get the resolved config */
|
|
24
|
+
getConfig() {
|
|
25
|
+
return this.config;
|
|
26
|
+
}
|
|
27
|
+
/** Get or create the Microsoft Graph client */
|
|
28
|
+
getClient() {
|
|
29
|
+
if (!this.graphClient) {
|
|
30
|
+
this.credential = new ClientSecretCredential(this.config.tenantId, this.config.clientId, this.config.clientSecret);
|
|
31
|
+
const authProvider = new TokenCredentialAuthenticationProvider(this.credential, {
|
|
32
|
+
scopes: ['https://graph.microsoft.com/.default'],
|
|
33
|
+
});
|
|
34
|
+
this.graphClient = Client.initWithMiddleware({
|
|
35
|
+
authProvider,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
return this.graphClient;
|
|
39
|
+
}
|
|
40
|
+
/** Check if operation is permitted */
|
|
41
|
+
checkPermission(operation, enabled) {
|
|
42
|
+
if (!enabled) {
|
|
43
|
+
throw new Error(`${operation} is not enabled. ` +
|
|
44
|
+
`Set the appropriate environment variable to enable this operation.`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/** Map Graph API user response to B2CUser */
|
|
48
|
+
mapUserResponse(response) {
|
|
49
|
+
return {
|
|
50
|
+
id: response.id,
|
|
51
|
+
displayName: response.displayName,
|
|
52
|
+
givenName: response.givenName,
|
|
53
|
+
surname: response.surname,
|
|
54
|
+
userPrincipalName: response.userPrincipalName,
|
|
55
|
+
mail: response.mail,
|
|
56
|
+
otherMails: response.otherMails,
|
|
57
|
+
identities: response.identities,
|
|
58
|
+
accountEnabled: response.accountEnabled,
|
|
59
|
+
createdDateTime: response.createdDateTime,
|
|
60
|
+
jobTitle: response.jobTitle,
|
|
61
|
+
department: response.department,
|
|
62
|
+
mobilePhone: response.mobilePhone,
|
|
63
|
+
city: response.city,
|
|
64
|
+
country: response.country,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/** Map array of Graph API user responses */
|
|
68
|
+
mapUsersResponse(responses) {
|
|
69
|
+
return responses.map((r) => this.mapUserResponse(r));
|
|
70
|
+
}
|
|
71
|
+
/** Map Graph API group response to B2CGroup */
|
|
72
|
+
mapGroupResponse(response) {
|
|
73
|
+
return {
|
|
74
|
+
id: response.id,
|
|
75
|
+
displayName: response.displayName,
|
|
76
|
+
description: response.description,
|
|
77
|
+
mailEnabled: response.mailEnabled,
|
|
78
|
+
securityEnabled: response.securityEnabled,
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/** Map array of Graph API group responses */
|
|
82
|
+
mapGroupsResponse(responses) {
|
|
83
|
+
return responses.map((r) => this.mapGroupResponse(r));
|
|
84
|
+
}
|
|
85
|
+
/** Enhance error with helpful context */
|
|
86
|
+
enhanceError(error, operation) {
|
|
87
|
+
const message = error.message || String(error);
|
|
88
|
+
if (error.statusCode === 401 || message.includes('Unauthorized')) {
|
|
89
|
+
return new Error(`Unauthorized to ${operation}. ` +
|
|
90
|
+
`Verify app registration has correct API permissions (User.ReadWrite.All) ` +
|
|
91
|
+
`and "User Administrator" role assignment. ` +
|
|
92
|
+
`Original error: ${message}`);
|
|
93
|
+
}
|
|
94
|
+
if (error.statusCode === 403 || message.includes('Forbidden')) {
|
|
95
|
+
return new Error(`Forbidden to ${operation}. ` +
|
|
96
|
+
`The app may lack required permissions or role assignments. ` +
|
|
97
|
+
`Original error: ${message}`);
|
|
98
|
+
}
|
|
99
|
+
if (error.statusCode === 404 || message.includes('Request_ResourceNotFound')) {
|
|
100
|
+
return new Error(`Resource not found when attempting to ${operation}. ` +
|
|
101
|
+
`Verify the user/group ID is correct. ` +
|
|
102
|
+
`Original error: ${message}`);
|
|
103
|
+
}
|
|
104
|
+
if (message.includes('Invalid password')) {
|
|
105
|
+
return new Error(`Invalid password format. Password must meet Azure AD B2C complexity requirements: ` +
|
|
106
|
+
`8-256 characters, at least 3 of: lowercase, uppercase, digit, symbol. ` +
|
|
107
|
+
`Original error: ${message}`);
|
|
108
|
+
}
|
|
109
|
+
return new Error(`Failed to ${operation}: ${message}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=b2c-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"b2c-client.js","sourceRoot":"","sources":["../src/b2c-client.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EAAE,qCAAqC,EAAE,MAAM,gFAAgF,CAAC;AAGvI,MAAM,OAAO,SAAS;IACZ,MAAM,CAAiB;IACvB,WAAW,GAAkB,IAAI,CAAC;IAClC,UAAU,GAAkC,IAAI,CAAC;IAEzD,YAAY,MAAsB;QAChC,IAAI,CAAC,MAAM,GAAG;YACZ,UAAU,EAAE,GAAG;YACf,aAAa,EAAE,GAAG;YAClB,GAAG,MAAM;SACV,CAAC;QAEF,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,EAAE,CAAC;YAChF,MAAM,IAAI,KAAK,CACb,uEAAuE,CACxE,CAAC;QACJ,CAAC;IACH,CAAC;IAED,8BAA8B;IAC9B,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,+CAA+C;IAC/C,SAAS;QACP,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,IAAI,CAAC,UAAU,GAAG,IAA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K,GAAG,IAAI,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAAC,EAAE,CAAC;YAC7E,OAAO,IAAI,KAAK,CACd,yCAAyC,SAAS,IAAI;gBACpD,uCAAuC;gBACvC,mBAAmB,OAAO,EAAE,CAC/B,CAAC;QACJ,CAAC;QAED,IAAI,OAAO,CAAC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;YACzC,OAAO,IAAI,KAAK,CACd,oFAAoF;gBAClF,wEAAwE;gBACxE,mBAAmB,OAAO,EAAE,CAC/B,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,KAAK,CAAC,aAAa,SAAS,KAAK,OAAO,EAAE,CAAC,CAAC;IACzD,CAAC;CACF"}
|
package/build/index.d.ts
CHANGED
|
@@ -1,25 +1,18 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* @mcp-consultant-tools/azure-b2c
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* Tools (11 total):
|
|
8
|
-
* - Read-only (6): list-users, get-user, search-users, list-groups, get-user-groups, get-group-members
|
|
9
|
-
* - Password (2): reset-user-password, force-password-change (requires AZURE_B2C_ENABLE_PASSWORD_RESET)
|
|
10
|
-
* - User Create (1): create-user (requires AZURE_B2C_ENABLE_USER_CREATE)
|
|
11
|
-
* - User Update (1): update-user (requires AZURE_B2C_ENABLE_USER_UPDATE)
|
|
12
|
-
* - User Delete (1): delete-user (requires AZURE_B2C_ENABLE_USER_DELETE)
|
|
13
|
-
*
|
|
14
|
-
* Prompts (2):
|
|
15
|
-
* - b2c-user-overview: Formatted user profile with group memberships
|
|
16
|
-
* - b2c-tenant-summary: Tenant statistics and user breakdown
|
|
5
|
+
* MCP server for Azure AD B2C user management via Microsoft Graph API.
|
|
6
|
+
* Entry point: MCP server startup + backward-compatible registerAzureB2CTools().
|
|
17
7
|
*/
|
|
18
|
-
import { AzureB2CService } from "./AzureB2CService.js";
|
|
19
|
-
export { AzureB2CService };
|
|
20
|
-
export type { AzureB2CConfig, B2CUser, B2CGroup, B2CIdentity, CreateUserRequest, UpdateUserRequest } from "./AzureB2CService.js";
|
|
21
8
|
/**
|
|
22
|
-
* Register Azure B2C tools and prompts on an MCP server
|
|
9
|
+
* Register Azure B2C tools and prompts on an MCP server.
|
|
10
|
+
* Backward-compatible API for the meta package.
|
|
23
11
|
*/
|
|
24
|
-
export declare function registerAzureB2CTools(server: any
|
|
12
|
+
export declare function registerAzureB2CTools(server: any): void;
|
|
13
|
+
export { B2CClient } from './b2c-client.js';
|
|
14
|
+
export { UserService } from './services/user-service.js';
|
|
15
|
+
export { GroupService } from './services/group-service.js';
|
|
16
|
+
export type { AzureB2CConfig, B2CUser, B2CGroup, B2CIdentity, CreateUserRequest, UpdateUserRequest, TenantSummary, } from './models/index.js';
|
|
17
|
+
export type { ServiceContext } from './types.js';
|
|
25
18
|
//# sourceMappingURL=index.d.ts.map
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;GAKG;AA6EH;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,GAAG,GAAG,IAAI,CAIvD;AAGD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,YAAY,EACV,cAAc,EACd,OAAO,EACP,QAAQ,EACR,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EACjB,aAAa,GACd,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC"}
|