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.
Files changed (153) hide show
  1. package/bin/fa-mcp.js +1040 -1039
  2. package/cli-template/eslint.config.js +16 -136
  3. package/cli-template/package.json +9 -10
  4. package/cli-template/tsconfig.json +1 -0
  5. package/dist/core/_types_/active-directory-config.d.ts.map +1 -1
  6. package/dist/core/_types_/config.d.ts +1 -1
  7. package/dist/core/_types_/config.d.ts.map +1 -1
  8. package/dist/core/_types_/types.d.ts.map +1 -1
  9. package/dist/core/ad/group-checker.d.ts.map +1 -1
  10. package/dist/core/ad/group-checker.js.map +1 -1
  11. package/dist/core/agent-tester/agent-tester-router.d.ts.map +1 -1
  12. package/dist/core/agent-tester/agent-tester-router.js +8 -8
  13. package/dist/core/agent-tester/agent-tester-router.js.map +1 -1
  14. package/dist/core/agent-tester/check-llm.d.ts.map +1 -1
  15. package/dist/core/agent-tester/check-llm.js +1 -1
  16. package/dist/core/agent-tester/check-llm.js.map +1 -1
  17. package/dist/core/agent-tester/services/TesterAgentService.d.ts.map +1 -1
  18. package/dist/core/agent-tester/services/TesterAgentService.js +53 -53
  19. package/dist/core/agent-tester/services/TesterAgentService.js.map +1 -1
  20. package/dist/core/agent-tester/services/TesterMcpClientService.d.ts.map +1 -1
  21. package/dist/core/agent-tester/services/TesterMcpClientService.js +2 -2
  22. package/dist/core/agent-tester/services/TesterMcpClientService.js.map +1 -1
  23. package/dist/core/auth/admin-auth.d.ts.map +1 -1
  24. package/dist/core/auth/admin-auth.js +3 -3
  25. package/dist/core/auth/admin-auth.js.map +1 -1
  26. package/dist/core/auth/basic.d.ts.map +1 -1
  27. package/dist/core/auth/basic.js.map +1 -1
  28. package/dist/core/auth/jwt.d.ts.map +1 -1
  29. package/dist/core/auth/jwt.js +6 -16
  30. package/dist/core/auth/jwt.js.map +1 -1
  31. package/dist/core/auth/middleware.d.ts.map +1 -1
  32. package/dist/core/auth/middleware.js +3 -2
  33. package/dist/core/auth/middleware.js.map +1 -1
  34. package/dist/core/auth/multi-auth.d.ts +0 -3
  35. package/dist/core/auth/multi-auth.d.ts.map +1 -1
  36. package/dist/core/auth/multi-auth.js +10 -7
  37. package/dist/core/auth/multi-auth.js.map +1 -1
  38. package/dist/core/auth/permanent.d.ts.map +1 -1
  39. package/dist/core/auth/permanent.js +1 -1
  40. package/dist/core/auth/permanent.js.map +1 -1
  41. package/dist/core/auth/token-generator/ntlm/ntlm-auth-options.d.ts.map +1 -1
  42. package/dist/core/auth/token-generator/ntlm/ntlm-auth-options.js +2 -2
  43. package/dist/core/auth/token-generator/ntlm/ntlm-auth-options.js.map +1 -1
  44. package/dist/core/auth/token-generator/ntlm/ntlm-domain-config.d.ts.map +1 -1
  45. package/dist/core/auth/token-generator/ntlm/ntlm-domain-config.js +1 -1
  46. package/dist/core/auth/token-generator/ntlm/ntlm-domain-config.js.map +1 -1
  47. package/dist/core/auth/token-generator/ntlm/ntlm-integration.d.ts.map +1 -1
  48. package/dist/core/auth/token-generator/ntlm/ntlm-integration.js +1 -1
  49. package/dist/core/auth/token-generator/ntlm/ntlm-integration.js.map +1 -1
  50. package/dist/core/auth/token-generator/ntlm/ntlm-templates.d.ts.map +1 -1
  51. package/dist/core/auth/token-generator/ntlm/ntlm-templates.js +222 -221
  52. package/dist/core/auth/token-generator/ntlm/ntlm-templates.js.map +1 -1
  53. package/dist/core/auth/token-generator/server.d.ts.map +1 -1
  54. package/dist/core/auth/token-generator/server.js +8 -8
  55. package/dist/core/auth/token-generator/server.js.map +1 -1
  56. package/dist/core/bootstrap/init-config.d.ts.map +1 -1
  57. package/dist/core/bootstrap/init-config.js +4 -4
  58. package/dist/core/bootstrap/init-config.js.map +1 -1
  59. package/dist/core/bootstrap/startup-info.d.ts.map +1 -1
  60. package/dist/core/bootstrap/startup-info.js +4 -4
  61. package/dist/core/bootstrap/startup-info.js.map +1 -1
  62. package/dist/core/cache/cache.d.ts.map +1 -1
  63. package/dist/core/cache/cache.js +3 -3
  64. package/dist/core/cache/cache.js.map +1 -1
  65. package/dist/core/consul/access-points-updater.d.ts.map +1 -1
  66. package/dist/core/consul/access-points-updater.js +3 -3
  67. package/dist/core/consul/access-points-updater.js.map +1 -1
  68. package/dist/core/consul/deregister.d.ts.map +1 -1
  69. package/dist/core/consul/deregister.js +1 -1
  70. package/dist/core/consul/deregister.js.map +1 -1
  71. package/dist/core/consul/get-consul-api.d.ts.map +1 -1
  72. package/dist/core/consul/get-consul-api.js +3 -3
  73. package/dist/core/consul/get-consul-api.js.map +1 -1
  74. package/dist/core/db/pg-db.d.ts +1 -1
  75. package/dist/core/db/pg-db.d.ts.map +1 -1
  76. package/dist/core/db/pg-db.js +2 -2
  77. package/dist/core/db/pg-db.js.map +1 -1
  78. package/dist/core/debug.js +1 -1
  79. package/dist/core/debug.js.map +1 -1
  80. package/dist/core/init-mcp-server.d.ts.map +1 -1
  81. package/dist/core/init-mcp-server.js +9 -9
  82. package/dist/core/init-mcp-server.js.map +1 -1
  83. package/dist/core/logger.d.ts.map +1 -1
  84. package/dist/core/logger.js +3 -3
  85. package/dist/core/logger.js.map +1 -1
  86. package/dist/core/mcp/create-mcp-server.d.ts.map +1 -1
  87. package/dist/core/mcp/create-mcp-server.js +1 -1
  88. package/dist/core/mcp/create-mcp-server.js.map +1 -1
  89. package/dist/core/mcp/prompts.d.ts.map +1 -1
  90. package/dist/core/mcp/prompts.js +1 -3
  91. package/dist/core/mcp/prompts.js.map +1 -1
  92. package/dist/core/mcp/resources.d.ts.map +1 -1
  93. package/dist/core/mcp/resources.js +8 -10
  94. package/dist/core/mcp/resources.js.map +1 -1
  95. package/dist/core/mcp/server-stdio.d.ts.map +1 -1
  96. package/dist/core/mcp/server-stdio.js.map +1 -1
  97. package/dist/core/utils/formatToolResult.d.ts.map +1 -1
  98. package/dist/core/utils/formatToolResult.js +1 -3
  99. package/dist/core/utils/formatToolResult.js.map +1 -1
  100. package/dist/core/utils/port-checker.d.ts.map +1 -1
  101. package/dist/core/utils/port-checker.js +1 -1
  102. package/dist/core/utils/port-checker.js.map +1 -1
  103. package/dist/core/utils/rate-limit.js +2 -2
  104. package/dist/core/utils/testing/McpSseClient.d.ts.map +1 -1
  105. package/dist/core/utils/testing/McpSseClient.js.map +1 -1
  106. package/dist/core/utils/testing/McpStdioClient.d.ts.map +1 -1
  107. package/dist/core/utils/testing/McpStdioClient.js.map +1 -1
  108. package/dist/core/utils/utils.d.ts.map +1 -1
  109. package/dist/core/utils/utils.js.map +1 -1
  110. package/dist/core/web/admin-router.d.ts.map +1 -1
  111. package/dist/core/web/admin-router.js +4 -4
  112. package/dist/core/web/admin-router.js.map +1 -1
  113. package/dist/core/web/cors.d.ts.map +1 -1
  114. package/dist/core/web/cors.js.map +1 -1
  115. package/dist/core/web/favicon-svg.d.ts.map +1 -1
  116. package/dist/core/web/favicon-svg.js.map +1 -1
  117. package/dist/core/web/home-api.d.ts.map +1 -1
  118. package/dist/core/web/home-api.js +4 -4
  119. package/dist/core/web/home-api.js.map +1 -1
  120. package/dist/core/web/openapi.d.ts.map +1 -1
  121. package/dist/core/web/openapi.js.map +1 -1
  122. package/dist/core/web/server-http.d.ts.map +1 -1
  123. package/dist/core/web/server-http.js +20 -22
  124. package/dist/core/web/server-http.js.map +1 -1
  125. package/dist/core/web/static/agent-tester/script.js +1503 -1513
  126. package/dist/core/web/static/home/script.js +646 -646
  127. package/dist/core/web/static/token-gen/script.js +561 -561
  128. package/dist/core/web/svg-icons.d.ts.map +1 -1
  129. package/dist/core/web/svg-icons.js +1 -1
  130. package/dist/core/web/svg-icons.js.map +1 -1
  131. package/package.json +2 -6
  132. package/scripts/copy-static.js +31 -31
  133. package/scripts/kill-port.js +107 -107
  134. package/scripts/npm/patch_node_modules.js +8 -8
  135. package/scripts/npm/run.js +31 -31
  136. package/scripts/remove-nul.js +53 -53
  137. package/scripts/update-doc.js +18 -18
  138. package/src/template/_types_/custom-config.ts +83 -83
  139. package/src/template/api/router.ts +86 -89
  140. package/src/template/custom-resources.ts +11 -11
  141. package/src/template/prompts/agent-brief.ts +8 -8
  142. package/src/template/prompts/agent-prompt.ts +10 -10
  143. package/src/template/prompts/custom-prompts.ts +12 -12
  144. package/src/template/start.ts +71 -72
  145. package/src/template/tools/handle-tool-call.ts +57 -56
  146. package/src/template/tools/tools.ts +89 -88
  147. package/src/tests/jest-simple-reporter.js +10 -10
  148. package/src/tests/mcp/sse/test-sse-npm-package.js +96 -96
  149. package/src/tests/mcp/test-cases.js +143 -143
  150. package/src/tests/mcp/test-http.js +76 -75
  151. package/src/tests/mcp/test-sse.js +80 -79
  152. package/src/tests/mcp/test-stdio.js +83 -81
  153. 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
