a-calc 3.0.0-beta.20250123.11 → 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.
- package/mcp-server/README.md +65 -2
- package/mcp-server/src/index.js +15 -0
- package/package.json +1 -1
package/mcp-server/README.md
CHANGED
|
@@ -48,13 +48,28 @@ npm install a-calc
|
|
|
48
48
|
|
|
49
49
|
在 Claude Desktop 配置文件中添加:
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
**
|
|
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
|
> - 使用项目已安装的版本,版本一致性更好
|
package/mcp-server/src/index.js
CHANGED
|
@@ -1334,9 +1334,24 @@ server.setRequestHandler(GetPromptRequestSchema, async (request) => {
|
|
|
1334
1334
|
// ==================== Start Server ====================
|
|
1335
1335
|
|
|
1336
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
|
+
|
|
1337
1351
|
const transport = new StdioServerTransport();
|
|
1338
1352
|
await server.connect(transport);
|
|
1339
1353
|
console.error("a-calc MCP Server running on stdio");
|
|
1354
|
+
console.error(`Working directory: ${process.cwd()}`);
|
|
1340
1355
|
}
|
|
1341
1356
|
|
|
1342
1357
|
main().catch((error) => {
|
package/package.json
CHANGED