a-calc 3.0.0-beta.20250123.10 → 3.0.0-beta.20250123.12

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.
@@ -48,13 +48,28 @@ npm install a-calc
48
48
 
49
49
  在 Claude Desktop 配置文件中添加:
50
50
 
51
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
52
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
51
+ **配置文件位置:**
52
+ - **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
53
+ - **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
54
+ - **Linux**: `~/.config/claude/claude_desktop_config.json`
53
55
 
54
56
  **方式一:使用项目本地安装(推荐)**
55
57
 
56
58
  如果你的项目已经安装了 a-calc:
57
59
 
60
+ #### macOS / Linux
61
+ ```json
62
+ {
63
+ "mcpServers": {
64
+ "a-calc": {
65
+ "command": "node",
66
+ "args": ["./node_modules/a-calc/mcp-server/src/index.js"]
67
+ }
68
+ }
69
+ }
70
+ ```
71
+
72
+ #### Windows
58
73
  ```json
59
74
  {
60
75
  "mcpServers": {
@@ -70,6 +85,7 @@ npm install a-calc
70
85
 
71
86
  如果项目未安装 a-calc,使用 npx 自动下载:
72
87
 
88
+ #### macOS / Linux
73
89
  ```json
74
90
  {
75
91
  "mcpServers": {
@@ -81,6 +97,53 @@ npm install a-calc
81
97
  }
82
98
  ```
83
99
 
100
+ #### Windows
101
+ ```json
102
+ {
103
+ "mcpServers": {
104
+ "a-calc": {
105
+ "command": "cmd",
106
+ "args": ["/c", "npx", "-y", "a-calc", "a-calc-mcp"]
107
+ }
108
+ }
109
+ }
110
+ ```
111
+
112
+ **⚠️ Windows 重要提示:** Windows 上必须使用 `cmd /c` 包装器来执行 `npx` 命令,否则会报错:`Windows requires 'cmd /c' wrapper to execute npx`。
113
+
114
+ **方式三:指定工作目录(推荐用于项目级配置)**
115
+
116
+ 如果你希望 MCP 服务器在特定目录下运行(例如项目根目录),可以使用 `--cwd` 参数:
117
+
118
+ #### macOS / Linux
119
+ ```json
120
+ {
121
+ "mcpServers": {
122
+ "a-calc": {
123
+ "command": "npx",
124
+ "args": ["-y", "a-calc", "a-calc-mcp", "--cwd", "/path/to/your/project"]
125
+ }
126
+ }
127
+ }
128
+ ```
129
+
130
+ #### Windows
131
+ ```json
132
+ {
133
+ "mcpServers": {
134
+ "a-calc": {
135
+ "command": "cmd",
136
+ "args": ["/c", "npx", "-y", "a-calc", "a-calc-mcp", "--cwd", "D:\\workspace\\your-project"]
137
+ }
138
+ }
139
+ }
140
+ ```
141
+
142
+ **使用场景:**
143
+ - 当你需要 MCP 服务器访问项目文件时
144
+ - 当你需要相对于项目根目录的路径时
145
+ - 当你使用全局安装但希望在项目目录下工作时
146
+
84
147
  > 💡 **推荐使用方式一的原因:**
85
148
  > - 启动速度更快(无需 npx 查找和下载)
86
149
  > - 使用项目已安装的版本,版本一致性更好
@@ -379,6 +379,24 @@ const itemTotal = calc("price * quantity | =2", item)
379
379
  required: ["topic"],
380
380
  },
381
381
  },
382
+ {
383
+ name: "debug_info",
384
+ description: `🔍 调试工具 - 获取 MCP 服务器的运行环境信息
385
+
386
+ 返回信息:
387
+ - cwd: 当前工作目录 (process.cwd())
388
+ - __dirname: 脚本所在目录
389
+ - __filename: 脚本文件路径
390
+ - node_version: Node.js 版本
391
+ - platform: 操作系统平台
392
+ - env: 相关环境变量
393
+
394
+ 用途:调试 MCP 服务器配置问题`,
395
+ inputSchema: {
396
+ type: "object",
397
+ properties: {},
398
+ },
399
+ },
382
400
  ];
383
401
 
384
402
  // ==================== Resources 定义 ====================
@@ -1229,6 +1247,31 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
1229
1247
  };
1230
1248
  }
1231
1249
 
1250
+ case "debug_info": {
1251
+ const debugInfo = {
1252
+ cwd: process.cwd(),
1253
+ __dirname: import.meta.url,
1254
+ node_version: process.version,
1255
+ platform: process.platform,
1256
+ arch: process.arch,
1257
+ env: {
1258
+ HOME: process.env.HOME,
1259
+ USERPROFILE: process.env.USERPROFILE,
1260
+ PATH: process.env.PATH?.split(process.platform === 'win32' ? ';' : ':').slice(0, 5).join('\n '),
1261
+ NODE_ENV: process.env.NODE_ENV,
1262
+ },
1263
+ };
1264
+
1265
+ return {
1266
+ content: [
1267
+ {
1268
+ type: "text",
1269
+ text: JSON.stringify(debugInfo, null, 2),
1270
+ },
1271
+ ],
1272
+ };
1273
+ }
1274
+
1232
1275
  default:
1233
1276
  throw new Error(`Unknown tool: ${name}`);
1234
1277
  }
@@ -1291,9 +1334,24 @@ server.setRequestHandler(GetPromptRequestSchema, async (request) => {
1291
1334
  // ==================== Start Server ====================
1292
1335
 
1293
1336
  async function main() {
1337
+ // 解析命令行参数
1338
+ const args = process.argv.slice(2);
1339
+ const cwdIndex = args.indexOf('--cwd');
1340
+
1341
+ if (cwdIndex !== -1 && args[cwdIndex + 1]) {
1342
+ const targetCwd = args[cwdIndex + 1];
1343
+ try {
1344
+ process.chdir(targetCwd);
1345
+ console.error(`Changed working directory to: ${process.cwd()}`);
1346
+ } catch (error) {
1347
+ console.error(`Failed to change directory to ${targetCwd}:`, error.message);
1348
+ }
1349
+ }
1350
+
1294
1351
  const transport = new StdioServerTransport();
1295
1352
  await server.connect(transport);
1296
1353
  console.error("a-calc MCP Server running on stdio");
1354
+ console.error(`Working directory: ${process.cwd()}`);
1297
1355
  }
1298
1356
 
1299
1357
  main().catch((error) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "a-calc",
3
- "version": "3.0.0-beta.20250123.10",
3
+ "version": "3.0.0-beta.20250123.12",
4
4
  "description": "A very powerful and easy-to-use number precision calculation and formatting library.",
5
5
  "main": "./cjs/index.js",
6
6
  "exports": {