fa-mcp-sdk 0.4.76 → 0.4.79

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 (198) hide show
  1. package/README.md +319 -314
  2. package/bin/fa-mcp.js +85 -68
  3. package/cli-template/.claude/agents/javascript-pro.md +276 -276
  4. package/cli-template/.claude/settings.json +50 -50
  5. package/cli-template/.claude/skills/upgrade-guide/SKILL.md +2 -1
  6. package/cli-template/.oxfmtrc.json +41 -0
  7. package/cli-template/.oxlintrc.json +120 -0
  8. package/cli-template/CLAUDE.md +358 -355
  9. package/cli-template/FA-MCP-SDK-DOC/00-FA-MCP-SDK-index.md +132 -132
  10. package/cli-template/FA-MCP-SDK-DOC/01-getting-started.md +146 -146
  11. package/cli-template/FA-MCP-SDK-DOC/02-1-tools-and-api.md +431 -431
  12. package/cli-template/FA-MCP-SDK-DOC/02-2-prompts-and-resources.md +201 -201
  13. package/cli-template/FA-MCP-SDK-DOC/03-configuration.md +384 -384
  14. package/cli-template/FA-MCP-SDK-DOC/04-authentication.md +412 -412
  15. package/cli-template/FA-MCP-SDK-DOC/05-ad-authorization.md +196 -196
  16. package/cli-template/FA-MCP-SDK-DOC/06-utilities.md +163 -163
  17. package/cli-template/FA-MCP-SDK-DOC/07-testing-and-operations.md +127 -127
  18. package/cli-template/jest.config.js +27 -30
  19. package/cli-template/package.json +10 -5
  20. package/cli-template/prompt-example-new-MCP.md +101 -101
  21. package/cli-template/readme-docs/SKILLS.md +1 -1
  22. package/cli-template/tsconfig.json +58 -58
  23. package/cli-template/update.cjs +41 -38
  24. package/config/custom-environment-variables.yaml +63 -63
  25. package/config/development.yaml +4 -4
  26. package/config/production.yaml +4 -4
  27. package/config/test.yaml +26 -26
  28. package/dist/core/_types_/TNtlm.d.ts.map +1 -1
  29. package/dist/core/_types_/active-directory-config.d.ts.map +1 -1
  30. package/dist/core/_types_/config.d.ts.map +1 -1
  31. package/dist/core/_types_/types.d.ts.map +1 -1
  32. package/dist/core/ad/group-checker.d.ts.map +1 -1
  33. package/dist/core/ad/group-checker.js.map +1 -1
  34. package/dist/core/agent-tester/agent-tester-router.d.ts.map +1 -1
  35. package/dist/core/agent-tester/agent-tester-router.js +6 -6
  36. package/dist/core/agent-tester/agent-tester-router.js.map +1 -1
  37. package/dist/core/agent-tester/check-llm.d.ts.map +1 -1
  38. package/dist/core/agent-tester/check-llm.js.map +1 -1
  39. package/dist/core/agent-tester/services/SummaryMemory.d.ts.map +1 -1
  40. package/dist/core/agent-tester/services/SummaryMemory.js +3 -9
  41. package/dist/core/agent-tester/services/SummaryMemory.js.map +1 -1
  42. package/dist/core/agent-tester/services/TesterAgentService.d.ts.map +1 -1
  43. package/dist/core/agent-tester/services/TesterAgentService.js +25 -27
  44. package/dist/core/agent-tester/services/TesterAgentService.js.map +1 -1
  45. package/dist/core/agent-tester/services/TesterMcpClientService.d.ts.map +1 -1
  46. package/dist/core/agent-tester/services/TesterMcpClientService.js +26 -25
  47. package/dist/core/agent-tester/services/TesterMcpClientService.js.map +1 -1
  48. package/dist/core/auth/admin-auth.d.ts.map +1 -1
  49. package/dist/core/auth/admin-auth.js +5 -5
  50. package/dist/core/auth/admin-auth.js.map +1 -1
  51. package/dist/core/auth/agent-tester-auth.d.ts.map +1 -1
  52. package/dist/core/auth/agent-tester-auth.js +1 -6
  53. package/dist/core/auth/agent-tester-auth.js.map +1 -1
  54. package/dist/core/auth/basic.d.ts.map +1 -1
  55. package/dist/core/auth/basic.js.map +1 -1
  56. package/dist/core/auth/ip-check.d.ts.map +1 -1
  57. package/dist/core/auth/ip-check.js +1 -1
  58. package/dist/core/auth/ip-check.js.map +1 -1
  59. package/dist/core/auth/jwt.d.ts.map +1 -1
  60. package/dist/core/auth/jwt.js +1 -1
  61. package/dist/core/auth/jwt.js.map +1 -1
  62. package/dist/core/auth/middleware.d.ts.map +1 -1
  63. package/dist/core/auth/middleware.js +9 -6
  64. package/dist/core/auth/middleware.js.map +1 -1
  65. package/dist/core/auth/multi-auth.d.ts.map +1 -1
  66. package/dist/core/auth/multi-auth.js +6 -6
  67. package/dist/core/auth/multi-auth.js.map +1 -1
  68. package/dist/core/auth/revocation.d.ts.map +1 -1
  69. package/dist/core/auth/revocation.js +2 -6
  70. package/dist/core/auth/revocation.js.map +1 -1
  71. package/dist/core/auth/token-generator/ntlm/ntlm-auth-options.d.ts.map +1 -1
  72. package/dist/core/auth/token-generator/ntlm/ntlm-auth-options.js +2 -2
  73. package/dist/core/auth/token-generator/ntlm/ntlm-auth-options.js.map +1 -1
  74. package/dist/core/auth/token-generator/ntlm/ntlm-domain-config.js +1 -1
  75. package/dist/core/auth/token-generator/ntlm/ntlm-domain-config.js.map +1 -1
  76. package/dist/core/auth/token-generator/ntlm/ntlm-integration.d.ts.map +1 -1
  77. package/dist/core/auth/token-generator/ntlm/ntlm-integration.js +4 -2
  78. package/dist/core/auth/token-generator/ntlm/ntlm-integration.js.map +1 -1
  79. package/dist/core/auth/token-generator/server.d.ts.map +1 -1
  80. package/dist/core/auth/token-generator/server.js.map +1 -1
  81. package/dist/core/bootstrap/init-config.d.ts.map +1 -1
  82. package/dist/core/bootstrap/init-config.js +2 -2
  83. package/dist/core/bootstrap/init-config.js.map +1 -1
  84. package/dist/core/bootstrap/startup-info.d.ts.map +1 -1
  85. package/dist/core/bootstrap/startup-info.js +3 -7
  86. package/dist/core/bootstrap/startup-info.js.map +1 -1
  87. package/dist/core/cache/cache.d.ts.map +1 -1
  88. package/dist/core/cache/cache.js +2 -2
  89. package/dist/core/cache/cache.js.map +1 -1
  90. package/dist/core/consul/deregister.d.ts.map +1 -1
  91. package/dist/core/consul/deregister.js.map +1 -1
  92. package/dist/core/consul/get-consul-api.d.ts.map +1 -1
  93. package/dist/core/consul/get-consul-api.js +1 -2
  94. package/dist/core/consul/get-consul-api.js.map +1 -1
  95. package/dist/core/db/pg-db.d.ts.map +1 -1
  96. package/dist/core/db/pg-db.js +3 -3
  97. package/dist/core/db/pg-db.js.map +1 -1
  98. package/dist/core/debug.d.ts.map +1 -1
  99. package/dist/core/debug.js.map +1 -1
  100. package/dist/core/errors/BaseMcpError.d.ts.map +1 -1
  101. package/dist/core/errors/BaseMcpError.js.map +1 -1
  102. package/dist/core/errors/ValidationError.d.ts.map +1 -1
  103. package/dist/core/errors/ValidationError.js.map +1 -1
  104. package/dist/core/errors/errors.d.ts.map +1 -1
  105. package/dist/core/errors/errors.js +1 -1
  106. package/dist/core/errors/errors.js.map +1 -1
  107. package/dist/core/index.d.ts +6 -6
  108. package/dist/core/index.d.ts.map +1 -1
  109. package/dist/core/index.js +5 -5
  110. package/dist/core/index.js.map +1 -1
  111. package/dist/core/init-mcp-server.d.ts.map +1 -1
  112. package/dist/core/init-mcp-server.js.map +1 -1
  113. package/dist/core/logger.d.ts.map +1 -1
  114. package/dist/core/logger.js +1 -1
  115. package/dist/core/logger.js.map +1 -1
  116. package/dist/core/mcp/create-mcp-server.d.ts.map +1 -1
  117. package/dist/core/mcp/create-mcp-server.js +1 -1
  118. package/dist/core/mcp/create-mcp-server.js.map +1 -1
  119. package/dist/core/mcp/prompts.d.ts.map +1 -1
  120. package/dist/core/mcp/prompts.js.map +1 -1
  121. package/dist/core/mcp/readme-assembler.d.ts.map +1 -1
  122. package/dist/core/mcp/readme-assembler.js +3 -1
  123. package/dist/core/mcp/readme-assembler.js.map +1 -1
  124. package/dist/core/mcp/resources.d.ts.map +1 -1
  125. package/dist/core/mcp/resources.js.map +1 -1
  126. package/dist/core/mcp/server-stdio.d.ts.map +1 -1
  127. package/dist/core/utils/formatToolResult.d.ts.map +1 -1
  128. package/dist/core/utils/formatToolResult.js.map +1 -1
  129. package/dist/core/utils/port-checker.d.ts.map +1 -1
  130. package/dist/core/utils/port-checker.js.map +1 -1
  131. package/dist/core/utils/rate-limit.d.ts.map +1 -1
  132. package/dist/core/utils/rate-limit.js +2 -8
  133. package/dist/core/utils/rate-limit.js.map +1 -1
  134. package/dist/core/utils/testing/BaseMcpClient.d.ts.map +1 -1
  135. package/dist/core/utils/testing/BaseMcpClient.js.map +1 -1
  136. package/dist/core/utils/testing/McpHttpClient.d.ts.map +1 -1
  137. package/dist/core/utils/testing/McpHttpClient.js +2 -2
  138. package/dist/core/utils/testing/McpHttpClient.js.map +1 -1
  139. package/dist/core/utils/testing/McpSseClient.d.ts.map +1 -1
  140. package/dist/core/utils/testing/McpSseClient.js +3 -8
  141. package/dist/core/utils/testing/McpSseClient.js.map +1 -1
  142. package/dist/core/utils/testing/McpStdioClient.d.ts.map +1 -1
  143. package/dist/core/utils/testing/McpStdioClient.js.map +1 -1
  144. package/dist/core/utils/testing/McpStreamableHttpClient.d.ts.map +1 -1
  145. package/dist/core/utils/testing/McpStreamableHttpClient.js +7 -8
  146. package/dist/core/utils/testing/McpStreamableHttpClient.js.map +1 -1
  147. package/dist/core/utils/utils.d.ts.map +1 -1
  148. package/dist/core/utils/utils.js +3 -5
  149. package/dist/core/utils/utils.js.map +1 -1
  150. package/dist/core/web/admin-router.d.ts.map +1 -1
  151. package/dist/core/web/admin-router.js +3 -3
  152. package/dist/core/web/admin-router.js.map +1 -1
  153. package/dist/core/web/cors.d.ts.map +1 -1
  154. package/dist/core/web/cors.js.map +1 -1
  155. package/dist/core/web/favicon-svg.d.ts.map +1 -1
  156. package/dist/core/web/favicon-svg.js +1 -5
  157. package/dist/core/web/favicon-svg.js.map +1 -1
  158. package/dist/core/web/home-api.d.ts.map +1 -1
  159. package/dist/core/web/home-api.js +7 -8
  160. package/dist/core/web/home-api.js.map +1 -1
  161. package/dist/core/web/openapi.d.ts.map +1 -1
  162. package/dist/core/web/openapi.js +1 -3
  163. package/dist/core/web/openapi.js.map +1 -1
  164. package/dist/core/web/server-http.d.ts.map +1 -1
  165. package/dist/core/web/server-http.js +4 -4
  166. package/dist/core/web/server-http.js.map +1 -1
  167. package/dist/core/web/static/agent-tester/index.html +323 -323
  168. package/dist/core/web/static/agent-tester/script.js +311 -200
  169. package/dist/core/web/static/agent-tester/styles.css +1840 -1840
  170. package/dist/core/web/static/home/index.html +220 -220
  171. package/dist/core/web/static/home/script.js +72 -43
  172. package/dist/core/web/static/styles.css +927 -927
  173. package/dist/core/web/static/token-gen/index.html +136 -136
  174. package/dist/core/web/static/token-gen/script.js +58 -56
  175. package/dist/core/web/svg-icons.d.ts.map +1 -1
  176. package/dist/core/web/svg-icons.js +1 -5
  177. package/dist/core/web/svg-icons.js.map +1 -1
  178. package/package.json +10 -5
  179. package/{cli-template/.claude/hooks/eslint-fix.cjs → scripts/cc-hook-oxlint-oxfmt-fix.cjs} +109 -100
  180. package/scripts/generate-jwt.js +5 -9
  181. package/scripts/kill-port.js +5 -2
  182. package/scripts/npm/run.js +1 -2
  183. package/scripts/remove-nul.js +1 -1
  184. package/scripts/update-sdk.js +36 -14
  185. package/src/template/api/router.ts +3 -3
  186. package/src/template/prompts/agent-brief.ts +0 -1
  187. package/src/template/start.ts +3 -8
  188. package/src/template/tools/handle-tool-call.ts +3 -3
  189. package/src/template/tools/tools.ts +3 -7
  190. package/src/tests/jest-simple-reporter.js +1 -1
  191. package/src/tests/mcp/sse/mcp-sse-client-handling.md +111 -111
  192. package/src/tests/mcp/sse/test-sse-npm-package.js +2 -3
  193. package/src/tests/mcp/test-cases.js +6 -7
  194. package/src/tests/mcp/test-http.js +2 -2
  195. package/src/tests/mcp/test-sse.js +9 -7
  196. package/src/tests/mcp/test-stdio.js +12 -8
  197. package/src/tests/utils.ts +4 -3
  198. package/cli-template/eslint.config.js +0 -27
