fa-mcp-sdk 0.2.203 → 0.2.206

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
@@ -142,12 +142,12 @@ const removeIfExists = async (targetPath, relPath, options = {}) => {
142
142
  finalOptions = { ...finalOptions, recursive: true };
143
143
  }
144
144
  } catch {
145
- // lstat упадёт, если файла/папки нет это ок, просто пойдем в rm с теми же опциями
145
+ // lstat will crash if there is no file/folder that's ok, just go to rm with the same options
146
146
  }
147
147
 
148
148
  await fs.rm(fullPath, finalOptions);
149
149
  } catch {
150
- // игнорируем любые ошибки удаления
150
+ // ignore any deletion errors
151
151
  }
152
152
  };
153
153
 
@@ -835,7 +835,7 @@ certificate's public and private keys`,
835
835
  async replaceTemplateParameters (config) {
836
836
  const targetPath = config.projectAbsPath;
837
837
  const files = await this.getAllFiles(targetPath, ALLOWED_FILES);
838
- const importRe = /'[^']+\/core\/index.js'/;
838
+ const importRe = /'[^']+\/core\/index.js'/ig;
839
839
  for (const filePath of files) {
840
840
  let content = await fs.readFile(filePath, 'utf8');
841
841
  let modified = false;
@@ -0,0 +1,100 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * ESLint Auto-Fix Hook for Claude Code
5
+ * Automatically formats JS/TS files after Write/Edit operations
6
+ */
7
+
8
+ const fs = require('fs');
9
+ const path = require('path');
10
+ const { execSync } = require('child_process');
11
+
12
+ const LOG_FILE = path.join(__dirname, 'log.log');
13
+ const IS_LOG = process.env.CLAUDE_HOOK_LOG === 'true';
14
+
15
+ function log (message) {
16
+ if (IS_LOG) {
17
+ const timestamp = new Date().toISOString();
18
+ const line = `[${timestamp}] ${message}\n`;
19
+ fs.appendFileSync(LOG_FILE, line);
20
+ }
21
+ }
22
+
23
+ function main () {
24
+ let input = '';
25
+
26
+ try {
27
+ // Read JSON input from stdin
28
+ input = fs.readFileSync(0, 'utf-8');
29
+ log(`Input received:\n====\n${input.substring(0, 200)}...\n====\n`);
30
+
31
+ const data = JSON.parse(input);
32
+ const filePath = data?.tool_input?.file_path;
33
+
34
+ if (!filePath) {
35
+ log('No file_path found in input');
36
+ process.exit(0);
37
+ }
38
+
39
+ log(`File path: ${filePath}`);
40
+
41
+ // Check if file extension is .js or .ts
42
+ if (!/\.(js|ts)$/.test(filePath)) {
43
+ log(`Skipping non-JS/TS file: ${filePath}`);
44
+ process.exit(0);
45
+ }
46
+
47
+ // Exclude files in node_modules, dist, coverage, etc.
48
+ const excludePatterns = [
49
+ /node_modules/,
50
+ /[/\\]dist[/\\]/,
51
+ /[/\\]coverage[/\\]/,
52
+ /\.d\.ts$/,
53
+ ];
54
+
55
+ for (const pattern of excludePatterns) {
56
+ if (pattern.test(filePath)) {
57
+ log(`Skipping excluded path: ${filePath}`);
58
+ process.exit(0);
59
+ }
60
+ }
61
+
62
+ // Get project directory from environment
63
+ const projectDir = process.env.CLAUDE_PROJECT_DIR;
64
+
65
+ if (!projectDir) {
66
+ log('CLAUDE_PROJECT_DIR not set');
67
+ process.exit(0);
68
+ }
69
+
70
+ log(`Project dir: ${projectDir}`);
71
+
72
+ // Change to project directory
73
+ process.chdir(projectDir);
74
+
75
+ // Run eslint --fix on the file
76
+ log(`Running ESLint on: ${filePath}`);
77
+
78
+ try {
79
+ const output = execSync(`npx eslint --fix "${filePath}"`, {
80
+ encoding: 'utf-8',
81
+ stdio: ['pipe', 'pipe', 'pipe'],
82
+ });
83
+ log(`ESLint output: ${output || '(empty)'}`);
84
+ console.log(`🔧 Formatted: ${filePath}`);
85
+ console.log('✅ Formatted successfully');
86
+ } catch (eslintError) {
87
+ // ESLint returns non-zero on warnings/errors but file is still fixed
88
+ log(`ESLint warnings/errors: ${eslintError.message}`);
89
+ console.log(`⚠️ ESLint warnings/errors (file still saved)`);
90
+ }
91
+
92
+ } catch (error) {
93
+ log(`Error: ${error.message}\nStack: ${error.stack}`);
94
+ }
95
+
96
+ // Always exit 0 to not block Claude's operations
97
+ process.exit(0);
98
+ }
99
+
100
+ main();
@@ -28,6 +28,19 @@
28
28
  "DISABLE_COST_WARNINGS": "0",
29
29
  "DISABLE_TELEMETRY": "0"
30
30
  },
31
+ "hooks": {
32
+ "PostToolUse": [
33
+ {
34
+ "matcher": "Write|Edit",
35
+ "hooks": [
36
+ {
37
+ "type": "command",
38
+ "command": "node .claude/hooks/eslint-fix.cjs"
39
+ }
40
+ ]
41
+ }
42
+ ]
43
+ },
31
44
  "hasCompletedOnboarding": true,
