@habitusnet/bc365 2.1.0 → 2.2.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/lib/onboard.js +9 -4
- package/package.json +1 -1
package/lib/onboard.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { execFile as _execFile } from 'node:child_process';
|
|
2
|
+
import { promisify } from 'node:util';
|
|
2
3
|
import inquirer from 'inquirer';
|
|
3
4
|
import { getToken } from './auth.js';
|
|
4
5
|
import { getEnvironments, getCompanies, getPermissions } from './discovery.js';
|
|
5
6
|
import { saveProfile } from './profiles.js';
|
|
6
7
|
|
|
8
|
+
const execFile = promisify(_execFile);
|
|
7
9
|
const BC_API_BASE = 'https://api.businesscentral.dynamics.com/v2.0';
|
|
8
10
|
|
|
9
11
|
export function buildMcpConfig(ctx) {
|
|
@@ -30,7 +32,7 @@ export function buildMcpConfig(ctx) {
|
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
export async function onboard(options = {}) {
|
|
33
|
-
const { tenantId,
|
|
35
|
+
const { tenantId, scope = 'local', profileName } = options;
|
|
34
36
|
const token = await getToken();
|
|
35
37
|
|
|
36
38
|
const environments = await getEnvironments(token, { tenantId, type: 'Production' });
|
|
@@ -65,8 +67,11 @@ export async function onboard(options = {}) {
|
|
|
65
67
|
|
|
66
68
|
const ctx = { tenantId: selectedEnv.aadTenantId, envName, companyId };
|
|
67
69
|
const config = buildMcpConfig(ctx);
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
|
|
71
|
+
for (const [name, serverConfig] of Object.entries(config.mcpServers)) {
|
|
72
|
+
await execFile('claude', ['mcp', 'add-json', '-s', scope, name, JSON.stringify(serverConfig)]);
|
|
73
|
+
}
|
|
74
|
+
console.log(`✓ Registered MCP servers (scope: ${scope})`);
|
|
70
75
|
|
|
71
76
|
const name = profileName ?? `${selectedEnv.aadTenantId}/${envName}`;
|
|
72
77
|
await saveProfile(name, ctx);
|