package/README.md CHANGED
@@ -1,314 +1,319 @@
1
- # MCP Server Template Generator
2
-
3
- Production-ready core framework for building MCP (Model Context Protocol) servers with comprehensive
4
- infrastructure support.
5
-
6
- CLI utility that creates ready-to-use MCP (Model Context Protocol) server projects from the official template.
7
-
8
- ## Overview
9
-
10
- This framework provides complete infrastructure for building enterprise-grade MCP servers:
11
-
12
- - **Dual Transport**: STDIO (Claude Desktop) and HTTP/SSE (web clients)
13
- - **Agent-Driven Tool Development**: Built-in AI agent system (Agent Tester) for iterative refinement of MCP tools through automated testing cycles — the agent calls your tools, you observe behavior, adjust descriptions/parameters/prompts, and re-test
14
- - **Headless Test API**: Direct HTTP endpoint (`POST /agent-tester/api/chat/test`) returns structured trace of every tool call, argument, result, and LLM decision — enabling CLI-based automated testing without a browser
15
- - **Authentication**: JWT (with optional IP restriction), Basic auth, permanent tokens, custom validators
16
- - **Database Integration**: PostgreSQL with pgvector for vector operations
17
- - **Service Discovery**: Consul integration for microservices
18
- - **Rate Limiting**: Configurable rate limiting for all endpoints
19
- - **API Documentation**: Automatic Swagger/OpenAPI generation
20
- - **Production Logging**: Structured logging with data masking
21
- - **Configuration Management**: YAML-based with environment overrides
22
- - **Deployment Ready**: PM2 scripts, Nginx templates, ESLint, Jest testing
23
-
24
- The framework uses dependency injection to keep the core completely agnostic of project-specific implementations.
25
-
26
-
27
- ## Steps to Get Started
28
-
29
- 1) Install `fa-mcp-sdk` globally:
30
-
31
- ```bash
32
- npm install -g fa-mcp-sdk
33
- ```
34
-
35
- 2) Run the CLI, specify the target directory, and follow the interactive prompts:
36
-
37
- ```bash
38
- fa-mcp
39
- ```
40
- Or using configuration file:
41
-
42
- ```bash
43
- fa-mcp config.yaml
44
- ```
45
-
46
- 3) Launching the template MCP server:
47
- - Navigate to the target directory: `cd <targetPath>`
48
- - Install dependencies: `npm install`
49
- - Build the project: `npm run build`
50
- - Start the server: `npm start`
51
-
52
- 4) Vibe-coding your MCP server logic:
53
- - Create an instruction file (prompt) for your preferred AI coding assistant.
54
- `fa-mcp-sdk` comes ready for use with `Claude Code`.
55
- You can find an example prompt for creating an MCP server (e.g., a currency exchange rate provider) in `cli-template/prompt-example-new-MCP.md`.
56
- - Launch your AI coder and provide it with the instructions to build your new MCP server.
57
-
58
-
59
-
60
- ## Configuration
61
-
62
- The CLI collects required and optional parameters through interactive prompts or configuration file.
63
-
64
- ### Required Parameters
65
-
66
- | Parameter | Description | Example |
67
- |-----------------------|-------------|---------|
68
- | `project.name` | Package.json name and MCP server identification | `"my-mcp-server"` |
69
- | `project.description` | Package.json description | `"A custom MCP server"` |
70
- | `project.productName` | Display name for UI and documentation | `"My MCP Server"` |
71
- | `port` | Web server port for HTTP and MCP protocol | `"3000"` |
72
-
73
- ### Optional Parameters
74
-
75
- | Parameter | Description | Default |
76
- |-------------------------------------|-------------|---------|
77
- | `author.name` | Package.json author name | `""` |
78
- | `author.email` | Package.json author email | `""` |
79
- | `git-base-url` | Git repository base URL | `"github.com/username"` |
80
- | `consul.service.enable` | Enable Consul service registration | `"false"` |
81
- | `consul.agent.reg.token` | Token for registering service with Consul | `"***"` |
82
- | `consul.envCode.dev` | Development environment code | `"<envCode.dev>"` |
83
- | `consul.envCode.prod` | Production environment code | `"<envCode.prod>"` |
84
- | `consul.agent.dev.dc` | Development Consul datacenter | `""` |
85
- | `consul.agent.dev.host` | Development Consul UI host | `"consul.my.ui"` |
86
- | `consul.agent.dev.token` | Development Consul access token | `"***"` |
87
- | `consul.agent.prd.dc` | Production Consul datacenter | `""` |
88
- | `consul.agent.prd.host` | Production Consul UI host | `"consul.my.ui"` |
89
- | `consul.agent.prd.token` | Production Consul access token | `"***"` |
90
- | `mcp.domain` | Domain name for nginx configuration | `""` |
91
- | `ssl-wildcard.conf.rel.path` | Relative path to SSL config in /etc/nginx | `"snippets/ssl-wildcard.conf"` |
92
- | `webServer.auth.enabled` | Enable token authorization | `"false"` |
93
- | `webServer.auth.token.checkMCPName` | Check MCP name in token | `"false"` |
94
- | `isProduction` | Production mode flag | `"false"` |
95
- | `SERVICE_INSTANCE` | Service name suffix for Consul and PM2 | `""` |
96
- | `maintainerUrl` | Support/maintainer URL | `""` |
97
- | `logger.useFileLogger` | Enable file logging | `""` |
98
-
99
- ### Configuration File Examples
100
-
101
-
102
- Link: [YAML Example with detailed comments](https://github.com/Bazilio-san/fa-mcp-sdk/blob/master/cli-config.example.yaml)
103
-
104
- The utility supports both **JSON** and **YAML** configuration formats.
105
- Use either `.json`, `.yaml`, or `.yml` file extensions.
106
-
107
- #### Usage:
108
-
109
- ```bash
110
- # Interactive setup (will prompt for all parameters)
111
- fa-mcp
112
-
113
- # Using JSON configuration
114
- fa-mcp config.json
115
- fa-mcp --config=my-config.json
116
-
117
- # Using YAML configuration (NEW!)
118
- fa-mcp config.yaml
119
- fa-mcp --config=my-config.yml
120
- ```
121
-
122
-
123
-
124
- ## Project Structure
125
-
126
- ```
127
- my-mcp-server/
128
- ├── .claude/ # Settings, Agents, Hooks for Claude Code
129
- │ ├── agents/ # Folder with Claude Code agents. Including the agent fa-mcp-sdk
130
- │ ├── hooks/ # Code formatting hook after changes made by Claude Code
131
- │ └── settings.json # Claude Code settings
132
- ├── .run/ # JetBrains IDE run configurations
133
- ├── config/ # Environment configurations
134
- │ ├── _local.yaml # Local configuration template
135
- │ ├── custom-environment-variables.yaml # Environment mapping
136
- │ ├── default.yaml # Base configuration
137
- │ ├── development.yaml # Development settings
138
- │ ├── local.yaml # Local configuration
139
- │ ├── production.yaml # Production settings
140
- │ └── test.yaml # Test environment
141
- ├── deploy/ # Deployment configurations
142
- │ ├── .gitkeep # Git directory keeper
143
- │ ├── NGINX/ # Nginx configuration templates
144
- │ │ ├── sites-enabled/ # Nginx site configurations
145
- │ │ └── snippets/ # Nginx configuration snippets
146
- │ ├── config.example.yml # Deployment config example
147
- │ ├── pm2.config.js # PM2 process manager config
148
- │ ├── pm2reg.sh # PM2 registration script
149
- │ ├── srv.cjs # Server management script
150
- │ └── srv.sh.readme.md # Server script documentation
151
- ├── FA-MCP-SDK-DOC/ # FA-MCP-SDK Documentation
152
- ├── scripts/ # Utility scripts
153
- │ ├── npm/ # NPM utility scripts
154
- │ ├── generate-jwt.js # CLI JWT token generator
155
- │ ├── kill-port.js # Port cleanup utility
156
- │ ├── pre-commit # Git pre-commit hook
157
- │ └── remove-nul.js # File cleanup utility
158
- ├── src/ # Source code
159
- │ ├── _types_/ # TypeScript type definitions
160
- │ ├── api/ # REST API routes
161
- │ │ └── router.ts # Express router
162
- │ ├── asset/ # Static assets
163
- │ │ └── logo.svg # Application logo/favicon
164
- │ ├── prompts/ # Agent prompts
165
- │ │ ├── agent-brief.ts # Agent brief
166
- │ │ ├── agent-prompt.ts # Main agent prompt
167
- │ │ └── custom-prompts.ts # Custom prompts
168
- │ ├── tools/ # MCP tool implementations
169
- │ │ ├── handle-tool-call.ts # Tool execution handler
170
- │ │ └── tools.ts # Tool definitions
171
- │ ├── custom-resources.ts # Custom MCP resources
172
- │ └── start.ts # Application entry point
173
- ├── swagger/
174
- │ └── openapi.yaml # API description. Generated if none
175
- ├── tests/ # Test suites
176
- │ ├── mcp/ # MCP protocol tests
177
- │ ├── jest-simple-reporter.js # Custom Jest reporter
178
- │ └── utils.ts # Test utilities
179
- ├── .editorconfig # Editor configuration
180
- ├── .env # Environment variables
181
- ├── .env.example # Environment variables template
182
- ├── .envrc # direnv configuration
183
- ├── .gitignore # Git ignore rules
184
- ├── eslint.config.js # ESLint configuration
185
- ├── jest.config.js # Jest test configuration
186
- ├── LICENSE # MIT license file
187
- ├── package.json # NPM package configuration
188
- ├── prompt-example-new-MCP.md # Example of instructions for Claude Code for vibe coding of a custom MCP server
189
- ├── README.md
190
- ├── tsconfig.json # TypeScript configuration
191
- └── update.cjs # Project update script
192
- ```
193
-
194
- Note: The `dist/` directory (compiled JavaScript) is created after running `npm run build`.
195
-
196
- ## Available Scripts
197
-
198
- | Script | Description |
199
- |--------|-------------|
200
- | `npm start` | Start compiled MCP server |
201
- | `npm run build` | Compile TypeScript |
202
- | `npm run cb` | Clean and build |
203
- | `npm run ci` | Install dependencies |
204
- | `npm run reinstall` | Reinstall all dependencies |
205
- | `npm run lint` | Run ESLint |
206
- | `npm run lint:fix` | Fix ESLint issues |
207
- | `npm run test:mcp` | Test MCP tools |
208
- | `npm run test:mcp-http` | Test HTTP transport |
209
- | `npm run test:mcp-sse` | Test SSE transport |
210
- | `npm run test:mcp-stdio` | Test STDIO transport |
211
- | `npm run generate-token` | Generate JWT tokens (Web UI) |
212
- | `node scripts/generate-jwt.js` | Generate JWT token (CLI) |
213
- | `/gen-jwt` | Generate JWT token (Claude Code skill) |
214
- | `/upgrade-guide` | Generate upgrade guide for downstream projects (Claude Code skill) |
215
- | `npm run consul:unreg` | Deregister from Consul |
216
-
217
-
218
- ## Server runs at
219
- `http://localhost:3000` with:
220
- - MCP endpoints at `/mcp/*`
221
- - Admin panel for generating access tokens at `/admin`
222
- - When `adminPanel.authType` includes `jwtToken`, the JWT **must** carry `allow: 'gen-token'`
223
- in its payload to be accepted. Tokens without this claim (e.g. the short-lived JWT
224
- auto-generated for the Agent Tester page) are rejected — this prevents them from
225
- being replayed to mint arbitrary long-lived tokens. `permanentServerTokens` and
226
- `basic` admin auth are unaffected.
227
- Generate an admin-capable JWT:
228
- `node scripts/generate-jwt.js -u admin -ttl 30d -p "allow=gen-token"`
229
- - JWT generation API at `/gen-jwt` (when `webServer.genJwtApiEnable: true`)
230
- - Swagger UI at `/docs`
231
- - Health check at `/health`
232
-
233
- ## Agent Tester
234
-
235
- Built-in chat interface for testing MCP server tools using an AI agent (OpenAI-compatible LLM).
236
- The agent automatically discovers available tools and calls them in a conversational loop.
237
-
238
- To enable, set environment variables (`.env` or shell):
239
- ```
240
- AGENT_TESTER_ENABLED=true
241
- AGENT_TESTER_OPENAI_API_KEY=sk-...
242
- ```
243
-
244
- Or configure in `config/default.yaml` (or `local.yaml`):
245
- ```yaml
246
- agentTester:
247
- enabled: true
248
- openAi:
249
- apiKey: sk-...
250
- ```
251
-
252
- The tester UI is available at `http://localhost:<port>/agent-tester` and auto-connects to the local MCP server.
253
- Supports custom LLM endpoints, configurable system prompts, and dynamic HTTP headers. Recommended model for testing: **gpt-5.2**.
254
-
255
- ## Upgrade Guide Skill
256
-
257
- Claude Code skill that generates a step-by-step upgrade guide for projects built on fa-mcp-sdk.
258
- Analyzes git diff between two versions/commits and produces an MD file covering config changes, template file updates, script changes, API changes, and dependency updates.
259
-
260
- **Usage in Claude Code:**
261
- ```
262
- /upgrade-guide 0.4.30 0.4.37
263
- /upgrade-guide 0.4.30
264
- /upgrade-guide abc1234
265
- /upgrade-guide 0.4.30 0.4.37 на русском
266
- ```
267
-
268
- Output language is English by default. Add a natural-language hint (e.g., "на русском", "in German") to change it.
269
-
270
- Skill location: `.claude/skills/upgrade-guide/SKILL.md`
271
-
272
- ## Directory Requirements
273
-
274
- - Use absolute paths for target directory
275
- - **Empty directories only** - CLI aborts if files exist except for the following:
276
-
277
- .git/
278
- .idea/
279
- .vscode
280
- .DS_Store
281
- node_modules/
282
- dist/
283
- __misc/
284
- _tmp/
285
- .swp
286
- .swo
287
- .sublime-project
288
- .sublime-workspace
289
- ~last-cli-config.json
290
-
291
- ## Deployment
292
-
293
- ### PM2 Production
294
- ```bash
295
- npm run build
296
- pm2 start deploy/pm2.config.js
297
- ```
298
-
299
- ### Systemd Service
300
- ```bash
301
- npm run build
302
- chmod +x deploy/srv.cjs
303
- ./deploy/srv.cjs install
304
- ```
305
-
306
- ### Consul Registration
307
- Set `consul.service.enable: true` and provide required tokens for automatic service registration.
308
-
309
- ### Nginx Configuration
310
- Generated nginx configuration files in `deploy/NGINX/` for domain-based routing.
311
-
312
- ## License
313
-
314
- MIT License
1
+ # MCP Server Template Generator
2
+
3
+ Production-ready core framework for building MCP (Model Context Protocol) servers with comprehensive
4
+ infrastructure support.
5
+
6
+ CLI utility that creates ready-to-use MCP (Model Context Protocol) server projects from the official template.
7
+
8
+ ## Overview
9
+
10
+ This framework provides complete infrastructure for building enterprise-grade MCP servers:
11
+
12
+ - **Dual Transport**: STDIO (Claude Desktop) and HTTP/SSE (web clients)
13
+ - **Agent-Driven Tool Development**: Built-in AI agent system (Agent Tester) for iterative refinement of MCP tools through automated testing cycles — the agent calls your tools, you observe behavior, adjust descriptions/parameters/prompts, and re-test
14
+ - **Headless Test API**: Direct HTTP endpoint (`POST /agent-tester/api/chat/test`) returns structured trace of every tool call, argument, result, and LLM decision — enabling CLI-based automated testing without a browser
15
+ - **Authentication**: JWT (with optional IP restriction), Basic auth, permanent tokens, custom validators
16
+ - **Database Integration**: PostgreSQL with pgvector for vector operations
17
+ - **Service Discovery**: Consul integration for microservices
18
+ - **Rate Limiting**: Configurable rate limiting for all endpoints
19
+ - **API Documentation**: Automatic Swagger/OpenAPI generation
20
+ - **Production Logging**: Structured logging with data masking
21
+ - **Configuration Management**: YAML-based with environment overrides
22
+ - **Deployment Ready**: PM2 scripts, Nginx templates, ESLint, Jest testing
23
+
24
+ The framework uses dependency injection to keep the core completely agnostic of project-specific implementations.
25
+
26
+
27
+ ## Steps to Get Started
28
+
29
+ 1) Install `fa-mcp-sdk` globally:
30
+
31
+ ```bash
32
+ npm install -g fa-mcp-sdk
33
+ ```
34
+
35
+ 2) Run the CLI, specify the target directory, and follow the interactive prompts:
36
+
37
+ ```bash
38
+ fa-mcp
39
+ ```
40
+ Or using configuration file:
41
+
42
+ ```bash
43
+ fa-mcp config.yaml
44
+ ```
45
+
46
+ 3) Launching the template MCP server:
47
+ - Navigate to the target directory: `cd <targetPath>`
48
+ - Install dependencies: `npm install`
49
+ - Build the project: `npm run build`
50
+ - Start the server: `npm start`
51
+
52
+ 4) Vibe-coding your MCP server logic:
53
+ - Create an instruction file (prompt) for your preferred AI coding assistant.
54
+ `fa-mcp-sdk` comes ready for use with `Claude Code`.
55
+ You can find an example prompt for creating an MCP server (e.g., a currency exchange rate provider) in `cli-template/prompt-example-new-MCP.md`.
56
+ - Launch your AI coder and provide it with the instructions to build your new MCP server.
57
+
58
+
59
+
60
+ ## Configuration
61
+
62
+ The CLI collects required and optional parameters through interactive prompts or configuration file.
63
+
64
+ ### Required Parameters
65
+
66
+ | Parameter | Description | Example |
67
+ |-----------------------|-------------|---------|
68
+ | `project.name` | Package.json name and MCP server identification | `"my-mcp-server"` |
69
+ | `project.description` | Package.json description | `"A custom MCP server"` |
70
+ | `project.productName` | Display name for UI and documentation | `"My MCP Server"` |
71
+ | `port` | Web server port for HTTP and MCP protocol | `"3000"` |
72
+
73
+ ### Optional Parameters
74
+
75
+ | Parameter | Description | Default |
76
+ |-------------------------------------|-------------|---------|
77
+ | `author.name` | Package.json author name | `""` |
78
+ | `author.email` | Package.json author email | `""` |
79
+ | `git-base-url` | Git repository base URL | `"github.com/username"` |
80
+ | `consul.service.enable` | Enable Consul service registration | `"false"` |
81
+ | `consul.agent.reg.token` | Token for registering service with Consul | `"***"` |
82
+ | `consul.envCode.dev` | Development environment code | `"<envCode.dev>"` |
83
+ | `consul.envCode.prod` | Production environment code | `"<envCode.prod>"` |
84
+ | `consul.agent.dev.dc` | Development Consul datacenter | `""` |
85
+ | `consul.agent.dev.host` | Development Consul UI host | `"consul.my.ui"` |
86
+ | `consul.agent.dev.token` | Development Consul access token | `"***"` |
87
+ | `consul.agent.prd.dc` | Production Consul datacenter | `""` |
88
+ | `consul.agent.prd.host` | Production Consul UI host | `"consul.my.ui"` |
89
+ | `consul.agent.prd.token` | Production Consul access token | `"***"` |
90
+ | `mcp.domain` | Domain name for nginx configuration | `""` |
91
+ | `ssl-wildcard.conf.rel.path` | Relative path to SSL config in /etc/nginx | `"snippets/ssl-wildcard.conf"` |
92
+ | `webServer.auth.enabled` | Enable token authorization | `"false"` |
93
+ | `webServer.auth.token.checkMCPName` | Check MCP name in token | `"false"` |
94
+ | `isProduction` | Production mode flag | `"false"` |
95
+ | `SERVICE_INSTANCE` | Service name suffix for Consul and PM2 | `""` |
96
+ | `maintainerUrl` | Support/maintainer URL | `""` |
97
+ | `logger.useFileLogger` | Enable file logging | `""` |
98
+
99
+ ### Configuration File Examples
100
+
101
+
102
+ Link: [YAML Example with detailed comments](https://github.com/Bazilio-san/fa-mcp-sdk/blob/master/cli-config.example.yaml)
103
+
104
+ The utility supports both **JSON** and **YAML** configuration formats.
105
+ Use either `.json`, `.yaml`, or `.yml` file extensions.
106
+
107
+ #### Usage:
108
+
109
+ ```bash
110
+ # Interactive setup (will prompt for all parameters)
111
+ fa-mcp
112
+
113
+ # Using JSON configuration
114
+ fa-mcp config.json
115
+ fa-mcp --config=my-config.json
116
+
117
+ # Using YAML configuration (NEW!)
118
+ fa-mcp config.yaml
119
+ fa-mcp --config=my-config.yml
120
+ ```
121
+
122
+
123
+
124
+ ## Project Structure
125
+
126
+ ```
127
+ my-mcp-server/
128
+ ├── .claude/ # Settings, Agents, Hooks for Claude Code
129
+ │ ├── agents/ # Folder with Claude Code agents. Including the agent fa-mcp-sdk
130
+ │ ├── hooks/ # Code formatting hook after changes made by Claude Code
131
+ │ └── settings.json # Claude Code settings
132
+ ├── .run/ # JetBrains IDE run configurations
133
+ ├── config/ # Environment configurations
134
+ │ ├── _local.yaml # Local configuration template
135
+ │ ├── custom-environment-variables.yaml # Environment mapping
136
+ │ ├── default.yaml # Base configuration
137
+ │ ├── development.yaml # Development settings
138
+ │ ├── local.yaml # Local configuration
139
+ │ ├── production.yaml # Production settings
140
+ │ └── test.yaml # Test environment
141
+ ├── deploy/ # Deployment configurations
142
+ │ ├── .gitkeep # Git directory keeper
143
+ │ ├── NGINX/ # Nginx configuration templates
144
+ │ │ ├── sites-enabled/ # Nginx site configurations
145
+ │ │ └── snippets/ # Nginx configuration snippets
146
+ │ ├── config.example.yml # Deployment config example
147
+ │ ├── pm2.config.js # PM2 process manager config
148
+ │ ├── pm2reg.sh # PM2 registration script
149
+ │ ├── srv.cjs # Server management script
150
+ │ └── srv.sh.readme.md # Server script documentation
151
+ ├── FA-MCP-SDK-DOC/ # FA-MCP-SDK Documentation
152
+ ├── scripts/ # Utility scripts
153
+ │ ├── npm/ # NPM utility scripts
154
+ │ ├── generate-jwt.js # CLI JWT token generator
155
+ │ ├── kill-port.js # Port cleanup utility
156
+ │ ├── pre-commit # Git pre-commit hook
157
+ │ └── remove-nul.js # File cleanup utility
158
+ ├── src/ # Source code
159
+ │ ├── _types_/ # TypeScript type definitions
160
+ │ ├── api/ # REST API routes
161
+ │ │ └── router.ts # Express router
162
+ │ ├── asset/ # Static assets
163
+ │ │ └── logo.svg # Application logo/favicon
164
+ │ ├── prompts/ # Agent prompts
165
+ │ │ ├── agent-brief.ts # Agent brief
166
+ │ │ ├── agent-prompt.ts # Main agent prompt
167
+ │ │ └── custom-prompts.ts # Custom prompts
168
+ │ ├── tools/ # MCP tool implementations
169
+ │ │ ├── handle-tool-call.ts # Tool execution handler
170
+ │ │ └── tools.ts # Tool definitions
171
+ │ ├── custom-resources.ts # Custom MCP resources
172
+ │ └── start.ts # Application entry point
173
+ ├── swagger/
174
+ │ └── openapi.yaml # API description. Generated if none
175
+ ├── tests/ # Test suites
176
+ │ ├── mcp/ # MCP protocol tests
177
+ │ ├── jest-simple-reporter.js # Custom Jest reporter
178
+ │ └── utils.ts # Test utilities
179
+ ├── .editorconfig # Editor configuration
180
+ ├── .env # Environment variables
181
+ ├── .env.example # Environment variables template
182
+ ├── .envrc # direnv configuration
183
+ ├── .gitignore # Git ignore rules
184
+ ├── .oxlintrc.json # Oxlint configuration
185
+ ├── .oxfmtrc.json # Oxfmt configuration
186
+ ├── jest.config.js # Jest test configuration
187
+ ├── LICENSE # MIT license file
188
+ ├── package.json # NPM package configuration
189
+ ├── prompt-example-new-MCP.md # Example of instructions for Claude Code for vibe coding of a custom MCP server
190
+ ├── README.md
191
+ ├── tsconfig.json # TypeScript configuration
192
+ └── update.cjs # Project update script
193
+ ```
194
+
195
+ Note: The `dist/` directory (compiled JavaScript) is created after running `npm run build`.
196
+
197
+ ## Available Scripts
198
+
199
+ | Script | Description |
200
+ |--------|-------------|
201
+ | `npm start` | Start compiled MCP server |
202
+ | `npm run build` | Compile TypeScript |
203
+ | `npm run cb` | Clean and build |
204
+ | `npm run ci` | Install dependencies |
205
+ | `npm run reinstall` | Reinstall all dependencies |
206
+ | `npm run lint` | Run Oxlint |
207
+ | `npm run lint:fix` | Fix Oxlint issues |
208
+ | `npm run format` | Check formatting via Oxfmt |
209
+ | `npm run format:fix` | Format the project via Oxfmt |
210
+ | `npm run quality` | Lint + format check |
211
+ | `npm run quality:fix` | Auto-fix lint + format |
212
+ | `npm run test:mcp` | Test MCP tools |
213
+ | `npm run test:mcp-http` | Test HTTP transport |
214
+ | `npm run test:mcp-sse` | Test SSE transport |
215
+ | `npm run test:mcp-stdio` | Test STDIO transport |
216
+ | `npm run generate-token` | Generate JWT tokens (Web UI) |
217
+ | `node scripts/generate-jwt.js` | Generate JWT token (CLI) |
218
+ | `/gen-jwt` | Generate JWT token (Claude Code skill) |
219
+ | `/upgrade-guide` | Generate upgrade guide for downstream projects (Claude Code skill) |
220
+ | `npm run consul:unreg` | Deregister from Consul |
221
+
222
+
223
+ ## Server runs at
224
+ `http://localhost:3000` with:
225
+ - MCP endpoints at `/mcp/*`
226
+ - Admin panel for generating access tokens at `/admin`
227
+ - When `adminPanel.authType` includes `jwtToken`, the JWT **must** carry `allow: 'gen-token'`
228
+ in its payload to be accepted. Tokens without this claim (e.g. the short-lived JWT
229
+ auto-generated for the Agent Tester page) are rejected — this prevents them from
230
+ being replayed to mint arbitrary long-lived tokens. `permanentServerTokens` and
231
+ `basic` admin auth are unaffected.
232
+ Generate an admin-capable JWT:
233
+ `node scripts/generate-jwt.js -u admin -ttl 30d -p "allow=gen-token"`
234
+ - JWT generation API at `/gen-jwt` (when `webServer.genJwtApiEnable: true`)
235
+ - Swagger UI at `/docs`
236
+ - Health check at `/health`
237
+
238
+ ## Agent Tester
239
+
240
+ Built-in chat interface for testing MCP server tools using an AI agent (OpenAI-compatible LLM).
241
+ The agent automatically discovers available tools and calls them in a conversational loop.
242
+
243
+ To enable, set environment variables (`.env` or shell):
244
+ ```
245
+ AGENT_TESTER_ENABLED=true
246
+ AGENT_TESTER_OPENAI_API_KEY=sk-...
247
+ ```
248
+
249
+ Or configure in `config/default.yaml` (or `local.yaml`):
250
+ ```yaml
251
+ agentTester:
252
+ enabled: true
253
+ openAi:
254
+ apiKey: sk-...
255
+ ```
256
+
257
+ The tester UI is available at `http://localhost:<port>/agent-tester` and auto-connects to the local MCP server.
258
+ Supports custom LLM endpoints, configurable system prompts, and dynamic HTTP headers. Recommended model for testing: **gpt-5.2**.
259
+
260
+ ## Upgrade Guide Skill
261
+
262
+ Claude Code skill that generates a step-by-step upgrade guide for projects built on fa-mcp-sdk.
263
+ Analyzes git diff between two versions/commits and produces an MD file covering config changes, template file updates, script changes, API changes, and dependency updates.
264
+
265
+ **Usage in Claude Code:**
266
+ ```
267
+ /upgrade-guide 0.4.30 0.4.37
268
+ /upgrade-guide 0.4.30
269
+ /upgrade-guide abc1234
270
+ /upgrade-guide 0.4.30 0.4.37 на русском
271
+ ```
272
+
273
+ Output language is English by default. Add a natural-language hint (e.g., "на русском", "in German") to change it.
274
+
275
+ Skill location: `.claude/skills/upgrade-guide/SKILL.md`
276
+
277
+ ## Directory Requirements
278
+
279
+ - Use absolute paths for target directory
280
+ - **Empty directories only** - CLI aborts if files exist except for the following:
281
+
282
+ .git/
283
+ .idea/
284
+ .vscode
285
+ .DS_Store
286
+ node_modules/
287
+ dist/
288
+ __misc/
289
+ _tmp/
290
+ .swp
291
+ .swo
292
+ .sublime-project
293
+ .sublime-workspace
294
+ ~last-cli-config.json
295
+
296
+ ## Deployment
297
+
298
+ ### PM2 Production
299
+ ```bash
300
+ npm run build
301
+ pm2 start deploy/pm2.config.js
302
+ ```
303
+
304
+ ### Systemd Service
305
+ ```bash
306
+ npm run build
307
+ chmod +x deploy/srv.cjs
308
+ ./deploy/srv.cjs install
309
+ ```
310
+
311
+ ### Consul Registration
312
+ Set `consul.service.enable: true` and provide required tokens for automatic service registration.
313
+
314
+ ### Nginx Configuration
315
+ Generated nginx configuration files in `deploy/NGINX/` for domain-based routing.
316
+
317
+ ## License
318
+
319
+ MIT License