32
45
  "hasTrustDialogAccepted": true,
33
46
  "hasCompletedProjectOnboarding": true,
@@ -2,11 +2,15 @@
2
2
 
3
3
  ## Overview
4
4
 
5
- The FA-MCP-SDK is a comprehensive TypeScript framework for building Model Context Protocol (MCP) servers. This is the documentation index - read the relevant sections based on your task.
5
+ The FA-MCP-SDK is a comprehensive TypeScript framework for building Model Context
6
+ Protocol (MCP) servers. This is the documentation index - read the relevant
7
+ sections based on your task.
6
8
 
7
9
  ## Using with Claude Code
8
10
 
9
- This project includes a specialized agent `.claude/agents/fa-mcp-sdk.md` for Claude Code. The agent automatically reads relevant documentation sections and follows SDK patterns.
11
+ This project includes a specialized agent `.claude/agents/fa-mcp-sdk.md` for
12
+ Claude Code. The agent automatically reads relevant documentation sections and
13
+ follows SDK patterns.
10
14
 
11
15
  ### Example Prompts
12
16
 
@@ -39,7 +43,8 @@ Use the fa-mcp-sdk subagent to create an MCP server for managing TODO lists with
39
43
  - REST API for web client
40
44
  ```
41
45
 
42
- The agent will read the appropriate documentation files and implement the functionality following SDK conventions.
46
+ The agent will read the appropriate documentation files and implement the
47
+ functionality following SDK conventions.
43
48
 
44
49
  ## Quick Start
45
50
 
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.2.203",
4
+ "version": "0.2.206",
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",
@@ -1,45 +1,45 @@
1
1
  /**
2
- * Пример расширения конфигурации fa-mcp-sdk кастомным блоком настроек.
2
+ * An example of extending the fa-mcp-sdk configuration with a custom settings block.
3
3
  *
4
- * Этот файл демонстрирует, как добавить собственные настройки
5
- * (например, для проверки членства пользователя в AD-группе).
4
+ * This file demonstrates how to add your own settings
5
+ * (for example, to check the user's membership in an AEC group).
6
6
  */
7
7
 
8
8
  import { AppConfig } from '../../core/index.js';
9
9
 
10
10
  /**
11
- * Настройки проверки членства в AD-группе
11
+ * AD Group Membership Verification Settings
12
12
  */
13
13
  export interface IGroupAccessConfig {
14
14
  groupAccess: {
15
- /** AD-группа, членство в которой требуется для доступа */
15
+ /** AD Group whose membership is required for access */
16
16
  requiredGroup: string;
17
17
 
18
- /** Опционально: разрешить доступ без проверки группы (для отладки) */
18
+ /** Optional: Allow access without checking the group (for debugging) */
19
19
  bypassGroupCheck?: boolean;
20
20
 
21
- /** Опционально: кэшировать результат проверки (секунды) */
21
+ /** Optional: cache the result of the check (seconds) */
22
22
  cacheTtlSeconds?: number;
23
23
 
24
- /** Опционально: список групп с разными уровнями доступа */
24
+ /** Optional: List of groups with different access levels */
25
25
  accessLevels?: {
26
- /** Группа для полного доступа (read/write) */
26
+ /** Full access group (read/write) */
27
27
  fullAccess?: string;
28
- /** Группа только для чтения */
28
+ /** Read-only group */
29
29
  readOnly?: string;
30
- /** Группа администраторов */
30
+ /** Administrators group */
31
31
  admin?: string;
32
32
  };
33
33
  };
34
34
  }
35
35
 
36
36
  /**
37
- * Расширенный конфиг приложения с настройками проверки групп
37
+ * Extended app config with group checking settings
38
38
  */
39
39
  export interface CustomAppConfig extends AppConfig, IGroupAccessConfig {}
40
40
 
41
41
  // ========================================================================
42
- // ПРИМЕР YAML-КОНФИГУРАЦИИ (config/default.yaml)
42
+ // YAML CONFIGURATION EXAMPLE (config/default.yaml)
43
43
  // ========================================================================
44
44
  /*
45
45
  groupAccess:
@@ -53,18 +53,18 @@ groupAccess:
53
53
  */
54
54
 
55
55
  // ========================================================================
56
- // ПРИМЕР ИСПОЛЬЗОВАНИЯ В КОДЕ
56
+ // EXAMPLE OF USE IN CODE
57
57
  // ========================================================================
58
58
  /*
59
59
  import { appConfig } from '../core/index.js';
60
60
 
61
- // Типизированный доступ к кастомным настройкам
61
+ // TYPED ACCESS TO CUSTOM SETTINGS
62
62
  const config = appConfig as CustomAppConfig;
63
63
 
64
64
  const requiredGroup = config.groupAccess.requiredGroup;
65
65
  const shouldBypass = config.groupAccess.bypassGroupCheck;
66
66
 
67
- // Проверка уровня доступа из payload
67
+ // Checking the Access Level from Payload
68
68
  function getUserAccessLevel(payload: { user: string; groups?: string[] }): 'admin' | 'full' | 'readonly' | 'none' {
69
69
  const { accessLevels } = config.groupAccess;
70
70
  const userGroups = payload.groups || [];