@softeria/ms-365-mcp-server 0.11.3 → 0.11.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.
@@ -0,0 +1,12 @@
1
+ {
2
+ "branches": ["main"],
3
+ "plugins": [
4
+ "@semantic-release/commit-analyzer",
5
+ "@semantic-release/release-notes-generator",
6
+ ["@semantic-release/exec", {
7
+ "prepareCmd": "npm run build"
8
+ }],
9
+ "@semantic-release/npm",
10
+ "@semantic-release/github"
11
+ ]
12
+ }
package/README.md CHANGED
@@ -9,7 +9,8 @@ API.
9
9
 
10
10
  ## Prerequisites
11
11
 
12
- - Node.js >= 14
12
+ - Node.js >= 20 (recommended)
13
+ - Node.js 14+ may work with dependency warnings
13
14
 
14
15
  ## Features
15
16
 
@@ -1,184 +1,192 @@
1
- import { z } from 'zod';
2
- export function registerAuthTools(server, authManager) {
3
- server.tool('login', {
4
- force: z.boolean().default(false).describe('Force a new login even if already logged in'),
5
- }, async ({ force }) => {
6
- try {
7
- if (!force) {
8
- const loginStatus = await authManager.testLogin();
9
- if (loginStatus.success) {
10
- return {
11
- content: [
12
- {
13
- type: 'text',
14
- text: JSON.stringify({
15
- status: 'Already logged in',
16
- ...loginStatus,
17
- }),
18
- },
19
- ],
20
- };
21
- }
22
- }
23
- const text = await new Promise((r) => {
24
- authManager.acquireTokenByDeviceCode(r);
25
- });
26
- return {
27
- content: [
28
- {
29
- type: 'text',
30
- text,
31
- },
32
- ],
33
- };
34
- }
35
- catch (error) {
36
- return {
37
- content: [
38
- {
39
- type: 'text',
40
- text: JSON.stringify({ error: `Authentication failed: ${error.message}` }),
41
- },
42
- ],
43
- };
44
- }
45
- });
46
- server.tool('logout', {}, async () => {
47
- try {
48
- await authManager.logout();
49
- return {
50
- content: [
51
- {
52
- type: 'text',
53
- text: JSON.stringify({ message: 'Logged out successfully' }),
54
- },
55
- ],
56
- };
57
- }
58
- catch (error) {
1
+ import { z } from "zod";
2
+ function registerAuthTools(server, authManager) {
3
+ server.tool(
4
+ "login",
5
+ {
6
+ force: z.boolean().default(false).describe("Force a new login even if already logged in")
7
+ },
8
+ async ({ force }) => {
9
+ try {
10
+ if (!force) {
11
+ const loginStatus = await authManager.testLogin();
12
+ if (loginStatus.success) {
59
13
  return {
60
- content: [
61
- {
62
- type: 'text',
63
- text: JSON.stringify({ error: 'Logout failed' }),
64
- },
65
- ],
66
- };
67
- }
68
- });
69
- server.tool('verify-login', async () => {
70
- const testResult = await authManager.testLogin();
71
- return {
72
- content: [
14
+ content: [
73
15
  {
74
- type: 'text',
75
- text: JSON.stringify(testResult),
76
- },
77
- ],
78
- };
79
- });
80
- server.tool('list-accounts', {}, async () => {
81
- try {
82
- const accounts = await authManager.listAccounts();
83
- const selectedAccountId = authManager.getSelectedAccountId();
84
- const result = accounts.map(account => ({
85
- id: account.homeAccountId,
86
- username: account.username,
87
- name: account.name,
88
- selected: account.homeAccountId === selectedAccountId
89
- }));
90
- return {
91
- content: [
92
- {
93
- type: 'text',
94
- text: JSON.stringify({ accounts: result }),
95
- },
96
- ],
97
- };
98
- }
99
- catch (error) {
100
- return {
101
- content: [
102
- {
103
- type: 'text',
104
- text: JSON.stringify({ error: `Failed to list accounts: ${error.message}` }),
105
- },
106
- ],
16
+ type: "text",
17
+ text: JSON.stringify({
18
+ status: "Already logged in",
19
+ ...loginStatus
20
+ })
21
+ }
22
+ ]
107
23
  };
24
+ }
108
25
  }
109
- });
110
- server.tool('select-account', {
111
- accountId: z.string().describe('The account ID to select'),
112
- }, async ({ accountId }) => {
113
- try {
114
- const success = await authManager.selectAccount(accountId);
115
- if (success) {
116
- return {
117
- content: [
118
- {
119
- type: 'text',
120
- text: JSON.stringify({ message: `Selected account: ${accountId}` }),
121
- },
122
- ],
123
- };
26
+ const text = await new Promise((r) => {
27
+ authManager.acquireTokenByDeviceCode(r);
28
+ });
29
+ return {
30
+ content: [
31
+ {
32
+ type: "text",
33
+ text
124
34
  }
125
- else {
126
- return {
127
- content: [
128
- {
129
- type: 'text',
130
- text: JSON.stringify({ error: `Account not found: ${accountId}` }),
131
- },
132
- ],
133
- };
35
+ ]
36
+ };
37
+ } catch (error) {
38
+ return {
39
+ content: [
40
+ {
41
+ type: "text",
42
+ text: JSON.stringify({ error: `Authentication failed: ${error.message}` })
134
43
  }
44
+ ]
45
+ };
46
+ }
47
+ }
48
+ );
49
+ server.tool("logout", {}, async () => {
50
+ try {
51
+ await authManager.logout();
52
+ return {
53
+ content: [
54
+ {
55
+ type: "text",
56
+ text: JSON.stringify({ message: "Logged out successfully" })
57
+ }
58
+ ]
59
+ };
60
+ } catch (error) {
61
+ return {
62
+ content: [
63
+ {
64
+ type: "text",
65
+ text: JSON.stringify({ error: "Logout failed" })
66
+ }
67
+ ]
68
+ };
69
+ }
70
+ });
71
+ server.tool("verify-login", async () => {
72
+ const testResult = await authManager.testLogin();
73
+ return {
74
+ content: [
75
+ {
76
+ type: "text",
77
+ text: JSON.stringify(testResult)
135
78
  }
136
- catch (error) {
137
- return {
138
- content: [
139
- {
140
- type: 'text',
141
- text: JSON.stringify({ error: `Failed to select account: ${error.message}` }),
142
- },
143
- ],
144
- };
79
+ ]
80
+ };
81
+ });
82
+ server.tool("list-accounts", {}, async () => {
83
+ try {
84
+ const accounts = await authManager.listAccounts();
85
+ const selectedAccountId = authManager.getSelectedAccountId();
86
+ const result = accounts.map((account) => ({
87
+ id: account.homeAccountId,
88
+ username: account.username,
89
+ name: account.name,
90
+ selected: account.homeAccountId === selectedAccountId
91
+ }));
92
+ return {
93
+ content: [
94
+ {
95
+ type: "text",
96
+ text: JSON.stringify({ accounts: result })
97
+ }
98
+ ]
99
+ };
100
+ } catch (error) {
101
+ return {
102
+ content: [
103
+ {
104
+ type: "text",
105
+ text: JSON.stringify({ error: `Failed to list accounts: ${error.message}` })
106
+ }
107
+ ]
108
+ };
109
+ }
110
+ });
111
+ server.tool(
112
+ "select-account",
113
+ {
114
+ accountId: z.string().describe("The account ID to select")
115
+ },
116
+ async ({ accountId }) => {
117
+ try {
118
+ const success = await authManager.selectAccount(accountId);
119
+ if (success) {
120
+ return {
121
+ content: [
122
+ {
123
+ type: "text",
124
+ text: JSON.stringify({ message: `Selected account: ${accountId}` })
125
+ }
126
+ ]
127
+ };
128
+ } else {
129
+ return {
130
+ content: [
131
+ {
132
+ type: "text",
133
+ text: JSON.stringify({ error: `Account not found: ${accountId}` })
134
+ }
135
+ ]
136
+ };
145
137
  }
146
- });
147
- server.tool('remove-account', {
148
- accountId: z.string().describe('The account ID to remove'),
149
- }, async ({ accountId }) => {
150
- try {
151
- const success = await authManager.removeAccount(accountId);
152
- if (success) {
153
- return {
154
- content: [
155
- {
156
- type: 'text',
157
- text: JSON.stringify({ message: `Removed account: ${accountId}` }),
158
- },
159
- ],
160
- };
161
- }
162
- else {
163
- return {
164
- content: [
165
- {
166
- type: 'text',
167
- text: JSON.stringify({ error: `Account not found: ${accountId}` }),
168
- },
169
- ],
170
- };
138
+ } catch (error) {
139
+ return {
140
+ content: [
141
+ {
142
+ type: "text",
143
+ text: JSON.stringify({ error: `Failed to select account: ${error.message}` })
171
144
  }
145
+ ]
146
+ };
147
+ }
148
+ }
149
+ );
150
+ server.tool(
151
+ "remove-account",
152
+ {
153
+ accountId: z.string().describe("The account ID to remove")
154
+ },
155
+ async ({ accountId }) => {
156
+ try {
157
+ const success = await authManager.removeAccount(accountId);
158
+ if (success) {
159
+ return {
160
+ content: [
161
+ {
162
+ type: "text",
163
+ text: JSON.stringify({ message: `Removed account: ${accountId}` })
164
+ }
165
+ ]
166
+ };
167
+ } else {
168
+ return {
169
+ content: [
170
+ {
171
+ type: "text",
172
+ text: JSON.stringify({ error: `Account not found: ${accountId}` })
173
+ }
174
+ ]
175
+ };
172
176
  }
173
- catch (error) {
174
- return {
175
- content: [
176
- {
177
- type: 'text',
178
- text: JSON.stringify({ error: `Failed to remove account: ${error.message}` }),
179
- },
180
- ],
181
- };
182
- }
183
- });
177
+ } catch (error) {
178
+ return {
179
+ content: [
180
+ {
181
+ type: "text",
182
+ text: JSON.stringify({ error: `Failed to remove account: ${error.message}` })
183
+ }
184
+ ]
185
+ };
186
+ }
187
+ }
188
+ );
184
189
  }
190
+ export {
191
+ registerAuthTools
192
+ };