@softeria/ms-365-mcp-server 0.11.4 → 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.
- package/.releaserc.json +12 -0
- package/README.md +2 -1
- package/dist/auth-tools.js +181 -173
- package/dist/auth.js +402 -415
- package/dist/cli.js +35 -36
- package/dist/generated/client.js +10355 -13943
- package/dist/generated/endpoint-types.js +0 -1
- package/dist/generated/hack.js +39 -33
- package/dist/graph-client.js +426 -473
- package/dist/graph-tools.js +217 -228
- package/dist/index.js +76 -79
- package/dist/lib/microsoft-auth.js +62 -72
- package/dist/logger.js +36 -27
- package/dist/oauth-provider.js +48 -47
- package/dist/server.js +277 -264
- package/dist/version.js +9 -6
- package/package.json +11 -3
- package/tsup.config.ts +30 -0
- package/bin/release.mjs +0 -69
package/.releaserc.json
ADDED
|
@@ -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
package/dist/auth-tools.js
CHANGED
|
@@ -1,184 +1,192 @@
|
|
|
1
|
-
import { z } from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
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
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
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
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
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
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
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
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
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
|
+
};
|