@ppdocs/mcp 3.1.6 → 3.1.8

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.
Files changed (2) hide show
  1. package/dist/cli.js +28 -15
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -161,15 +161,15 @@ async function initProject(opts) {
161
161
  hasIdeDir = true;
162
162
  }
163
163
  if (detectedIdes.includes('cursor')) {
164
- installCursorTemplates(cwd);
164
+ installCursorTemplates(cwd, apiUrl);
165
165
  hasIdeDir = true;
166
166
  }
167
167
  if (detectedIdes.includes('antigravity')) {
168
- installAntigravityTemplates(cwd);
168
+ installAntigravityTemplates(cwd, apiUrl);
169
169
  hasIdeDir = true;
170
170
  }
171
171
  if (detectedIdes.includes('kiro')) {
172
- installKiroTemplates(cwd);
172
+ installKiroTemplates(cwd, apiUrl);
173
173
  hasIdeDir = true;
174
174
  }
175
175
  // Fallback behavior: if no specific IDE config directories found
@@ -185,7 +185,7 @@ async function initProject(opts) {
185
185
  const registered = autoRegisterMcp(apiUrl, opts.user);
186
186
  // 如果没有检测到任何 AI CLI,并且也没有检测到配置文件夹,创建 .mcp.json 作为备用
187
187
  if (!registered && !hasIdeDir) {
188
- createMcpJson(cwd);
188
+ createMcpJson(cwd, apiUrl);
189
189
  }
190
190
  // --from: 从模板项目拉取 IDE 配置文件
191
191
  if (opts.from) {
@@ -344,7 +344,7 @@ function autoRegisterMcp(apiUrl, user) {
344
344
  return true;
345
345
  }
346
346
  /** 在指定路径创建或更新 mcp.json 配置 */
347
- function createMcpConfigAt(mcpPath, autoCreatedTemplate) {
347
+ function createMcpConfigAt(mcpPath, apiUrl) {
348
348
  let mcpConfig = {};
349
349
  if (fs.existsSync(mcpPath)) {
350
350
  try {
@@ -356,9 +356,22 @@ function createMcpConfigAt(mcpPath, autoCreatedTemplate) {
356
356
  }
357
357
  // Windows 需要 cmd /c 包装才能执行 npx
358
358
  const isWindows = process.platform === 'win32';
359
+ // 对于 Mac/Linux,IDE 可能没有用户的完整 PATH,导致找不到 npx
359
360
  const ppdocsServer = isWindows
360
- ? { command: 'cmd', args: ['/c', 'npx', '-y', '@ppdocs/mcp@latest'] }
361
- : { command: 'npx', args: ['-y', '@ppdocs/mcp@latest'] };
361
+ ? {
362
+ command: 'cmd',
363
+ args: ['/c', 'npx', '-y', '@ppdocs/mcp@latest'],
364
+ env: { "PPDOCS_API_URL": apiUrl }
365
+ }
366
+ : {
367
+ command: 'npx',
368
+ args: ['-y', '@ppdocs/mcp@latest'],
369
+ env: {
370
+ "PPDOCS_API_URL": apiUrl,
371
+ // 强行注入常见路径,防止找不到 node/npx
372
+ "PATH": "$PATH:/usr/local/bin:/opt/homebrew/bin:/home/linuxbrew/.linuxbrew/bin"
373
+ }
374
+ };
362
375
  mcpConfig.mcpServers = {
363
376
  ...(mcpConfig.mcpServers || {}),
364
377
  "ppdocs-kg": ppdocsServer,
@@ -372,8 +385,8 @@ function createMcpConfigAt(mcpPath, autoCreatedTemplate) {
372
385
  console.log(`✅ Configured MCP in ${mcpPath}`);
373
386
  }
374
387
  /** 创建 .mcp.json (手动配置备用) */
375
- function createMcpJson(cwd) {
376
- createMcpConfigAt(path.join(cwd, '.mcp.json'));
388
+ function createMcpJson(cwd, apiUrl) {
389
+ createMcpConfigAt(path.join(cwd, '.mcp.json'), apiUrl);
377
390
  }
378
391
  /** 递归复制目录 */
379
392
  function copyDirRecursive(src, dest) {
@@ -496,9 +509,9 @@ function generateAgentsMd(cwd) {
496
509
  }
497
510
  }
498
511
  /** 安装 Cursor 模板 */
499
- function installCursorTemplates(cwd) {
512
+ function installCursorTemplates(cwd, apiUrl) {
500
513
  // 1. 生成 Cursor MCP 配置
501
- createMcpConfigAt(path.join(cwd, '.cursor', 'mcp.json'));
514
+ createMcpConfigAt(path.join(cwd, '.cursor', 'mcp.json'), apiUrl);
502
515
  // 2. 生成 .cursorrules 提示词
503
516
  const srcRules = path.join(TEMPLATES_DIR, 'cursorrules.md');
504
517
  const destRules = path.join(cwd, '.cursorrules');
@@ -508,9 +521,9 @@ function installCursorTemplates(cwd) {
508
521
  }
509
522
  }
510
523
  /** 安装 Antigravity (Gemini IDE) 模板 */
511
- function installAntigravityTemplates(cwd) {
524
+ function installAntigravityTemplates(cwd, apiUrl) {
512
525
  // 1. 填充 .gemini/settings.json
513
- createMcpConfigAt(path.join(cwd, '.gemini', 'settings.json'));
526
+ createMcpConfigAt(path.join(cwd, '.gemini', 'settings.json'), apiUrl);
514
527
  // 2. 生成 AGENTS.md
515
528
  generateAgentsMd(cwd);
516
529
  // 3. 安装斜杠命令 → .agents/workflows/ (Antigravity 的 slash command 机制)
@@ -546,9 +559,9 @@ function installAntigravityTemplates(cwd) {
546
559
  }
547
560
  }
548
561
  /** 安装 Kiro 模板 */
549
- function installKiroTemplates(cwd) {
562
+ function installKiroTemplates(cwd, apiUrl) {
550
563
  // 1. 生成 Kiro MCP 配置
551
- createMcpConfigAt(path.join(cwd, '.kiro', 'settings', 'mcp.json'));
564
+ createMcpConfigAt(path.join(cwd, '.kiro', 'settings', 'mcp.json'), apiUrl);
552
565
  // 2. 生成 Kiro Agent 规则
553
566
  const kiroRulesDir = path.join(cwd, '.kiro', 'rules');
554
567
  if (!fs.existsSync(kiroRulesDir)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ppdocs/mcp",
3
- "version": "3.1.6",
3
+ "version": "3.1.8",
4
4
  "description": "ppdocs MCP Server - Knowledge Graph for Claude",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",