@temporal-cortex/cortex-mcp 0.1.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.
package/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # @temporal-cortex/cortex-mcp
2
+
3
+ MCP server for AI-native calendar operations.
4
+
5
+ **Full documentation, examples, and guides: [github.com/billylui/temporal-cortex-mcp](https://github.com/billylui/temporal-cortex-mcp)**
package/bin/run.js ADDED
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env node
2
+
3
+ // Platform-specific binary launcher for @temporal-cortex/cortex-mcp.
4
+ //
5
+ // Resolution strategy:
6
+ // 1. Try the platform-specific optional dependency (installed by npm automatically)
7
+ // 2. Fall back to a binary downloaded by the postinstall script
8
+ // 3. Provide a clear error message if neither is available
9
+
10
+ "use strict";
11
+
12
+ const { execFileSync } = require("child_process");
13
+ const path = require("path");
14
+ const fs = require("fs");
15
+ const os = require("os");
16
+
17
+ const PLATFORM_MAP = {
18
+ "darwin-arm64": "@temporal-cortex/cortex-mcp-darwin-arm64",
19
+ "darwin-x64": "@temporal-cortex/cortex-mcp-darwin-x64",
20
+ "linux-x64": "@temporal-cortex/cortex-mcp-linux-x64",
21
+ "linux-arm64": "@temporal-cortex/cortex-mcp-linux-arm64",
22
+ "win32-x64": "@temporal-cortex/cortex-mcp-win32-x64",
23
+ };
24
+
25
+ const BINARY_NAME = os.platform() === "win32" ? "cortex-mcp.exe" : "cortex-mcp";
26
+
27
+ function getBinaryPath() {
28
+ const platformKey = `${os.platform()}-${os.arch()}`;
29
+ const packageName = PLATFORM_MAP[platformKey];
30
+
31
+ if (!packageName) {
32
+ throw new Error(
33
+ `Unsupported platform: ${platformKey}. ` +
34
+ `Supported: ${Object.keys(PLATFORM_MAP).join(", ")}`
35
+ );
36
+ }
37
+
38
+ // Strategy 1: Try the platform-specific npm package.
39
+ try {
40
+ const packageDir = path.dirname(require.resolve(`${packageName}/package.json`));
41
+ const binPath = path.join(packageDir, "bin", BINARY_NAME);
42
+ if (fs.existsSync(binPath)) {
43
+ return binPath;
44
+ }
45
+ } catch {
46
+ // Package not installed — try fallback.
47
+ }
48
+
49
+ // Strategy 2: Try the postinstall fallback binary.
50
+ const fallbackPath = path.join(__dirname, "..", "bin", BINARY_NAME);
51
+ if (fs.existsSync(fallbackPath) && fallbackPath !== __filename) {
52
+ return fallbackPath;
53
+ }
54
+
55
+ throw new Error(
56
+ `Could not find the cortex-mcp binary for ${platformKey}.\n` +
57
+ `Try reinstalling: npm install @temporal-cortex/cortex-mcp\n` +
58
+ `If the problem persists, please file an issue at:\n` +
59
+ `https://github.com/billylui/temporal-cortex-mcp/issues`
60
+ );
61
+ }
62
+
63
+ try {
64
+ const binPath = getBinaryPath();
65
+
66
+ // Pass through all arguments and stdio.
67
+ execFileSync(binPath, process.argv.slice(2), {
68
+ stdio: "inherit",
69
+ env: process.env,
70
+ });
71
+ } catch (err) {
72
+ if (err.status !== undefined) {
73
+ // Binary exited with a non-zero code — propagate it.
74
+ process.exit(err.status);
75
+ }
76
+ console.error(err.message);
77
+ process.exit(1);
78
+ }
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "@temporal-cortex/cortex-mcp",
3
+ "version": "0.1.1",
4
+ "description": "MCP server for AI-native calendar operations — atomic booking, RRULE expansion, and availability merging",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/billylui/temporal-cortex-mcp.git"
9
+ },
10
+ "homepage": "https://github.com/billylui/temporal-cortex-mcp#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/billylui/temporal-cortex-mcp/issues"
13
+ },
14
+ "mcpName": "io.github.billylui/temporal-cortex-mcp",
15
+ "keywords": [
16
+ "mcp",
17
+ "calendar",
18
+ "google-calendar",
19
+ "ai",
20
+ "scheduling",
21
+ "booking",
22
+ "rrule",
23
+ "availability"
24
+ ],
25
+ "bin": {
26
+ "cortex-mcp": "bin/run.js"
27
+ },
28
+ "files": [
29
+ "bin/",
30
+ "scripts/"
31
+ ],
32
+ "scripts": {
33
+ "postinstall": "node scripts/postinstall.js"
34
+ },
35
+ "optionalDependencies": {
36
+ "@temporal-cortex/cortex-mcp-darwin-arm64": "0.1.1",
37
+ "@temporal-cortex/cortex-mcp-darwin-x64": "0.1.1",
38
+ "@temporal-cortex/cortex-mcp-linux-x64": "0.1.1",
39
+ "@temporal-cortex/cortex-mcp-linux-arm64": "0.1.1",
40
+ "@temporal-cortex/cortex-mcp-win32-x64": "0.1.1"
41
+ },
42
+ "engines": {
43
+ "node": ">=18"
44
+ }
45
+ }
@@ -0,0 +1,145 @@
1
+ #!/usr/bin/env node
2
+
3
+ // Postinstall fallback for @temporal-cortex/cortex-mcp.
4
+ //
5
+ // If the platform-specific optional dependency wasn't installed (e.g., because
6
+ // `--no-optional` was used or the platform isn't in optionalDependencies),
7
+ // this script downloads the correct binary from GitHub Releases.
8
+ //
9
+ // This is a best-effort fallback — the primary distribution mechanism is the
10
+ // platform-specific npm packages via optionalDependencies.
11
+
12
+ "use strict";
13
+
14
+ const https = require("https");
15
+ const fs = require("fs");
16
+ const path = require("path");
17
+ const os = require("os");
18
+ const { execSync } = require("child_process");
19
+
20
+ const VERSION = require("../package.json").version;
21
+ const BINARY_NAME = os.platform() === "win32" ? "cortex-mcp.exe" : "cortex-mcp";
22
+
23
+ const PLATFORM_MAP = {
24
+ "darwin-arm64": "cortex-mcp-darwin-arm64",
25
+ "darwin-x64": "cortex-mcp-darwin-x64",
26
+ "linux-x64": "cortex-mcp-linux-x64",
27
+ "linux-arm64": "cortex-mcp-linux-arm64",
28
+ "win32-x64": "cortex-mcp-win32-x64",
29
+ };
30
+
31
+ function getPlatformKey() {
32
+ return `${os.platform()}-${os.arch()}`;
33
+ }
34
+
35
+ function alreadyInstalled() {
36
+ const platformKey = getPlatformKey();
37
+ const packageNames = {
38
+ "darwin-arm64": "@temporal-cortex/cortex-mcp-darwin-arm64",
39
+ "darwin-x64": "@temporal-cortex/cortex-mcp-darwin-x64",
40
+ "linux-x64": "@temporal-cortex/cortex-mcp-linux-x64",
41
+ "linux-arm64": "@temporal-cortex/cortex-mcp-linux-arm64",
42
+ "win32-x64": "@temporal-cortex/cortex-mcp-win32-x64",
43
+ };
44
+
45
+ const packageName = packageNames[platformKey];
46
+ if (!packageName) return false;
47
+
48
+ try {
49
+ require.resolve(`${packageName}/package.json`);
50
+ return true;
51
+ } catch {
52
+ return false;
53
+ }
54
+ }
55
+
56
+ async function downloadBinary() {
57
+ const platformKey = getPlatformKey();
58
+ const artifact = PLATFORM_MAP[platformKey];
59
+
60
+ if (!artifact) {
61
+ console.warn(
62
+ `[cortex-mcp] No prebuilt binary for ${platformKey}. ` +
63
+ `You may need to build from source.`
64
+ );
65
+ return;
66
+ }
67
+
68
+ // Skip if the platform package is already installed.
69
+ if (alreadyInstalled()) {
70
+ return;
71
+ }
72
+
73
+ const tarball = `${artifact}.tar.gz`;
74
+ const url = `https://github.com/billylui/temporal-cortex-mcp/releases/download/mcp-v${VERSION}/${tarball}`;
75
+ const binDir = path.join(__dirname, "..", "bin");
76
+ const tmpFile = path.join(os.tmpdir(), tarball);
77
+
78
+ console.log(`[cortex-mcp] Downloading binary for ${platformKey}...`);
79
+
80
+ try {
81
+ await download(url, tmpFile);
82
+
83
+ // Extract the binary from the tarball.
84
+ fs.mkdirSync(binDir, { recursive: true });
85
+ execSync(`tar -xzf "${tmpFile}" -C "${binDir}"`, { stdio: "pipe" });
86
+
87
+ // Make executable on Unix.
88
+ if (os.platform() !== "win32") {
89
+ fs.chmodSync(path.join(binDir, BINARY_NAME), 0o755);
90
+ }
91
+
92
+ console.log(`[cortex-mcp] Binary installed successfully.`);
93
+ } catch (err) {
94
+ console.warn(
95
+ `[cortex-mcp] Failed to download binary: ${err.message}\n` +
96
+ `You can manually download from: ${url}`
97
+ );
98
+ } finally {
99
+ // Clean up temp file.
100
+ try {
101
+ fs.unlinkSync(tmpFile);
102
+ } catch {
103
+ // Ignore cleanup errors.
104
+ }
105
+ }
106
+ }
107
+
108
+ function download(url, dest) {
109
+ return new Promise((resolve, reject) => {
110
+ const file = fs.createWriteStream(dest);
111
+ https
112
+ .get(url, (response) => {
113
+ // Follow redirects (GitHub releases redirect to S3).
114
+ if (response.statusCode === 302 || response.statusCode === 301) {
115
+ file.close();
116
+ fs.unlinkSync(dest);
117
+ return download(response.headers.location, dest).then(resolve, reject);
118
+ }
119
+
120
+ if (response.statusCode !== 200) {
121
+ file.close();
122
+ fs.unlinkSync(dest);
123
+ return reject(new Error(`HTTP ${response.statusCode}`));
124
+ }
125
+
126
+ response.pipe(file);
127
+ file.on("finish", () => {
128
+ file.close(resolve);
129
+ });
130
+ })
131
+ .on("error", (err) => {
132
+ file.close();
133
+ try {
134
+ fs.unlinkSync(dest);
135
+ } catch {
136
+ // Ignore.
137
+ }
138
+ reject(err);
139
+ });
140
+ });
141
+ }
142
+
143
+ downloadBinary().catch(() => {
144
+ // Non-fatal — the binary just won't be available.
145
+ });