fa-mcp-sdk 0.2.38 → 0.2.78

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 (121) hide show
  1. package/bin/fa-mcp.js +781 -0
  2. package/cli-template/.editorconfig +13 -0
  3. package/cli-template/.env.example +29 -0
  4. package/cli-template/.envrc +3 -0
  5. package/cli-template/.run/== START ==.run.xml +14 -0
  6. package/cli-template/.run/TEST HTTP.run.xml +5 -0
  7. package/cli-template/.run/TEST SSE.run.xml +5 -0
  8. package/cli-template/.run/TEST STDIO.run.xml +5 -0
  9. package/cli-template/.run/TEST search.run.xml +11 -0
  10. package/cli-template/.run/cb.run.xml +12 -0
  11. package/cli-template/.run/ci.run.xml +12 -0
  12. package/cli-template/.run/kill-port 3030.run.xml +5 -0
  13. package/cli-template/.run/lint.run.xml +12 -0
  14. package/cli-template/.run/lint_fix.run.xml +12 -0
  15. package/cli-template/.run/reinstall.run.xml +12 -0
  16. package/cli-template/.run/remove-nul.js.run.xml +5 -0
  17. package/cli-template/LICENSE +21 -0
  18. package/cli-template/config/_local.yaml +64 -0
  19. package/cli-template/config/custom-environment-variables.yaml +33 -0
  20. package/cli-template/config/default.yaml +101 -0
  21. package/cli-template/config/development.yaml +4 -0
  22. package/cli-template/config/production.yaml +4 -0
  23. package/cli-template/config/test.yaml +26 -0
  24. package/cli-template/deploy/.gitkeep +0 -0
  25. package/cli-template/deploy/config.example.yml +3 -0
  26. package/cli-template/deploy/mcp-template.com.conf +58 -0
  27. package/cli-template/deploy/pm2.config.js +30 -0
  28. package/cli-template/deploy/pm2reg.sh +49 -0
  29. package/cli-template/deploy/srv.sh +359 -0
  30. package/cli-template/deploy/srv.sh.readme.md +347 -0
  31. package/cli-template/eslint.config.js +139 -0
  32. package/cli-template/jest.config.js +30 -0
  33. package/cli-template/package.json +73 -0
  34. package/cli-template/scripts/kill-port.js +107 -0
  35. package/cli-template/scripts/npm/patch_node_modules.js +9 -0
  36. package/cli-template/scripts/npm/run.js +31 -0
  37. package/cli-template/scripts/npm/yarn-ci.ps1 +16 -0
  38. package/cli-template/scripts/npm/yarn-ci.sh +8 -0
  39. package/cli-template/scripts/npm/yarn-reinstall.ps1 +54 -0
  40. package/cli-template/scripts/npm/yarn-reinstall.sh +10 -0
  41. package/cli-template/scripts/pre-commit +58 -0
  42. package/cli-template/scripts/remove-nul.js +53 -0
  43. package/cli-template/src/_types_/common.d.ts +27 -0
  44. package/cli-template/src/api/router.ts +35 -0
  45. package/cli-template/src/api/swagger.ts +167 -0
  46. package/cli-template/src/asset/favicon.svg +4 -0
  47. package/cli-template/src/custom-resources.ts +11 -0
  48. package/cli-template/src/prompts/agent-brief.ts +8 -0
  49. package/cli-template/src/prompts/agent-prompt.ts +1 -0
  50. package/cli-template/src/prompts/custom-prompts.ts +12 -0
  51. package/cli-template/src/start.ts +84 -0
  52. package/cli-template/src/tools/handle-tool-call.ts +55 -0
  53. package/cli-template/src/tools/tools.ts +88 -0
  54. package/cli-template/tests/jest-simple-reporter.js +10 -0
  55. package/cli-template/tests/mcp/sse/mcp-sse-client-handling.md +111 -0
  56. package/cli-template/tests/mcp/sse/test-sse-npm-package.js +96 -0
  57. package/cli-template/tests/mcp/test-cases.js +143 -0
  58. package/cli-template/tests/mcp/test-http.js +63 -0
  59. package/cli-template/tests/mcp/test-sse.js +67 -0
  60. package/cli-template/tests/mcp/test-stdio.js +78 -0
  61. package/cli-template/tests/utils.ts +154 -0
  62. package/cli-template/tsconfig.json +48 -0
  63. package/cli-template/update.cjs +631 -0
  64. package/dist/core/_types_/active-directory-config.d.ts +24 -0
  65. package/dist/core/_types_/active-directory-config.d.ts.map +1 -0
  66. package/dist/core/_types_/active-directory-config.js +2 -0
  67. package/dist/core/_types_/active-directory-config.js.map +1 -0
  68. package/dist/core/bootstrap/init-config.d.ts.map +1 -1
  69. package/dist/core/bootstrap/init-config.js +14 -3
  70. package/dist/core/bootstrap/init-config.js.map +1 -1
  71. package/dist/core/bootstrap/startup-info.js +1 -1
  72. package/dist/core/bootstrap/startup-info.js.map +1 -1
  73. package/dist/core/index.d.ts +3 -2
  74. package/dist/core/index.d.ts.map +1 -1
  75. package/dist/core/index.js +5 -2
  76. package/dist/core/index.js.map +1 -1
  77. package/dist/core/init-mcp-server.js +1 -1
  78. package/dist/core/init-mcp-server.js.map +1 -1
  79. package/dist/core/token/gen-token-app/gen-token-server.d.ts.map +1 -1
  80. package/dist/core/token/gen-token-app/gen-token-server.js +85 -9
  81. package/dist/core/token/gen-token-app/gen-token-server.js.map +1 -1
  82. package/dist/core/token/gen-token-app/html.d.ts +8 -1
  83. package/dist/core/token/gen-token-app/html.d.ts.map +1 -1
  84. package/dist/core/token/gen-token-app/html.js +98 -2
  85. package/dist/core/token/gen-token-app/html.js.map +1 -1
  86. package/dist/core/token/gen-token-app/ntlm-auth-options.d.ts +4 -0
  87. package/dist/core/token/gen-token-app/ntlm-auth-options.d.ts.map +1 -0
  88. package/dist/core/token/gen-token-app/ntlm-auth-options.js +94 -0
  89. package/dist/core/token/gen-token-app/ntlm-auth-options.js.map +1 -0
  90. package/dist/core/token/gen-token-app/ntlm-domain-config.d.ts +16 -0
  91. package/dist/core/token/gen-token-app/ntlm-domain-config.d.ts.map +1 -0
  92. package/dist/core/token/gen-token-app/ntlm-domain-config.js +71 -0
  93. package/dist/core/token/gen-token-app/ntlm-domain-config.js.map +1 -0
  94. package/dist/core/token/gen-token-app/ntlm-integration.d.ts +3 -0
  95. package/dist/core/token/gen-token-app/ntlm-integration.d.ts.map +1 -0
  96. package/dist/core/token/gen-token-app/ntlm-integration.js +69 -0
  97. package/dist/core/token/gen-token-app/ntlm-integration.js.map +1 -0
  98. package/dist/core/token/gen-token-app/ntlm-session-storage.d.ts +16 -0
  99. package/dist/core/token/gen-token-app/ntlm-session-storage.d.ts.map +1 -0
  100. package/dist/core/token/gen-token-app/ntlm-session-storage.js +74 -0
  101. package/dist/core/token/gen-token-app/ntlm-session-storage.js.map +1 -0
  102. package/dist/core/token/gen-token-app/ntlm-templates.d.ts +21 -0
  103. package/dist/core/token/gen-token-app/ntlm-templates.d.ts.map +1 -0
  104. package/dist/core/token/gen-token-app/ntlm-templates.js +246 -0
  105. package/dist/core/token/gen-token-app/ntlm-templates.js.map +1 -0
  106. package/dist/core/token/{token.d.ts → token-auth.d.ts} +1 -1
  107. package/dist/core/token/token-auth.d.ts.map +1 -0
  108. package/dist/core/token/{token.js → token-auth.js} +4 -6
  109. package/dist/core/token/token-auth.js.map +1 -0
  110. package/dist/core/token/token-core.d.ts +5 -1
  111. package/dist/core/token/token-core.d.ts.map +1 -1
  112. package/dist/core/token/token-core.js +13 -3
  113. package/dist/core/token/token-core.js.map +1 -1
  114. package/dist/core/web/about-page/render.d.ts.map +1 -1
  115. package/dist/core/web/about-page/render.js +26 -3
  116. package/dist/core/web/about-page/render.js.map +1 -1
  117. package/dist/core/web/server-http.js +1 -1
  118. package/dist/core/web/server-http.js.map +1 -1
  119. package/package.json +10 -3
  120. package/dist/core/token/token.d.ts.map +0 -1
  121. package/dist/core/token/token.js.map +0 -1