- import { logger, createAuthMW } from '../../core/index.js';
4
-
5
- export const apiRouter: Router | null = Router();
6
-
7
- // Create universal auth middleware
8
- const authMW = createAuthMW();
9
-
10
- // Example response interfaces for tsoa
11
- export interface ExampleResponse {
12
- success: boolean;
13
- message: string;
14
- data: {
15
- timestamp: string;
16
- };
17
- }
18
-
19
- /**
20
- * Example TSOA Controller
21
- * This demonstrates how to use tsoa decorators for automatic OpenAPI generation
22
- */
23
- @Route('api')
24
- export class ExampleController {
25
- /**
26
- * Example protected endpoint
27
- * Template endpoint - customize as needed
28
- */
29
- @Get('example')
30
- @Tags('Example')
31
- public async getExample (): Promise<ExampleResponse> {
32
- try {
33
- logger.info('Example endpoint called');
34
-
35
- return {
36
- success: true,
37
- message: 'This is a template endpoint',
38
- data: {
39
- timestamp: new Date().toISOString(),
40
- },
41
- };
42
- } catch (error) {
43
- logger.error('Error in example endpoint:', error);
44
- throw new Error(error instanceof Error ? error.message : 'Unknown error');
45
- }
46
- }
47
-
48
- /**
49
- * Health check endpoint
50
- * Simple health check for monitoring
51
- */
52
- @Get('health')
53
- @Tags('Server')
54
- public async getHealth (): Promise<{
55
- status: string;
56
- timestamp: string;
57
- version: string;
58
- }> {
59
- const { appConfig } = await import('../../core/index.js');
60
-
61
- return {
62
- status: 'ok',
63
- timestamp: new Date().toISOString(),
64
- version: appConfig.version || '1.0.0',
65
- };
66
- }
67
- }
68
-
69
- // Manual Express routes for backward compatibility and custom endpoints
70
- // Example protected endpoint using auth middleware
71
- apiRouter.get('/example', authMW, async (req: Request, res: Response) => {
72
- try {
73
- logger.info('Example endpoint called');
74
-
75
- res.json({
76
- success: true,
77
- message: 'This is a template endpoint',
78
- data: {
79
- timestamp: new Date().toISOString(),
80
- },
81
- });
82
- } catch (error) {
83
- logger.error('Error in example endpoint:', error);
84
- res.status(500).json({
85
- success: false,
86
- error: error instanceof Error ? error.message : 'Unknown error',
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
+ ];
@@ -1,72 +1,71 @@
1
- // Import all project data from existing files
2
- import { appConfig, initMcpServer, McpServerData, getAsset } from '../core/index.js';
3
- import { tools } from './tools/tools.js';
4
- import { handleToolCall } from './tools/handle-tool-call.js';
5
- import { AGENT_BRIEF } from './prompts/agent-brief.js';
6
- import { AGENT_PROMPT } from './prompts/agent-prompt.js';
7
- import { customPrompts } from './prompts/custom-prompts.js';
8
- import { customResources } from './custom-resources.js';
9
- import { apiRouter } from './api/router.js';
10
-
11
- const isConsulProd = (process.env.NODE_CONSUL_ENV || process.env.NODE_ENV) === 'production';
12
-
13
- /**
14
- * Main function that assembles all project data and starts the MCP server
15
- */
16
- const startProject = async (): Promise<void> => {
17
- // Read logo from assets
18
- const logoSvg = getAsset('logo.svg')!;
19
-
20
- // Assemble all data to pass to the core
21
- const serverData: McpServerData = {
22
- // MCP components
23
- tools,
24
- toolHandler: handleToolCall,
25
-
26
- // Prompts
27
- agentBrief: AGENT_BRIEF,
28
- agentPrompt: AGENT_PROMPT,
29
- customPrompts,
30
- usedHttpHeaders: [
31
- { name: 'Authorization', description: 'JWT Token issued on request' },
32
- { name: 'x-test-header', description: 'Any custom header', isOptional: true },
33
- ],
34
- // Resources
35
- customResources,
36
-
37
- // HTTP components
38
- httpComponents: {
39
- apiRouter,
40
- },
41
-
42
- // Assets
43
- assets: {
44
- logoSvg: logoSvg,
45
- maintainerHtml: '<a href="https://support.com/page/2805" target="_blank" rel="noopener" class="clickable">Support</a>',
46
- },
47
- // Function to get Consul UI address (if consul enabled: consul.service.enable = true)
48
- getConsulUIAddress: (serviceId: string) => {
49
- const { agent } = appConfig.consul || {};
50
- if (!agent?.dev?.host || !agent?.prd?.host) {
51
- return '--consul-ui-not-configured--';
52
- }
53
- return `${isConsulProd
54
- ? `https://${agent.prd.host}/ui/${agent.prd.dc}`
55
- : `https://${agent.dev.host}/ui/${agent.dev.dc}`
56
- }/services/${serviceId}/instances`;
57
- },
58
-
59
- // Custom startup diagnostic info displayed in the console at server start
60
- customStartupInfo: [
61
- ['Custom param', 'any value'],
62
- ],
63
- };
64
-
65
- // Start MCP server with assembled data
66
- await initMcpServer(serverData);
67
- };
68
-
69
- startProject().catch(error => {
70
- console.error('Failed to start project:', error);
71
- process.exit(1);
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
+ });