@sam2kb/m365-mcp 1.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.
@@ -0,0 +1,207 @@
1
+ /**
2
+ * Contacts tools — list, search, read, create, update, delete
3
+ */
4
+ import type { GraphClient } from "../graph.js";
5
+ export declare function registerContactsTools(client: GraphClient): {
6
+ contacts_list(args: {
7
+ top?: number;
8
+ folderId?: string;
9
+ }): Promise<string>;
10
+ contacts_search(args: {
11
+ query: string;
12
+ top?: number;
13
+ }): Promise<string>;
14
+ contacts_read(args: {
15
+ contactId: string;
16
+ }): Promise<string>;
17
+ contacts_create(args: {
18
+ givenName?: string;
19
+ surname?: string;
20
+ email?: string;
21
+ company?: string;
22
+ jobTitle?: string;
23
+ mobilePhone?: string;
24
+ businessPhone?: string;
25
+ notes?: string;
26
+ }): Promise<string>;
27
+ contacts_update(args: {
28
+ contactId: string;
29
+ givenName?: string;
30
+ surname?: string;
31
+ email?: string;
32
+ company?: string;
33
+ jobTitle?: string;
34
+ mobilePhone?: string;
35
+ }): Promise<string>;
36
+ contacts_delete(args: {
37
+ contactId: string;
38
+ }): Promise<string>;
39
+ };
40
+ export declare const contactsToolSchemas: ({
41
+ name: string;
42
+ description: string;
43
+ inputSchema: {
44
+ type: string;
45
+ properties: {
46
+ top: {
47
+ type: string;
48
+ description: string;
49
+ default: number;
50
+ };
51
+ folderId: {
52
+ type: string;
53
+ description: string;
54
+ };
55
+ query?: undefined;
56
+ contactId?: undefined;
57
+ givenName?: undefined;
58
+ surname?: undefined;
59
+ email?: undefined;
60
+ company?: undefined;
61
+ jobTitle?: undefined;
62
+ mobilePhone?: undefined;
63
+ businessPhone?: undefined;
64
+ notes?: undefined;
65
+ };
66
+ required?: undefined;
67
+ };
68
+ } | {
69
+ name: string;
70
+ description: string;
71
+ inputSchema: {
72
+ type: string;
73
+ properties: {
74
+ query: {
75
+ type: string;
76
+ description: string;
77
+ };
78
+ top: {
79
+ type: string;
80
+ description: string;
81
+ default: number;
82
+ };
83
+ folderId?: undefined;
84
+ contactId?: undefined;
85
+ givenName?: undefined;
86
+ surname?: undefined;
87
+ email?: undefined;
88
+ company?: undefined;
89
+ jobTitle?: undefined;
90
+ mobilePhone?: undefined;
91
+ businessPhone?: undefined;
92
+ notes?: undefined;
93
+ };
94
+ required: string[];
95
+ };
96
+ } | {
97
+ name: string;
98
+ description: string;
99
+ inputSchema: {
100
+ type: string;
101
+ properties: {
102
+ contactId: {
103
+ type: string;
104
+ description: string;
105
+ };
106
+ top?: undefined;
107
+ folderId?: undefined;
108
+ query?: undefined;
109
+ givenName?: undefined;
110
+ surname?: undefined;
111
+ email?: undefined;
112
+ company?: undefined;
113
+ jobTitle?: undefined;
114
+ mobilePhone?: undefined;
115
+ businessPhone?: undefined;
116
+ notes?: undefined;
117
+ };
118
+ required: string[];
119
+ };
120
+ } | {
121
+ name: string;
122
+ description: string;
123
+ inputSchema: {
124
+ type: string;
125
+ properties: {
126
+ givenName: {
127
+ type: string;
128
+ description: string;
129
+ };
130
+ surname: {
131
+ type: string;
132
+ description: string;
133
+ };
134
+ email: {
135
+ type: string;
136
+ description: string;
137
+ };
138
+ company: {
139
+ type: string;
140
+ description: string;
141
+ };
142
+ jobTitle: {
143
+ type: string;
144
+ description: string;
145
+ };
146
+ mobilePhone: {
147
+ type: string;
148
+ description: string;
149
+ };
150
+ businessPhone: {
151
+ type: string;
152
+ description: string;
153
+ };
154
+ notes: {
155
+ type: string;
156
+ description: string;
157
+ };
158
+ top?: undefined;
159
+ folderId?: undefined;
160
+ query?: undefined;
161
+ contactId?: undefined;
162
+ };
163
+ required?: undefined;
164
+ };
165
+ } | {
166
+ name: string;
167
+ description: string;
168
+ inputSchema: {
169
+ type: string;
170
+ properties: {
171
+ contactId: {
172
+ type: string;
173
+ description: string;
174
+ };
175
+ givenName: {
176
+ type: string;
177
+ description?: undefined;
178
+ };
179
+ surname: {
180
+ type: string;
181
+ description?: undefined;
182
+ };
183
+ email: {
184
+ type: string;
185
+ description?: undefined;
186
+ };
187
+ company: {
188
+ type: string;
189
+ description?: undefined;
190
+ };
191
+ jobTitle: {
192
+ type: string;
193
+ description?: undefined;
194
+ };
195
+ mobilePhone: {
196
+ type: string;
197
+ description?: undefined;
198
+ };
199
+ top?: undefined;
200
+ folderId?: undefined;
201
+ query?: undefined;
202
+ businessPhone?: undefined;
203
+ notes?: undefined;
204
+ };
205
+ required: string[];
206
+ };
207
+ })[];
@@ -0,0 +1,169 @@
1
+ /**
2
+ * Contacts tools — list, search, read, create, update, delete
3
+ */
4
+ export function registerContactsTools(client) {
5
+ const user = "/me";
6
+ return {
7
+ async contacts_list(args) {
8
+ const top = args.top || 50;
9
+ const folderPath = args.folderId
10
+ ? `/contactFolders/${encodeURIComponent(args.folderId)}`
11
+ : "";
12
+ const path = `${user}${folderPath}/contacts?$top=${top}&$orderby=displayName`;
13
+ const contacts = await client.getAll(path, 10, top);
14
+ return JSON.stringify(contacts.map((c) => ({
15
+ id: c.id,
16
+ name: c.displayName,
17
+ email: c.emailAddresses?.[0]?.address,
18
+ company: c.companyName,
19
+ jobTitle: c.jobTitle,
20
+ phones: c.businessPhones,
21
+ mobile: c.mobilePhone,
22
+ })), null, 2);
23
+ },
24
+ async contacts_search(args) {
25
+ const top = args.top || 20;
26
+ const path = `${user}/contacts?$search="${encodeURIComponent(args.query)}"&$top=${top}`;
27
+ const contacts = await client.getAll(path, 10, top);
28
+ return JSON.stringify(contacts.map((c) => ({
29
+ id: c.id,
30
+ name: c.displayName,
31
+ email: c.emailAddresses?.map((e) => e.address).join(", "),
32
+ company: c.companyName,
33
+ jobTitle: c.jobTitle,
34
+ })), null, 2);
35
+ },
36
+ async contacts_read(args) {
37
+ const contactId = encodeURIComponent(args.contactId);
38
+ const c = await client.get(`${user}/contacts/${contactId}`);
39
+ return JSON.stringify(c, null, 2);
40
+ },
41
+ async contacts_create(args) {
42
+ const contact = {};
43
+ if (args.givenName)
44
+ contact.givenName = args.givenName;
45
+ if (args.surname)
46
+ contact.surname = args.surname;
47
+ if (args.email) {
48
+ contact.emailAddresses = [{ address: args.email, name: `${args.givenName || ""} ${args.surname || ""}`.trim() }];
49
+ }
50
+ if (args.company)
51
+ contact.companyName = args.company;
52
+ if (args.jobTitle)
53
+ contact.jobTitle = args.jobTitle;
54
+ if (args.mobilePhone)
55
+ contact.mobilePhone = args.mobilePhone;
56
+ if (args.businessPhone)
57
+ contact.businessPhones = [args.businessPhone];
58
+ if (args.notes)
59
+ contact.personalNotes = args.notes;
60
+ const data = await client.post(`${user}/contacts`, contact);
61
+ return JSON.stringify({ id: data.id, displayName: data.displayName, success: true }, null, 2);
62
+ },
63
+ async contacts_update(args) {
64
+ const patch = {};
65
+ if (args.givenName)
66
+ patch.givenName = args.givenName;
67
+ if (args.surname)
68
+ patch.surname = args.surname;
69
+ if (args.email)
70
+ patch.emailAddresses = [{ address: args.email }];
71
+ if (args.company)
72
+ patch.companyName = args.company;
73
+ if (args.jobTitle)
74
+ patch.jobTitle = args.jobTitle;
75
+ if (args.mobilePhone)
76
+ patch.mobilePhone = args.mobilePhone;
77
+ const contactId = encodeURIComponent(args.contactId);
78
+ await client.patch(`${user}/contacts/${contactId}`, patch);
79
+ return JSON.stringify({ success: true, contactId: args.contactId });
80
+ },
81
+ async contacts_delete(args) {
82
+ const contactId = encodeURIComponent(args.contactId);
83
+ await client.delete(`${user}/contacts/${contactId}`);
84
+ return JSON.stringify({ success: true });
85
+ },
86
+ };
87
+ }
88
+ export const contactsToolSchemas = [
89
+ {
90
+ name: "m365_contacts_list",
91
+ description: "List your contacts",
92
+ inputSchema: {
93
+ type: "object",
94
+ properties: {
95
+ top: { type: "number", description: "Max results", default: 50 },
96
+ folderId: { type: "string", description: "Contact folder ID (optional)" },
97
+ },
98
+ },
99
+ },
100
+ {
101
+ name: "m365_contacts_search",
102
+ description: "Search your contacts by name, email, or company",
103
+ inputSchema: {
104
+ type: "object",
105
+ properties: {
106
+ query: { type: "string", description: "Search query" },
107
+ top: { type: "number", description: "Max results", default: 20 },
108
+ },
109
+ required: ["query"],
110
+ },
111
+ },
112
+ {
113
+ name: "m365_contacts_read",
114
+ description: "Read a contact's full details",
115
+ inputSchema: {
116
+ type: "object",
117
+ properties: {
118
+ contactId: { type: "string", description: "Contact ID" },
119
+ },
120
+ required: ["contactId"],
121
+ },
122
+ },
123
+ {
124
+ name: "m365_contacts_create",
125
+ description: "Create a new contact",
126
+ inputSchema: {
127
+ type: "object",
128
+ properties: {
129
+ givenName: { type: "string", description: "First name" },
130
+ surname: { type: "string", description: "Last name" },
131
+ email: { type: "string", description: "Email address" },
132
+ company: { type: "string", description: "Company name" },
133
+ jobTitle: { type: "string", description: "Job title" },
134
+ mobilePhone: { type: "string", description: "Mobile phone" },
135
+ businessPhone: { type: "string", description: "Business phone" },
136
+ notes: { type: "string", description: "Personal notes" },
137
+ },
138
+ },
139
+ },
140
+ {
141
+ name: "m365_contacts_update",
142
+ description: "Update an existing contact",
143
+ inputSchema: {
144
+ type: "object",
145
+ properties: {
146
+ contactId: { type: "string", description: "Contact ID" },
147
+ givenName: { type: "string" },
148
+ surname: { type: "string" },
149
+ email: { type: "string" },
150
+ company: { type: "string" },
151
+ jobTitle: { type: "string" },
152
+ mobilePhone: { type: "string" },
153
+ },
154
+ required: ["contactId"],
155
+ },
156
+ },
157
+ {
158
+ name: "m365_contacts_delete",
159
+ description: "Delete a contact",
160
+ inputSchema: {
161
+ type: "object",
162
+ properties: {
163
+ contactId: { type: "string", description: "Contact ID" },
164
+ },
165
+ required: ["contactId"],
166
+ },
167
+ },
168
+ ];
169
+ //# sourceMappingURL=contacts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contacts.js","sourceRoot":"","sources":["../../src/tools/contacts.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,MAAM,UAAU,qBAAqB,CAAC,MAAmB;IACvD,MAAM,IAAI,GAAG,KAAK,CAAC;IAEnB,OAAO;QACL,KAAK,CAAC,aAAa,CAAC,IAAyC;Y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,EAAE,WAAW,EAAE,YAAY,EAAE;gBACxD,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAC7B,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAC3B,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBACzB,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAC3B,QAAQ,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;gBAC5B,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;aAChC;YACD,QAAQ,EAAE,CAAC,WAAW,CAAC;SACxB;KACF;IACD;QACE,IAAI,EAAE,sBAAsB;QAC5B,WAAW,EAAE,kBAAkB;QAC/B,WAAW,EAAE;YACX,IAAI,EAAE,QAAQ;YACd,UAAU,EAAE;gBACV,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,YAAY,EAAE;aACzD;YACD,QAAQ,EAAE,CAAC,WAAW,CAAC;SACxB;KACF;CACF,CAAC"}
@@ -0,0 +1,135 @@
1
+ /**
2
+ * OneDrive files tools — list, search, read, info, create folder
3
+ */
4
+ import type { GraphClient } from "../graph.js";
5
+ export declare function registerFilesTools(client: GraphClient): {
6
+ files_list(args: {
7
+ path?: string;
8
+ top?: number;
9
+ }): Promise<string>;
10
+ files_search(args: {
11
+ query: string;
12
+ top?: number;
13
+ }): Promise<string>;
14
+ files_read(args: {
15
+ itemId: string;
16
+ maxBytes?: number;
17
+ }): Promise<string>;
18
+ files_info(args: {
19
+ itemId: string;
20
+ }): Promise<string>;
21
+ files_create_folder(args: {
22
+ name: string;
23
+ parentPath?: string;
24
+ }): Promise<string>;
25
+ };
26
+ export declare const filesToolSchemas: ({
27
+ name: string;
28
+ description: string;
29
+ inputSchema: {
30
+ type: string;
31
+ properties: {
32
+ path: {
33
+ type: string;
34
+ description: string;
35
+ };
36
+ top: {
37
+ type: string;
38
+ description: string;
39
+ default: number;
40
+ };
41
+ query?: undefined;
42
+ itemId?: undefined;
43
+ maxBytes?: undefined;
44
+ name?: undefined;
45
+ parentPath?: undefined;
46
+ };
47
+ required?: undefined;
48
+ };
49
+ } | {
50
+ name: string;
51
+ description: string;
52
+ inputSchema: {
53
+ type: string;
54
+ properties: {
55
+ query: {
56
+ type: string;
57
+ description: string;
58
+ };
59
+ top: {
60
+ type: string;
61
+ description: string;
62
+ default: number;
63
+ };
64
+ path?: undefined;
65
+ itemId?: undefined;
66
+ maxBytes?: undefined;
67
+ name?: undefined;
68
+ parentPath?: undefined;
69
+ };
70
+ required: string[];
71
+ };
72
+ } | {
73
+ name: string;
74
+ description: string;
75
+ inputSchema: {
76
+ type: string;
77
+ properties: {
78
+ itemId: {
79
+ type: string;
80
+ description: string;
81
+ };
82
+ maxBytes: {
83
+ type: string;
84
+ description: string;
85
+ };
86
+ path?: undefined;
87
+ top?: undefined;
88
+ query?: undefined;
89
+ name?: undefined;
90
+ parentPath?: undefined;
91
+ };
92
+ required: string[];
93
+ };
94
+ } | {
95
+ name: string;
96
+ description: string;
97
+ inputSchema: {
98
+ type: string;
99
+ properties: {
100
+ itemId: {
101
+ type: string;
102
+ description: string;
103
+ };
104
+ path?: undefined;
105
+ top?: undefined;
106
+ query?: undefined;
107
+ maxBytes?: undefined;
108
+ name?: undefined;
109
+ parentPath?: undefined;
110
+ };
111
+ required: string[];
112
+ };
113
+ } | {
114
+ name: string;
115
+ description: string;
116
+ inputSchema: {
117
+ type: string;
118
+ properties: {
119
+ name: {
120
+ type: string;
121
+ description: string;
122
+ };
123
+ parentPath: {
124
+ type: string;
125
+ description: string;
126
+ };
127
+ path?: undefined;
128
+ top?: undefined;
129
+ query?: undefined;
130
+ itemId?: undefined;
131
+ maxBytes?: undefined;
132
+ };
133
+ required: string[];
134
+ };
135
+ })[];
@@ -0,0 +1,127 @@
1
+ /**
2
+ * OneDrive files tools — list, search, read, info, create folder
3
+ */
4
+ function encodeDrivePath(value) {
5
+ return value.split("/").filter(Boolean).map(encodeURIComponent).join("/");
6
+ }
7
+ export function registerFilesTools(client) {
8
+ const user = "/me";
9
+ return {
10
+ async files_list(args) {
11
+ const top = args.top || 50;
12
+ const folderPath = args.path ? `:/${encodeDrivePath(args.path)}:` : "";
13
+ const path = `${user}/drive/root${folderPath}/children?$top=${top}&$select=id,name,size,folder,file,webUrl,lastModifiedDateTime`;
14
+ const items = await client.getAll(path, 10, top);
15
+ return JSON.stringify(items.map((f) => ({
16
+ id: f.id,
17
+ name: f.name,
18
+ size: f.size,
19
+ isFolder: !!f.folder,
20
+ childCount: f.folder?.childCount,
21
+ mimeType: f.file?.mimeType,
22
+ modified: f.lastModifiedDateTime,
23
+ webUrl: f.webUrl,
24
+ })), null, 2);
25
+ },
26
+ async files_search(args) {
27
+ const top = args.top || 20;
28
+ const query = encodeURIComponent(args.query.replace(/'/g, "''")).replace(/'/g, "%27");
29
+ const path = `${user}/drive/root/search(q='${query}')?$top=${top}&$select=id,name,size,file,webUrl,parentReference`;
30
+ const items = await client.getAll(path, 10, top);
31
+ return JSON.stringify(items.map((f) => ({
32
+ id: f.id,
33
+ name: f.name,
34
+ size: f.size,
35
+ path: f.parentReference?.path,
36
+ webUrl: f.webUrl,
37
+ })), null, 2);
38
+ },
39
+ async files_read(args) {
40
+ // Get item metadata first to find download URL
41
+ const itemId = encodeURIComponent(args.itemId);
42
+ const meta = await client.get(`${user}/drive/items/${itemId}`);
43
+ const downloadUrl = meta["@microsoft.graph.downloadUrl"];
44
+ if (!downloadUrl) {
45
+ // For folders or items without direct download, return metadata
46
+ return JSON.stringify(meta, null, 2);
47
+ }
48
+ const content = await client.download(downloadUrl, args.maxBytes ?? 50_000);
49
+ return content;
50
+ },
51
+ async files_info(args) {
52
+ const itemId = encodeURIComponent(args.itemId);
53
+ const data = await client.get(`${user}/drive/items/${itemId}?$select=id,name,size,folder,file,webUrl,lastModifiedDateTime,createdDateTime,parentReference`);
54
+ return JSON.stringify(data, null, 2);
55
+ },
56
+ async files_create_folder(args) {
57
+ const parentPath = args.parentPath ? `:/${encodeDrivePath(args.parentPath)}:` : "";
58
+ const path = `${user}/drive/root${parentPath}/children`;
59
+ const data = await client.post(path, {
60
+ name: args.name,
61
+ folder: {},
62
+ });
63
+ return JSON.stringify({ id: data.id, name: data.name, webUrl: data.webUrl, success: true }, null, 2);
64
+ },
65
+ };
66
+ }
67
+ export const filesToolSchemas = [
68
+ {
69
+ name: "m365_files_list",
70
+ description: "List files and folders in your OneDrive",
71
+ inputSchema: {
72
+ type: "object",
73
+ properties: {
74
+ path: { type: "string", description: "Folder path (e.g. Documents/Work)" },
75
+ top: { type: "number", description: "Max results", default: 50 },
76
+ },
77
+ },
78
+ },
79
+ {
80
+ name: "m365_files_search",
81
+ description: "Search for files in your OneDrive",
82
+ inputSchema: {
83
+ type: "object",
84
+ properties: {
85
+ query: { type: "string", description: "Search query" },
86
+ top: { type: "number", description: "Max results", default: 20 },
87
+ },
88
+ required: ["query"],
89
+ },
90
+ },
91
+ {
92
+ name: "m365_files_read",
93
+ description: "Read a file's content (text files only, max 50KB by default)",
94
+ inputSchema: {
95
+ type: "object",
96
+ properties: {
97
+ itemId: { type: "string", description: "File item ID from list/search" },
98
+ maxBytes: { type: "number", description: "Max bytes to read (default 50000)" },
99
+ },
100
+ required: ["itemId"],
101
+ },
102
+ },
103
+ {
104
+ name: "m365_files_info",
105
+ description: "Get file or folder metadata",
106
+ inputSchema: {
107
+ type: "object",
108
+ properties: {
109
+ itemId: { type: "string", description: "Item ID" },
110
+ },
111
+ required: ["itemId"],
112
+ },
113
+ },
114
+ {
115
+ name: "m365_files_create_folder",
116
+ description: "Create a new folder in OneDrive",
117
+ inputSchema: {
118
+ type: "object",
119
+ properties: {
120
+ name: { type: "string", description: "Folder name" },
121
+ parentPath: { type: "string", description: "Parent folder path (default: root)" },
122
+ },
123
+ required: ["name"],
124
+ },
125
+ },
126
+ ];
127
+ //# sourceMappingURL=files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"files.js","sourceR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