@@ -0,0 +1,139 @@
1
+ import tsParser from '@typescript-eslint/parser';
2
+ import tsPlugin from '@typescript-eslint/eslint-plugin';
3
+ import importPlugin from 'eslint-plugin-import';
4
+ import unusedImports from 'eslint-plugin-unused-imports';
5
+
6
+ export default [
7
+ {
8
+ files: ['**/*.ts'],
9
+ languageOptions: {
10
+ parser: tsParser,
11
+ parserOptions: {
12
+ ecmaVersion: 'latest',
13
+ sourceType: 'module',
14
+ project: './tsconfig.json',
15
+ },
16
+ globals: {
17
+ console: 'readonly',
18
+ process: 'readonly',
19
+ Buffer: 'readonly',
20
+ __dirname: 'readonly',
21
+ __filename: 'readonly',
22
+ },
23
+ },
24
+ plugins: {
25
+ '@typescript-eslint': tsPlugin,
26
+ 'import': importPlugin,
27
+ 'unused-imports': unusedImports,
28
+ },
29
+ rules: {
30
+ ...tsPlugin.configs.recommended.rules,
31
+ '@typescript-eslint/ban-ts-comment': 'off',
32
+ '@typescript-eslint/no-unused-vars': 'off',
33
+ '@typescript-eslint/no-unsafe-function-type': 'off',
34
+ 'unused-imports/no-unused-imports': 'error',
35
+ 'unused-imports/no-unused-vars': ['warn', {
36
+ 'argsIgnorePattern': '^_',
37
+ 'varsIgnorePattern': '^_',
38
+ 'caughtErrorsIgnorePattern': '^_',
39
+ 'ignoreRestSiblings': true
40
+ }],
41
+ '@typescript-eslint/no-explicit-any': 'off',
42
+ '@typescript-eslint/no-unsafe-member-access': 'off',
43
+ 'import/no-default-export': 'error',
44
+ 'import/extensions': ['error', 'always', {
45
+ 'ts': 'never',
46
+ 'js': 'always',
47
+ 'pattern': {
48
+ '**/*.ts': 'always'
49
+ },
50
+ 'ignorePackages': true
51
+ }],
52
+ // Formatting rules
53
+ 'semi': ['error', 'always'],
54
+ 'quotes': ['error', 'single', { 'avoidEscape': true }],
55
+ 'space-before-function-paren': ['error', {
56
+ 'anonymous': 'always',
57
+ 'named': 'always',
58
+ 'asyncArrow': 'always'
59
+ }],
60
+ 'object-curly-spacing': ['error', 'always'],
61
+ 'curly': ['error', 'all'],
62
+ 'eol-last': ['error', 'always'],
63
+ },
64
+ },
65
+ {
66
+ files: ['**/*.js'],
67
+ languageOptions: {
68
+ ecmaVersion: 'latest',
69
+ sourceType: 'module',
70
+ globals: {
71
+ console: 'readonly',
72
+ process: 'readonly',
73
+ Buffer: 'readonly',
74
+ __dirname: 'readonly',
75
+ __filename: 'readonly',
76
+ },
77
+ },
78
+ plugins: {
79
+ 'import': importPlugin,
80
+ },
81
+ rules: {
82
+ 'import/no-default-export': 'off',
83
+ // Formatting rules
84
+ 'semi': ['error', 'always'],
85
+ 'quotes': ['error', 'single', { 'avoidEscape': true }],
86
+ 'space-before-function-paren': ['error', {
87
+ 'anonymous': 'always',
88
+ 'named': 'always',
89
+ 'asyncArrow': 'always'
90
+ }],
91
+ 'object-curly-spacing': ['error', 'always'],
92
+ 'curly': ['error', 'all'],
93
+ 'eol-last': ['error', 'always'],
94
+ },
95
+ },
96
+ {
97
+ files: ['src/index.ts'],
98
+ rules: {
99
+ 'import/no-default-export': 'off',
100
+ },
101
+ },
102
+ {
103
+ files: ['**/*.test.ts', '**/*.spec.ts'],
104
+ languageOptions: {
105
+ globals: {
106
+ jest: 'readonly',
107
+ describe: 'readonly',
108
+ it: 'readonly',
109
+ expect: 'readonly',
110
+ beforeEach: 'readonly',
111
+ afterEach: 'readonly',
112
+ beforeAll: 'readonly',
113
+ afterAll: 'readonly',
114
+ },
115
+ },
116
+ rules: {
117
+ '@typescript-eslint/no-explicit-any': 'off',
118
+ '@typescript-eslint/no-unsafe-assignment': 'off',
119
+ '@typescript-eslint/no-unsafe-member-access': 'off',
120
+ '@typescript-eslint/no-unsafe-call': 'off',
121
+ },
122
+ },
123
+ {
124
+ ignores: [
125
+ '.claude/',
126
+ '.idea/',
127
+ '.run/',
128
+ '_misc/',
129
+ '_tmp/',
130
+ 'config/',
131
+ 'deploy/',
132
+ 'dist/',
133
+ 'doc/',
134
+ 'node_modules/',
135
+ 'coverage/',
136
+ '**/*.d.ts',
137
+ ],
138
+ },
139
+ ];
@@ -0,0 +1,30 @@
1
+ export default {
2
+ preset: 'ts-jest',
3
+ testEnvironment: 'node',
4
+ testMatch: ['**/tests/**/*.test.ts', '**/tests/**/*.spec.ts'],
5
+ collectCoverageFrom: [
6
+ 'src/**/*.ts',
7
+ '!src/**/*.d.ts',
8
+ '!src/index.ts'
9
+ ],
10
+ coverageDirectory: 'coverage',
11
+ coverageReporters: ['text', 'lcov'],
12
+ verbose: false,
13
+ silent: true,
14
+ reporters: ['<rootDir>/tests/jest-simple-reporter.js'],
15
+ moduleNameMapper: {
16
+ '^(\\.{1,2}/.*)\\.js$': '$1'
17
+ },
18
+ transform: {
19
+ '^.+\\.ts$': ['ts-jest', {
20
+ useESM: true
21
+ }]
22
+ },
23
+ transformIgnorePatterns: [
24
+ 'node_modules/(?!(chalk|@modelcontextprotocol|af-.*)/)'
25
+ ],
26
+ extensionsToTreatAsEsm: ['.ts'],
27
+ forceExit: true,
28
+ detectOpenHandles: true,
29
+ testTimeout: 10000
30
+ };
@@ -0,0 +1,73 @@
1
+ {
2
+ "name": "{{project.name}}",
3
+ "productName": "{{project.productName}}",
4
+ "version": "0.0.1",
5
+ "description": "{{project.description}}",
6
+ "type": "module",
7
+ "main": "dist/core/index.js",
8
+ "engines": {
9
+ "node": ">=20.0.0"
10
+ },
11
+ "scripts": {
12
+ "start": "node dist/src/start.js",
13
+ "build": "tsc",
14
+ "clean": "rimraf dist",
15
+ "cb": "npm run clean && npm run build",
16
+ "ci": "node --no-deprecation ./scripts/npm/run.js",
17
+ "reinstall": "node --no-deprecation ./scripts/npm/run.js reinstall",
18
+ "typecheck": "tsc --noEmit",
19
+ "lint": "eslint .",
20
+ "lint:fix": "eslint --fix .",
21
+ "generate-token": "node node_modules/fa-mcp-sdk/dist/core/token/gen-token-app/gen-token-server.js",
22
+ "dead:exports": "ts-prune",
23
+ "dead:files": "knip",
24
+ "postinstall": "node scripts/npm/patch_node_modules.js",
25
+ "consul:unreg": "node node_modules/fa-mcp-sdk/dist/core/consul/deregister.js",
26
+ "test": "jest",
27
+ "test:mcp": "node scripts/test-mcp-tools.js",
28
+ "test:mcp-http": "node tests/mcp/test-http.js",
29
+ "test:mcp-sse": "node tests/mcp/test-sse.js",
30
+ "test:mcp-stdio": "node tests/mcp/test-stdio.js"
31
+ },
32
+ "keywords": [
33
+ "mcp",
34
+ "model-context-protocol",
35
+ "typescript",
36
+ "template",
37
+ "ai",
38
+ "prompts",
39
+ "tools",
40
+ "resources"
41
+ ],
42
+ "author": {
43
+ "name": "{{author.name}}",
44
+ "email": "{{author.email}}"
45
+ },
46
+ "license": "MIT",
47
+ "dependencies": {
48
+ "@modelcontextprotocol/sdk": "^1.22.0",
49
+ "dotenv": "^17.2.3",
50
+ "fa-mcp-sdk": "^0.2.64",
51
+ "swagger-jsdoc": "^6.2.8",
52
+ "swagger-ui-express": "^5.0.1"
53
+ },
54
+ "devDependencies": {
55
+ "@types/express": "^5.0.5",
56
+ "@types/jest": "^30.0.0",
57
+ "@types/node": "^24.10.1",
58
+ "@types/swagger-jsdoc": "^6.0.4",
59
+ "@types/swagger-ui-express": "^4.1.8",
60
+ "cross-env": "^10.1.0",
61
+ "eslint-config-at-25": "^25.9.6",
62
+ "jest": "^30.2.0",
63
+ "rimraf": "^6.1.0",
64
+ "ts-jest": "^29.4.5",
65
+ "tsx": "^4.20.6",
66
+ "typescript": "^5.9.3"
67
+ },
68
+ "repository": {
69
+ "type": "git",
70
+ "url": "git+https://{{git-base-url}}/{{project.name}}.git"
71
+ },
72
+ "private": true
73
+ }
@@ -0,0 +1,107 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Kill process on specified port (cross-platform)
4
+ * Usage: node scripts/kill-port.js [port_number]
5
+ */
6
+
7
+ import { exec } from 'child_process';
8
+ import { promisify } from 'util';
9
+
10
+ const execAsync = promisify(exec);
11
+ const port = process.argv[2];
12
+
13
+ if (!port) {
14
+ console.error('Usage: node scripts/kill-port.js [port_number]');
15
+ process.exit(1);
16
+ }
17
+
18
+ async function killProcessOnPort (portNumber) {
19
+ const isWindows = process.platform === 'win32';
20
+
21
+ console.log(`Searching for process on port ${portNumber}...`);
22
+
23
+ try {
24
+ if (isWindows) {
25
+ // Windows: netstat + taskkill
26
+ let stdout;
27
+ try {
28
+ const result = await execAsync(`netstat -ano | findstr :${portNumber}`);
29
+ stdout = result.stdout;
30
+ } catch (error) {
31
+ // findstr returns error when no matches found
32
+ console.log(`No process found on port ${portNumber}`);
33
+ return;
34
+ }
35
+
36
+ if (!stdout || !stdout.trim()) {
37
+ console.log(`No process found on port ${portNumber}`);
38
+ return;
39
+ }
40
+
41
+ // Parse PIDs from netstat output
42
+ const lines = stdout.trim().split('\n');
43
+ const pids = new Set();
44
+
45
+ for (const line of lines) {
46
+ const parts = line.trim().split(/\s+/);
47
+ const pid = parts[parts.length - 1];
48
+ if (pid && pid !== '0' && !isNaN(pid)) {
49
+ pids.add(pid);
50
+ }
51
+ }
52
+
53
+ if (pids.size === 0) {
54
+ console.log(`No process found on port ${portNumber}`);
55
+ return;
56
+ }
57
+
58
+ // Kill all PIDs
59
+ for (const pid of pids) {
60
+ try {
61
+ console.log(`Found process PID: ${pid}`);
62
+ await execAsync(`taskkill /F /PID ${pid}`);
63
+ console.log(`Process ${pid} on port ${portNumber} killed`);
64
+ } catch (error) {
65
+ console.error(`Failed to kill process ${pid}:`, error.message);
66
+ }
67
+ }
68
+ } else {
69
+ // Unix-like: lsof + kill
70
+ try {
71
+ const { stdout } = await execAsync(`lsof -ti:${portNumber}`);
72
+
73
+ if (!stdout.trim()) {
74
+ console.log(`No process found on port ${portNumber}`);
75
+ return;
76
+ }
77
+
78
+ const pids = stdout.trim().split('\n').filter(pid => pid);
79
+
80
+ for (const pid of pids) {
81
+ try {
82
+ console.log(`Found process PID: ${pid}`);
83
+ await execAsync(`kill -9 ${pid}`);
84
+ console.log(`Process ${pid} on port ${portNumber} killed`);
85
+ } catch (error) {
86
+ console.error(`Failed to kill process ${pid}:`, error.message);
87
+ }
88
+ }
89
+ } catch (error) {
90
+ if (error.message.includes('No such file or directory')) {
91
+ console.error('Error: lsof command not found. Please install lsof.');
92
+ process.exit(1);
93
+ }
94
+ console.log(`No process found on port ${portNumber}`);
95
+ }
96
+ }
97
+ } catch (error) {
98
+ if (error.stdout && error.stdout.includes('')) {
99
+ console.log(`No process found on port ${portNumber}`);
100
+ } else {
101
+ console.error('Error:', error.message);
102
+ process.exit(1);
103
+ }
104
+ }
105
+ }
106
+
107
+ killProcessOnPort(port);
@@ -0,0 +1,9 @@
1
+ import fs from 'fs';
2
+ import path from 'path';
3
+
4
+ const virusFilePath = path.join(process.env.INIT_CWD || process.cwd(), 'node_modules/es5-ext/_postinstall.js');
5
+
6
+ if (fs.existsSync(virusFilePath)) {
7
+ console.log('Deleting file "es5-ext module _postinstall"');
8
+ fs.unlinkSync(virusFilePath);
9
+ }
@@ -0,0 +1,31 @@
1
+
2
+ import { spawn } from 'child_process';
3
+ import os from 'os';
4
+
5
+ function runScript (command, args) {
6
+ const process = spawn(command, args);
7
+
8
+ process.stdout.on('data', (data) => {
9
+ console.log(data.toString());
10
+ });
11
+
12
+ process.stderr.on('data', (data) => {
13
+ console.error(data.toString());
14
+ });
15
+
16
+ process.on('close', (code) => {
17
+ console.log(`${command} script is completed with code: ${code}`);
18
+ });
19
+ }
20
+
21
+ const platform = os.platform();
22
+
23
+ const scriptType = process.argv[2] === 'reinstall' ? 'reinstall' : 'ci';
24
+
25
+ const scriptsPath = `./scripts/npm/yarn-${scriptType}`;
26
+
27
+ if (platform === 'win32') {
28
+ runScript('powershell.exe', ['-ExecutionPolicy', 'Bypass', '-File', `${scriptsPath}.ps1`]);
29
+ } else {
30
+ runScript('bash', [`${scriptsPath}.sh`]);
31
+ }
@@ -0,0 +1,16 @@
1
+ Write-Host "Removing node_modules. It may take a while..."
2
+
3
+ # Ignore errors, equivalent to set +e
4
+ $ErrorActionPreference = "Continue"
5
+
6
+ # Remove node_modules directory
7
+ Remove-Item -Recurse -Force -ErrorAction SilentlyContinue node_modules
8
+
9
+ Write-Host "Do yarn ci..."
10
+
11
+ yarn install --frozen-lockfile
12
+
13
+ # If argument is passed, wait for key press
14
+ if ($args.Count -gt 0) {
15
+ Read-Host "Press Enter to resume ..."
16
+ }
@@ -0,0 +1,8 @@
1
+ #!/bin/bash
2
+
3
+ set +e
4
+ rm -rf node_modules/
5
+ yarn install --frozen-lockfile
6
+ if [[ -n "$1" ]]; then
7
+ read -p "Press any key to resume ..."
8
+ fi;
@@ -0,0 +1,54 @@
1
+ # Set English language for errors
2
+ [System.Threading.Thread]::CurrentThread.CurrentUICulture = 'en-US'
3
+ [System.Threading.Thread]::CurrentThread.CurrentCulture = 'en-US'
4
+ $OutputEncoding = [Console]::OutputEncoding = [Text.Encoding]::UTF8
5
+ chcp 65001 > $null
6
+
7
+ # Get processes that use node_modules
8
+ $processes = Get-Process | Where-Object {$_.Path -like "*node_modules*"}
9
+
10
+ # Check if there are such processes
11
+ if ($processes.Count -gt 0) {
12
+ Write-Host "Found the following processes holding files in node_modules folder:" -ForegroundColor Yellow
13
+
14
+ # Display information about each process
15
+ $processes | ForEach-Object {
16
+ Write-Host "- $($_.ProcessName) (ID: $($_.Id))" -ForegroundColor Cyan
17
+ }
18
+
19
+ Write-Host "`nTerminating processes..." -ForegroundColor Yellow
20
+
21
+ # Terminate processes
22
+ $processes | ForEach-Object {
23
+ Stop-Process -Id $_.Id -Force
24
+ Write-Host "Process $($_.ProcessName) (ID: $($_.Id)) terminated" -ForegroundColor Green
25
+ }
26
+ }
27
+
28
+ Write-Host "Removing node_modules. It may take a while..."
29
+
30
+ # Ignore errors, equivalent to set +e
31
+ #$ErrorActionPreference = "Continue"
32
+
33
+ # Remove node_modules directory
34
+ Remove-Item -Recurse -Force -ErrorAction SilentlyContinue node_modules
35
+
36
+
37
+ # Check if directory still exists
38
+ if (Test-Path -Path "node_modules") {
39
+ Write-Host "ERROR: Failed to completely remove node_modules folder!" -ForegroundColor Red
40
+ }
41
+
42
+ # Remove yarn.lock file if it exists
43
+ if (Test-Path -Path "yarn.lock") {
44
+ Remove-Item -Path "yarn.lock" -Force
45
+ }
46
+
47
+ Write-Host "Do yarn install..."
48
+
49
+ yarn install
50
+
51
+ # If argument is passed, wait for key press
52
+ if ($args.Count -gt 0) {
53
+ Read-Host "Press Enter to resume ..."
54
+ }
@@ -0,0 +1,10 @@
1
+ #!/bin/bash
2
+
3
+ set +e
4
+ rm -rf node_modules/
5
+ if [ -f "yarn.lock" ]; then rm yarn.lock; fi;
6
+ yarn install
7
+ if [[ -n "$1" ]]; then
8
+ read -p "Press any key to resume ..."
9
+ fi;
10
+
@@ -0,0 +1,58 @@
1
+ #!/bin/bash
2
+
3
+ #=============== Version update before commit: minor + 1 ==========================
4
+
5
+ #File: .git/hooks/pre-commit
6
+ # Version 2020-08-22
7
+
8
+ c='\033[0;35m'
9
+ y='\033[0;33m'
10
+ c0='\033[0;0m'
11
+ g='\033[0;32m'
12
+ set -e
13
+ echo -e "$c**** [pre-commit hook] ****$c0"
14
+
15
+
16
+ update_version(){
17
+ old_version=`cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]'`
18
+ echo -e "$c**** Old version is $g$old_version$c ****$c0"
19
+ version_split=( ${old_version//./ } )
20
+ major=${version_split[0]:-0}
21
+ minor=${version_split[1]:-0}
22
+ patch=${version_split[2]:-0}
23
+ let "patch=patch+1"
24
+ new_version="${major}.${minor}.${patch}"
25
+
26
+ repo=`cat package.json | grep name | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]'`
27
+ echo -e "$c**** Bumping version of $g$repo$c: $y$old_version$c -> $g$new_version$c ****$c0"
28
+ sed -i -e "0,/$old_version/s/$old_version/$new_version/" package.json
29
+ echo -e "$g"
30
+ npm version 2>&1 | head -2 | tail -1
31
+ echo -e "$c0"
32
+ }
33
+
34
+ branch_name=$(git symbolic-ref --short HEAD)
35
+ retcode=$?
36
+
37
+ if [[ $retcode -ne 0 ]] ; then
38
+ echo -e "$y**** Version will not be bumped since retcode is not equals 0 ****$c0"
39
+ exit 0
40
+ fi
41
+
42
+ if [[ $branch_name == *"_nap" ]] ; then
43
+ echo -e "$y**** Version will not be bumped since branch name ends with '_nap'. ****$c0"
44
+ exit 0
45
+ fi
46
+
47
+ if [[ $branch_name == *"_local" ]] ; then
48
+ echo -e "$y**** Version will not be bumped since branch name ends with '_local'. ****$c0"
49
+ exit 0
50
+ fi
51
+
52
+ if [[ "$DONT_BUMP_VERSION" -eq "1" ]] ; then
53
+ echo -e "$y**** Version will not be bumped since variable DONT_BUMP_VERSION is set. ****$c0"
54
+ exit 0
55
+ fi
56
+
57
+ update_version
58
+ git add package.json
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Script to remove 'nul' file that accidentally gets created on Windows
5
+ * This file is created when using 2>nul redirection in Windows commands
6
+ */
7
+
8
+ import fs from 'fs';
9
+ import path from 'path';
10
+ import { fileURLToPath } from 'url';
11
+ import { dirname } from 'path';
12
+
13
+ const __filename = fileURLToPath(import.meta.url);
14
+ const __dirname = dirname(__filename);
15
+
16
+ // Get project root (parent of scripts directory)
17
+ const projectRoot = path.resolve(__dirname, '..');
18
+
19
+ // File to remove
20
+ const nulFile = path.join(projectRoot, 'nul');
21
+
22
+ // Check if file exists and remove it
23
+ if (fs.existsSync(nulFile)) {
24
+ try {
25
+ fs.unlinkSync(nulFile);
26
+ console.log('✅ Removed "nul" file from project root');
27
+ } catch (error) {
28
+ console.error('❌ Error removing "nul" file:', error.message);
29
+ process.exit(1);
30
+ }
31
+ } else {
32
+ console.log('ℹ️ No "nul" file found in project root');
33
+ }
34
+
35
+ // Also check for other common accidental files on Windows
36
+ const accidentalFiles = ['nul', 'NUL', 'con', 'CON', 'aux', 'AUX', 'prn', 'PRN'];
37
+
38
+ accidentalFiles.forEach(fileName => {
39
+ const filePath = path.join(projectRoot, fileName);
40
+ if (fs.existsSync(filePath)) {
41
+ try {
42
+ const stats = fs.statSync(filePath);
43
+ if (stats.isFile()) {
44
+ fs.unlinkSync(filePath);
45
+ console.log(`✅ Removed "${fileName}" file from project root`);
46
+ }
47
+ } catch (error) {
48
+ console.error(`⚠️ Could not remove "${fileName}":`, error.message);
49
+ }
50
+ }
51
+ });
52
+
53
+ console.log('🎯 Cleanup completed');
@@ -0,0 +1,27 @@
1
+ export interface ISearchParams {
2
+ query: string; // Search query string
3
+ limit?: number; // Maximum number of results (default: 20)
4
+ threshold?: number; // Minimum similarity threshold (0-1)
5
+ }
6
+
7
+ export interface ISearchResultRow {
8
+ similarity_score: number;
9
+ word_similarity_score: number;
10
+ final_score: number;
11
+ similarity: number; // mapped from final_score
12
+
13
+ [prop: string]: number | string;
14
+ }
15
+
16
+ export interface ISearchResultRow {
17
+ similarity_score: number;
18
+ word_similarity_score: number;
19
+ final_score: number;
20
+
21
+ [prop: string]: number | string;
22
+ }
23
+
24
+ export type ISearchResult = {
25
+ similarity: number; // mapped from final_score
26
+ [prop: string]: number | string | undefined;
27
+ }[]
@@ -0,0 +1,35 @@
1
+ import { Router, Request, Response } from 'express';
2
+ import { logger, authTokenMW, IEndpointsOn404 } from 'fa-mcp-sdk';
3
+
4
+ export const apiRouter: Router | null = Router();
5
+
6
+ /**
7
+ * Template for API routes
8
+ * Modify this file to implement your specific API endpoints
9
+ */
10
+
11
+ // Example protected endpoint using auth middleware
12
+ apiRouter.get('/example', authTokenMW, async (req: Request, res: Response) => {
13
+ try {
14
+ logger.info('Example endpoint called');
15
+
16
+ res.json({
17
+ success: true,
18
+ message: 'This is a template endpoint',
19
+ data: {
20
+ timestamp: new Date().toISOString(),
21
+ },
22
+ });
23
+ } catch (error) {
24
+ logger.error('Error in example endpoint:', error);
25
+ res.status(500).json({
26
+ success: false,
27
+ error: error instanceof Error ? error.message : 'Unknown error',
28
+ });
29
+ }
30
+ });
31
+
32
+ export const endpointsOn404: IEndpointsOn404 = {
33
+ myEndpoints1: ['/my-endpoint-1', '/my-endpoint-2'],
34
+ myEndpoint3: '/my-endpoint-3',
35
+ };