@mkterswingman/yt-mcp 0.3.1 → 0.3.3

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/dist/cli/index.js CHANGED
@@ -1,4 +1,19 @@
1
1
  #!/usr/bin/env node
2
+ import { execSync } from "node:child_process";
3
+ import { readFileSync } from "node:fs";
4
+ import { join, dirname } from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ const __dirname = dirname(fileURLToPath(import.meta.url));
7
+ const pkgPath = join(__dirname, "..", "..", "package.json");
8
+ function getVersion() {
9
+ try {
10
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
11
+ return pkg.version ?? "unknown";
12
+ }
13
+ catch {
14
+ return "unknown";
15
+ }
16
+ }
2
17
  const command = process.argv[2];
3
18
  async function main() {
4
19
  switch (command) {
@@ -17,14 +32,53 @@ async function main() {
17
32
  await runSetupCookies();
18
33
  break;
19
34
  }
35
+ case "update": {
36
+ const current = getVersion();
37
+ console.log(`Current version: ${current}`);
38
+ console.log("Checking for updates...\n");
39
+ try {
40
+ const latest = execSync("npm view @mkterswingman/yt-mcp version", {
41
+ encoding: "utf8",
42
+ stdio: ["ignore", "pipe", "ignore"],
43
+ }).trim();
44
+ if (latest === current) {
45
+ console.log(`✅ Already on the latest version (${current})`);
46
+ }
47
+ else {
48
+ console.log(`New version available: ${latest}`);
49
+ console.log("Updating...\n");
50
+ execSync("npm install -g @mkterswingman/yt-mcp@latest", {
51
+ stdio: "inherit",
52
+ });
53
+ console.log(`\n✅ Updated to ${latest}`);
54
+ }
55
+ }
56
+ catch (err) {
57
+ const msg = err instanceof Error ? err.message : String(err);
58
+ console.error(`❌ Update failed: ${msg}`);
59
+ console.error("Try manually: npm install -g @mkterswingman/yt-mcp@latest");
60
+ process.exit(1);
61
+ }
62
+ break;
63
+ }
64
+ case "version":
65
+ case "--version":
66
+ case "-v": {
67
+ console.log(getVersion());
68
+ break;
69
+ }
20
70
  default:
21
71
  console.log(`
72
+ yt-mcp v${getVersion()}
73
+
22
74
  Usage: yt-mcp <command>
23
75
 
24
76
  Commands:
25
77
  setup Run first-time setup (OAuth + cookies + MCP registration)
26
78
  serve Start the MCP server (stdio transport)
27
79
  setup-cookies Refresh YouTube cookies using browser login
80
+ update Update to the latest version
81
+ version Show current version
28
82
 
29
83
  Environment variables:
30
84
  YT_MCP_TOKEN Personal Access Token (skips OAuth)
@@ -36,4 +90,3 @@ main().catch((err) => {
36
90
  console.error("Fatal error:", err);
37
91
  process.exit(1);
38
92
  });
39
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mkterswingman/yt-mcp",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "YouTube MCP client — local subtitles + remote API proxy",
5
5
  "type": "module",
6
6
  "bin": {
@@ -13,7 +13,7 @@
13
13
  "build": "tsc -p tsconfig.json",
14
14
  "dev": "tsx src/cli/index.ts",
15
15
  "start": "node dist/cli/index.js",
16
- "postinstall": "node scripts/download-ytdlp.mjs"
16
+ "postinstall": "node scripts/download-ytdlp.mjs && node scripts/postinstall-hint.mjs"
17
17
  },
18
18
  "dependencies": {
19
19
  "@modelcontextprotocol/sdk": "^1.27.1",
@@ -36,6 +36,7 @@
36
36
  "files": [
37
37
  "dist/",
38
38
  "scripts/download-ytdlp.mjs",
39
+ "scripts/postinstall-hint.mjs",
39
40
  "README.md"
40
41
  ],
41
42
  "devDependencies": {
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Post-install: if global install + TTY available + not yet set up → auto-run setup.
5
+ * Otherwise print a hint.
6
+ */
7
+
8
+ import { existsSync } from "node:fs";
9
+ import { join } from "node:path";
10
+ import { execFileSync } from "node:child_process";
11
+
12
+ const home = process.env.HOME || process.env.USERPROFILE || "";
13
+ const authFile = join(home, ".yt-mcp", "auth.json");
14
+
15
+ // Already set up — skip silently
16
+ if (existsSync(authFile)) {
17
+ process.exit(0);
18
+ }
19
+
20
+ // Not a TTY (CI, Docker, piped) — just print hint
21
+ if (!process.stdin.isTTY) {
22
+ console.log("\n yt-mcp installed! Run: yt-mcp setup\n");
23
+ process.exit(0);
24
+ }
25
+
26
+ // Auto-launch setup
27
+ console.log("\n First time? Starting setup automatically...\n");
28
+ try {
29
+ execFileSync(process.execPath, [join(import.meta.dirname, "..", "dist", "cli", "index.js"), "setup"], {
30
+ stdio: "inherit",
31
+ });
32
+ } catch {
33
+ console.log("\n Setup interrupted. Run later: yt-mcp setup\n");
34
+ }