@mafdet/mcp 0.1.0 → 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.
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAgBpE,wBAAgB,WAAW,CAAC,MAAM,kCAAe,GAAG,SAAS,CAmE5D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAgBpE,wBAAgB,WAAW,CAAC,MAAM,kCAAe,GAAG,SAAS,CAmE5D"}
package/dist/index.js CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env node
2
+ import { realpathSync } from "node:fs";
3
+ import { fileURLToPath } from "node:url";
2
4
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
5
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
4
6
  import { z } from "zod";
@@ -9,7 +11,7 @@ import { getBalance, getSubscription, getUsageSummary, listModels, searchDocsToo
9
11
  // it); everything diagnostic goes to stderr via logError. The five tools are
10
12
  // read-only; account tools need MAFDET_API_KEY, the two public tools do not.
11
13
  export function buildServer(config = loadConfig()) {
12
- const server = new McpServer({ name: "mafdet-mcp", version: "0.1.0" });
14
+ const server = new McpServer({ name: "mafdet-mcp", version: "0.1.1" });
13
15
  server.registerTool("list_models", {
14
16
  title: "List Mafdet AI models",
15
17
  description: "List the models available on Mafdet AI with provider, tier, and per-1M-token pricing. No API key required.",
@@ -55,8 +57,22 @@ async function main() {
55
57
  process.on("SIGINT", shutdown);
56
58
  process.on("SIGTERM", shutdown);
57
59
  }
58
- // Only run when invoked as the binary, not when imported by tests.
59
- if (process.argv[1] && import.meta.url === `file://${process.argv[1]}`) {
60
+ // Only run when invoked as the binary, not when imported by tests. npm/npx run
61
+ // the bin through a symlink (`node_modules/.bin/mafdet-mcp`), so process.argv[1]
62
+ // is the symlink path while import.meta.url is the resolved file — compare their
63
+ // real paths, or the server would silently never start when launched via npx.
64
+ function isInvokedAsBinary() {
65
+ const entry = process.argv[1];
66
+ if (!entry)
67
+ return false;
68
+ try {
69
+ return realpathSync(entry) === realpathSync(fileURLToPath(import.meta.url));
70
+ }
71
+ catch {
72
+ return false;
73
+ }
74
+ }
75
+ if (isInvokedAsBinary()) {
60
76
  main().catch((error) => {
61
77
  logError(error instanceof Error ? error.message : String(error));
62
78
  process.exit(1);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mafdet/mcp",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Mafdet AI MCP server — read-only account tools (models, balance, usage, subscription, docs) for Claude Code, Cursor, Codex, OpenCode, and Claude Desktop.",
5
5
  "type": "module",
6
6
  "license": "MIT",