fa-mcp-sdk 0.2.121 → 0.2.131
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 +44 -12
- package/cli-template/config/_local.yaml +40 -2
- package/cli-template/config/custom-environment-variables.yaml +5 -1
- package/cli-template/config/default.yaml +35 -5
- package/cli-template/fa-mcp-sdk-spec.md +620 -30
- package/cli-template/package.json +72 -73
- package/dist/core/_types_/TNtlm.d.ts +5 -0
- package/dist/core/_types_/TNtlm.d.ts.map +1 -0
- package/dist/core/_types_/TNtlm.js +2 -0
- package/dist/core/_types_/TNtlm.js.map +1 -0
- package/dist/core/_types_/config.d.ts +75 -0
- package/dist/core/_types_/config.d.ts.map +1 -0
- package/dist/core/_types_/config.js +2 -0
- package/dist/core/_types_/config.js.map +1 -0
- package/dist/core/_types_/types.d.ts +14 -9
- package/dist/core/_types_/types.d.ts.map +1 -1
- package/dist/core/{token/token-core.d.ts → auth/jwt-validation.d.ts} +2 -2
- package/dist/core/auth/jwt-validation.d.ts.map +1 -0
- package/dist/core/{token/token-core.js → auth/jwt-validation.js} +4 -4
- package/dist/core/auth/jwt-validation.js.map +1 -0
- package/dist/core/auth/middleware.d.ts +19 -0
- package/dist/core/auth/middleware.d.ts.map +1 -0
- package/dist/core/{token/token-auth.js → auth/middleware.js} +52 -55
- package/dist/core/auth/middleware.js.map +1 -0
- package/dist/core/auth/multi-auth.d.ts +23 -0
- package/dist/core/auth/multi-auth.d.ts.map +1 -0
- package/dist/core/auth/multi-auth.js +213 -0
- package/dist/core/auth/multi-auth.js.map +1 -0
- package/dist/core/auth/token-generator/html.d.ts.map +1 -0
- package/dist/core/{token/gen-token-app → auth/token-generator}/html.js +2 -2
- package/dist/core/auth/token-generator/html.js.map +1 -0
- package/dist/core/auth/token-generator/ntlm-auth-options.d.ts.map +1 -0
- package/dist/core/{token/gen-token-app → auth/token-generator}/ntlm-auth-options.js +1 -1
- package/dist/core/auth/token-generator/ntlm-auth-options.js.map +1 -0
- package/dist/core/auth/token-generator/ntlm-domain-config.d.ts.map +1 -0
- package/dist/core/auth/token-generator/ntlm-domain-config.js.map +1 -0
- package/dist/core/auth/token-generator/ntlm-integration.d.ts.map +1 -0
- package/dist/core/{token/gen-token-app → auth/token-generator}/ntlm-integration.js +4 -4
- package/dist/core/auth/token-generator/ntlm-integration.js.map +1 -0
- package/dist/core/auth/token-generator/ntlm-session-storage.d.ts.map +1 -0
- package/dist/core/{token/gen-token-app → auth/token-generator}/ntlm-session-storage.js +1 -1
- package/dist/core/auth/token-generator/ntlm-session-storage.js.map +1 -0
- package/dist/core/auth/token-generator/ntlm-templates.d.ts.map +1 -0
- package/dist/core/auth/token-generator/ntlm-templates.js.map +1 -0
- package/dist/core/{token/gen-token-app/gen-token-server.d.ts → auth/token-generator/server.d.ts} +1 -1
- package/dist/core/auth/token-generator/server.d.ts.map +1 -0
- package/dist/core/{token/gen-token-app/gen-token-server.js → auth/token-generator/server.js} +3 -3
- package/dist/core/auth/token-generator/server.js.map +1 -0
- package/dist/core/auth/types.d.ts +29 -0
- package/dist/core/auth/types.d.ts.map +1 -0
- package/dist/core/auth/types.js +5 -0
- package/dist/core/auth/types.js.map +1 -0
- package/dist/core/bootstrap/init-config.d.ts.map +1 -1
- package/dist/core/bootstrap/init-config.js +4 -0
- package/dist/core/bootstrap/init-config.js.map +1 -1
- package/dist/core/cache/cache.d.ts.map +1 -1
- package/dist/core/cache/cache.js +3 -2
- package/dist/core/cache/cache.js.map +1 -1
- package/dist/core/index.d.ts +6 -4
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +6 -3
- package/dist/core/index.js.map +1 -1
- package/dist/core/utils/utils.d.ts +6 -0
- package/dist/core/utils/utils.d.ts.map +1 -1
- package/dist/core/utils/utils.js +25 -0
- package/dist/core/utils/utils.js.map +1 -1
- package/dist/core/web/server-http.d.ts.map +1 -1
- package/dist/core/web/server-http.js +32 -18
- package/dist/core/web/server-http.js.map +1 -1
- package/package.json +2 -2
- package/cli-template/src/_types_/common.d.ts +0 -27
- package/cli-template/src/api/router.ts +0 -35
- package/cli-template/src/api/swagger.ts +0 -167
- package/cli-template/src/asset/favicon.svg +0 -3
- package/cli-template/src/custom-resources.ts +0 -11
- package/cli-template/src/prompts/agent-brief.ts +0 -8
- package/cli-template/src/prompts/agent-prompt.ts +0 -10
- package/cli-template/src/prompts/custom-prompts.ts +0 -12
- package/cli-template/src/start.ts +0 -71
- package/cli-template/src/tools/handle-tool-call.ts +0 -55
- package/cli-template/src/tools/tools.ts +0 -88
- package/cli-template/tests/jest-simple-reporter.js +0 -10
- package/cli-template/tests/mcp/sse/mcp-sse-client-handling.md +0 -111
- package/cli-template/tests/mcp/sse/test-sse-npm-package.js +0 -96
- package/cli-template/tests/mcp/test-cases.js +0 -143
- package/cli-template/tests/mcp/test-http.js +0 -63
- package/cli-template/tests/mcp/test-sse.js +0 -67
- package/cli-template/tests/mcp/test-stdio.js +0 -78
- package/cli-template/tests/utils.ts +0 -154
- package/dist/core/token/gen-token-app/gen-token-server.d.ts.map +0 -1
- package/dist/core/token/gen-token-app/gen-token-server.js.map +0 -1
- package/dist/core/token/gen-token-app/html.d.ts.map +0 -1
- package/dist/core/token/gen-token-app/html.js.map +0 -1
- package/dist/core/token/gen-token-app/ntlm-auth-options.d.ts.map +0 -1
- package/dist/core/token/gen-token-app/ntlm-auth-options.js.map +0 -1
- package/dist/core/token/gen-token-app/ntlm-domain-config.d.ts.map +0 -1
- package/dist/core/token/gen-token-app/ntlm-domain-config.js.map +0 -1
- package/dist/core/token/gen-token-app/ntlm-integration.d.ts.map +0 -1
- package/dist/core/token/gen-token-app/ntlm-integration.js.map +0 -1
- package/dist/core/token/gen-token-app/ntlm-session-storage.d.ts.map +0 -1
- package/dist/core/token/gen-token-app/ntlm-session-storage.js.map +0 -1
- package/dist/core/token/gen-token-app/ntlm-templates.d.ts.map +0 -1
- package/dist/core/token/gen-token-app/ntlm-templates.js.map +0 -1
- package/dist/core/token/i-token.d.ts +0 -13
- package/dist/core/token/i-token.d.ts.map +0 -1
- package/dist/core/token/i-token.js +0 -2
- package/dist/core/token/i-token.js.map +0 -1
- package/dist/core/token/token-auth.d.ts +0 -17
- package/dist/core/token/token-auth.d.ts.map +0 -1
- package/dist/core/token/token-auth.js.map +0 -1
- package/dist/core/token/token-core.d.ts.map +0 -1
- package/dist/core/token/token-core.js.map +0 -1
- /package/dist/core/{token/gen-token-app → auth/token-generator}/html.d.ts +0 -0
- /package/dist/core/{token/gen-token-app → auth/token-generator}/ntlm-auth-options.d.ts +0 -0
- /package/dist/core/{token/gen-token-app → auth/token-generator}/ntlm-domain-config.d.ts +0 -0
- /package/dist/core/{token/gen-token-app → auth/token-generator}/ntlm-domain-config.js +0 -0
- /package/dist/core/{token/gen-token-app → auth/token-generator}/ntlm-integration.d.ts +0 -0
- /package/dist/core/{token/gen-token-app → auth/token-generator}/ntlm-session-storage.d.ts +0 -0
- /package/dist/core/{token/gen-token-app → auth/token-generator}/ntlm-templates.d.ts +0 -0
- /package/dist/core/{token/gen-token-app → auth/token-generator}/ntlm-templates.js +0 -0
package/bin/fa-mcp.js
CHANGED
|
@@ -11,6 +11,7 @@ import yaml from 'js-yaml';
|
|
|
11
11
|
const __filename = fileURLToPath(import.meta.url);
|
|
12
12
|
const __dirname = path.dirname(__filename);
|
|
13
13
|
const PRINT_FILLED = true;
|
|
14
|
+
const PROJ_ROOT = path.join(__dirname, '..');
|
|
14
15
|
|
|
15
16
|
const hl = (v) => chalk.bgGreen.black(v);
|
|
16
17
|
const hly = (v) => chalk.bgYellow.black(v);
|
|
@@ -26,6 +27,8 @@ const printFilled = (paramName, paramValue) => {
|
|
|
26
27
|
}
|
|
27
28
|
};
|
|
28
29
|
|
|
30
|
+
const faMcpSdkVersion = require(path.join(PROJ_ROOT, 'package.json')).version;
|
|
31
|
+
|
|
29
32
|
const getAsk = () => {
|
|
30
33
|
const rl = readline.createInterface({
|
|
31
34
|
input: process.stdin,
|
|
@@ -100,9 +103,29 @@ const parseConfigFile = (filePath, content) => {
|
|
|
100
103
|
}
|
|
101
104
|
};
|
|
102
105
|
|
|
106
|
+
const removeIfExists = async (targetPath, relPath, options = {}) => {
|
|
107
|
+
const fullPath = path.join(targetPath, relPath);
|
|
108
|
+
|
|
109
|
+
try {
|
|
110
|
+
let finalOptions = { force: true, ...options };
|
|
111
|
+
|
|
112
|
+
try {
|
|
113
|
+
const stat = await fs.lstat(fullPath);
|
|
114
|
+
if (stat.isDirectory() && finalOptions.recursive === undefined) {
|
|
115
|
+
finalOptions = { ...finalOptions, recursive: true };
|
|
116
|
+
}
|
|
117
|
+
} catch {
|
|
118
|
+
// lstat упадёт, если файла/папки нет — это ок, просто пойдем в rm с теми же опциями
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
await fs.rm(fullPath, finalOptions);
|
|
122
|
+
} catch {
|
|
123
|
+
// игнорируем любые ошибки удаления
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
103
127
|
class MCPGenerator {
|
|
104
128
|
constructor () {
|
|
105
|
-
this.templateDir = path.join(__dirname, '..', 'cli-template');
|
|
106
129
|
this.lastConfigPath = path.join(process.cwd(), '~last-cli-config.json');
|
|
107
130
|
this.requiredParams = [
|
|
108
131
|
{
|
|
@@ -723,6 +746,7 @@ certificate's public and private keys`,
|
|
|
723
746
|
|
|
724
747
|
async handlePackageJson (content, config) {
|
|
725
748
|
try {
|
|
749
|
+
content = content.replace('"project.name"', '"{{project.name}}"');
|
|
726
750
|
// First replace all template parameters in the content string
|
|
727
751
|
let updatedContent = content;
|
|
728
752
|
for (const [param, value] of Object.entries(config)) {
|
|
@@ -752,7 +776,7 @@ certificate's public and private keys`,
|
|
|
752
776
|
delete packageJson.author;
|
|
753
777
|
}
|
|
754
778
|
}
|
|
755
|
-
|
|
779
|
+
packageJson.dependencies['fa-mcp-sdk'] = `^${faMcpSdkVersion}`;
|
|
756
780
|
return JSON.stringify(packageJson, null, 2);
|
|
757
781
|
} catch (error) {
|
|
758
782
|
throw new Error(`Error processing package.json: ${error.message}`);
|
|
@@ -805,6 +829,11 @@ certificate's public and private keys`,
|
|
|
805
829
|
modified = true;
|
|
806
830
|
}
|
|
807
831
|
}
|
|
832
|
+
content = content.replace(/'[^']+\/core\/index.js'/g, 'fa-mcp-sdk');
|
|
833
|
+
}
|
|
834
|
+
if (filePath.endsWith('test-sse-npm-package.js')) {
|
|
835
|
+
content = content.replace(/http:\/\/localhost:9876/g, `http://localhost:${config.port}`);
|
|
836
|
+
modified = true;
|
|
808
837
|
}
|
|
809
838
|
|
|
810
839
|
if (modified) {
|
|
@@ -856,8 +885,10 @@ certificate's public and private keys`,
|
|
|
856
885
|
async createProject (config) {
|
|
857
886
|
const targetPath = config.projectAbsPath;
|
|
858
887
|
// Copy template files
|
|
859
|
-
await this.copyDirectory(
|
|
860
|
-
await
|
|
888
|
+
await this.copyDirectory(path.join(PROJ_ROOT, 'cli-template'), targetPath);
|
|
889
|
+
await this.copyDirectory(path.join(PROJ_ROOT, 'src/template'), path.join(targetPath, 'src'));
|
|
890
|
+
await this.copyDirectory(path.join(PROJ_ROOT, 'src/tests'), path.join(targetPath, 'tests'));
|
|
891
|
+
await fs.copyFile(path.join(targetPath, '.env.example'), path.join(targetPath, '.env'));
|
|
861
892
|
|
|
862
893
|
// Rename mcp-template.com.conf if mcp.domain is provided
|
|
863
894
|
const mcpDomain = config['mcp.domain'];
|
|
@@ -917,15 +948,16 @@ certificate's public and private keys`,
|
|
|
917
948
|
console.log('⚠️ Warning: Could not create config/_local.yaml file:', error.message);
|
|
918
949
|
}
|
|
919
950
|
}
|
|
951
|
+
const pathsToRemove = [
|
|
952
|
+
{ rel: 'node_modules' },
|
|
953
|
+
{ rel: 'yarn.lock' },
|
|
954
|
+
{ rel: 'package-lock.json' },
|
|
955
|
+
{ rel: 'src/index-to-remove.ts' },
|
|
956
|
+
];
|
|
920
957
|
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
await fs.access(nodeModulesPath);
|
|
925
|
-
await fs.rm(nodeModulesPath, { recursive: true, force: true });
|
|
926
|
-
} catch {
|
|
927
|
-
// node_modules doesn't exist, which is fine
|
|
928
|
-
}
|
|
958
|
+
await Promise.all(
|
|
959
|
+
pathsToRemove.map(({ rel, options }) => removeIfExists(targetPath, rel, options)),
|
|
960
|
+
);
|
|
929
961
|
}
|
|
930
962
|
|
|
931
963
|
async run () {
|
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
# Copy this file to local.yaml and update with your database credentials
|
|
2
2
|
# local.yaml is gitignored and won't be committed
|
|
3
3
|
---
|
|
4
|
+
#ad:
|
|
5
|
+
# domains:
|
|
6
|
+
# MYDOMAIN:
|
|
7
|
+
# default: true
|
|
8
|
+
# controllers:
|
|
9
|
+
# - 'ldap://c1.corp.com'
|
|
10
|
+
# - 'ldap://c2.corp.com'
|
|
11
|
+
# username: '***'
|
|
12
|
+
# password: '***'
|
|
13
|
+
|
|
4
14
|
# --------------------------------------------------
|
|
5
15
|
# CACHING Reduces API calls by caching responses
|
|
6
16
|
# --------------------------------------------------
|
|
@@ -65,12 +75,40 @@ webServer:
|
|
|
65
75
|
port: {{port}}
|
|
66
76
|
# array of hosts that CORS skips
|
|
67
77
|
originHosts: ['localhost', '0.0.0.0']
|
|
78
|
+
# Authentication is configured here only when accessing the MCP server
|
|
79
|
+
# Authentication in services that enable tools, resources, and prompts
|
|
80
|
+
# is implemented more deeply. To do this, you need to use the information passed in HTTP headers
|
|
81
|
+
# You can also use a custom authorization function
|
|
68
82
|
auth:
|
|
69
83
|
enabled: {{webServer.auth.enabled}} # Enables/disables token authorization
|
|
70
|
-
#
|
|
84
|
+
# ========================================================================
|
|
85
|
+
# PERMANENT SERVER TOKENS
|
|
86
|
+
# Static tokens for server-to-server communication
|
|
87
|
+
# CPU cost: O(1) - fastest authentication method
|
|
88
|
+
#
|
|
89
|
+
# To enable this authentication, you need to set auth.enabled = true
|
|
90
|
+
# and set one token of at least 20 characters in length
|
|
91
|
+
# ========================================================================
|
|
71
92
|
permanentServerTokens: []
|
|
72
|
-
|
|
93
|
+
# ========================================================================
|
|
94
|
+
# JWT TOKEN WITH SYMMETRIC ENCRYPTION
|
|
95
|
+
# Custom JWT tokens with AES-256 encryption
|
|
96
|
+
# CPU cost: Medium - decryption + JSON parsing
|
|
97
|
+
#
|
|
98
|
+
# To enable this authentication, you need to set auth.enabled = true and set
|
|
99
|
+
# encryptKey to at least 20 characters
|
|
100
|
+
# ========================================================================
|
|
101
|
+
jwtToken:
|
|
73
102
|
# Symmetric encryption key to generate a token for this MCP
|
|
74
103
|
encryptKey: '{{webServer.auth.token.encryptKey}}'
|
|
75
104
|
# If webServer.auth.enabled and the parameter true, the service name and the service specified in the token will be checked
|
|
76
105
|
checkMCPName: {{webServer.auth.token.checkMCPName}}
|
|
106
|
+
# ========================================================================
|
|
107
|
+
# Basic Authentication - Base64 encoded username:password
|
|
108
|
+
# CPU cost: Medium - Base64 decoding + string comparison
|
|
109
|
+
# To enable this authentication, you need to set auth.enabled = true
|
|
110
|
+
# and set username and password to valid values
|
|
111
|
+
# ========================================================================
|
|
112
|
+
basic:
|
|
113
|
+
username: ''
|
|
114
|
+
password: '***'
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
cache:
|
|
2
2
|
ttlSeconds: CACHE_TTL_SECONDS
|
|
3
3
|
maxItems: CACHE_MAX_ITEMS
|
|
4
|
+
checkPeriod: CACHE_CHECK_PERIOD
|
|
4
5
|
|
|
5
6
|
db:
|
|
6
7
|
postgres:
|
|
@@ -33,6 +34,9 @@ webServer:
|
|
|
33
34
|
auth:
|
|
34
35
|
enabled: WS_AUTH_ENABLED
|
|
35
36
|
permanentServerTokens: WS_SERVER_TOKENS # comma separated list
|
|
36
|
-
|
|
37
|
+
jwtToken:
|
|
37
38
|
encryptKey: WS_TOKEN_ENCRYPT_KEY
|
|
38
39
|
checkMCPName: WS_CHECK_MC_NAME
|
|
40
|
+
basic:
|
|
41
|
+
username: WS_AUTH_BASIC_USERNAME
|
|
42
|
+
password: WS_AUTH_BASIC_PASSWORD
|
|
@@ -110,12 +110,42 @@ webServer:
|
|
|
110
110
|
port: {{port}}
|
|
111
111
|
# array of hosts that CORS skips
|
|
112
112
|
originHosts: ['localhost', '0.0.0.0']
|
|
113
|
+
# Authentication is configured here only when accessing the MCP server
|
|
114
|
+
# Authentication in services that enable tools, resources, and prompts
|
|
115
|
+
# is implemented more deeply. To do this, you need to use the information passed in HTTP headers
|
|
116
|
+
# You can also use a custom authorization function
|
|
113
117
|
auth:
|
|
114
|
-
enabled: false # Enables/disables
|
|
115
|
-
#
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
118
|
+
enabled: false # Enables/disables authorization
|
|
119
|
+
# ========================================================================
|
|
120
|
+
# PERMANENT SERVER TOKENS
|
|
121
|
+
# Static tokens for server-to-server communication
|
|
122
|
+
# CPU cost: O(1) - fastest authentication method
|
|
123
|
+
#
|
|
124
|
+
# To enable this authentication, you need to set auth.enabled = true
|
|
125
|
+
# and set one token of at least 20 characters in length
|
|
126
|
+
# ========================================================================
|
|
127
|
+
permanentServerTokens: [ ] # Add your server tokens here: ['token1', 'token2']
|
|
128
|
+
|
|
129
|
+
# ========================================================================
|
|
130
|
+
# JWT TOKEN WITH SYMMETRIC ENCRYPTION
|
|
131
|
+
# Custom JWT tokens with AES-256 encryption
|
|
132
|
+
# CPU cost: Medium - decryption + JSON parsing
|
|
133
|
+
#
|
|
134
|
+
# To enable this authentication, you need to set auth.enabled = true and set
|
|
135
|
+
# encryptKey to at least 20 characters
|
|
136
|
+
# ========================================================================
|
|
137
|
+
jwtToken:
|
|
138
|
+
# Symmetric encryption key to generate a token for this MCP (minimum 8 chars)
|
|
119
139
|
encryptKey: '***'
|
|
120
140
|
# If webServer.auth.enabled and the parameter true, the service name and the service specified in the token will be checked
|
|
121
141
|
checkMCPName: true
|
|
142
|
+
|
|
143
|
+
# ========================================================================
|
|
144
|
+
# Basic Authentication - Base64 encoded username:password
|
|
145
|
+
# CPU cost: Medium - Base64 decoding + string comparison
|
|
146
|
+
# To enable this authentication, you need to set auth.enabled = true
|
|
147
|
+
# and set username and password to valid values
|
|
148
|
+
# ========================================================================
|
|
149
|
+
basic:
|
|
150
|
+
username: ''
|
|
151
|
+
password: '***'
|