@trackmcp/cli 0.1.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/README.md +9 -0
- package/bin/trackmcp.mjs +50 -0
- package/package.json +12 -0
package/README.md
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# @trackmcp/cli
|
|
2
|
+
|
|
3
|
+
The safe onboarding companion to `@trackmcp/sdk`:
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npx @trackmcp/cli setup
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
It opens the TrackMCP dashboard, lets the server owner create a workspace API key, and writes the pasted one-time secret to `.env.local`. Package installation itself never sends email or creates cloud resources. The CLI does not need to know, store, or display your Supabase service-role key.
|
package/bin/trackmcp.mjs
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { existsSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { createInterface } from "node:readline/promises";
|
|
4
|
+
import { stdin as input, stdout as output } from "node:process";
|
|
5
|
+
import { exec } from "node:child_process";
|
|
6
|
+
|
|
7
|
+
const dashboard = process.env.TRACKMCP_DASHBOARD_URL || "https://trackmcp.com/dashboard";
|
|
8
|
+
const envFile = process.env.TRACKMCP_ENV_FILE || ".env.local";
|
|
9
|
+
const command = process.argv[2] || "setup";
|
|
10
|
+
|
|
11
|
+
function open(url) {
|
|
12
|
+
const opener = process.platform === "darwin" ? "open" : process.platform === "win32" ? "start" : "xdg-open";
|
|
13
|
+
exec(`${opener} "${url}"`, () => {});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function saveKey(key) {
|
|
17
|
+
const line = `TRACKMCP_KEY=${key}`;
|
|
18
|
+
if (existsSync(envFile)) {
|
|
19
|
+
const current = readFileSync(envFile, "utf8");
|
|
20
|
+
const updated = current.match(/^TRACKMCP_KEY=.*$/m) ? current.replace(/^TRACKMCP_KEY=.*$/m, line) : `${current.trimEnd()}\n${line}\n`;
|
|
21
|
+
writeFileSync(envFile, updated);
|
|
22
|
+
} else {
|
|
23
|
+
writeFileSync(envFile, `${line}\n`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (!["setup", "init"].includes(command)) {
|
|
28
|
+
console.error("Usage: npx @trackmcp/cli setup");
|
|
29
|
+
process.exit(1);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
console.log("\nTrackMCP setup\n==============\n");
|
|
33
|
+
console.log("1. We’ll open your TrackMCP dashboard.");
|
|
34
|
+
console.log("2. Sign in with your email and create a workspace API key.");
|
|
35
|
+
console.log("3. Paste the key here; we’ll save it only in your local environment file.\n");
|
|
36
|
+
open(dashboard);
|
|
37
|
+
const rl = createInterface({ input, output });
|
|
38
|
+
const answer = await rl.question("Paste your TrackMCP API key (or press Enter to finish in the browser): ");
|
|
39
|
+
rl.close();
|
|
40
|
+
if (!answer.trim()) {
|
|
41
|
+
console.log(`\nFinish setup in the browser: ${dashboard}`);
|
|
42
|
+
process.exit(0);
|
|
43
|
+
}
|
|
44
|
+
if (!/^tmcp_[A-Za-z0-9_-]{20,}$/.test(answer.trim())) {
|
|
45
|
+
console.error("That does not look like a TrackMCP key. Keys begin with tmcp_. Nothing was changed.");
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
48
|
+
saveKey(answer.trim());
|
|
49
|
+
console.log(`\nSaved TRACKMCP_KEY to ${envFile}.`);
|
|
50
|
+
console.log("Next, wrap your server:\n\n import { withTrackMCP } from \"@trackmcp/sdk\";\n export default withTrackMCP(server, { apiKey: process.env.TRACKMCP_KEY, service: \"my-mcp-server\" });\n");
|
package/package.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@trackmcp/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Set up TrackMCP and connect an MCP server from the terminal",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": { "trackmcp": "./bin/trackmcp.mjs" },
|
|
7
|
+
"files": ["bin", "README.md"],
|
|
8
|
+
"keywords": ["mcp", "trackmcp", "observability"],
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": { "type": "git", "url": "https://github.com/Krishna3956/CRV/tree/main/trackmcp-web/packages/cli" },
|
|
11
|
+
"engines": { "node": ">=18" }
|
|
12
|
+
}
|