@mcp-consultant-tools/azure-b2c 28.0.0-beta.7 → 28.0.0
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/cli/commands/group-commands.d.ts +9 -0
- package/build/cli/commands/group-commands.d.ts.map +1 -0
- package/build/cli/commands/group-commands.js +64 -0
- package/build/cli/commands/group-commands.js.map +1 -0
- package/build/cli/commands/index.d.ts +10 -0
- package/build/cli/commands/index.d.ts.map +1 -0
- package/build/cli/commands/index.js +15 -0
- package/build/cli/commands/index.js.map +1 -0
- package/build/cli/commands/tenant-commands.d.ts +9 -0
- package/build/cli/commands/tenant-commands.d.ts.map +1 -0
- package/build/cli/commands/tenant-commands.js +27 -0
- package/build/cli/commands/tenant-commands.js.map +1 -0
- package/build/cli/commands/user-commands.d.ts +11 -0
- package/build/cli/commands/user-commands.d.ts.map +1 -0
- package/build/cli/commands/user-commands.js +239 -0
- package/build/cli/commands/user-commands.js.map +1 -0
- package/build/cli/output.d.ts +11 -0
- package/build/cli/output.d.ts.map +1 -0
- package/build/cli/output.js +10 -0
- package/build/cli/output.js.map +1 -0
- package/build/cli.d.ts +9 -0
- package/build/cli.d.ts.map +1 -0
- package/build/cli.js +27 -0
- package/build/cli.js.map +1 -0
- package/build/context-factory.d.ts +4 -0
- package/build/context-factory.d.ts.map +1 -0
- package/build/context-factory.js +59 -0
- package/build/context-factory.js.map +1 -0
- package/package.json +5 -3
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Group CLI Commands - 3 commands mapping to group-related MCP tools
|
|
3
|
+
*
|
|
4
|
+
* list-groups, get-user-groups, get-group-members
|
|
5
|
+
*/
|
|
6
|
+
import type { Command } from 'commander';
|
|
7
|
+
import type { ServiceContext } from '../../context-factory.js';
|
|
8
|
+
export declare function registerGroupCommands(program: Command, ctx: ServiceContext): void;
|
|
9
|
+
//# sourceMappingURL=group-commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group-commands.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/group-commands.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG/D,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,GAAG,IAAI,CA0DjF"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Group CLI Commands - 3 commands mapping to group-related MCP tools
|
|
3
|
+
*
|
|
4
|
+
* list-groups, get-user-groups, get-group-members
|
|
5
|
+
*/
|
|
6
|
+
import { getGlobalFlags, handleCliError } from '@mcp-consultant-tools/core';
|
|
7
|
+
import { outputResult } from '../output.js';
|
|
8
|
+
export function registerGroupCommands(program, ctx) {
|
|
9
|
+
const group = program.command('group').description('Group operations');
|
|
10
|
+
group
|
|
11
|
+
.command('list')
|
|
12
|
+
.description('List all groups in the Azure AD B2C tenant')
|
|
13
|
+
.option('-n, --top <n>', 'Maximum number of groups to return', '50')
|
|
14
|
+
.action(async (opts) => {
|
|
15
|
+
try {
|
|
16
|
+
const groups = await ctx.groups.listGroups(parseInt(opts.top));
|
|
17
|
+
outputResult({
|
|
18
|
+
fileName: 'b2c-groups',
|
|
19
|
+
data: groups,
|
|
20
|
+
summary: `Found ${groups.length} group(s)`,
|
|
21
|
+
}, getGlobalFlags(program));
|
|
22
|
+
}
|
|
23
|
+
catch (error) {
|
|
24
|
+
handleCliError(error, 'list groups');
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
group
|
|
28
|
+
.command('user-groups')
|
|
29
|
+
.description('Get all groups that a user is a member of')
|
|
30
|
+
.argument('<userId>', 'User ID (GUID) or email address')
|
|
31
|
+
.action(async (userId) => {
|
|
32
|
+
try {
|
|
33
|
+
const groups = await ctx.groups.getUserGroups(userId);
|
|
34
|
+
outputResult({
|
|
35
|
+
fileName: `b2c-user-groups-${userId}`,
|
|
36
|
+
data: groups,
|
|
37
|
+
summary: `User ${userId} is a member of ${groups.length} group(s)`,
|
|
38
|
+
}, getGlobalFlags(program));
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
handleCliError(error, 'get user groups');
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
group
|
|
45
|
+
.command('members')
|
|
46
|
+
.description('Get all members of a specific group')
|
|
47
|
+
.argument('<groupId>', 'Group ID (GUID)')
|
|
48
|
+
.option('-n, --top <n>', 'Maximum members to return', '50')
|
|
49
|
+
.option('--all-fields', 'Return all fields including extension_* attributes', false)
|
|
50
|
+
.action(async (groupId, opts) => {
|
|
51
|
+
try {
|
|
52
|
+
const members = await ctx.groups.getGroupMembers(groupId, parseInt(opts.top), opts.allFields);
|
|
53
|
+
outputResult({
|
|
54
|
+
fileName: `b2c-group-members-${groupId}`,
|
|
55
|
+
data: members,
|
|
56
|
+
summary: `Found ${Array.isArray(members) ? members.length : 0} member(s) in group ${groupId}`,
|
|
57
|
+
}, getGlobalFlags(program));
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
handleCliError(error, 'get group members');
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=group-commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"group-commands.js","sourceRoot":"","sources":["../../../src/cli/commands/group-commands.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5E,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,UAAU,qBAAqB,CAAC,OAAgB,EAAE,GAAmB;IACzE,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,kBA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OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,qCAAqC,CAAC;SAClD,QAAQ,CAAC,WAAW,EAAE,iBAAiB,CAAC;SACxC,MAAM,CAAC,eAAe,EAAE,2BAA2B,EAAE,IAAI,CAAC;SAC1D,MAAM,CAAC,cAAc,EAAE,oDAAoD,EAAE,KAAK,CAAC;SACnF,MAAM,CAAC,KAAK,EAAE,OAAe,EAAE,IAAS,EAAE,EAAE;QAC3C,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,eAAe,CAAC,OAAO,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;YAC9F,YAAY,CACV;gBACE,QAAQ,EAAE,qBAAqB,OAAO,EAAE;gBACxC,IAAI,EAAE,OAAO;gBACb,OAAO,EAAE,SAAS,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,uBAAuB,OAAO,EAAE;aAC9F,EACD,cAAc,CAAC,OAAO,CAAC,CACxB,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAAC,cAAc,CAAC,KAAK,EAAE,mBAAmB,CAAC,CAAC;QAAC,CAAC;IACjE,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Commands barrel export + combined registration
|
|
3
|
+
*/
|
|
4
|
+
import type { Command } from 'commander';
|
|
5
|
+
import type { ServiceContext } from '../../context-factory.js';
|
|
6
|
+
export declare function registerAllCommands(program: Command, ctx: ServiceContext): void;
|
|
7
|
+
export { registerUserCommands } from './user-commands.js';
|
|
8
|
+
export { registerGroupCommands } from './group-commands.js';
|
|
9
|
+
export { registerTenantCommands } from './tenant-commands.js';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAK/D,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,GAAG,IAAI,CAI/E;AAED,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI Commands barrel export + combined registration
|
|
3
|
+
*/
|
|
4
|
+
import { registerUserCommands } from './user-commands.js';
|
|
5
|
+
import { registerGroupCommands } from './group-commands.js';
|
|
6
|
+
import { registerTenantCommands } from './tenant-commands.js';
|
|
7
|
+
export function registerAllCommands(program, ctx) {
|
|
8
|
+
registerUserCommands(program, ctx);
|
|
9
|
+
registerGroupCommands(program, ctx);
|
|
10
|
+
registerTenantCommands(program, ctx);
|
|
11
|
+
}
|
|
12
|
+
export { registerUserCommands } from './user-commands.js';
|
|
13
|
+
export { registerGroupCommands } from './group-commands.js';
|
|
14
|
+
export { registerTenantCommands } from './tenant-commands.js';
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/commands/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,MAAM,UAAU,mBAAmB,CAAC,OAAgB,EAAE,GAAmB;IACvE,oBAAoB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IACnC,qBAAqB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IACpC,sBAAsB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AACvC,CAAC;AAED,OAAO,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tenant CLI Commands - tenant-level operations
|
|
3
|
+
*
|
|
4
|
+
* summary (maps to b2c-tenant-summary prompt / getTenantSummary service method)
|
|
5
|
+
*/
|
|
6
|
+
import type { Command } from 'commander';
|
|
7
|
+
import type { ServiceContext } from '../../context-factory.js';
|
|
8
|
+
export declare function registerTenantCommands(program: Command, ctx: ServiceContext): void;
|
|
9
|
+
//# sourceMappingURL=tenant-commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenant-commands.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/tenant-commands.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG/D,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,GAAG,IAAI,CAmBlF"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tenant CLI Commands - tenant-level operations
|
|
3
|
+
*
|
|
4
|
+
* summary (maps to b2c-tenant-summary prompt / getTenantSummary service method)
|
|
5
|
+
*/
|
|
6
|
+
import { getGlobalFlags, handleCliError } from '@mcp-consultant-tools/core';
|
|
7
|
+
import { outputResult } from '../output.js';
|
|
8
|
+
export function registerTenantCommands(program, ctx) {
|
|
9
|
+
const tenant = program.command('tenant').description('Tenant-level operations');
|
|
10
|
+
tenant
|
|
11
|
+
.command('summary')
|
|
12
|
+
.description('Get a summary of the Azure AD B2C tenant including user and group statistics')
|
|
13
|
+
.action(async () => {
|
|
14
|
+
try {
|
|
15
|
+
const summary = await ctx.groups.getTenantSummary();
|
|
16
|
+
outputResult({
|
|
17
|
+
fileName: 'b2c-tenant-summary',
|
|
18
|
+
data: summary,
|
|
19
|
+
summary: `Tenant ${summary.tenantId}: ${summary.userCount} users, ${summary.groupCount} groups (${summary.enabledUserCount} enabled, ${summary.disabledUserCount} disabled)`,
|
|
20
|
+
}, getGlobalFlags(program));
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
handleCliError(error, 'get tenant summary');
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
//# sourceMappingURL=tenant-commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tenant-commands.js","sourceRoot":"","sources":["../../../src/cli/commands/tenant-commands.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAE5E,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,UAAU,sBAAsB,CAAC,OAAgB,EAAE,GAAmB;IAC1E,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,WAAW,CAAC,yBAAyB,CAAC,CAAC;IAEhF,MAAM;SACH,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,8EAA8E,CAAC;SAC3F,MAAM,CAAC,KAAK,IAAI,EAAE;QACjB,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,MAAM,CAAC,gBAAgB,EAAE,CAAC;YACpD,YAAY,CACV;gBACE,QAAQ,EAAE,oBAAoB;gBAC9B,IAAI,EAAE,OAAO;gBACb,OAAO,EAAE,UAAU,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,SAAS,WAAW,OAAO,CAAC,UAAU,YAAY,OAAO,CAAC,gBAAgB,aAAa,OAAO,CAAC,iBAAiB,YAAY;aAC7K,EACD,cAAc,CAAC,OAAO,CAAC,CACxB,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAAC,cAAc,CAAC,KAAK,EAAE,oBAAoB,CAAC,CAAC;QAAC,CAAC;IAClE,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User CLI Commands - 8 commands mapping to user-related MCP tools
|
|
3
|
+
*
|
|
4
|
+
* Read-only: list, get, search
|
|
5
|
+
* Password: reset-password, force-pwd-change
|
|
6
|
+
* Write: create, update, delete
|
|
7
|
+
*/
|
|
8
|
+
import type { Command } from 'commander';
|
|
9
|
+
import type { ServiceContext } from '../../context-factory.js';
|
|
10
|
+
export declare function registerUserCommands(program: Command, ctx: ServiceContext): void;
|
|
11
|
+
//# sourceMappingURL=user-commands.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-commands.d.ts","sourceRoot":"","sources":["../../../src/cli/commands/user-commands.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEzC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAI/D,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,cAAc,GAAG,IAAI,CAqPhF"}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* User CLI Commands - 8 commands mapping to user-related MCP tools
|
|
3
|
+
*
|
|
4
|
+
* Read-only: list, get, search
|
|
5
|
+
* Password: reset-password, force-pwd-change
|
|
6
|
+
* Write: create, update, delete
|
|
7
|
+
*/
|
|
8
|
+
import { getGlobalFlags, handleCliError } from '@mcp-consultant-tools/core';
|
|
9
|
+
import { outputResult } from '../output.js';
|
|
10
|
+
export function registerUserCommands(program, ctx) {
|
|
11
|
+
const user = program.command('user').description('User management operations');
|
|
12
|
+
// ========================================
|
|
13
|
+
// READ-ONLY
|
|
14
|
+
// ========================================
|
|
15
|
+
user
|
|
16
|
+
.command('list')
|
|
17
|
+
.description('List Azure AD B2C users with optional filtering')
|
|
18
|
+
.option('-n, --top <n>', 'Maximum number of users to return', '50')
|
|
19
|
+
.option('-f, --filter <expr>', 'OData filter expression')
|
|
20
|
+
.option('--all-fields', 'Return all fields including extension_* attributes', false)
|
|
21
|
+
.action(async (opts) => {
|
|
22
|
+
try {
|
|
23
|
+
const users = await ctx.users.listUsers(parseInt(opts.top), opts.filter, false, opts.allFields);
|
|
24
|
+
outputResult({
|
|
25
|
+
fileName: 'b2c-users',
|
|
26
|
+
data: users,
|
|
27
|
+
summary: `Found ${Array.isArray(users) ? users.length : 0} user(s)`,
|
|
28
|
+
}, getGlobalFlags(program));
|
|
29
|
+
}
|
|
30
|
+
catch (error) {
|
|
31
|
+
handleCliError(error, 'list users');
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
user
|
|
35
|
+
.command('get')
|
|
36
|
+
.description('Get detailed information about a specific user')
|
|
37
|
+
.argument('<userId>', 'User ID (GUID) or email address')
|
|
38
|
+
.option('--all-fields', 'Return all fields including extension_* attributes', false)
|
|
39
|
+
.action(async (userId, opts) => {
|
|
40
|
+
try {
|
|
41
|
+
const result = await ctx.users.getUser(userId, opts.allFields);
|
|
42
|
+
outputResult({
|
|
43
|
+
fileName: `b2c-user-${userId}`,
|
|
44
|
+
data: result,
|
|
45
|
+
summary: `User: ${result.displayName || userId}`,
|
|
46
|
+
}, getGlobalFlags(program));
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
handleCliError(error, 'get user');
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
user
|
|
53
|
+
.command('search')
|
|
54
|
+
.description('Search for users by display name, email, or other fields')
|
|
55
|
+
.argument('<searchTerm>', 'Search term to match against user fields')
|
|
56
|
+
.option('-f, --fields <fields>', 'Comma-separated fields to search (displayName,mail,userPrincipalName,givenName,surname)', 'displayName,mail')
|
|
57
|
+
.option('-n, --top <n>', 'Maximum results to return', '25')
|
|
58
|
+
.option('--all-fields', 'Return all fields including extension_* attributes', false)
|
|
59
|
+
.action(async (searchTerm, opts) => {
|
|
60
|
+
try {
|
|
61
|
+
const searchFields = opts.fields.split(',').map((f) => f.trim());
|
|
62
|
+
const users = await ctx.users.searchUsers(searchTerm, searchFields, parseInt(opts.top), opts.allFields);
|
|
63
|
+
outputResult({
|
|
64
|
+
fileName: `b2c-search-${searchTerm.replace(/\s+/g, '-')}`,
|
|
65
|
+
data: users,
|
|
66
|
+
summary: `Found ${Array.isArray(users) ? users.length : 0} user(s) matching '${searchTerm}'`,
|
|
67
|
+
}, getGlobalFlags(program));
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
handleCliError(error, 'search users');
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
// ========================================
|
|
74
|
+
// PASSWORD OPERATIONS
|
|
75
|
+
// ========================================
|
|
76
|
+
user
|
|
77
|
+
.command('reset-password')
|
|
78
|
+
.description('Reset a user\'s password (requires AZURE_B2C_ENABLE_PASSWORD_RESET=true)')
|
|
79
|
+
.argument('<userId>', 'User ID (GUID) or email address')
|
|
80
|
+
.argument('<newPassword>', 'New password (must meet B2C complexity requirements)')
|
|
81
|
+
.option('--force-change', 'Force user to change password on next login', false)
|
|
82
|
+
.action(async (userId, newPassword, opts) => {
|
|
83
|
+
try {
|
|
84
|
+
await ctx.users.resetUserPassword(userId, newPassword, opts.forceChange);
|
|
85
|
+
outputResult({
|
|
86
|
+
fileName: `b2c-reset-pwd-${userId}`,
|
|
87
|
+
data: { success: true, message: `Password reset for user ${userId}`, forceChangeOnNextLogin: opts.forceChange },
|
|
88
|
+
summary: `Password reset successfully for user ${userId}`,
|
|
89
|
+
}, getGlobalFlags(program));
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
handleCliError(error, 'reset password');
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
user
|
|
96
|
+
.command('force-pwd-change')
|
|
97
|
+
.description('Force a user to change their password on next login (requires AZURE_B2C_ENABLE_PASSWORD_RESET=true)')
|
|
98
|
+
.argument('<userId>', 'User ID (GUID) or email address')
|
|
99
|
+
.action(async (userId) => {
|
|
100
|
+
try {
|
|
101
|
+
await ctx.users.forcePasswordChange(userId);
|
|
102
|
+
outputResult({
|
|
103
|
+
fileName: `b2c-force-pwd-${userId}`,
|
|
104
|
+
data: { success: true, message: `User ${userId} will be required to change password on next login` },
|
|
105
|
+
summary: `User ${userId} will be required to change password on next login`,
|
|
106
|
+
}, getGlobalFlags(program));
|
|
107
|
+
}
|
|
108
|
+
catch (error) {
|
|
109
|
+
handleCliError(error, 'force password change');
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
// ========================================
|
|
113
|
+
// CREATE / UPDATE / DELETE
|
|
114
|
+
// ========================================
|
|
115
|
+
user
|
|
116
|
+
.command('create')
|
|
117
|
+
.description('Create a new local account user (requires AZURE_B2C_ENABLE_USER_CREATE=true)')
|
|
118
|
+
.requiredOption('--display-name <name>', 'User\'s display name')
|
|
119
|
+
.requiredOption('--email <email>', 'User\'s email address (used for sign-in)')
|
|
120
|
+
.requiredOption('--password <password>', 'Initial password (must meet B2C complexity requirements)')
|
|
121
|
+
.option('--no-force-change', 'Do not force password change on first login')
|
|
122
|
+
.option('--given-name <name>', 'First name')
|
|
123
|
+
.option('--surname <name>', 'Last name')
|
|
124
|
+
.option('--job-title <title>', 'Job title')
|
|
125
|
+
.option('--department <dept>', 'Department')
|
|
126
|
+
.option('--mobile-phone <phone>', 'Mobile phone number')
|
|
127
|
+
.option('--city <city>', 'City')
|
|
128
|
+
.option('--country <country>', 'Country')
|
|
129
|
+
.action(async (opts) => {
|
|
130
|
+
try {
|
|
131
|
+
const configStatus = ctx.users.getConfigStatus();
|
|
132
|
+
const issuer = configStatus.tenantId.includes('.')
|
|
133
|
+
? configStatus.tenantId
|
|
134
|
+
: `${configStatus.tenantId}.onmicrosoft.com`;
|
|
135
|
+
const request = {
|
|
136
|
+
displayName: opts.displayName,
|
|
137
|
+
identities: [
|
|
138
|
+
{
|
|
139
|
+
signInType: 'emailAddress',
|
|
140
|
+
issuer: issuer,
|
|
141
|
+
issuerAssignedId: opts.email,
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
passwordProfile: {
|
|
145
|
+
password: opts.password,
|
|
146
|
+
forceChangePasswordNextSignIn: opts.forceChange !== false,
|
|
147
|
+
},
|
|
148
|
+
givenName: opts.givenName,
|
|
149
|
+
surname: opts.surname,
|
|
150
|
+
jobTitle: opts.jobTitle,
|
|
151
|
+
department: opts.department,
|
|
152
|
+
mobilePhone: opts.mobilePhone,
|
|
153
|
+
city: opts.city,
|
|
154
|
+
country: opts.country,
|
|
155
|
+
};
|
|
156
|
+
const result = await ctx.users.createUser(request);
|
|
157
|
+
outputResult({
|
|
158
|
+
fileName: `b2c-created-user`,
|
|
159
|
+
data: { success: true, message: 'User created successfully', user: result },
|
|
160
|
+
summary: `Created user '${opts.displayName}' (${result.id})`,
|
|
161
|
+
}, getGlobalFlags(program));
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
handleCliError(error, 'create user');
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
user
|
|
168
|
+
.command('update')
|
|
169
|
+
.description('Update a user\'s profile information (requires AZURE_B2C_ENABLE_USER_UPDATE=true)')
|
|
170
|
+
.argument('<userId>', 'User ID (GUID) or email address')
|
|
171
|
+
.option('--display-name <name>', 'New display name')
|
|
172
|
+
.option('--given-name <name>', 'First name')
|
|
173
|
+
.option('--surname <name>', 'Last name')
|
|
174
|
+
.option('--job-title <title>', 'Job title')
|
|
175
|
+
.option('--department <dept>', 'Department')
|
|
176
|
+
.option('--mobile-phone <phone>', 'Mobile phone number')
|
|
177
|
+
.option('--city <city>', 'City')
|
|
178
|
+
.option('--country <country>', 'Country')
|
|
179
|
+
.option('--account-enabled <bool>', 'Enable or disable the account (true/false)')
|
|
180
|
+
.action(async (userId, opts) => {
|
|
181
|
+
try {
|
|
182
|
+
const updates = {};
|
|
183
|
+
if (opts.displayName !== undefined)
|
|
184
|
+
updates.displayName = opts.displayName;
|
|
185
|
+
if (opts.givenName !== undefined)
|
|
186
|
+
updates.givenName = opts.givenName;
|
|
187
|
+
if (opts.surname !== undefined)
|
|
188
|
+
updates.surname = opts.surname;
|
|
189
|
+
if (opts.jobTitle !== undefined)
|
|
190
|
+
updates.jobTitle = opts.jobTitle;
|
|
191
|
+
if (opts.department !== undefined)
|
|
192
|
+
updates.department = opts.department;
|
|
193
|
+
if (opts.mobilePhone !== undefined)
|
|
194
|
+
updates.mobilePhone = opts.mobilePhone;
|
|
195
|
+
if (opts.city !== undefined)
|
|
196
|
+
updates.city = opts.city;
|
|
197
|
+
if (opts.country !== undefined)
|
|
198
|
+
updates.country = opts.country;
|
|
199
|
+
if (opts.accountEnabled !== undefined)
|
|
200
|
+
updates.accountEnabled = opts.accountEnabled === 'true';
|
|
201
|
+
if (Object.keys(updates).length === 0) {
|
|
202
|
+
process.stderr.write('Error: No updates provided. Specify at least one field to update.\n');
|
|
203
|
+
process.exit(1);
|
|
204
|
+
}
|
|
205
|
+
const result = await ctx.users.updateUser(userId, updates);
|
|
206
|
+
outputResult({
|
|
207
|
+
fileName: `b2c-updated-user-${userId}`,
|
|
208
|
+
data: { success: true, message: 'User updated successfully', updatedFields: Object.keys(updates), user: result },
|
|
209
|
+
summary: `Updated user ${userId} (fields: ${Object.keys(updates).join(', ')})`,
|
|
210
|
+
}, getGlobalFlags(program));
|
|
211
|
+
}
|
|
212
|
+
catch (error) {
|
|
213
|
+
handleCliError(error, 'update user');
|
|
214
|
+
}
|
|
215
|
+
});
|
|
216
|
+
user
|
|
217
|
+
.command('delete')
|
|
218
|
+
.description('Delete a user from Azure AD B2C (IRREVERSIBLE, requires AZURE_B2C_ENABLE_USER_DELETE=true)')
|
|
219
|
+
.argument('<userId>', 'User ID (GUID) to delete')
|
|
220
|
+
.option('--confirm', 'Confirm deletion (required)')
|
|
221
|
+
.action(async (userId, opts) => {
|
|
222
|
+
try {
|
|
223
|
+
if (!opts.confirm) {
|
|
224
|
+
process.stderr.write('Error: Deletion not confirmed. Use --confirm to proceed.\n');
|
|
225
|
+
process.exit(1);
|
|
226
|
+
}
|
|
227
|
+
await ctx.users.deleteUser(userId);
|
|
228
|
+
outputResult({
|
|
229
|
+
fileName: `b2c-deleted-user-${userId}`,
|
|
230
|
+
data: { success: true, message: `User ${userId} has been permanently deleted`, warning: 'This action cannot be undone' },
|
|
231
|
+
summary: `User ${userId} has been permanently deleted`,
|
|
232
|
+
}, getGlobalFlags(program));
|
|
233
|
+
}
|
|
234
|
+
catch (error) {
|
|
235
|
+
handleCliError(error, 'delete user');
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
//# sourceMappingURL=user-commands.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"user-commands.js","sourceRoot":"","sources":["../../../src/cli/commands/user-commands.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAG5E,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,MAAM,UAAU,oBAAoB,CAAC,OAAgB,EAAE,GAAmB;IACxE,MAAM,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,WAAW,CAAC,4BAA4B,CAAC,CAAC;IAE/E,2CAA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AU,EAAE,0BAA0B,CAAC;SAChD,MAAM,CAAC,WAAW,EAAE,6BAA6B,CAAC;SAClD,MAAM,CAAC,KAAK,EAAE,MAAc,EAAE,IAAS,EAAE,EAAE;QAC1C,IAAI,CAAC;YACH,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;gBAClB,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,4DAA4D,CAAC,CAAC;gBACnF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClB,CAAC;YAED,MAAM,GAAG,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;YACnC,YAAY,CACV;gBACE,QAAQ,EAAE,oBAAoB,MAAM,EAAE;gBACtC,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,MAAM,+BAA+B,EAAE,OAAO,EAAE,8BAA8B,EAAE;gBACxH,OAAO,EAAE,QAAQ,MAAM,+BAA+B;aACvD,EACD,cAAc,CAAC,OAAO,CAAC,CACxB,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAAC,cAAc,CAAC,KAAK,EAAE,aAAa,CAAC,CAAC;QAAC,CAAC;IAC3D,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI output helper for azure-b2c package.
|
|
3
|
+
* Thin wrapper setting the package-specific cache directory.
|
|
4
|
+
*/
|
|
5
|
+
import { type GlobalFlags } from '@mcp-consultant-tools/core';
|
|
6
|
+
export declare function outputResult(opts: {
|
|
7
|
+
fileName: string;
|
|
8
|
+
data: unknown;
|
|
9
|
+
summary: string;
|
|
10
|
+
}, flags: GlobalFlags): void;
|
|
11
|
+
//# sourceMappingURL=output.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.d.ts","sourceRoot":"","sources":["../../src/cli/output.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAoC,KAAK,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAIhG,wBAAgB,YAAY,CAC1B,IAAI,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,EAC1D,KAAK,EAAE,WAAW,GACjB,IAAI,CAEN"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CLI output helper for azure-b2c package.
|
|
3
|
+
* Thin wrapper setting the package-specific cache directory.
|
|
4
|
+
*/
|
|
5
|
+
import { outputResult as coreOutputResult } from '@mcp-consultant-tools/core';
|
|
6
|
+
const CACHE_DIR = '.mcp-azure-b2c-cache';
|
|
7
|
+
export function outputResult(opts, flags) {
|
|
8
|
+
coreOutputResult({ ...opts, cacheDir: CACHE_DIR }, flags);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/cli/output.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,YAAY,IAAI,gBAAgB,EAAoB,MAAM,4BAA4B,CAAC;AAEhG,MAAM,SAAS,GAAG,sBAAsB,CAAC;AAEzC,MAAM,UAAU,YAAY,CAC1B,IAA0D,EAC1D,KAAkB;IAElB,gBAAgB,CAAC,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,KAAK,CAAC,CAAC;AAC5D,CAAC"}
|
package/build/cli.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;;GAKG"}
|
package/build/cli.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* @mcp-consultant-tools/azure-b2c CLI
|
|
4
|
+
*
|
|
5
|
+
* Command-line interface for Azure AD B2C operations.
|
|
6
|
+
* Reuses the same ServiceContext and services as the MCP server.
|
|
7
|
+
*/
|
|
8
|
+
import { createCliProgram, loadEnvForCli } from '@mcp-consultant-tools/core';
|
|
9
|
+
import { createServiceContext } from './context-factory.js';
|
|
10
|
+
import { registerAllCommands } from './cli/commands/index.js';
|
|
11
|
+
const program = createCliProgram({
|
|
12
|
+
name: 'mcp-azure-b2c-cli',
|
|
13
|
+
description: 'Azure AD B2C CLI - users, groups, passwords, tenant management',
|
|
14
|
+
version: '27.0.0',
|
|
15
|
+
});
|
|
16
|
+
// Load env before parsing (--env-file handled by commander hook)
|
|
17
|
+
program.hook('preAction', (thisCommand) => {
|
|
18
|
+
const opts = thisCommand.opts();
|
|
19
|
+
loadEnvForCli(opts.envFile);
|
|
20
|
+
});
|
|
21
|
+
const ctx = createServiceContext();
|
|
22
|
+
registerAllCommands(program, ctx);
|
|
23
|
+
program.parseAsync(process.argv).catch((error) => {
|
|
24
|
+
console.error('CLI error:', error.message);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
});
|
|
27
|
+
//# sourceMappingURL=cli.js.map
|
package/build/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":";AAEA;;;;;GAKG;AAGH,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,MAAM,OAAO,GAAG,gBAAgB,CAAC;IAC/B,IAAI,EAAE,mBAAmB;IACzB,WAAW,EAAE,gEAAgE;IAC7E,OAAO,EAAE,QAAQ;CAClB,CAAC,CAAC;AAEH,iEAAiE;AACjE,OAAO,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,WAAoB,EAAE,EAAE;IACjD,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,EAAE,CAAC;IAChC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AAC9B,CAAC,CAAC,CAAC;AAEH,MAAM,GAAG,GAAG,oBAAoB,EAAE,CAAC;AACnC,mBAAmB,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;AAElC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,KAAY,EAAE,EAAE;IACtD,OAAO,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAC3C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-factory.d.ts","sourceRoot":"","sources":["../src/context-factory.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,wBAAgB,oBAAoB,IAAI,cAAc,CAyDrD"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared service context factory - used by both MCP server and CLI.
|
|
3
|
+
*/
|
|
4
|
+
import { B2CClient } from './b2c-client.js';
|
|
5
|
+
import { UserService } from './services/user-service.js';
|
|
6
|
+
import { GroupService } from './services/group-service.js';
|
|
7
|
+
export function createServiceContext() {
|
|
8
|
+
let client = null;
|
|
9
|
+
let userService = null;
|
|
10
|
+
let groupService = null;
|
|
11
|
+
function getClient() {
|
|
12
|
+
if (!client) {
|
|
13
|
+
const missingConfig = [];
|
|
14
|
+
const tenantId = process.env.AZURE_B2C_TENANT_ID;
|
|
15
|
+
const clientId = process.env.AZURE_B2C_CLIENT_ID;
|
|
16
|
+
const clientSecret = process.env.AZURE_B2C_CLIENT_SECRET;
|
|
17
|
+
if (!tenantId)
|
|
18
|
+
missingConfig.push('AZURE_B2C_TENANT_ID');
|
|
19
|
+
if (!clientId)
|
|
20
|
+
missingConfig.push('AZURE_B2C_CLIENT_ID');
|
|
21
|
+
if (!clientSecret)
|
|
22
|
+
missingConfig.push('AZURE_B2C_CLIENT_SECRET');
|
|
23
|
+
if (missingConfig.length > 0) {
|
|
24
|
+
throw new Error(`Missing Azure B2C configuration: ${missingConfig.join(', ')}`);
|
|
25
|
+
}
|
|
26
|
+
const config = {
|
|
27
|
+
tenantId: tenantId,
|
|
28
|
+
clientId: clientId,
|
|
29
|
+
clientSecret: clientSecret,
|
|
30
|
+
enablePasswordReset: process.env.AZURE_B2C_ENABLE_PASSWORD_RESET === 'true',
|
|
31
|
+
enableUserCreate: process.env.AZURE_B2C_ENABLE_USER_CREATE === 'true',
|
|
32
|
+
enableUserUpdate: process.env.AZURE_B2C_ENABLE_USER_UPDATE === 'true',
|
|
33
|
+
enableUserDelete: process.env.AZURE_B2C_ENABLE_USER_DELETE === 'true',
|
|
34
|
+
maxResults: parseInt(process.env.AZURE_B2C_MAX_RESULTS || '100'),
|
|
35
|
+
};
|
|
36
|
+
client = new B2CClient(config);
|
|
37
|
+
console.error('Azure B2C client initialized');
|
|
38
|
+
}
|
|
39
|
+
return client;
|
|
40
|
+
}
|
|
41
|
+
function getUserService() {
|
|
42
|
+
if (!userService) {
|
|
43
|
+
userService = new UserService(getClient());
|
|
44
|
+
}
|
|
45
|
+
return userService;
|
|
46
|
+
}
|
|
47
|
+
function getGroupService() {
|
|
48
|
+
if (!groupService) {
|
|
49
|
+
groupService = new GroupService(getClient(), getUserService());
|
|
50
|
+
}
|
|
51
|
+
return groupService;
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
get client() { return getClient(); },
|
|
55
|
+
get users() { return getUserService(); },
|
|
56
|
+
get groups() { return getGroupService(); },
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=context-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G,CAAC,+BAA+B,KAAK,MAAM;gBAC3E,gBAAgB,EAAE,OAAO,CAAC,GAAG,CAAC,4BAA4B,KAAK,MAAM;gBACrE,gBAAgB,EAAE,OAAO,CAAC,GAAG,CAAC,4BAA4B,KAAK,MAAM;gBACrE,gBAAgB,EAAE,OAAO,CAAC,GAAG,CAAC,4BAA4B,KAAK,MAAM;gBACrE,UAAU,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,KAAK,CAAC;aACjE,CAAC;YAEF,MAAM,GAAG,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC;YAC/B,OAAO,CAAC,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAChD,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,SAAS,cAAc;QACrB,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,WAAW,GAAG,IAAI,WAAW,CAAC,SAAS,EAAE,CAAC,CAAC;QAC7C,CAAC;QACD,OAAO,WAAW,CAAC;IACrB,CAAC;IAED,SAAS,eAAe;QACtB,IAAI,CAAC,YAAY,EAAE,CAAC;YAClB,YAAY,GAAG,IAAI,YAAY,CAAC,SAAS,EAAE,EAAE,cAAc,EAAE,CAAC,CAAC;QACjE,CAAC;QACD,OAAO,YAAY,CAAC;IACtB,CAAC;IAED,OAAO;QACL,IAAI,MAAM,KAAK,OAAO,SAAS,EAAE,CAAC,CAAC,CAAC;QACpC,IAAI,KAAK,KAAK,OAAO,cAAc,EAAE,CAAC,CAAC,CAAC;QACxC,IAAI,MAAM,KAAK,OAAO,eAAe,EAAE,CAAC,CAAC,CAAC;KAC3C,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcp-consultant-tools/azure-b2c",
|
|
3
|
-
"version": "28.0.0
|
|
3
|
+
"version": "28.0.0",
|
|
4
4
|
"description": "MCP server for Azure AD B2C - user management, password reset, and group operations",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./build/index.js",
|
|
@@ -41,10 +41,11 @@
|
|
|
41
41
|
"node": ">=16.0.0"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@mcp-consultant-tools/core": "28.0.0
|
|
44
|
+
"@mcp-consultant-tools/core": "28.0.0",
|
|
45
45
|
"@modelcontextprotocol/sdk": "^1.0.4",
|
|
46
46
|
"@azure/identity": "^4.5.0",
|
|
47
47
|
"@microsoft/microsoft-graph-client": "^3.0.7",
|
|
48
|
+
"commander": "^14.0.3",
|
|
48
49
|
"zod": "^3.24.1"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
@@ -52,6 +53,7 @@
|
|
|
52
53
|
"typescript": "^5.8.2"
|
|
53
54
|
},
|
|
54
55
|
"bin": {
|
|
55
|
-
"mcp-azure-b2c": "build/index.js"
|
|
56
|
+
"mcp-azure-b2c": "build/index.js",
|
|
57
|
+
"mcp-azure-b2c-cli": "build/cli.js"
|
|
56
58
|
}
|
|
57
59
|
}
|