fa-mcp-sdk 0.4.25 → 0.4.27

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/bin/fa-mcp.js CHANGED
@@ -154,7 +154,7 @@ const removeIfExists = async (targetPath, relPath, options = {}) => {
154
154
 
155
155
  class MCPGenerator {
156
156
  constructor () {
157
- this.lastConfigPath = path.join(process.cwd(), '~last-cli-config.json');
157
+ this.lastConfigPath = null;
158
158
  this.requiredParams = [
159
159
  {
160
160
  name: 'project.name',
@@ -348,7 +348,7 @@ certificate's public and private keys`,
348
348
  }
349
349
 
350
350
  createConfigProxy (config) {
351
- const { lastConfigPath } = this; // Capture this in closure
351
+ const self = this; // Capture this in closure
352
352
 
353
353
  return new Proxy(config, {
354
354
  set (target, prop, value, receiver) {
@@ -359,14 +359,35 @@ certificate's public and private keys`,
359
359
  }
360
360
  // Regular assignment behavior first
361
361
  const result = Reflect.set(target, prop, value, receiver);
362
- // Save to file asynchronously without blocking
363
- fs.writeFile(lastConfigPath, JSON.stringify(target, null, 2), 'utf8')
364
- .catch(error => console.warn(`⚠️ Warning: Could not save config to file ${lastConfigPath}:`, error.message));
362
+ // Save to file asynchronously without blocking — only if project path is known
363
+ const lastConfigPath = self.lastConfigPath;
364
+ if (lastConfigPath) {
365
+ fs.writeFile(lastConfigPath, JSON.stringify(target, null, 2), 'utf8')
366
+ .catch(error => console.warn(`⚠️ Warning: Could not save config to file ${lastConfigPath}:`, error.message));
367
+ }
365
368
  return result;
366
369
  },
367
370
  });
368
371
  }
369
372
 
373
+ async setLastConfigPath (projectAbsPath, config) {
374
+ const tp = path.resolve(projectAbsPath);
375
+ try {
376
+ await fs.mkdir(tp, { recursive: true });
377
+ } catch (error) {
378
+ console.warn(`⚠️ Warning: Could not create project directory ${tp}: ${error.message}`);
379
+ return;
380
+ }
381
+ this.lastConfigPath = path.join(tp, '~last-cli-config.json');
382
+ if (config) {
383
+ try {
384
+ await fs.writeFile(this.lastConfigPath, JSON.stringify(config, null, 2), 'utf8');
385
+ } catch (error) {
386
+ console.warn(`⚠️ Warning: Could not save config to file ${this.lastConfigPath}: ${error.message}`);
387
+ }
388
+ }
389
+ }
390
+
370
391
  async collectConfigData (config, isRetry = false) {
371
392
  const ask = getAsk();
372
393
  // Collect required parameters
@@ -682,13 +703,10 @@ certificate's public and private keys`,
682
703
  // Create proxy for automatic saving before starting data collection
683
704
  const configProxy = this.createConfigProxy(config);
684
705
 
685
- // Save initial state if there's any pre-loaded config
686
- if (Object.keys(config).length > 0) {
687
- try {
688
- await fs.writeFile(this.lastConfigPath, JSON.stringify(config, null, 2), 'utf8');
689
- } catch (error) {
690
- console.warn('⚠️ Warning: Could not save initial config to file:', error.message);
691
- }
706
+ // If project path is already known from preloaded config, set save target now
707
+ // so that subsequent proxy writes land in the new project folder.
708
+ if (config.projectAbsPath) {
709
+ await this.setLastConfigPath(config.projectAbsPath, config);
692
710
  }
693
711
 
694
712
  if (configProxy.NODE_ENV === 'development') {
@@ -747,6 +765,10 @@ certificate's public and private keys`,
747
765
  console.log('Creating directory recursively...');
748
766
  await fs.mkdir(tp, { recursive: true });
749
767
  }
768
+ // Make sure ~last-cli-config.json is saved into the new project folder
769
+ if (this.lastConfigPath !== path.join(tp, '~last-cli-config.json')) {
770
+ await this.setLastConfigPath(tp, config);
771
+ }
750
772
 
751
773
  const errMsg = `❌ Directory ${hl(tp)} not empty - cannot create project here. Use an empty directory or specify a different path.`;
752
774
 
@@ -50,7 +50,7 @@
50
50
  "dependencies": {
51
51
  "@modelcontextprotocol/sdk": "^1.29.0",
52
52
  "dotenv": "^17.4.1",
53
- "fa-mcp-sdk": "^0.4.25"
53
+ "fa-mcp-sdk": "^0.4.27"
54
54
  },
55
55
  "devDependencies": {
56
56
  "@types/express": "^5.0.6",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "fa-mcp-sdk",
3
3
  "productName": "FA MCP SDK",
4
- "version": "0.4.25",
4
+ "version": "0.4.27",
5
5
  "description": "Core infrastructure and templates for building Model Context Protocol (MCP) servers with TypeScript",
6
6
  "type": "module",
7
7
  "main": "dist/core/index.js",