@softeria/ms-365-mcp-server 0.193.0 → 0.193.1
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.
|
@@ -2,7 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import path from 'path';
|
|
4
4
|
import { fileURLToPath } from 'url';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
downloadGraphOpenAPI,
|
|
7
|
+
GRAPH_METADATA_REVISION,
|
|
8
|
+
GRAPH_OPENAPI,
|
|
9
|
+
} from './modules/download-openapi.mjs';
|
|
6
10
|
import { generateMcpTools } from './modules/generate-mcp-tools.mjs';
|
|
7
11
|
import { createAndSaveSimplifiedOpenAPI } from './modules/simplified-openapi.mjs';
|
|
8
12
|
|
|
@@ -10,6 +14,8 @@ const __filename = fileURLToPath(import.meta.url);
|
|
|
10
14
|
const __dirname = path.dirname(__filename);
|
|
11
15
|
const rootDir = path.resolve(__dirname, '..');
|
|
12
16
|
const openapiDir = path.join(rootDir, 'openapi');
|
|
17
|
+
// Raw specs from older revisions (including the original unpinned cache) are never used.
|
|
18
|
+
const specCacheDir = path.join(openapiDir, GRAPH_METADATA_REVISION);
|
|
13
19
|
const srcDir = path.join(rootDir, 'src');
|
|
14
20
|
|
|
15
21
|
const endpointsFile = path.join(srcDir, 'endpoints.json');
|
|
@@ -21,15 +27,13 @@ const generatedDir = path.join(srcDir, 'generated');
|
|
|
21
27
|
const targets = [
|
|
22
28
|
{
|
|
23
29
|
version: 'v1.0',
|
|
24
|
-
|
|
25
|
-
specFile: path.join(openapiDir, 'openapi.yaml'),
|
|
30
|
+
specFile: path.join(specCacheDir, 'openapi.yaml'),
|
|
26
31
|
trimmedFile: path.join(openapiDir, 'openapi-trimmed.yaml'),
|
|
27
32
|
clientFile: path.join(generatedDir, 'client.ts'),
|
|
28
33
|
},
|
|
29
34
|
{
|
|
30
35
|
version: 'beta',
|
|
31
|
-
|
|
32
|
-
specFile: path.join(openapiDir, 'openapi-beta.yaml'),
|
|
36
|
+
specFile: path.join(specCacheDir, 'openapi-beta.yaml'),
|
|
33
37
|
trimmedFile: path.join(openapiDir, 'openapi-trimmed-beta.yaml'),
|
|
34
38
|
clientFile: path.join(generatedDir, 'client-beta.ts'),
|
|
35
39
|
},
|
|
@@ -48,12 +52,11 @@ async function main() {
|
|
|
48
52
|
|
|
49
53
|
console.log(`📥 Step 1: Downloading ${target.version} OpenAPI specification`);
|
|
50
54
|
const downloaded = await downloadGraphOpenAPI(
|
|
51
|
-
openapiDir,
|
|
52
55
|
target.specFile,
|
|
53
|
-
target.
|
|
56
|
+
GRAPH_OPENAPI[target.version],
|
|
54
57
|
forceDownload
|
|
55
58
|
);
|
|
56
|
-
console.log(downloaded ? '✅ Downloaded' : '⏭️
|
|
59
|
+
console.log(downloaded ? '✅ Downloaded' : '⏭️ Using verified cached specification');
|
|
57
60
|
|
|
58
61
|
console.log('🔧 Step 2: Creating simplified OpenAPI specification');
|
|
59
62
|
createAndSaveSimplifiedOpenAPI(
|
|
@@ -1,45 +1,43 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
2
|
+
import path from 'path';
|
|
3
|
+
import { createHash } from 'crypto';
|
|
4
|
+
|
|
5
|
+
export const GRAPH_METADATA_REVISION = '411a1a7976f32abecef2422005fac0d22e4b6c8a';
|
|
6
|
+
const GRAPH_OPENAPI_ROOT = `https://raw.githubusercontent.com/microsoftgraph/msgraph-metadata/${GRAPH_METADATA_REVISION}/openapi`;
|
|
7
|
+
|
|
8
|
+
// Update this revision and both hashes together to adopt new Microsoft metadata.
|
|
9
|
+
export const GRAPH_OPENAPI = {
|
|
10
|
+
'v1.0': {
|
|
11
|
+
url: `${GRAPH_OPENAPI_ROOT}/v1.0/openapi.yaml`,
|
|
12
|
+
sha256: 'bd6385c5eb3df05a69da5f39359d9df61a44d0032d9b2234a97f4c29c0826d4d',
|
|
13
|
+
},
|
|
14
|
+
beta: {
|
|
15
|
+
url: `${GRAPH_OPENAPI_ROOT}/beta/openapi.yaml`,
|
|
16
|
+
sha256: '906f72ba16b7351f0459397828082ebbaa0baa7e08a0c903a0b63f8a30eff67e',
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
function verifySpec(content, sha256, source) {
|
|
21
|
+
if (createHash('sha256').update(content).digest('hex') !== sha256) {
|
|
22
|
+
throw new Error(`SHA-256 mismatch for OpenAPI specification: ${source}`);
|
|
20
23
|
}
|
|
24
|
+
}
|
|
21
25
|
|
|
26
|
+
export async function downloadGraphOpenAPI(targetFile, { url, sha256 }, forceDownload = false) {
|
|
22
27
|
if (fs.existsSync(targetFile) && !forceDownload) {
|
|
23
|
-
|
|
24
|
-
console.log('Use --force to download again');
|
|
28
|
+
verifySpec(fs.readFileSync(targetFile), sha256, `${targetFile} (retry with --force)`);
|
|
25
29
|
return false;
|
|
26
30
|
}
|
|
27
31
|
|
|
28
|
-
console.log(`Downloading OpenAPI specification from ${
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
if (!response.ok) {
|
|
34
|
-
throw new Error(`Failed to download: ${response.status} ${response.statusText}`);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
const content = await response.text();
|
|
38
|
-
fs.writeFileSync(targetFile, content);
|
|
39
|
-
console.log(`OpenAPI specification downloaded to ${targetFile}`);
|
|
40
|
-
return true;
|
|
41
|
-
} catch (error) {
|
|
42
|
-
console.error('Error downloading OpenAPI specification:', error.message);
|
|
43
|
-
throw error;
|
|
32
|
+
console.log(`Downloading OpenAPI specification from ${url}`);
|
|
33
|
+
const response = await fetch(url);
|
|
34
|
+
if (!response.ok) {
|
|
35
|
+
throw new Error(`Failed to download: ${response.status} ${response.statusText}`);
|
|
44
36
|
}
|
|
37
|
+
|
|
38
|
+
const content = Buffer.from(await response.arrayBuffer());
|
|
39
|
+
verifySpec(content, sha256, url);
|
|
40
|
+
fs.mkdirSync(path.dirname(targetFile), { recursive: true });
|
|
41
|
+
fs.writeFileSync(targetFile, content);
|
|
42
|
+
return true;
|
|
45
43
|
}
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import {
|
|
3
|
+
import { execFileSync } from 'child_process';
|
|
4
|
+
import { fileURLToPath } from 'url';
|
|
5
|
+
|
|
6
|
+
const projectRoot = fileURLToPath(new URL('../../', import.meta.url));
|
|
7
|
+
|
|
8
|
+
function runLocalCli(name, args) {
|
|
9
|
+
const dir = path.join(projectRoot, 'node_modules', name);
|
|
10
|
+
const { bin } = JSON.parse(fs.readFileSync(path.join(dir, 'package.json'), 'utf8'));
|
|
11
|
+
const executable = typeof bin === 'string' ? bin : bin[name];
|
|
12
|
+
execFileSync(process.execPath, [path.join(dir, executable), ...args], { stdio: 'inherit' });
|
|
13
|
+
}
|
|
4
14
|
|
|
5
15
|
/**
|
|
6
16
|
* Converts single-quoted `path:` strings that contain function-style OData segments with
|
|
@@ -48,12 +58,14 @@ export function generateMcpTools(openapiTrimmedFile, clientFilePath) {
|
|
|
48
58
|
console.log(`Created directory: ${outputDir}`);
|
|
49
59
|
}
|
|
50
60
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
runLocalCli('openapi-zod-client', [
|
|
62
|
+
openapiTrimmedFile,
|
|
63
|
+
'-o',
|
|
64
|
+
clientFilePath,
|
|
65
|
+
'--with-description',
|
|
66
|
+
'--strict-objects',
|
|
67
|
+
'--additional-props-default-value=false',
|
|
68
|
+
]);
|
|
57
69
|
|
|
58
70
|
console.log(`Generated client code at: ${clientFilePath}`);
|
|
59
71
|
|
|
@@ -95,7 +107,7 @@ export function generateMcpTools(openapiTrimmedFile, clientFilePath) {
|
|
|
95
107
|
// Format the generated client so `npm run generate` output is prettier-stable and
|
|
96
108
|
// the format:check step in `npm run verify` passes deterministically across versions.
|
|
97
109
|
console.log('Formatting generated client with Prettier...');
|
|
98
|
-
|
|
110
|
+
runLocalCli('prettier', ['--write', clientFilePath]);
|
|
99
111
|
|
|
100
112
|
return true;
|
|
101
113
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softeria/ms-365-mcp-server",
|
|
3
3
|
"mcpName": "io.github.Softeria/ms-365-mcp-server",
|
|
4
|
-
"version": "0.193.
|
|
4
|
+
"version": "0.193.1",
|
|
5
5
|
"description": " A Model Context Protocol (MCP) server for interacting with Microsoft 365 and Office services through the Graph API",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/index.js",
|
|
@@ -69,6 +69,7 @@
|
|
|
69
69
|
"@vitest/coverage-v8": "^4.1.8",
|
|
70
70
|
"eslint": "^9.31.0",
|
|
71
71
|
"globals": "^16.3.0",
|
|
72
|
+
"openapi-zod-client": "1.18.3",
|
|
72
73
|
"prettier": "^3.5.3",
|
|
73
74
|
"semantic-release": "^25.0.2",
|
|
74
75
|
"tsup": "^8.5.0",
|
package/src/generated/README.md
CHANGED
|
@@ -43,14 +43,16 @@ improvements should now be much easier to implement and maintain.
|
|
|
43
43
|
|
|
44
44
|
To regenerate the client code (e.g., after API changes or to update the supported endpoints):
|
|
45
45
|
|
|
46
|
+
```sh
|
|
47
|
+
npm ci
|
|
48
|
+
npm run generate
|
|
46
49
|
```
|
|
47
|
-
node bin/generate-graph-client.mjs
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
This command does the following:
|
|
51
50
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
Generation uses v1.0 and beta OpenAPI specs from the same pinned Microsoft Graph metadata commit.
|
|
52
|
+
The raw specs are cached under `openapi/<metadata-commit>/` and verified against their pinned
|
|
53
|
+
SHA-256 hashes; old unversioned files are ignored. To re-download the same pinned inputs, run
|
|
54
|
+
`node bin/generate-graph-client.mjs --force`.
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
The lockfile supplies `openapi-zod-client` and Prettier. Generation writes `client.ts` and
|
|
57
|
+
`client-beta.ts` and refreshes the tracked `PRESETS.md`. To update the Graph specs, change the
|
|
58
|
+
revision and both hashes in `bin/modules/download-openapi.mjs` together and review the outputs.
|