fa-mcp-sdk 0.4.76 → 0.4.77
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/README.md +319 -314
- package/bin/fa-mcp.js +85 -68
- package/cli-template/.claude/agents/javascript-pro.md +276 -276
- package/cli-template/.claude/settings.json +50 -50
- package/cli-template/.claude/skills/upgrade-guide/SKILL.md +2 -1
- package/cli-template/.oxfmtrc.json +41 -0
- package/cli-template/.oxlintrc.json +120 -0
- package/cli-template/CLAUDE.md +358 -355
- package/cli-template/FA-MCP-SDK-DOC/00-FA-MCP-SDK-index.md +132 -132
- package/cli-template/FA-MCP-SDK-DOC/01-getting-started.md +146 -146
- package/cli-template/FA-MCP-SDK-DOC/02-1-tools-and-api.md +431 -431
- package/cli-template/FA-MCP-SDK-DOC/02-2-prompts-and-resources.md +201 -201
- package/cli-template/FA-MCP-SDK-DOC/03-configuration.md +384 -384
- package/cli-template/FA-MCP-SDK-DOC/04-authentication.md +412 -412
- package/cli-template/FA-MCP-SDK-DOC/05-ad-authorization.md +196 -196
- package/cli-template/FA-MCP-SDK-DOC/06-utilities.md +163 -163
- package/cli-template/FA-MCP-SDK-DOC/07-testing-and-operations.md +127 -127
- package/cli-template/jest.config.js +27 -30
- package/cli-template/package.json +10 -5
- package/cli-template/prompt-example-new-MCP.md +101 -101
- package/cli-template/readme-docs/SKILLS.md +1 -1
- package/cli-template/tsconfig.json +58 -58
- package/cli-template/update.cjs +41 -38
- package/config/custom-environment-variables.yaml +63 -63
- package/config/development.yaml +4 -4
- package/config/production.yaml +4 -4
- package/config/test.yaml +26 -26
- package/dist/core/_types_/TNtlm.d.ts.map +1 -1
- package/dist/core/_types_/active-directory-config.d.ts.map +1 -1
- package/dist/core/_types_/config.d.ts.map +1 -1
- package/dist/core/_types_/types.d.ts.map +1 -1
- package/dist/core/ad/group-checker.d.ts.map +1 -1
- package/dist/core/ad/group-checker.js.map +1 -1
- package/dist/core/agent-tester/agent-tester-router.d.ts.map +1 -1
- package/dist/core/agent-tester/agent-tester-router.js +6 -6
- package/dist/core/agent-tester/agent-tester-router.js.map +1 -1
- package/dist/core/agent-tester/check-llm.d.ts.map +1 -1
- package/dist/core/agent-tester/check-llm.js.map +1 -1
- package/dist/core/agent-tester/services/SummaryMemory.d.ts.map +1 -1
- package/dist/core/agent-tester/services/SummaryMemory.js +3 -9
- package/dist/core/agent-tester/services/SummaryMemory.js.map +1 -1
- package/dist/core/agent-tester/services/TesterAgentService.d.ts.map +1 -1
- package/dist/core/agent-tester/services/TesterAgentService.js +25 -27
- package/dist/core/agent-tester/services/TesterAgentService.js.map +1 -1
- package/dist/core/agent-tester/services/TesterMcpClientService.d.ts.map +1 -1
- package/dist/core/agent-tester/services/TesterMcpClientService.js +26 -25
- package/dist/core/agent-tester/services/TesterMcpClientService.js.map +1 -1
- package/dist/core/auth/admin-auth.d.ts.map +1 -1
- package/dist/core/auth/admin-auth.js +5 -5
- package/dist/core/auth/admin-auth.js.map +1 -1
- package/dist/core/auth/agent-tester-auth.d.ts.map +1 -1
- package/dist/core/auth/agent-tester-auth.js +1 -6
- package/dist/core/auth/agent-tester-auth.js.map +1 -1
- package/dist/core/auth/basic.d.ts.map +1 -1
- package/dist/core/auth/basic.js.map +1 -1
- package/dist/core/auth/ip-check.d.ts.map +1 -1
- package/dist/core/auth/ip-check.js +1 -1
- package/dist/core/auth/ip-check.js.map +1 -1
- package/dist/core/auth/jwt.d.ts.map +1 -1
- package/dist/core/auth/jwt.js +1 -1
- package/dist/core/auth/jwt.js.map +1 -1
- package/dist/core/auth/middleware.d.ts.map +1 -1
- package/dist/core/auth/middleware.js +9 -6
- package/dist/core/auth/middleware.js.map +1 -1
- package/dist/core/auth/multi-auth.d.ts.map +1 -1
- package/dist/core/auth/multi-auth.js +6 -6
- package/dist/core/auth/multi-auth.js.map +1 -1
- package/dist/core/auth/revocation.d.ts.map +1 -1
- package/dist/core/auth/revocation.js +2 -6
- package/dist/core/auth/revocation.js.map +1 -1
- package/dist/core/auth/token-generator/ntlm/ntlm-auth-options.d.ts.map +1 -1
- package/dist/core/auth/token-generator/ntlm/ntlm-auth-options.js +2 -2
- package/dist/core/auth/token-generator/ntlm/ntlm-auth-options.js.map +1 -1
- package/dist/core/auth/token-generator/ntlm/ntlm-domain-config.js +1 -1
- package/dist/core/auth/token-generator/ntlm/ntlm-domain-config.js.map +1 -1
- package/dist/core/auth/token-generator/ntlm/ntlm-integration.d.ts.map +1 -1
- package/dist/core/auth/token-generator/ntlm/ntlm-integration.js +4 -2
- package/dist/core/auth/token-generator/ntlm/ntlm-integration.js.map +1 -1
- package/dist/core/auth/token-generator/server.d.ts.map +1 -1
- package/dist/core/auth/token-generator/server.js.map +1 -1
- package/dist/core/bootstrap/init-config.d.ts.map +1 -1
- package/dist/core/bootstrap/init-config.js +2 -2
- package/dist/core/bootstrap/init-config.js.map +1 -1
- package/dist/core/bootstrap/startup-info.d.ts.map +1 -1
- package/dist/core/bootstrap/startup-info.js +3 -7
- package/dist/core/bootstrap/startup-info.js.map +1 -1
- package/dist/core/cache/cache.d.ts.map +1 -1
- package/dist/core/cache/cache.js +2 -2
- package/dist/core/cache/cache.js.map +1 -1
- package/dist/core/consul/deregister.d.ts.map +1 -1
- package/dist/core/consul/deregister.js.map +1 -1
- package/dist/core/consul/get-consul-api.d.ts.map +1 -1
- package/dist/core/consul/get-consul-api.js +1 -2
- package/dist/core/consul/get-consul-api.js.map +1 -1
- package/dist/core/db/pg-db.d.ts.map +1 -1
- package/dist/core/db/pg-db.js +3 -3
- package/dist/core/db/pg-db.js.map +1 -1
- package/dist/core/debug.d.ts.map +1 -1
- package/dist/core/debug.js.map +1 -1
- package/dist/core/errors/BaseMcpError.d.ts.map +1 -1
- package/dist/core/errors/BaseMcpError.js.map +1 -1
- package/dist/core/errors/ValidationError.d.ts.map +1 -1
- package/dist/core/errors/ValidationError.js.map +1 -1
- package/dist/core/errors/errors.d.ts.map +1 -1
- package/dist/core/errors/errors.js +1 -1
- package/dist/core/errors/errors.js.map +1 -1
- package/dist/core/index.d.ts +6 -6
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +5 -5
- package/dist/core/index.js.map +1 -1
- package/dist/core/init-mcp-server.d.ts.map +1 -1
- package/dist/core/init-mcp-server.js.map +1 -1
- package/dist/core/logger.d.ts.map +1 -1
- package/dist/core/logger.js +1 -1
- package/dist/core/logger.js.map +1 -1
- package/dist/core/mcp/create-mcp-server.d.ts.map +1 -1
- package/dist/core/mcp/create-mcp-server.js +1 -1
- package/dist/core/mcp/create-mcp-server.js.map +1 -1
- package/dist/core/mcp/prompts.d.ts.map +1 -1
- package/dist/core/mcp/prompts.js.map +1 -1
- package/dist/core/mcp/readme-assembler.d.ts.map +1 -1
- package/dist/core/mcp/readme-assembler.js +3 -1
- package/dist/core/mcp/readme-assembler.js.map +1 -1
- package/dist/core/mcp/resources.d.ts.map +1 -1
- package/dist/core/mcp/resources.js.map +1 -1
- package/dist/core/mcp/server-stdio.d.ts.map +1 -1
- package/dist/core/utils/formatToolResult.d.ts.map +1 -1
- package/dist/core/utils/formatToolResult.js.map +1 -1
- package/dist/core/utils/port-checker.d.ts.map +1 -1
- package/dist/core/utils/port-checker.js.map +1 -1
- package/dist/core/utils/rate-limit.d.ts.map +1 -1
- package/dist/core/utils/rate-limit.js +2 -8
- package/dist/core/utils/rate-limit.js.map +1 -1
- package/dist/core/utils/testing/BaseMcpClient.d.ts.map +1 -1
- package/dist/core/utils/testing/BaseMcpClient.js.map +1 -1
- package/dist/core/utils/testing/McpHttpClient.d.ts.map +1 -1
- package/dist/core/utils/testing/McpHttpClient.js +2 -2
- package/dist/core/utils/testing/McpHttpClient.js.map +1 -1
- package/dist/core/utils/testing/McpSseClient.d.ts.map +1 -1
- package/dist/core/utils/testing/McpSseClient.js +3 -8
- package/dist/core/utils/testing/McpSseClient.js.map +1 -1
- package/dist/core/utils/testing/McpStdioClient.d.ts.map +1 -1
- package/dist/core/utils/testing/McpStdioClient.js.map +1 -1
- package/dist/core/utils/testing/McpStreamableHttpClient.d.ts.map +1 -1
- package/dist/core/utils/testing/McpStreamableHttpClient.js +7 -8
- package/dist/core/utils/testing/McpStreamableHttpClient.js.map +1 -1
- package/dist/core/utils/utils.d.ts.map +1 -1
- package/dist/core/utils/utils.js +3 -5
- package/dist/core/utils/utils.js.map +1 -1
- package/dist/core/web/admin-router.d.ts.map +1 -1
- package/dist/core/web/admin-router.js +3 -3
- package/dist/core/web/admin-router.js.map +1 -1
- package/dist/core/web/cors.d.ts.map +1 -1
- package/dist/core/web/cors.js.map +1 -1
- package/dist/core/web/favicon-svg.d.ts.map +1 -1
- package/dist/core/web/favicon-svg.js +1 -5
- package/dist/core/web/favicon-svg.js.map +1 -1
- package/dist/core/web/home-api.d.ts.map +1 -1
- package/dist/core/web/home-api.js +7 -8
- package/dist/core/web/home-api.js.map +1 -1
- package/dist/core/web/openapi.d.ts.map +1 -1
- package/dist/core/web/openapi.js +1 -3
- package/dist/core/web/openapi.js.map +1 -1
- package/dist/core/web/server-http.d.ts.map +1 -1
- package/dist/core/web/server-http.js +4 -4
- package/dist/core/web/server-http.js.map +1 -1
- package/dist/core/web/static/agent-tester/index.html +323 -323
- package/dist/core/web/static/agent-tester/script.js +311 -200
- package/dist/core/web/static/agent-tester/styles.css +1840 -1840
- package/dist/core/web/static/home/index.html +220 -220
- package/dist/core/web/static/home/script.js +72 -43
- package/dist/core/web/static/styles.css +927 -927
- package/dist/core/web/static/token-gen/index.html +136 -136
- package/dist/core/web/static/token-gen/script.js +58 -56
- package/dist/core/web/svg-icons.d.ts.map +1 -1
- package/dist/core/web/svg-icons.js +1 -5
- package/dist/core/web/svg-icons.js.map +1 -1
- package/package.json +10 -5
- package/{cli-template/.claude/hooks/eslint-fix.cjs → scripts/cc-hook-oxlint-oxfmt-fix.cjs} +109 -100
- package/scripts/generate-jwt.js +5 -9
- package/scripts/kill-port.js +5 -2
- package/scripts/npm/run.js +1 -2
- package/scripts/remove-nul.js +1 -1
- package/scripts/update-sdk.js +36 -14
- package/src/template/api/router.ts +3 -3
- package/src/template/prompts/agent-brief.ts +0 -1
- package/src/template/start.ts +3 -8
- package/src/template/tools/handle-tool-call.ts +3 -3
- package/src/template/tools/tools.ts +3 -7
- package/src/tests/jest-simple-reporter.js +1 -1
- package/src/tests/mcp/sse/mcp-sse-client-handling.md +111 -111
- package/src/tests/mcp/sse/test-sse-npm-package.js +2 -3
- package/src/tests/mcp/test-cases.js +6 -7
- package/src/tests/mcp/test-http.js +2 -2
- package/src/tests/mcp/test-sse.js +9 -7
- package/src/tests/mcp/test-stdio.js +12 -8
- package/src/tests/utils.ts +4 -3
- package/cli-template/eslint.config.js +0 -27
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.
|
|
4
|
+
"version": "0.4.77",
|
|
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",
|
|
@@ -31,9 +31,13 @@
|
|
|
31
31
|
"clean": "rimraf dist",
|
|
32
32
|
"cb": "npm run clean && npm run build",
|
|
33
33
|
"dev": "tsc --watch",
|
|
34
|
-
"lint": "
|
|
35
|
-
"lint:fix": "
|
|
36
|
-
"
|
|
34
|
+
"lint": "oxlint .",
|
|
35
|
+
"lint:fix": "oxlint --fix .",
|
|
36
|
+
"format": "oxfmt --check .",
|
|
37
|
+
"format:fix": "oxfmt .",
|
|
38
|
+
"quality": "npm run lint && npm run format",
|
|
39
|
+
"quality:fix": "npm run lint:fix && npm run format:fix",
|
|
40
|
+
"lint-fix-build": "oxlint --fix . && oxfmt . && rimraf dist && tsc && node scripts/copy-static.js",
|
|
37
41
|
"ci": "node --no-deprecation ./scripts/npm/run.js",
|
|
38
42
|
"reinstall": "node --no-deprecation ./scripts/npm/run.js reinstall",
|
|
39
43
|
"typecheck": "tsc --noEmit",
|
|
@@ -100,7 +104,8 @@
|
|
|
100
104
|
"@types/mssql": "^9.1.11",
|
|
101
105
|
"@types/node": "^25.5.2",
|
|
102
106
|
"@types/swagger-ui-express": "^4.1.8",
|
|
103
|
-
"
|
|
107
|
+
"oxfmt": "^0.48.0",
|
|
108
|
+
"oxlint": "^1.63.0",
|
|
104
109
|
"rimraf": "^6.1.3",
|
|
105
110
|
"typescript": "^6.0.2"
|
|
106
111
|
}
|
|
@@ -1,100 +1,109 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
*
|
|
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
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
});
|
|
83
|
-
log(
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Oxlint + Oxfmt Auto-Fix Hook for Claude Code
|
|
5
|
+
* Automatically lints and 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 = [/node_modules/, /[/\\]dist[/\\]/, /[/\\]coverage[/\\]/, /\.d\.ts$/];
|
|
49
|
+
|
|
50
|
+
for (const pattern of excludePatterns) {
|
|
51
|
+
if (pattern.test(filePath)) {
|
|
52
|
+
log(`Skipping excluded path: ${filePath}`);
|
|
53
|
+
process.exit(0);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// Get project directory from environment
|
|
58
|
+
const projectDir = process.env.CLAUDE_PROJECT_DIR;
|
|
59
|
+
|
|
60
|
+
if (!projectDir) {
|
|
61
|
+
log('CLAUDE_PROJECT_DIR not set');
|
|
62
|
+
process.exit(0);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
log(`Project dir: ${projectDir}`);
|
|
66
|
+
|
|
67
|
+
// Change to project directory
|
|
68
|
+
process.chdir(projectDir);
|
|
69
|
+
|
|
70
|
+
// Run oxlint --fix on the file
|
|
71
|
+
log(`Running Oxlint on: ${filePath}`);
|
|
72
|
+
|
|
73
|
+
try {
|
|
74
|
+
const output = execSync(`npx oxlint --fix "${filePath}"`, {
|
|
75
|
+
encoding: 'utf-8',
|
|
76
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
77
|
+
});
|
|
78
|
+
log(`Oxlint output: ${output || '(empty)'}`);
|
|
79
|
+
console.log(`🔧 Linted: ${filePath}`);
|
|
80
|
+
} catch (oxlintError) {
|
|
81
|
+
// Oxlint returns non-zero on warnings/errors but file is still fixed
|
|
82
|
+
log(`Oxlint warnings/errors: ${oxlintError.message}`);
|
|
83
|
+
console.log(`⚠️ Oxlint warnings/errors (file still saved)`);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Run oxfmt on the file
|
|
87
|
+
log(`Running Oxfmt on: ${filePath}`);
|
|
88
|
+
|
|
89
|
+
try {
|
|
90
|
+
const output = execSync(`npx oxfmt "${filePath}"`, {
|
|
91
|
+
encoding: 'utf-8',
|
|
92
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
93
|
+
});
|
|
94
|
+
log(`Oxfmt output: ${output || '(empty)'}`);
|
|
95
|
+
console.log(`✨ Formatted: ${filePath}`);
|
|
96
|
+
console.log('✅ Done');
|
|
97
|
+
} catch (oxfmtError) {
|
|
98
|
+
log(`Oxfmt warnings/errors: ${oxfmtError.message}`);
|
|
99
|
+
console.log(`⚠️ Oxfmt warnings/errors (file still saved)`);
|
|
100
|
+
}
|
|
101
|
+
} catch (error) {
|
|
102
|
+
log(`Error: ${error.message}\nStack: ${error.stack}`);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Always exit 0 to not block Claude's operations
|
|
106
|
+
process.exit(0);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
main();
|
package/scripts/generate-jwt.js
CHANGED
|
@@ -22,7 +22,7 @@ import configModule from 'config';
|
|
|
22
22
|
|
|
23
23
|
// ── CLI argument parsing ────────────────────────────────────────────
|
|
24
24
|
|
|
25
|
-
function getArg
|
|
25
|
+
function getArg(shortFlag, longFlag) {
|
|
26
26
|
const args = process.argv.slice(2);
|
|
27
27
|
for (let i = 0; i < args.length; i++) {
|
|
28
28
|
if (args[i] === shortFlag || args[i] === longFlag) {
|
|
@@ -84,13 +84,9 @@ if (!encryptKey || String(encryptKey).trim() === '' || encryptKey === '***') {
|
|
|
84
84
|
// ── Encryption (mirrors src/core/auth/jwt.ts) ───────────────────────
|
|
85
85
|
|
|
86
86
|
const ALGORITHM = 'aes-256-ctr';
|
|
87
|
-
const KEY = crypto
|
|
88
|
-
.createHash('sha256')
|
|
89
|
-
.update(String(encryptKey))
|
|
90
|
-
.digest('base64')
|
|
91
|
-
.substring(0, 32);
|
|
87
|
+
const KEY = crypto.createHash('sha256').update(String(encryptKey)).digest('base64').substring(0, 32);
|
|
92
88
|
|
|
93
|
-
function encrypt
|
|
89
|
+
function encrypt(text) {
|
|
94
90
|
const buffer = Buffer.from(text);
|
|
95
91
|
const iv = crypto.randomBytes(16);
|
|
96
92
|
const cipher = crypto.createCipheriv(ALGORITHM, KEY, iv);
|
|
@@ -102,7 +98,7 @@ function encrypt (text) {
|
|
|
102
98
|
|
|
103
99
|
let effectiveService = service;
|
|
104
100
|
|
|
105
|
-
if (
|
|
101
|
+
if (!effectiveService || !effectiveService.trim()) {
|
|
106
102
|
let checkMCPName = false;
|
|
107
103
|
try {
|
|
108
104
|
checkMCPName = configModule.get('webServer.auth.jwtToken.checkMCPName');
|
|
@@ -158,7 +154,7 @@ if (paramsRaw && paramsRaw.trim()) {
|
|
|
158
154
|
}
|
|
159
155
|
}
|
|
160
156
|
|
|
161
|
-
const expire = Date.now() +
|
|
157
|
+
const expire = Date.now() + liveTimeSec * 1000;
|
|
162
158
|
payload.expire = expire;
|
|
163
159
|
payload.iat = new Date().toISOString();
|
|
164
160
|
|
package/scripts/kill-port.js
CHANGED
|
@@ -15,7 +15,7 @@ if (!port) {
|
|
|
15
15
|
process.exit(1);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
async function killProcessOnPort
|
|
18
|
+
async function killProcessOnPort(portNumber) {
|
|
19
19
|
const isWindows = process.platform === 'win32';
|
|
20
20
|
|
|
21
21
|
console.log(`Searching for process on port ${portNumber}...`);
|
|
@@ -75,7 +75,10 @@ async function killProcessOnPort (portNumber) {
|
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
const pids = stdout
|
|
78
|
+
const pids = stdout
|
|
79
|
+
.trim()
|
|
80
|
+
.split('\n')
|
|
81
|
+
.filter((pid) => pid);
|
|
79
82
|
|
|
80
83
|
for (const pid of pids) {
|
|
81
84
|
try {
|
package/scripts/npm/run.js
CHANGED
package/scripts/remove-nul.js
CHANGED
|
@@ -35,7 +35,7 @@ if (fs.existsSync(nulFile)) {
|
|
|
35
35
|
// Also check for other common accidental files on Windows
|
|
36
36
|
const accidentalFiles = ['nul', 'NUL', 'con', 'CON', 'aux', 'AUX', 'prn', 'PRN'];
|
|
37
37
|
|
|
38
|
-
accidentalFiles.forEach(fileName => {
|
|
38
|
+
accidentalFiles.forEach((fileName) => {
|
|
39
39
|
const filePath = path.join(projectRoot, fileName);
|
|
40
40
|
if (fs.existsSync(filePath)) {
|
|
41
41
|
try {
|
package/scripts/update-sdk.js
CHANGED
|
@@ -18,41 +18,57 @@ const targets = [
|
|
|
18
18
|
|
|
19
19
|
// A folder containing a direct file named `pin` is preserved untouched —
|
|
20
20
|
// it is neither deleted nor overwritten with new content from the template.
|
|
21
|
-
function findPinnedFolders
|
|
21
|
+
function findPinnedFolders(rootDir) {
|
|
22
22
|
const pinned = new Set();
|
|
23
|
-
if (!existsSync(rootDir)) {
|
|
23
|
+
if (!existsSync(rootDir)) {
|
|
24
|
+
return pinned;
|
|
25
|
+
}
|
|
24
26
|
const walk = (currentDir) => {
|
|
25
27
|
const entries = readdirSync(currentDir, { withFileTypes: true });
|
|
26
28
|
if (entries.some((e) => e.isFile() && e.name === 'pin')) {
|
|
27
29
|
const rel = relative(rootDir, currentDir);
|
|
28
|
-
if (rel) {
|
|
30
|
+
if (rel) {
|
|
31
|
+
pinned.add(rel);
|
|
32
|
+
}
|
|
29
33
|
return;
|
|
30
34
|
}
|
|
31
35
|
for (const entry of entries) {
|
|
32
|
-
if (entry.isDirectory()) {
|
|
36
|
+
if (entry.isDirectory()) {
|
|
37
|
+
walk(join(currentDir, entry.name));
|
|
38
|
+
}
|
|
33
39
|
}
|
|
34
40
|
};
|
|
35
41
|
walk(rootDir);
|
|
36
42
|
return pinned;
|
|
37
43
|
}
|
|
38
44
|
|
|
39
|
-
function isInsidePinned
|
|
40
|
-
if (!relPath) {
|
|
41
|
-
|
|
45
|
+
function isInsidePinned(relPath, pinned) {
|
|
46
|
+
if (!relPath) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
if (pinned.has(relPath)) {
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
42
52
|
for (const p of pinned) {
|
|
43
|
-
if (relPath.startsWith(p + sep)) {
|
|
53
|
+
if (relPath.startsWith(p + sep)) {
|
|
54
|
+
return true;
|
|
55
|
+
}
|
|
44
56
|
}
|
|
45
57
|
return false;
|
|
46
58
|
}
|
|
47
59
|
|
|
48
|
-
function cleanExceptPinned
|
|
49
|
-
if (!existsSync(rootDir)) {
|
|
60
|
+
function cleanExceptPinned(rootDir, pinned) {
|
|
61
|
+
if (!existsSync(rootDir)) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
50
64
|
const walk = (currentDir) => {
|
|
51
65
|
const entries = readdirSync(currentDir, { withFileTypes: true });
|
|
52
66
|
for (const entry of entries) {
|
|
53
67
|
const full = join(currentDir, entry.name);
|
|
54
68
|
const fullRel = relative(rootDir, full);
|
|
55
|
-
if (pinned.has(fullRel)) {
|
|
69
|
+
if (pinned.has(fullRel)) {
|
|
70
|
+
continue;
|
|
71
|
+
}
|
|
56
72
|
const hasPinnedDescendant = [...pinned].some((p) => p.startsWith(fullRel + sep));
|
|
57
73
|
if (entry.isDirectory() && hasPinnedDescendant) {
|
|
58
74
|
walk(full);
|
|
@@ -72,7 +88,9 @@ for (const { name, src, dest, preserve = [], respectPin = false } of targets) {
|
|
|
72
88
|
const saved = {};
|
|
73
89
|
for (const file of preserve) {
|
|
74
90
|
const p = join(dest, file);
|
|
75
|
-
if (existsSync(p)) {
|
|
91
|
+
if (existsSync(p)) {
|
|
92
|
+
saved[file] = readFileSync(p);
|
|
93
|
+
}
|
|
76
94
|
}
|
|
77
95
|
|
|
78
96
|
const pinned = respectPin ? findPinnedFolders(dest) : new Set();
|
|
@@ -88,10 +106,14 @@ for (const { name, src, dest, preserve = [], respectPin = false } of targets) {
|
|
|
88
106
|
cpSync(src, dest, {
|
|
89
107
|
recursive: true,
|
|
90
108
|
filter: (srcPath) => {
|
|
91
|
-
if (preserve.includes(basename(srcPath))) {
|
|
109
|
+
if (preserve.includes(basename(srcPath))) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
92
112
|
if (respectPin && pinned.size > 0) {
|
|
93
113
|
const rel = relative(src, srcPath);
|
|
94
|
-
if (isInsidePinned(rel, pinned)) {
|
|
114
|
+
if (isInsidePinned(rel, pinned)) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
95
117
|
}
|
|
96
118
|
return true;
|
|
97
119
|
},
|
|
@@ -29,7 +29,7 @@ export class ExampleController {
|
|
|
29
29
|
*/
|
|
30
30
|
@Get('example')
|
|
31
31
|
@Tags('Example')
|
|
32
|
-
public async getExample
|
|
32
|
+
public async getExample(): Promise<ExampleResponse> {
|
|
33
33
|
try {
|
|
34
34
|
logger.info('Example endpoint called');
|
|
35
35
|
|
|
@@ -40,7 +40,7 @@ export class ExampleController {
|
|
|
40
40
|
};
|
|
41
41
|
} catch (error) {
|
|
42
42
|
logger.error('Error in example endpoint:', error);
|
|
43
|
-
throw new Error(error instanceof Error ? error.message : 'Unknown error');
|
|
43
|
+
throw new Error(error instanceof Error ? error.message : 'Unknown error', { cause: error });
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -50,7 +50,7 @@ export class ExampleController {
|
|
|
50
50
|
*/
|
|
51
51
|
@Get('health')
|
|
52
52
|
@Tags('Server')
|
|
53
|
-
public async getHealth
|
|
53
|
+
public async getHealth(): Promise<{
|
|
54
54
|
status: string;
|
|
55
55
|
timestamp: string;
|
|
56
56
|
version: string;
|
package/src/template/start.ts
CHANGED
|
@@ -46,23 +46,18 @@ const startProject = async (): Promise<void> => {
|
|
|
46
46
|
if (!agent?.dev?.host || !agent?.prd?.host) {
|
|
47
47
|
return '--consul-ui-not-configured--';
|
|
48
48
|
}
|
|
49
|
-
return `${isConsulProd
|
|
50
|
-
? `https://${agent.prd.host}/ui/${agent.prd.dc}`
|
|
51
|
-
: `https://${agent.dev.host}/ui/${agent.dev.dc}`
|
|
52
|
-
}/services/${serviceId}/instances`;
|
|
49
|
+
return `${isConsulProd ? `https://${agent.prd.host}/ui/${agent.prd.dc}` : `https://${agent.dev.host}/ui/${agent.dev.dc}`}/services/${serviceId}/instances`;
|
|
53
50
|
},
|
|
54
51
|
|
|
55
52
|
// Custom startup diagnostic info displayed in the console at server start
|
|
56
|
-
customStartupInfo: [
|
|
57
|
-
['Custom param', 'any value'],
|
|
58
|
-
],
|
|
53
|
+
customStartupInfo: [['Custom param', 'any value']],
|
|
59
54
|
};
|
|
60
55
|
|
|
61
56
|
// Start MCP server with assembled data
|
|
62
57
|
await initMcpServer(serverData);
|
|
63
58
|
};
|
|
64
59
|
|
|
65
|
-
startProject().catch(error => {
|
|
60
|
+
startProject().catch((error) => {
|
|
66
61
|
console.error('Failed to start project:', error);
|
|
67
62
|
process.exit(1);
|
|
68
63
|
});
|
|
@@ -8,7 +8,7 @@ const logger = lgr.getSubLogger({ name: chalk.bgGrey('tools') });
|
|
|
8
8
|
* Template tool handler - customize this for your specific tools
|
|
9
9
|
* This handles MCP tool execution requests
|
|
10
10
|
*/
|
|
11
|
-
export const handleToolCall = async (params: { name: string
|
|
11
|
+
export const handleToolCall = async (params: { name: string; arguments?: any }): Promise<any> => {
|
|
12
12
|
const { name, arguments: args } = params;
|
|
13
13
|
|
|
14
14
|
logger.info(`Tool called: ${name}`);
|
|
@@ -33,7 +33,7 @@ export const handleToolCall = async (params: { name: string, arguments?: any }):
|
|
|
33
33
|
* Example tool implementation
|
|
34
34
|
* Replace this with your actual tool logic
|
|
35
35
|
*/
|
|
36
|
-
async function handleExampleTool
|
|
36
|
+
async function handleExampleTool(args: any): Promise<string> {
|
|
37
37
|
const { query } = args || {};
|
|
38
38
|
|
|
39
39
|
if (!query) {
|
|
@@ -41,7 +41,7 @@ async function handleExampleTool (args: any): Promise<string> {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
// Simulate some work
|
|
44
|
-
await new Promise(resolve => setTimeout(resolve, 100));
|
|
44
|
+
await new Promise((resolve) => setTimeout(resolve, 100));
|
|
45
45
|
|
|
46
46
|
const result = {
|
|
47
47
|
message: `Processed query: ${query}`,
|
|
@@ -7,11 +7,7 @@ import { IToolInputSchema, IToolProperties } from '../../core/index.js';
|
|
|
7
7
|
* Define your tools according to your server's functionality
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
const getGenericInputSchema = (
|
|
12
|
-
queryDescription?: string,
|
|
13
|
-
additionalProperties?: IToolProperties,
|
|
14
|
-
): IToolInputSchema => {
|
|
10
|
+
const getGenericInputSchema = (queryDescription?: string, additionalProperties?: IToolProperties): IToolInputSchema => {
|
|
15
11
|
const properties = {
|
|
16
12
|
query: {
|
|
17
13
|
type: 'string',
|
|
@@ -80,10 +76,10 @@ export const tools: Tool[] = [
|
|
|
80
76
|
|
|
81
77
|
// Helper to get tool by name
|
|
82
78
|
export const getToolByName = (name: string): Tool | undefined => {
|
|
83
|
-
return tools.find(tool => tool.name === name);
|
|
79
|
+
return tools.find((tool) => tool.name === name);
|
|
84
80
|
};
|
|
85
81
|
|
|
86
82
|
// Helper to get all tool names
|
|
87
83
|
export const getToolNames = (): string[] => {
|
|
88
|
-
return tools.map(tool => tool.name);
|
|
84
|
+
return tools.map((tool) => tool.name);
|
|
89
85
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export default class SimpleReporter {
|
|
2
|
-
onRunComplete
|
|
2
|
+
onRunComplete(contexts, runResults) {
|
|
3
3
|
const { numPassedTests, numFailedTests, numPendingTests } = runResults;
|
|
4
4
|
const total = numPassedTests + numFailedTests + numPendingTests;
|
|
5
5
|
const actualSuccess = numFailedTests === 0 && total > 0;
|