apphud-mcp 0.1.0 → 0.1.2

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/src/cli.js CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { access, writeFile } from "node:fs/promises";
3
- import { constants } from "node:fs";
3
+ import { constants, realpathSync } from "node:fs";
4
4
  import path from "node:path";
5
5
  import { fileURLToPath } from "node:url";
6
6
  import { buildExampleSimpleConfig } from "./config/env.js";
@@ -85,8 +85,20 @@ async function main() {
85
85
  }
86
86
  }
87
87
  }
88
- const isDirectRun = process.argv[1] ? path.resolve(process.argv[1]) === fileURLToPath(import.meta.url) : false;
89
- if (isDirectRun) {
88
+ function isDirectRun() {
89
+ if (!process.argv[1]) {
90
+ return false;
91
+ }
92
+ const currentFile = fileURLToPath(import.meta.url);
93
+ try {
94
+ // npm links bin to a symlink in node_modules/.bin; resolve it to actual file.
95
+ return realpathSync(process.argv[1]) === currentFile;
96
+ }
97
+ catch {
98
+ return path.resolve(process.argv[1]) === currentFile;
99
+ }
100
+ }
101
+ if (isDirectRun()) {
90
102
  main().catch((error) => {
91
103
  console.error(error instanceof Error ? error.message : String(error));
92
104
  process.exitCode = 1;
package/dist/src/index.js CHANGED
@@ -5,6 +5,7 @@ import { startMcpStdioServer } from "./mcp/server.js";
5
5
  export async function startRuntime(container) {
6
6
  await initializeServiceContainer(container);
7
7
  let httpServer;
8
+ let stdioStarted = false;
8
9
  if (container.config.httpEnabled) {
9
10
  const app = createHttpServer(container);
10
11
  await new Promise((resolve) => {
@@ -15,14 +16,11 @@ export async function startRuntime(container) {
15
16
  });
16
17
  }
17
18
  if (container.config.mcpStdioEnabled) {
18
- startMcpStdioServer(container)
19
- .then(() => {
20
- console.error("MCP stdio transport started");
21
- })
22
- .catch((error) => {
23
- console.error("Failed to start MCP stdio server", error);
24
- process.exitCode = 1;
25
- });
19
+ // Keep stdin flowing for stdio transport and wait for successful handshake setup.
20
+ process.stdin.resume();
21
+ await startMcpStdioServer(container);
22
+ stdioStarted = true;
23
+ console.error("MCP stdio transport started");
26
24
  }
27
25
  async function shutdown() {
28
26
  if (httpServer) {
@@ -37,6 +35,9 @@ export async function startRuntime(container) {
37
35
  });
38
36
  }
39
37
  await container.close();
38
+ if (stdioStarted) {
39
+ process.stdin.pause();
40
+ }
40
41
  }
41
42
  return { shutdown };
42
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "apphud-mcp",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "description": "MCP server for Apphud dashboard analytics",
6
6
  "license": "MIT",