fa-mcp-sdk 0.4.3 → 0.4.6
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 +1040 -1039
- package/cli-template/eslint.config.js +16 -136
- package/cli-template/package.json +9 -10
- package/cli-template/tsconfig.json +1 -0
- package/dist/core/_types_/active-directory-config.d.ts.map +1 -1
- package/dist/core/_types_/config.d.ts +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 +8 -8
- 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 +1 -1
- package/dist/core/agent-tester/check-llm.js.map +1 -1
- package/dist/core/agent-tester/services/TesterAgentService.d.ts.map +1 -1
- package/dist/core/agent-tester/services/TesterAgentService.js +53 -53
- 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 +2 -2
- 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 +3 -3
- package/dist/core/auth/admin-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/jwt.d.ts.map +1 -1
- package/dist/core/auth/jwt.js +6 -16
- 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 +3 -2
- package/dist/core/auth/middleware.js.map +1 -1
- package/dist/core/auth/multi-auth.d.ts +0 -3
- package/dist/core/auth/multi-auth.d.ts.map +1 -1
- package/dist/core/auth/multi-auth.js +10 -7
- package/dist/core/auth/multi-auth.js.map +1 -1
- package/dist/core/auth/permanent.d.ts.map +1 -1
- package/dist/core/auth/permanent.js +1 -1
- package/dist/core/auth/permanent.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.d.ts.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 +1 -1
- package/dist/core/auth/token-generator/ntlm/ntlm-integration.js.map +1 -1
- package/dist/core/auth/token-generator/ntlm/ntlm-templates.d.ts.map +1 -1
- package/dist/core/auth/token-generator/ntlm/ntlm-templates.js +222 -221
- package/dist/core/auth/token-generator/ntlm/ntlm-templates.js.map +1 -1
- package/dist/core/auth/token-generator/server.d.ts.map +1 -1
- package/dist/core/auth/token-generator/server.js +8 -8
- 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 +4 -4
- 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 +4 -4
- 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 +3 -3
- package/dist/core/cache/cache.js.map +1 -1
- package/dist/core/consul/access-points-updater.d.ts.map +1 -1
- package/dist/core/consul/access-points-updater.js +3 -3
- package/dist/core/consul/access-points-updater.js.map +1 -1
- package/dist/core/consul/deregister.d.ts.map +1 -1
- package/dist/core/consul/deregister.js +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 +3 -3
- package/dist/core/consul/get-consul-api.js.map +1 -1
- package/dist/core/db/pg-db.d.ts +1 -1
- package/dist/core/db/pg-db.d.ts.map +1 -1
- package/dist/core/db/pg-db.js +2 -2
- package/dist/core/db/pg-db.js.map +1 -1
- package/dist/core/debug.js +1 -1
- package/dist/core/debug.js.map +1 -1
- package/dist/core/init-mcp-server.d.ts.map +1 -1
- package/dist/core/init-mcp-server.js +9 -9
- package/dist/core/init-mcp-server.js.map +1 -1
- package/dist/core/logger.d.ts.map +1 -1
- package/dist/core/logger.js +3 -3
- 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 +1 -3
- package/dist/core/mcp/prompts.js.map +1 -1
- package/dist/core/mcp/resources.d.ts.map +1 -1
- package/dist/core/mcp/resources.js +8 -10
- package/dist/core/mcp/resources.js.map +1 -1
- package/dist/core/mcp/server-stdio.d.ts.map +1 -1
- package/dist/core/mcp/server-stdio.js.map +1 -1
- package/dist/core/utils/formatToolResult.d.ts.map +1 -1
- package/dist/core/utils/formatToolResult.js +1 -3
- 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 +1 -1
- package/dist/core/utils/port-checker.js.map +1 -1
- package/dist/core/utils/rate-limit.js +2 -2
- package/dist/core/utils/testing/McpSseClient.d.ts.map +1 -1
- 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/utils.d.ts.map +1 -1
- 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 +4 -4
- 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.map +1 -1
- package/dist/core/web/home-api.d.ts.map +1 -1
- package/dist/core/web/home-api.js +4 -4
- 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.map +1 -1
- package/dist/core/web/server-http.d.ts.map +1 -1
- package/dist/core/web/server-http.js +20 -22
- package/dist/core/web/server-http.js.map +1 -1
- package/dist/core/web/static/agent-tester/script.js +1503 -1513
- package/dist/core/web/static/home/script.js +646 -646
- package/dist/core/web/static/token-gen/script.js +561 -561
- package/dist/core/web/svg-icons.d.ts.map +1 -1
- package/dist/core/web/svg-icons.js +1 -1
- package/dist/core/web/svg-icons.js.map +1 -1
- package/package.json +2 -6
- package/scripts/copy-static.js +31 -31
- package/scripts/kill-port.js +107 -107
- package/scripts/npm/patch_node_modules.js +8 -8
- package/scripts/npm/run.js +31 -31
- package/scripts/remove-nul.js +53 -53
- package/scripts/update-doc.js +18 -18
- package/src/template/_types_/custom-config.ts +83 -83
- package/src/template/api/router.ts +86 -89
- package/src/template/custom-resources.ts +11 -11
- package/src/template/prompts/agent-brief.ts +8 -8
- package/src/template/prompts/agent-prompt.ts +10 -10
- package/src/template/prompts/custom-prompts.ts +12 -12
- package/src/template/start.ts +71 -72
- package/src/template/tools/handle-tool-call.ts +57 -56
- package/src/template/tools/tools.ts +89 -88
- package/src/tests/jest-simple-reporter.js +10 -10
- package/src/tests/mcp/sse/test-sse-npm-package.js +96 -96
- package/src/tests/mcp/test-cases.js +143 -143
- package/src/tests/mcp/test-http.js +76 -75
- package/src/tests/mcp/test-sse.js +80 -79
- package/src/tests/mcp/test-stdio.js +83 -81
- package/src/tests/utils.ts +157 -156
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* An example of extending the fa-mcp-sdk configuration with a custom settings block.
|
|
3
|
-
*
|
|
4
|
-
* This file demonstrates how to add your own settings
|
|
5
|
-
* (for example, to check the user's membership in an AEC group).
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { AppConfig } from '../../core/index.js';
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* AD Group Membership Verification Settings
|
|
12
|
-
*/
|
|
13
|
-
export interface IGroupAccessConfig {
|
|
14
|
-
groupAccess: {
|
|
15
|
-
/** AD Group whose membership is required for access */
|
|
16
|
-
requiredGroup: string;
|
|
17
|
-
|
|
18
|
-
/** Optional: Allow access without checking the group (for debugging) */
|
|
19
|
-
bypassGroupCheck?: boolean;
|
|
20
|
-
|
|
21
|
-
/** Optional: cache the result of the check (seconds) */
|
|
22
|
-
cacheTtlSeconds?: number;
|
|
23
|
-
|
|
24
|
-
/** Optional: List of groups with different access levels */
|
|
25
|
-
accessLevels?: {
|
|
26
|
-
/** Full access group (read/write) */
|
|
27
|
-
fullAccess?: string;
|
|
28
|
-
/** Read-only group */
|
|
29
|
-
readOnly?: string;
|
|
30
|
-
/** Administrators group */
|
|
31
|
-
admin?: string;
|
|
32
|
-
};
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Extended app config with group checking settings
|
|
38
|
-
*/
|
|
39
|
-
export interface CustomAppConfig extends AppConfig, IGroupAccessConfig {}
|
|
40
|
-
|
|
41
|
-
// ========================================================================
|
|
42
|
-
// YAML CONFIGURATION EXAMPLE (config/default.yaml)
|
|
43
|
-
// ========================================================================
|
|
44
|
-
/*
|
|
45
|
-
groupAccess:
|
|
46
|
-
requiredGroup: "DOMAIN\\MCP-Users"
|
|
47
|
-
bypassGroupCheck: false
|
|
48
|
-
cacheTtlSeconds: 300
|
|
49
|
-
accessLevels:
|
|
50
|
-
fullAccess: "DOMAIN\\MCP-FullAccess"
|
|
51
|
-
readOnly: "DOMAIN\\MCP-ReadOnly"
|
|
52
|
-
admin: "DOMAIN\\MCP-Admins"
|
|
53
|
-
*/
|
|
54
|
-
|
|
55
|
-
// ========================================================================
|
|
56
|
-
// EXAMPLE OF USE IN CODE
|
|
57
|
-
// ========================================================================
|
|
58
|
-
/*
|
|
59
|
-
import { appConfig } from '../core/index.js';
|
|
60
|
-
|
|
61
|
-
// TYPED ACCESS TO CUSTOM SETTINGS
|
|
62
|
-
const config = appConfig as CustomAppConfig;
|
|
63
|
-
|
|
64
|
-
const requiredGroup = config.groupAccess.requiredGroup;
|
|
65
|
-
const shouldBypass = config.groupAccess.bypassGroupCheck;
|
|
66
|
-
|
|
67
|
-
// Checking the Access Level from Payload
|
|
68
|
-
function getUserAccessLevel(payload: { user: string; groups?: string[] }): 'admin' | 'full' | 'readonly' | 'none' {
|
|
69
|
-
const { accessLevels } = config.groupAccess;
|
|
70
|
-
const userGroups = payload.groups || [];
|
|
71
|
-
|
|
72
|
-
if (accessLevels?.admin && userGroups.includes(accessLevels.admin)) {
|
|
73
|
-
return 'admin';
|
|
74
|
-
}
|
|
75
|
-
if (accessLevels?.fullAccess && userGroups.includes(accessLevels.fullAccess)) {
|
|
76
|
-
return 'full';
|
|
77
|
-
}
|
|
78
|
-
if (accessLevels?.readOnly && userGroups.includes(accessLevels.readOnly)) {
|
|
79
|
-
return 'readonly';
|
|
80
|
-
}
|
|
81
|
-
return 'none';
|
|
82
|
-
}
|
|
83
|
-
*/
|
|
1
|
+
/**
|
|
2
|
+
* An example of extending the fa-mcp-sdk configuration with a custom settings block.
|
|
3
|
+
*
|
|
4
|
+
* This file demonstrates how to add your own settings
|
|
5
|
+
* (for example, to check the user's membership in an AEC group).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { AppConfig } from '../../core/index.js';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* AD Group Membership Verification Settings
|
|
12
|
+
*/
|
|
13
|
+
export interface IGroupAccessConfig {
|
|
14
|
+
groupAccess: {
|
|
15
|
+
/** AD Group whose membership is required for access */
|
|
16
|
+
requiredGroup: string;
|
|
17
|
+
|
|
18
|
+
/** Optional: Allow access without checking the group (for debugging) */
|
|
19
|
+
bypassGroupCheck?: boolean;
|
|
20
|
+
|
|
21
|
+
/** Optional: cache the result of the check (seconds) */
|
|
22
|
+
cacheTtlSeconds?: number;
|
|
23
|
+
|
|
24
|
+
/** Optional: List of groups with different access levels */
|
|
25
|
+
accessLevels?: {
|
|
26
|
+
/** Full access group (read/write) */
|
|
27
|
+
fullAccess?: string;
|
|
28
|
+
/** Read-only group */
|
|
29
|
+
readOnly?: string;
|
|
30
|
+
/** Administrators group */
|
|
31
|
+
admin?: string;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Extended app config with group checking settings
|
|
38
|
+
*/
|
|
39
|
+
export interface CustomAppConfig extends AppConfig, IGroupAccessConfig {}
|
|
40
|
+
|
|
41
|
+
// ========================================================================
|
|
42
|
+
// YAML CONFIGURATION EXAMPLE (config/default.yaml)
|
|
43
|
+
// ========================================================================
|
|
44
|
+
/*
|
|
45
|
+
groupAccess:
|
|
46
|
+
requiredGroup: "DOMAIN\\MCP-Users"
|
|
47
|
+
bypassGroupCheck: false
|
|
48
|
+
cacheTtlSeconds: 300
|
|
49
|
+
accessLevels:
|
|
50
|
+
fullAccess: "DOMAIN\\MCP-FullAccess"
|
|
51
|
+
readOnly: "DOMAIN\\MCP-ReadOnly"
|
|
52
|
+
admin: "DOMAIN\\MCP-Admins"
|
|
53
|
+
*/
|
|
54
|
+
|
|
55
|
+
// ========================================================================
|
|
56
|
+
// EXAMPLE OF USE IN CODE
|
|
57
|
+
// ========================================================================
|
|
58
|
+
/*
|
|
59
|
+
import { appConfig } from '../core/index.js';
|
|
60
|
+
|
|
61
|
+
// TYPED ACCESS TO CUSTOM SETTINGS
|
|
62
|
+
const config = appConfig as CustomAppConfig;
|
|
63
|
+
|
|
64
|
+
const requiredGroup = config.groupAccess.requiredGroup;
|
|
65
|
+
const shouldBypass = config.groupAccess.bypassGroupCheck;
|
|
66
|
+
|
|
67
|
+
// Checking the Access Level from Payload
|
|
68
|
+
function getUserAccessLevel(payload: { user: string; groups?: string[] }): 'admin' | 'full' | 'readonly' | 'none' {
|
|
69
|
+
const { accessLevels } = config.groupAccess;
|
|
70
|
+
const userGroups = payload.groups || [];
|
|
71
|
+
|
|
72
|
+
if (accessLevels?.admin && userGroups.includes(accessLevels.admin)) {
|
|
73
|
+
return 'admin';
|
|
74
|
+
}
|
|
75
|
+
if (accessLevels?.fullAccess && userGroups.includes(accessLevels.fullAccess)) {
|
|
76
|
+
return 'full';
|
|
77
|
+
}
|
|
78
|
+
if (accessLevels?.readOnly && userGroups.includes(accessLevels.readOnly)) {
|
|
79
|
+
return 'readonly';
|
|
80
|
+
}
|
|
81
|
+
return 'none';
|
|
82
|
+
}
|
|
83
|
+
*/
|
|
@@ -1,89 +1,86 @@
|
|
|
1
|
-
import { Router, Request, Response } from 'express';
|
|
2
|
-
import { Route, Get, Tags } from 'tsoa';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
*
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
*
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
@
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
});
|
|
1
|
+
import { Router, Request, Response } from 'express';
|
|
2
|
+
import { Route, Get, Tags } from 'tsoa';
|
|
3
|
+
|
|
4
|
+
import { logger, createAuthMW } from '../../core/index.js';
|
|
5
|
+
|
|
6
|
+
export const apiRouter: Router | null = Router();
|
|
7
|
+
|
|
8
|
+
// Create universal auth middleware
|
|
9
|
+
const authMW = createAuthMW();
|
|
10
|
+
|
|
11
|
+
// Example response interfaces for tsoa
|
|
12
|
+
export interface ExampleResponse {
|
|
13
|
+
success: boolean;
|
|
14
|
+
message: string;
|
|
15
|
+
data: {
|
|
16
|
+
timestamp: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Example TSOA Controller
|
|
22
|
+
* This demonstrates how to use tsoa decorators for automatic OpenAPI generation
|
|
23
|
+
*/
|
|
24
|
+
@Route('api')
|
|
25
|
+
export class ExampleController {
|
|
26
|
+
/**
|
|
27
|
+
* Example protected endpoint
|
|
28
|
+
* Template endpoint - customize as needed
|
|
29
|
+
*/
|
|
30
|
+
@Get('example')
|
|
31
|
+
@Tags('Example')
|
|
32
|
+
public async getExample (): Promise<ExampleResponse> {
|
|
33
|
+
try {
|
|
34
|
+
logger.info('Example endpoint called');
|
|
35
|
+
|
|
36
|
+
return {
|
|
37
|
+
success: true,
|
|
38
|
+
message: 'This is a template endpoint',
|
|
39
|
+
data: { timestamp: new Date().toISOString() },
|
|
40
|
+
};
|
|
41
|
+
} catch (error) {
|
|
42
|
+
logger.error('Error in example endpoint:', error);
|
|
43
|
+
throw new Error(error instanceof Error ? error.message : 'Unknown error');
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Health check endpoint
|
|
49
|
+
* Simple health check for monitoring
|
|
50
|
+
*/
|
|
51
|
+
@Get('health')
|
|
52
|
+
@Tags('Server')
|
|
53
|
+
public async getHealth (): Promise<{
|
|
54
|
+
status: string;
|
|
55
|
+
timestamp: string;
|
|
56
|
+
version: string;
|
|
57
|
+
}> {
|
|
58
|
+
const { appConfig } = await import('../../core/index.js');
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
status: 'ok',
|
|
62
|
+
timestamp: new Date().toISOString(),
|
|
63
|
+
version: appConfig.version || '1.0.0',
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// Manual Express routes for backward compatibility and custom endpoints
|
|
69
|
+
// Example protected endpoint using auth middleware
|
|
70
|
+
apiRouter.get('/example', authMW, async (req: Request, res: Response) => {
|
|
71
|
+
try {
|
|
72
|
+
logger.info('Example endpoint called');
|
|
73
|
+
|
|
74
|
+
res.json({
|
|
75
|
+
success: true,
|
|
76
|
+
message: 'This is a template endpoint',
|
|
77
|
+
data: { timestamp: new Date().toISOString() },
|
|
78
|
+
});
|
|
79
|
+
} catch (error) {
|
|
80
|
+
logger.error('Error in example endpoint:', error);
|
|
81
|
+
res.status(500).json({
|
|
82
|
+
success: false,
|
|
83
|
+
error: error instanceof Error ? error.message : 'Unknown error',
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { IResourceData } from '../core/index.js';
|
|
2
|
-
|
|
3
|
-
export const customResources: IResourceData[] = [
|
|
4
|
-
{
|
|
5
|
-
uri: 'custom-resource://resource1',
|
|
6
|
-
name: 'Custom Resource',
|
|
7
|
-
description: 'Custom resource description',
|
|
8
|
-
mimeType: 'text/plain',
|
|
9
|
-
content: 'Custom resource content',
|
|
10
|
-
}
|
|
11
|
-
];
|
|
1
|
+
import { IResourceData } from '../core/index.js';
|
|
2
|
+
|
|
3
|
+
export const customResources: IResourceData[] = [
|
|
4
|
+
{
|
|
5
|
+
uri: 'custom-resource://resource1',
|
|
6
|
+
name: 'Custom Resource',
|
|
7
|
+
description: 'Custom resource description',
|
|
8
|
+
mimeType: 'text/plain',
|
|
9
|
+
content: 'Custom resource content',
|
|
10
|
+
},
|
|
11
|
+
];
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Level 1: Brief agent description
|
|
3
|
-
* Used when LLM selects agents from a list based on user query
|
|
4
|
-
* LLM doesn't see tools at this level
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
export const AGENT_BRIEF = 'Agent brief';
|
|
8
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Level 1: Brief agent description
|
|
3
|
+
* Used when LLM selects agents from a list based on user query
|
|
4
|
+
* LLM doesn't see tools at this level
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export const AGENT_BRIEF = 'Agent brief';
|
|
8
|
+
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Level 2: Agent description This prompt becomes visible to the LLM after the
|
|
3
|
-
* agent router has selected this agent from among others based on their short
|
|
4
|
-
* descriptions. At that point, the LLM gains access to the full list of tools
|
|
5
|
-
* and this detailed prompt, which may include instructions on how to call those
|
|
6
|
-
* tools. In simple scenarios, this prompt can be very short or even empty if
|
|
7
|
-
* the tool descriptions alone are sufficient.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
export const AGENT_PROMPT = 'Agent Prompt';
|
|
1
|
+
/**
|
|
2
|
+
* Level 2: Agent description This prompt becomes visible to the LLM after the
|
|
3
|
+
* agent router has selected this agent from among others based on their short
|
|
4
|
+
* descriptions. At that point, the LLM gains access to the full list of tools
|
|
5
|
+
* and this detailed prompt, which may include instructions on how to call those
|
|
6
|
+
* tools. In simple scenarios, this prompt can be very short or even empty if
|
|
7
|
+
* the tool descriptions alone are sufficient.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export const AGENT_PROMPT = 'Agent Prompt';
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { IPromptData, IGetPromptRequest } from '../../core/index.js';
|
|
2
|
-
|
|
3
|
-
export const customPrompts: IPromptData[] = [
|
|
4
|
-
{
|
|
5
|
-
name: 'custom_prompt',
|
|
6
|
-
description: 'Custom prompt',
|
|
7
|
-
arguments: [],
|
|
8
|
-
content: (request: IGetPromptRequest) => {
|
|
9
|
-
return `Custom prompt content ${request.method}`;
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
];
|
|
1
|
+
import { IPromptData, IGetPromptRequest } from '../../core/index.js';
|
|
2
|
+
|
|
3
|
+
export const customPrompts: IPromptData[] = [
|
|
4
|
+
{
|
|
5
|
+
name: 'custom_prompt',
|
|
6
|
+
description: 'Custom prompt',
|
|
7
|
+
arguments: [],
|
|
8
|
+
content: (request: IGetPromptRequest) => {
|
|
9
|
+
return `Custom prompt content ${request.method}`;
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
];
|
package/src/template/start.ts
CHANGED
|
@@ -1,72 +1,71 @@
|
|
|
1
|
-
// Import all project data from existing files
|
|
2
|
-
import { appConfig, initMcpServer, McpServerData, getAsset } from '../core/index.js';
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
{ name: '
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
});
|
|
1
|
+
// Import all project data from existing files
|
|
2
|
+
import { appConfig, initMcpServer, McpServerData, getAsset } from '../core/index.js';
|
|
3
|
+
|
|
4
|
+
import { apiRouter } from './api/router.js';
|
|
5
|
+
import { customResources } from './custom-resources.js';
|
|
6
|
+
import { AGENT_BRIEF } from './prompts/agent-brief.js';
|
|
7
|
+
import { AGENT_PROMPT } from './prompts/agent-prompt.js';
|
|
8
|
+
import { customPrompts } from './prompts/custom-prompts.js';
|
|
9
|
+
import { handleToolCall } from './tools/handle-tool-call.js';
|
|
10
|
+
import { tools } from './tools/tools.js';
|
|
11
|
+
|
|
12
|
+
const isConsulProd = (process.env.NODE_CONSUL_ENV || process.env.NODE_ENV) === 'production';
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Main function that assembles all project data and starts the MCP server
|
|
16
|
+
*/
|
|
17
|
+
const startProject = async (): Promise<void> => {
|
|
18
|
+
// Read logo from assets
|
|
19
|
+
const logoSvg = getAsset('logo.svg')!;
|
|
20
|
+
|
|
21
|
+
// Assemble all data to pass to the core
|
|
22
|
+
const serverData: McpServerData = {
|
|
23
|
+
// MCP components
|
|
24
|
+
tools,
|
|
25
|
+
toolHandler: handleToolCall,
|
|
26
|
+
|
|
27
|
+
// Prompts
|
|
28
|
+
agentBrief: AGENT_BRIEF,
|
|
29
|
+
agentPrompt: AGENT_PROMPT,
|
|
30
|
+
customPrompts,
|
|
31
|
+
usedHttpHeaders: [
|
|
32
|
+
{ name: 'Authorization', description: 'JWT Token issued on request' },
|
|
33
|
+
{ name: 'x-test-header', description: 'Any custom header', isOptional: true },
|
|
34
|
+
],
|
|
35
|
+
// Resources
|
|
36
|
+
customResources,
|
|
37
|
+
|
|
38
|
+
// HTTP components
|
|
39
|
+
httpComponents: { apiRouter },
|
|
40
|
+
|
|
41
|
+
// Assets
|
|
42
|
+
assets: {
|
|
43
|
+
logoSvg: logoSvg,
|
|
44
|
+
maintainerHtml: '<a href="https://support.com/page/2805" target="_blank" rel="noopener" class="clickable">Support</a>',
|
|
45
|
+
},
|
|
46
|
+
// Function to get Consul UI address (if consul enabled: consul.service.enable = true)
|
|
47
|
+
getConsulUIAddress: (serviceId: string) => {
|
|
48
|
+
const { agent } = appConfig.consul || {};
|
|
49
|
+
if (!agent?.dev?.host || !agent?.prd?.host) {
|
|
50
|
+
return '--consul-ui-not-configured--';
|
|
51
|
+
}
|
|
52
|
+
return `${isConsulProd
|
|
53
|
+
? `https://${agent.prd.host}/ui/${agent.prd.dc}`
|
|
54
|
+
: `https://${agent.dev.host}/ui/${agent.dev.dc}`
|
|
55
|
+
}/services/${serviceId}/instances`;
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
// Custom startup diagnostic info displayed in the console at server start
|
|
59
|
+
customStartupInfo: [
|
|
60
|
+
['Custom param', 'any value'],
|
|
61
|
+
],
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// Start MCP server with assembled data
|
|
65
|
+
await initMcpServer(serverData);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
startProject().catch(error => {
|
|
69
|
+
console.error('Failed to start project:', error);
|
|
70
|
+
process.exit(1);
|
|
71
|
+
});
|