@floriscornel/teams-mcp 0.1.2 → 0.3.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/LICENSE +21 -0
- package/README.md +64 -6
- package/dist/index.js +1 -1
- package/dist/test-utils/setup.d.ts +19 -0
- package/dist/test-utils/setup.d.ts.map +1 -0
- package/dist/test-utils/setup.js +315 -0
- package/dist/test-utils/setup.js.map +1 -0
- package/dist/test-utils/vitest.setup.d.ts +2 -0
- package/dist/test-utils/vitest.setup.d.ts.map +1 -0
- package/dist/test-utils/vitest.setup.js +30 -0
- package/dist/test-utils/vitest.setup.js.map +1 -0
- package/dist/tools/auth.js +1 -1
- package/dist/tools/auth.js.map +1 -1
- package/dist/tools/chats.d.ts.map +1 -1
- package/dist/tools/chats.js +76 -9
- package/dist/tools/chats.js.map +1 -1
- package/dist/tools/teams.d.ts.map +1 -1
- package/dist/tools/teams.js +325 -18
- package/dist/tools/teams.js.map +1 -1
- package/dist/utils/attachments.d.ts +37 -0
- package/dist/utils/attachments.d.ts.map +1 -0
- package/dist/utils/attachments.js +91 -0
- package/dist/utils/attachments.js.map +1 -0
- package/dist/utils/markdown.d.ts +13 -0
- package/dist/utils/markdown.d.ts.map +1 -0
- package/dist/utils/markdown.js +100 -0
- package/dist/utils/markdown.js.map +1 -0
- package/dist/utils/users.d.ts +48 -0
- package/dist/utils/users.d.ts.map +1 -0
- package/dist/utils/users.js +122 -0
- package/dist/utils/users.js.map +1 -0
- package/package.json +38 -13
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Floris Cornel
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Teams MCP
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@floriscornel/teams-mcp)
|
|
4
|
+
[](https://www.npmjs.com/package/@floriscornel/teams-mcp)
|
|
5
|
+
[](https://app.codecov.io/gh/floriscornel/teams-mcp)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://github.com/floriscornel/teams-mcp/stargazers)
|
|
8
|
+
|
|
3
9
|
A Model Context Protocol (MCP) server that provides seamless integration with Microsoft Graph APIs, enabling AI assistants to interact with Microsoft Teams, users, and organizational data.
|
|
4
10
|
|
|
5
11
|
## 📦 Installation
|
|
@@ -60,25 +66,77 @@ To use this MCP server in Cursor/Claude/VS Code, add the following configuration
|
|
|
60
66
|
- Get recent messages with advanced filtering options
|
|
61
67
|
- Find messages mentioning specific users
|
|
62
68
|
|
|
69
|
+
## Rich Message Formatting Support
|
|
70
|
+
|
|
71
|
+
The following tools now support rich message formatting in Teams channels and chats:
|
|
72
|
+
- `send_channel_message`
|
|
73
|
+
- `send_chat_message`
|
|
74
|
+
- `reply_to_channel_message`
|
|
75
|
+
|
|
76
|
+
### Format Options
|
|
77
|
+
|
|
78
|
+
You can specify the `format` parameter to control the message formatting:
|
|
79
|
+
- `text` (default): Plain text
|
|
80
|
+
- `markdown`: Markdown formatting (bold, italic, lists, links, code, etc.) - converted to sanitized HTML
|
|
81
|
+
|
|
82
|
+
When `format` is set to `markdown`, the message content is converted to HTML using a secure markdown parser and sanitized to remove potentially dangerous content before being sent to Teams.
|
|
83
|
+
|
|
84
|
+
If `format` is not specified, the message will be sent as plain text.
|
|
85
|
+
|
|
86
|
+
### Example Usage
|
|
87
|
+
|
|
88
|
+
```json
|
|
89
|
+
{
|
|
90
|
+
"teamId": "...",
|
|
91
|
+
"channelId": "...",
|
|
92
|
+
"message": "**Bold text** and _italic text_\n\n- List item 1\n- List item 2\n\n[Link](https://example.com)",
|
|
93
|
+
"format": "markdown"
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
```json
|
|
98
|
+
{
|
|
99
|
+
"chatId": "...",
|
|
100
|
+
"message": "Simple plain text message",
|
|
101
|
+
"format": "text"
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Security Features
|
|
106
|
+
|
|
107
|
+
- **HTML Sanitization**: All markdown content is converted to HTML and sanitized to remove potentially dangerous elements (scripts, event handlers, etc.)
|
|
108
|
+
- **Allowed Tags**: Only safe HTML tags are permitted (p, strong, em, a, ul, ol, li, h1-h6, code, pre, etc.)
|
|
109
|
+
- **Safe Attributes**: Only safe attributes are allowed (href, target, src, alt, title, width, height)
|
|
110
|
+
- **XSS Prevention**: Content is automatically sanitized to prevent cross-site scripting attacks
|
|
111
|
+
|
|
112
|
+
### Supported Markdown Features
|
|
63
113
|
|
|
114
|
+
- **Text formatting**: Bold (`**text**`), italic (`_text_`), strikethrough (`~~text~~`)
|
|
115
|
+
- **Links**: `[text](url)`
|
|
116
|
+
- **Lists**: Bulleted (`- item`) and numbered (`1. item`)
|
|
117
|
+
- **Code**: Inline `` `code` `` and blocks ``` ```code``` ```
|
|
118
|
+
- **Headings**: `# H1` through `###### H6`
|
|
119
|
+
- **Line breaks**: Automatic conversion of newlines to `<br>` tags
|
|
120
|
+
- **Blockquotes**: `> quoted text`
|
|
121
|
+
- **Tables**: GitHub-flavored markdown tables
|
|
64
122
|
|
|
65
123
|
## 📦 Installation
|
|
66
124
|
|
|
67
125
|
```bash
|
|
68
126
|
# Install dependencies
|
|
69
|
-
|
|
127
|
+
npm install
|
|
70
128
|
|
|
71
129
|
# Build the project
|
|
72
|
-
|
|
130
|
+
npm run build
|
|
73
131
|
|
|
74
132
|
# Set up authentication
|
|
75
|
-
|
|
133
|
+
npm run auth
|
|
76
134
|
```
|
|
77
135
|
|
|
78
136
|
## 🔧 Configuration
|
|
79
137
|
|
|
80
138
|
### Prerequisites
|
|
81
|
-
- Node.js 18+
|
|
139
|
+
- Node.js 18+
|
|
82
140
|
- Microsoft 365 account with appropriate permissions
|
|
83
141
|
- Azure App Registration with Microsoft Graph permissions
|
|
84
142
|
|
|
@@ -101,10 +159,10 @@ bun run auth
|
|
|
101
159
|
### Starting the Server
|
|
102
160
|
```bash
|
|
103
161
|
# Development mode with hot reload
|
|
104
|
-
|
|
162
|
+
npm run dev
|
|
105
163
|
|
|
106
164
|
# Production mode
|
|
107
|
-
|
|
165
|
+
npm run build && node dist/index.js
|
|
108
166
|
```
|
|
109
167
|
|
|
110
168
|
### Available MCP Tools
|
package/dist/index.js
CHANGED
|
@@ -110,7 +110,7 @@ async function startMcpServer() {
|
|
|
110
110
|
// Create MCP server
|
|
111
111
|
const server = new McpServer({
|
|
112
112
|
name: "teams-mcp",
|
|
113
|
-
version: "0.
|
|
113
|
+
version: "0.3.0",
|
|
114
114
|
});
|
|
115
115
|
// Initialize Graph service (singleton)
|
|
116
116
|
const graphService = GraphService.getInstance();
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { Channel, Chat, ChatMessage, ConversationMember, Team, User } from "../types/graph.js";
|
|
2
|
+
export declare const mockUser: User;
|
|
3
|
+
export declare const mockTeam: Team;
|
|
4
|
+
export declare const mockChannel: Channel;
|
|
5
|
+
export declare const mockChat: Chat;
|
|
6
|
+
export declare const mockChatMessage: ChatMessage;
|
|
7
|
+
export declare const mockConversationMember: ConversationMember;
|
|
8
|
+
export declare const graphApiHandlers: import("msw").HttpHandler[];
|
|
9
|
+
export declare const server: import("msw/node").SetupServerApi;
|
|
10
|
+
export declare function createMockGraphService(): any;
|
|
11
|
+
export declare function createMockUnauthenticatedGraphService(): any;
|
|
12
|
+
export declare function createMockMcpServer(): {
|
|
13
|
+
tool: import("vitest").Mock<(...args: any[]) => any>;
|
|
14
|
+
connect: import("vitest").Mock<(...args: any[]) => any>;
|
|
15
|
+
getTool: (name: string) => any;
|
|
16
|
+
getAllTools: () => any[];
|
|
17
|
+
};
|
|
18
|
+
export declare function testMcpTool(toolName: string, parameters: any, mockServer: any, expectedResult?: any): Promise<any>;
|
|
19
|
+
//# sourceMappingURL=setup.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.d.ts","sourceRoot":"","sources":["../../src/test-utils/setup.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,OAAO,EACP,IAAI,EACJ,WAAW,EACX,kBAAkB,EAElB,IAAI,EACJ,IAAI,EACL,MAAM,mBAAmB,CAAC;AAG3B,eAAO,MAAM,QAAQ,EAAE,IAQtB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,IAKtB,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,OAKzB,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,IAItB,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,WAc7B,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,kBAIpC,CAAC;AAGF,eAAO,MAAM,gBAAgB,6BAoN5B,CAAC;AAGF,eAAO,MAAM,MAAM,mCAAmC,CAAC;AAkCvD,wBAAgB,sBAAsB,QAoBrC;AAGD,wBAAgB,qCAAqC,QAWpD;AAGD,wBAAgB,mBAAmB;;;oBAQf,MAAM;;EAGzB;AAGD,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,GAAG,EACf,UAAU,EAAE,GAAG,EACf,cAAc,CAAC,EAAE,GAAG,gBAcrB"}
|
|
@@ -0,0 +1,315 @@
|
|
|
1
|
+
import { http, HttpResponse } from "msw";
|
|
2
|
+
import { setupServer } from "msw/node";
|
|
3
|
+
import { afterEach, beforeEach, expect, vi } from "vitest";
|
|
4
|
+
// Mock data fixtures
|
|
5
|
+
export const mockUser = {
|
|
6
|
+
id: "test-user-id",
|
|
7
|
+
displayName: "Test User",
|
|
8
|
+
userPrincipalName: "test.user@example.com",
|
|
9
|
+
mail: "test.user@example.com",
|
|
10
|
+
jobTitle: "Test Engineer",
|
|
11
|
+
department: "Engineering",
|
|
12
|
+
officeLocation: "Remote",
|
|
13
|
+
};
|
|
14
|
+
export const mockTeam = {
|
|
15
|
+
id: "test-team-id",
|
|
16
|
+
displayName: "Test Team",
|
|
17
|
+
description: "A test team for unit tests",
|
|
18
|
+
isArchived: false,
|
|
19
|
+
};
|
|
20
|
+
export const mockChannel = {
|
|
21
|
+
id: "test-channel-id",
|
|
22
|
+
displayName: "General",
|
|
23
|
+
description: "General discussion channel",
|
|
24
|
+
membershipType: "standard",
|
|
25
|
+
};
|
|
26
|
+
export const mockChat = {
|
|
27
|
+
id: "test-chat-id",
|
|
28
|
+
topic: "Test Chat",
|
|
29
|
+
chatType: "group",
|
|
30
|
+
};
|
|
31
|
+
export const mockChatMessage = {
|
|
32
|
+
id: "test-message-id",
|
|
33
|
+
createdDateTime: "2024-01-01T12:00:00Z",
|
|
34
|
+
body: {
|
|
35
|
+
content: "Test message content",
|
|
36
|
+
contentType: "text",
|
|
37
|
+
},
|
|
38
|
+
from: {
|
|
39
|
+
user: {
|
|
40
|
+
id: "test-user-id",
|
|
41
|
+
displayName: "Test User",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
importance: "normal",
|
|
45
|
+
};
|
|
46
|
+
export const mockConversationMember = {
|
|
47
|
+
id: "test-member-id",
|
|
48
|
+
displayName: "Test Member",
|
|
49
|
+
roles: ["owner"],
|
|
50
|
+
};
|
|
51
|
+
// Microsoft Graph API mock handlers
|
|
52
|
+
export const graphApiHandlers = [
|
|
53
|
+
// User endpoints
|
|
54
|
+
http.get("https://graph.microsoft.com/v1.0/me", () => {
|
|
55
|
+
return HttpResponse.json(mockUser);
|
|
56
|
+
}),
|
|
57
|
+
http.get("https://graph.microsoft.com/v1.0/users", ({ request }) => {
|
|
58
|
+
const url = new URL(request.url);
|
|
59
|
+
const filter = url.searchParams.get("$filter");
|
|
60
|
+
// Simulate search functionality
|
|
61
|
+
const response = {
|
|
62
|
+
value: filter?.includes("test") ? [mockUser] : [],
|
|
63
|
+
};
|
|
64
|
+
return HttpResponse.json(response);
|
|
65
|
+
}),
|
|
66
|
+
http.get("https://graph.microsoft.com/v1.0/users/:userId", ({ params }) => {
|
|
67
|
+
if (params.userId === "test-user-id" || params.userId === "test.user@example.com") {
|
|
68
|
+
return HttpResponse.json(mockUser);
|
|
69
|
+
}
|
|
70
|
+
return new HttpResponse(null, { status: 404 });
|
|
71
|
+
}),
|
|
72
|
+
// Teams endpoints
|
|
73
|
+
http.get("https://graph.microsoft.com/v1.0/me/joinedTeams", () => {
|
|
74
|
+
const response = {
|
|
75
|
+
value: [mockTeam],
|
|
76
|
+
};
|
|
77
|
+
return HttpResponse.json(response);
|
|
78
|
+
}),
|
|
79
|
+
http.get("https://graph.microsoft.com/v1.0/teams/:teamId/channels", ({ params }) => {
|
|
80
|
+
if (params.teamId === "test-team-id") {
|
|
81
|
+
const response = {
|
|
82
|
+
value: [mockChannel],
|
|
83
|
+
};
|
|
84
|
+
return HttpResponse.json(response);
|
|
85
|
+
}
|
|
86
|
+
return new HttpResponse(null, { status: 404 });
|
|
87
|
+
}),
|
|
88
|
+
http.get("https://graph.microsoft.com/v1.0/teams/:teamId/members", ({ params }) => {
|
|
89
|
+
if (params.teamId === "test-team-id") {
|
|
90
|
+
const response = {
|
|
91
|
+
value: [mockConversationMember],
|
|
92
|
+
};
|
|
93
|
+
return HttpResponse.json(response);
|
|
94
|
+
}
|
|
95
|
+
return new HttpResponse(null, { status: 404 });
|
|
96
|
+
}),
|
|
97
|
+
// Channel messages
|
|
98
|
+
http.get("https://graph.microsoft.com/v1.0/teams/:teamId/channels/:channelId/messages", ({ params }) => {
|
|
99
|
+
if (params.teamId === "test-team-id" && params.channelId === "test-channel-id") {
|
|
100
|
+
const response = {
|
|
101
|
+
value: [mockChatMessage],
|
|
102
|
+
};
|
|
103
|
+
return HttpResponse.json(response);
|
|
104
|
+
}
|
|
105
|
+
return new HttpResponse(null, { status: 404 });
|
|
106
|
+
}),
|
|
107
|
+
http.post("https://graph.microsoft.com/v1.0/teams/:teamId/channels/:channelId/messages", async ({ params, request }) => {
|
|
108
|
+
if (params.teamId === "test-team-id" && params.channelId === "test-channel-id") {
|
|
109
|
+
const body = (await request.json());
|
|
110
|
+
const response = {
|
|
111
|
+
...mockChatMessage,
|
|
112
|
+
id: "new-message-id",
|
|
113
|
+
body: body.body,
|
|
114
|
+
createdDateTime: new Date().toISOString(),
|
|
115
|
+
};
|
|
116
|
+
return HttpResponse.json(response);
|
|
117
|
+
}
|
|
118
|
+
return new HttpResponse(null, { status: 404 });
|
|
119
|
+
}),
|
|
120
|
+
// Chats endpoints
|
|
121
|
+
http.get("https://graph.microsoft.com/v1.0/me/chats", () => {
|
|
122
|
+
const response = {
|
|
123
|
+
value: [mockChat],
|
|
124
|
+
};
|
|
125
|
+
return HttpResponse.json(response);
|
|
126
|
+
}),
|
|
127
|
+
http.get("https://graph.microsoft.com/v1.0/me/chats/:chatId/messages", ({ params, request }) => {
|
|
128
|
+
if (params.chatId === "test-chat-id") {
|
|
129
|
+
const url = new URL(request.url);
|
|
130
|
+
const fromUser = url.searchParams.get("$filter")?.includes("from/user/id");
|
|
131
|
+
const response = {
|
|
132
|
+
value: fromUser ? [] : [mockChatMessage],
|
|
133
|
+
};
|
|
134
|
+
return HttpResponse.json(response);
|
|
135
|
+
}
|
|
136
|
+
return new HttpResponse(null, { status: 404 });
|
|
137
|
+
}),
|
|
138
|
+
http.post("https://graph.microsoft.com/v1.0/me/chats/:chatId/messages", async ({ params, request }) => {
|
|
139
|
+
if (params.chatId === "test-chat-id") {
|
|
140
|
+
const body = (await request.json());
|
|
141
|
+
const response = {
|
|
142
|
+
...mockChatMessage,
|
|
143
|
+
id: "new-chat-message-id",
|
|
144
|
+
body: body.body,
|
|
145
|
+
createdDateTime: new Date().toISOString(),
|
|
146
|
+
};
|
|
147
|
+
return HttpResponse.json(response);
|
|
148
|
+
}
|
|
149
|
+
return new HttpResponse(null, { status: 404 });
|
|
150
|
+
}),
|
|
151
|
+
http.post("https://graph.microsoft.com/v1.0/me/chats", async ({ request }) => {
|
|
152
|
+
const body = (await request.json());
|
|
153
|
+
const response = {
|
|
154
|
+
...mockChat,
|
|
155
|
+
id: "new-chat-id",
|
|
156
|
+
topic: body.topic,
|
|
157
|
+
chatType: body.chatType,
|
|
158
|
+
};
|
|
159
|
+
return HttpResponse.json(response);
|
|
160
|
+
}),
|
|
161
|
+
// Search endpoints
|
|
162
|
+
http.post("https://graph.microsoft.com/v1.0/search/query", async ({ request }) => {
|
|
163
|
+
const body = (await request.json());
|
|
164
|
+
const searchRequest = body.requests[0];
|
|
165
|
+
const response = {
|
|
166
|
+
value: [
|
|
167
|
+
{
|
|
168
|
+
searchTerms: [searchRequest.query.queryString],
|
|
169
|
+
hitsContainers: [
|
|
170
|
+
{
|
|
171
|
+
hits: [
|
|
172
|
+
{
|
|
173
|
+
hitId: "search-hit-1",
|
|
174
|
+
rank: 1,
|
|
175
|
+
summary: "Test message found in search",
|
|
176
|
+
resource: {
|
|
177
|
+
"@odata.type": "#microsoft.graph.chatMessage",
|
|
178
|
+
id: "search-message-id",
|
|
179
|
+
createdDateTime: "2024-01-01T12:00:00Z",
|
|
180
|
+
from: {
|
|
181
|
+
user: {
|
|
182
|
+
displayName: "Test User",
|
|
183
|
+
id: "test-user-id",
|
|
184
|
+
},
|
|
185
|
+
},
|
|
186
|
+
body: {
|
|
187
|
+
content: "Test search result message",
|
|
188
|
+
contentType: "text",
|
|
189
|
+
},
|
|
190
|
+
chatId: "test-chat-id",
|
|
191
|
+
},
|
|
192
|
+
},
|
|
193
|
+
],
|
|
194
|
+
total: 1,
|
|
195
|
+
moreResultsAvailable: false,
|
|
196
|
+
},
|
|
197
|
+
],
|
|
198
|
+
},
|
|
199
|
+
],
|
|
200
|
+
};
|
|
201
|
+
return HttpResponse.json(response);
|
|
202
|
+
}),
|
|
203
|
+
// Error scenarios for testing
|
|
204
|
+
http.get("https://graph.microsoft.com/v1.0/error/401", () => {
|
|
205
|
+
return HttpResponse.json({
|
|
206
|
+
error: {
|
|
207
|
+
code: "InvalidAuthenticationToken",
|
|
208
|
+
message: "Access token is empty.",
|
|
209
|
+
},
|
|
210
|
+
}, { status: 401 });
|
|
211
|
+
}),
|
|
212
|
+
http.get("https://graph.microsoft.com/v1.0/error/403", () => {
|
|
213
|
+
return HttpResponse.json({
|
|
214
|
+
error: {
|
|
215
|
+
code: "Forbidden",
|
|
216
|
+
message: "Insufficient privileges to complete the operation.",
|
|
217
|
+
},
|
|
218
|
+
}, { status: 403 });
|
|
219
|
+
}),
|
|
220
|
+
http.get("https://graph.microsoft.com/v1.0/error/429", () => {
|
|
221
|
+
return HttpResponse.json({
|
|
222
|
+
error: {
|
|
223
|
+
code: "TooManyRequests",
|
|
224
|
+
message: "Too many requests",
|
|
225
|
+
},
|
|
226
|
+
}, { status: 429, headers: { "Retry-After": "30" } });
|
|
227
|
+
}),
|
|
228
|
+
];
|
|
229
|
+
// Setup MSW server
|
|
230
|
+
export const server = setupServer(...graphApiHandlers);
|
|
231
|
+
// Global test setup
|
|
232
|
+
beforeEach(() => {
|
|
233
|
+
// Reset all mocks before each test
|
|
234
|
+
vi.clearAllMocks();
|
|
235
|
+
// Mock file system operations for token storage
|
|
236
|
+
vi.mock("node:fs", async () => {
|
|
237
|
+
const actual = (await vi.importActual("node:fs"));
|
|
238
|
+
return {
|
|
239
|
+
...actual,
|
|
240
|
+
promises: {
|
|
241
|
+
...(actual.promises || {}),
|
|
242
|
+
readFile: vi.fn(),
|
|
243
|
+
writeFile: vi.fn(),
|
|
244
|
+
unlink: vi.fn(),
|
|
245
|
+
access: vi.fn(),
|
|
246
|
+
},
|
|
247
|
+
};
|
|
248
|
+
});
|
|
249
|
+
// Mock Azure identity
|
|
250
|
+
vi.mock("@azure/identity", () => ({
|
|
251
|
+
DeviceCodeCredential: vi.fn(),
|
|
252
|
+
}));
|
|
253
|
+
});
|
|
254
|
+
afterEach(() => {
|
|
255
|
+
// Clean up after each test
|
|
256
|
+
vi.resetAllMocks();
|
|
257
|
+
});
|
|
258
|
+
// Helper function to create mock authenticated GraphService
|
|
259
|
+
export function createMockGraphService() {
|
|
260
|
+
const GraphService = vi.fn().mockImplementation(() => ({
|
|
261
|
+
getInstance: vi.fn().mockReturnThis(),
|
|
262
|
+
getAuthStatus: vi.fn().mockResolvedValue({
|
|
263
|
+
isAuthenticated: true,
|
|
264
|
+
userPrincipalName: mockUser.userPrincipalName,
|
|
265
|
+
displayName: mockUser.displayName,
|
|
266
|
+
expiresAt: new Date(Date.now() + 3600000).toISOString(),
|
|
267
|
+
}),
|
|
268
|
+
getClient: vi.fn().mockResolvedValue({
|
|
269
|
+
api: vi.fn().mockReturnValue({
|
|
270
|
+
get: vi.fn(),
|
|
271
|
+
post: vi.fn(),
|
|
272
|
+
filter: vi.fn().mockReturnThis(),
|
|
273
|
+
}),
|
|
274
|
+
}),
|
|
275
|
+
isAuthenticated: vi.fn().mockReturnValue(true),
|
|
276
|
+
}));
|
|
277
|
+
return new GraphService();
|
|
278
|
+
}
|
|
279
|
+
// Helper function to create mock unauthenticated GraphService
|
|
280
|
+
export function createMockUnauthenticatedGraphService() {
|
|
281
|
+
const GraphService = vi.fn().mockImplementation(() => ({
|
|
282
|
+
getInstance: vi.fn().mockReturnThis(),
|
|
283
|
+
getAuthStatus: vi.fn().mockResolvedValue({
|
|
284
|
+
isAuthenticated: false,
|
|
285
|
+
}),
|
|
286
|
+
getClient: vi.fn().mockRejectedValue(new Error("Not authenticated")),
|
|
287
|
+
isAuthenticated: vi.fn().mockReturnValue(false),
|
|
288
|
+
}));
|
|
289
|
+
return new GraphService();
|
|
290
|
+
}
|
|
291
|
+
// Helper function to create mock MCP server
|
|
292
|
+
export function createMockMcpServer() {
|
|
293
|
+
const tools = new Map();
|
|
294
|
+
return {
|
|
295
|
+
tool: vi.fn().mockImplementation((name, schema, handler) => {
|
|
296
|
+
tools.set(name, { schema, handler });
|
|
297
|
+
}),
|
|
298
|
+
connect: vi.fn(),
|
|
299
|
+
getTool: (name) => tools.get(name),
|
|
300
|
+
getAllTools: () => Array.from(tools.keys()),
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
// Helper function to test MCP tool execution
|
|
304
|
+
export async function testMcpTool(toolName, parameters, mockServer, expectedResult) {
|
|
305
|
+
const tool = mockServer.getTool(toolName);
|
|
306
|
+
if (!tool) {
|
|
307
|
+
throw new Error(`Tool ${toolName} not found`);
|
|
308
|
+
}
|
|
309
|
+
const result = await tool.handler(parameters);
|
|
310
|
+
if (expectedResult) {
|
|
311
|
+
expect(result).toEqual(expectedResult);
|
|
312
|
+
}
|
|
313
|
+
return result;
|
|
314
|
+
}
|
|
315
|
+
//# sourceMappingURL=setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup.js","sourceRoot":"","sources":["../../src/test-utils/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,KAAK,CAA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,MAAM,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC;IAE9C,IAAI,cAAc,EAAE,CAAC;QACnB,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,cAAc,CAAC,CAAC;IACzC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vitest.setup.d.ts","sourceRoot":"","sources":["../../src/test-utils/vitest.setup.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { afterAll, afterEach, beforeAll } from "vitest";
|
|
2
|
+
import { server } from "./setup.js";
|
|
3
|
+
// Start MSW server before all tests
|
|
4
|
+
beforeAll(() => {
|
|
5
|
+
server.listen({ onUnhandledRequest: "error" });
|
|
6
|
+
});
|
|
7
|
+
// Reset handlers after each test
|
|
8
|
+
afterEach(() => {
|
|
9
|
+
server.resetHandlers();
|
|
10
|
+
});
|
|
11
|
+
// Clean up after all tests
|
|
12
|
+
afterAll(() => {
|
|
13
|
+
server.close();
|
|
14
|
+
});
|
|
15
|
+
// Global test environment setup
|
|
16
|
+
global.TextEncoder = TextEncoder;
|
|
17
|
+
global.TextDecoder = TextDecoder;
|
|
18
|
+
// Mock console methods to reduce noise in tests
|
|
19
|
+
const originalError = console.error;
|
|
20
|
+
console.error = (...args) => {
|
|
21
|
+
// Suppress specific known warnings/errors during tests
|
|
22
|
+
if (typeof args[0] === "string" &&
|
|
23
|
+
(args[0].includes("MSW") ||
|
|
24
|
+
args[0].includes("Warning") ||
|
|
25
|
+
args[0].includes("Failed to initialize"))) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
originalError.apply(console, args);
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=vitest.setup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vitest.setup.js","sourceRoot":"","sources":["../../src/test-utils/vitest.setup.ts"],"names":[],"mappings":"AAA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ticated as ${status.displayName} (${status.userPrincipalName})`
|
|
10
|
+
? `✅ Authenticated as ${status.displayName || "Unknown User"} (${status.userPrincipalName || "No email available"})`
|
|
11
11
|
: "❌ Not authenticated. Please run: npx @floriscornel/teams-mcp@latest authenticate",
|
|
12
12
|
},
|
|
13
13
|
],
|
package/dist/tools/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/tools/auth.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,iBAAiB,CAAC,MAAiB,EAAE,YAA0B;IAC7E,6BAA6B;IAC7B,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,EAAE,KAAK,IAAI,EAAE;QACxC,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,aAAa,EAAE,CAAC;QAClD,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,MAAM,CAAC,eAAe;wBAC1B,CAAC,CAAC,sBAAsB,MAAM,CAAC,WAAW,KAAK,MAAM,CAAC,iBAAiB,GAAG;
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/tools/auth.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,iBAAiB,CAAC,MAAiB,EAAE,YAA0B;IAC7E,6BAA6B;IAC7B,MAAM,CAAC,IAAI,CAAC,aAAa,EAAE,EAAE,EAAE,KAAK,IAAI,EAAE;QACxC,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,aAAa,EAAE,CAAC;QAClD,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,MAAM,CAAC,eAAe;wBAC1B,CAAC,CAAC,sBAAsB,MAAM,CAAC,WAAW,IAAI,cAAc,KAAK,MAAM,CAAC,iBAAiB,IAAI,oBAAoB,GAAG;wBACpH,CAAC,CAAC,kFAAkF;iBACvF;aACF;SACF,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chats.d.ts","sourceRoot":"","sources":["../../src/tools/chats.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"chats.d.ts","sourceRoot":"","sources":["../../src/tools/chats.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAczD,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,QA4W9E"}
|