@ppdocs/mcp 3.1.6 → 3.1.7

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 +20 -16
  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,13 @@ function createMcpConfigAt(mcpPath, autoCreatedTemplate) {
356
356
  }
357
357
  // Windows 需要 cmd /c 包装才能执行 npx
358
358
  const isWindows = process.platform === 'win32';
359
- const ppdocsServer = isWindows
360
- ? { command: 'cmd', args: ['/c', 'npx', '-y', '@ppdocs/mcp@latest'] }
361
- : { command: 'npx', args: ['-y', '@ppdocs/mcp@latest'] };
359
+ const ppdocsServer = {
360
+ command: isWindows ? 'cmd' : 'npx',
361
+ args: isWindows ? ['/c', 'npx', '-y', '@ppdocs/mcp@latest'] : ['-y', '@ppdocs/mcp@latest'],
362
+ env: {
363
+ "PPDOCS_API_URL": apiUrl
364
+ }
365
+ };
362
366
  mcpConfig.mcpServers = {
363
367
  ...(mcpConfig.mcpServers || {}),
364
368
  "ppdocs-kg": ppdocsServer,
@@ -372,8 +376,8 @@ function createMcpConfigAt(mcpPath, autoCreatedTemplate) {
372
376
  console.log(`✅ Configured MCP in ${mcpPath}`);
373
377
  }
374
378
  /** 创建 .mcp.json (手动配置备用) */
375
- function createMcpJson(cwd) {
376
- createMcpConfigAt(path.join(cwd, '.mcp.json'));
379
+ function createMcpJson(cwd, apiUrl) {
380
+ createMcpConfigAt(path.join(cwd, '.mcp.json'), apiUrl);
377
381
  }
378
382
  /** 递归复制目录 */
379
383
  function copyDirRecursive(src, dest) {
@@ -496,9 +500,9 @@ function generateAgentsMd(cwd) {
496
500
  }
497
501
  }
498
502
  /** 安装 Cursor 模板 */
499
- function installCursorTemplates(cwd) {
503
+ function installCursorTemplates(cwd, apiUrl) {
500
504
  // 1. 生成 Cursor MCP 配置
501
- createMcpConfigAt(path.join(cwd, '.cursor', 'mcp.json'));
505
+ createMcpConfigAt(path.join(cwd, '.cursor', 'mcp.json'), apiUrl);
502
506
  // 2. 生成 .cursorrules 提示词
503
507
  const srcRules = path.join(TEMPLATES_DIR, 'cursorrules.md');
504
508
  const destRules = path.join(cwd, '.cursorrules');
@@ -508,9 +512,9 @@ function installCursorTemplates(cwd) {
508
512
  }
509
513
  }
510
514
  /** 安装 Antigravity (Gemini IDE) 模板 */
511
- function installAntigravityTemplates(cwd) {
515
+ function installAntigravityTemplates(cwd, apiUrl) {
512
516
  // 1. 填充 .gemini/settings.json
513
- createMcpConfigAt(path.join(cwd, '.gemini', 'settings.json'));
517
+ createMcpConfigAt(path.join(cwd, '.gemini', 'settings.json'), apiUrl);
514
518
  // 2. 生成 AGENTS.md
515
519
  generateAgentsMd(cwd);
516
520
  // 3. 安装斜杠命令 → .agents/workflows/ (Antigravity 的 slash command 机制)
@@ -546,9 +550,9 @@ function installAntigravityTemplates(cwd) {
546
550
  }
547
551
  }
548
552
  /** 安装 Kiro 模板 */
549
- function installKiroTemplates(cwd) {
553
+ function installKiroTemplates(cwd, apiUrl) {
550
554
  // 1. 生成 Kiro MCP 配置
551
- createMcpConfigAt(path.join(cwd, '.kiro', 'settings', 'mcp.json'));
555
+ createMcpConfigAt(path.join(cwd, '.kiro', 'settings', 'mcp.json'), apiUrl);
552
556
  // 2. 生成 Kiro Agent 规则
553
557
  const kiroRulesDir = path.join(cwd, '.kiro', 'rules');
554
558
  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.7",
4
4
  "description": "ppdocs MCP Server - Knowledge Graph for Claude",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",