ms365-mcp-server 1.1.19 → 1.1.20
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,62 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import os from 'os';
|
|
4
|
+
/**
|
|
5
|
+
* Get configuration directory with simple fallback logic
|
|
6
|
+
* 1. First try: os.homedir()/.ms365-mcp
|
|
7
|
+
* 2. Fallback: /home/siya/.ms365-mcp
|
|
8
|
+
*/
|
|
9
|
+
export function getConfigDir() {
|
|
10
|
+
const primaryPath = path.join(os.homedir(), '.ms365-mcp');
|
|
11
|
+
const fallbackPath = '/home/siya/.ms365-mcp';
|
|
12
|
+
// Check if primary path exists or can be created
|
|
13
|
+
try {
|
|
14
|
+
if (fs.existsSync(primaryPath)) {
|
|
15
|
+
return primaryPath;
|
|
16
|
+
}
|
|
17
|
+
// Try to create primary path
|
|
18
|
+
fs.mkdirSync(primaryPath, { recursive: true });
|
|
19
|
+
return primaryPath;
|
|
20
|
+
}
|
|
21
|
+
catch (error) {
|
|
22
|
+
// If primary path fails, use fallback
|
|
23
|
+
try {
|
|
24
|
+
if (!fs.existsSync(fallbackPath)) {
|
|
25
|
+
fs.mkdirSync(fallbackPath, { recursive: true });
|
|
26
|
+
}
|
|
27
|
+
return fallbackPath;
|
|
28
|
+
}
|
|
29
|
+
catch (fallbackError) {
|
|
30
|
+
// If everything fails, return primary path anyway
|
|
31
|
+
return primaryPath;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Check if config files exist in a directory
|
|
37
|
+
*/
|
|
38
|
+
export function hasConfigFiles(dirPath) {
|
|
39
|
+
const credentialsFile = path.join(dirPath, 'credentials.json');
|
|
40
|
+
const tokenFile = path.join(dirPath, 'token.json');
|
|
41
|
+
const msalCacheFile = path.join(dirPath, 'msal-cache.json');
|
|
42
|
+
return fs.existsSync(credentialsFile) ||
|
|
43
|
+
fs.existsSync(tokenFile) ||
|
|
44
|
+
fs.existsSync(msalCacheFile);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Get configuration directory, checking fallback if no config files found in primary
|
|
48
|
+
*/
|
|
49
|
+
export function getConfigDirWithFallback() {
|
|
50
|
+
const primaryPath = path.join(os.homedir(), '.ms365-mcp');
|
|
51
|
+
const fallbackPath = '/home/siya/.ms365-mcp';
|
|
52
|
+
// If primary path has config files, use it
|
|
53
|
+
if (fs.existsSync(primaryPath) && hasConfigFiles(primaryPath)) {
|
|
54
|
+
return primaryPath;
|
|
55
|
+
}
|
|
56
|
+
// If fallback path has config files, use it
|
|
57
|
+
if (fs.existsSync(fallbackPath) && hasConfigFiles(fallbackPath)) {
|
|
58
|
+
return fallbackPath;
|
|
59
|
+
}
|
|
60
|
+
// Default to primary path for new installations
|
|
61
|
+
return getConfigDir();
|
|
62
|
+
}
|
|
@@ -2,12 +2,12 @@ import { ConfidentialClientApplication, PublicClientApplication } from '@azure/m
|
|
|
2
2
|
import { Client } from '@microsoft/microsoft-graph-client';
|
|
3
3
|
import * as fs from 'fs';
|
|
4
4
|
import * as path from 'path';
|
|
5
|
-
import * as os from 'os';
|
|
6
5
|
import open from 'open';
|
|
7
6
|
import { createServer } from 'http';
|
|
8
7
|
import { URL } from 'url';
|
|
9
8
|
import { logger } from './api.js';
|
|
10
9
|
import { credentialStore } from './credential-store.js';
|
|
10
|
+
import { getConfigDirWithFallback } from './config-dir.js';
|
|
11
11
|
// Scopes required for Microsoft 365 operations
|
|
12
12
|
const SCOPES = [
|
|
13
13
|
'https://graph.microsoft.com/Mail.ReadWrite',
|
|
@@ -21,7 +21,7 @@ const SCOPES = [
|
|
|
21
21
|
const BUILTIN_CLIENT_ID = "14d82eec-204b-4c2f-b7e8-296a70dab67e"; // Microsoft Graph Command Line Tools
|
|
22
22
|
const DEFAULT_TENANT_ID = "common";
|
|
23
23
|
// Configuration directory and file paths
|
|
24
|
-
const CONFIG_DIR =
|
|
24
|
+
const CONFIG_DIR = getConfigDirWithFallback();
|
|
25
25
|
const CREDENTIALS_FILE = path.join(CONFIG_DIR, 'credentials.json');
|
|
26
26
|
const DEVICE_CODE_FILE = path.join(CONFIG_DIR, 'device-code.json');
|
|
27
27
|
const TOKEN_CACHE_FILE = path.join(CONFIG_DIR, 'msal-cache.json');
|
package/dist/utils/ms365-auth.js
CHANGED
|
@@ -2,11 +2,11 @@ import { ConfidentialClientApplication } from '@azure/msal-node';
|
|
|
2
2
|
import { Client } from '@microsoft/microsoft-graph-client';
|
|
3
3
|
import * as fs from 'fs';
|
|
4
4
|
import * as path from 'path';
|
|
5
|
-
import * as os from 'os';
|
|
6
5
|
import open from 'open';
|
|
7
6
|
import { createServer } from 'http';
|
|
8
7
|
import { URL } from 'url';
|
|
9
8
|
import { logger } from './api.js';
|
|
9
|
+
import { getConfigDirWithFallback } from './config-dir.js';
|
|
10
10
|
// Scopes required for Microsoft 365 operations
|
|
11
11
|
const SCOPES = [
|
|
12
12
|
'https://graph.microsoft.com/Mail.ReadWrite',
|
|
@@ -17,7 +17,7 @@ const SCOPES = [
|
|
|
17
17
|
'offline_access'
|
|
18
18
|
];
|
|
19
19
|
// Configuration directory and file paths
|
|
20
|
-
const CONFIG_DIR =
|
|
20
|
+
const CONFIG_DIR = getConfigDirWithFallback();
|
|
21
21
|
const CREDENTIALS_FILE = path.join(CONFIG_DIR, 'credentials.json');
|
|
22
22
|
const TOKEN_FILE = path.join(CONFIG_DIR, 'token.json');
|
|
23
23
|
/**
|
|
@@ -2,11 +2,11 @@ import { ConfidentialClientApplication } from '@azure/msal-node';
|
|
|
2
2
|
import { Client } from '@microsoft/microsoft-graph-client';
|
|
3
3
|
import * as fs from 'fs';
|
|
4
4
|
import * as path from 'path';
|
|
5
|
-
import * as os from 'os';
|
|
6
5
|
import { createServer } from 'http';
|
|
7
6
|
import { URL } from 'url';
|
|
8
7
|
import { logger } from './api.js';
|
|
9
8
|
import { createHash, randomBytes } from 'crypto';
|
|
9
|
+
import { getConfigDirWithFallback } from './config-dir.js';
|
|
10
10
|
// Scopes required for Microsoft 365 operations
|
|
11
11
|
const SCOPES = [
|
|
12
12
|
'https://graph.microsoft.com/Mail.ReadWrite',
|
|
@@ -17,7 +17,7 @@ const SCOPES = [
|
|
|
17
17
|
'offline_access'
|
|
18
18
|
];
|
|
19
19
|
// Configuration directory
|
|
20
|
-
const CONFIG_DIR =
|
|
20
|
+
const CONFIG_DIR = getConfigDirWithFallback();
|
|
21
21
|
/**
|
|
22
22
|
* Multi-user Microsoft 365 authentication manager
|
|
23
23
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ms365-mcp-server",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.20",
|
|
4
4
|
"description": "Microsoft 365 MCP Server for managing Microsoft 365 email through natural language interactions with full OAuth2 authentication support",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|