fa-mcp-sdk 0.2.220 → 0.2.224
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +285 -219
- package/bin/fa-mcp.js +1 -0
- package/cli-template/package.json +1 -1
- package/cli-template/prompt-example-new-MCP.md +77 -0
- package/dist/core/web/openapi.d.ts.map +1 -1
- package/dist/core/web/openapi.js +1 -2
- package/dist/core/web/openapi.js.map +1 -1
- package/package.json +1 -1
- package/scripts/publish.sh +78 -0
- package/src/template/start.ts +2 -2
package/README.md
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
# fa-mcp
|
|
1
|
+
# MCP Server Template Generator (`fa-mcp`)
|
|
2
2
|
|
|
3
|
-
Production-ready core framework for building MCP (Model Context Protocol) servers with comprehensive
|
|
3
|
+
Production-ready core framework for building MCP (Model Context Protocol) servers with comprehensive
|
|
4
4
|
infrastructure support.
|
|
5
5
|
|
|
6
|
+
CLI utility that creates ready-to-use MCP (Model Context Protocol) server projects from the official template.
|
|
7
|
+
|
|
6
8
|
## Overview
|
|
7
9
|
|
|
8
10
|
This framework provides complete infrastructure for building enterprise-grade MCP servers with support for:
|
|
@@ -18,284 +20,348 @@ This framework provides complete infrastructure for building enterprise-grade MC
|
|
|
18
20
|
|
|
19
21
|
The framework uses dependency injection to keep the core completely agnostic of project-specific implementations.
|
|
20
22
|
|
|
21
|
-
## Project Structure
|
|
22
23
|
|
|
23
|
-
|
|
24
|
-
fa-mcp-sdk/
|
|
25
|
-
├── src/core/ # Core framework (published to npm)
|
|
26
|
-
│ ├── bootstrap/ # Configuration and startup
|
|
27
|
-
│ ├── mcp/ # MCP protocol implementation
|
|
28
|
-
│ ├── web/ # HTTP server and endpoints
|
|
29
|
-
│ ├── db/ # PostgreSQL integration
|
|
30
|
-
│ ├── cache/ # Caching system with node-cache wrapper
|
|
31
|
-
│ ├── consul/ # Service discovery
|
|
32
|
-
│ ├── token/ # Authentication
|
|
33
|
-
│ ├── errors/ # Error handling
|
|
34
|
-
│ ├── utils/ # Utilities
|
|
35
|
-
│ └── index.ts # Public API
|
|
36
|
-
│
|
|
37
|
-
└── src/template/ # Reference implementation
|
|
38
|
-
├── tools/ # Example MCP tools
|
|
39
|
-
├── prompts/ # Agent prompts
|
|
40
|
-
├── api/ # Custom HTTP endpoints
|
|
41
|
-
└── start.ts # Entry point
|
|
42
|
-
```
|
|
24
|
+
## Steps to Get Started
|
|
43
25
|
|
|
44
|
-
|
|
26
|
+
1) Install `fa-mcp-sdk` globally:
|
|
45
27
|
|
|
46
|
-
|
|
28
|
+
```bash
|
|
29
|
+
npm install -g fa-mcp-sdk
|
|
30
|
+
```
|
|
47
31
|
|
|
48
|
-
|
|
49
|
-
npm install
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
### 2. Configure
|
|
53
|
-
|
|
54
|
-
Create configuration files in `config/`:
|
|
55
|
-
|
|
56
|
-
See [config/default.yaml](config/default.yaml) for all available options.
|
|
57
|
-
See [config/_local.yaml](config/_local.yaml) for template of local configuration.
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
### 3. Basic Usage
|
|
61
|
-
|
|
62
|
-
```typescript
|
|
63
|
-
import { initMcpServer, isMainModule, McpServerData } from '../core/index.js';
|
|
64
|
-
import { readFileSync } from 'fs';
|
|
65
|
-
import { join } from 'path';
|
|
66
|
-
|
|
67
|
-
export async function startProject(): Promise<void> {
|
|
68
|
-
// Read favicon from assets
|
|
69
|
-
const faviconPath = join(process.cwd(), 'src/template/asset/favicon.svg');
|
|
70
|
-
let favicon: string;
|
|
71
|
-
|
|
72
|
-
try {
|
|
73
|
-
favicon = readFileSync(faviconPath, 'utf-8');
|
|
74
|
-
} catch (_error) {
|
|
75
|
-
// Fallback if favicon not found
|
|
76
|
-
favicon = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">
|
|
77
|
-
<rect width="16" height="16" fill="#007ACC"/>
|
|
78
|
-
</svg>`;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// Assemble all data to pass to the core
|
|
82
|
-
const serverData: McpServerData = {
|
|
83
|
-
// Required: MCP components
|
|
84
|
-
tools: [
|
|
85
|
-
{
|
|
86
|
-
name: 'example_tool',
|
|
87
|
-
description: 'Example tool',
|
|
88
|
-
inputSchema: {
|
|
89
|
-
type: 'object',
|
|
90
|
-
properties: {
|
|
91
|
-
query: { type: 'string', description: 'Query parameter' }
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
],
|
|
96
|
-
toolHandler: async (params) => {
|
|
97
|
-
const { name, arguments: args } = params;
|
|
98
|
-
if (name === 'example_tool') {
|
|
99
|
-
return `Result: ${args.query}`;
|
|
100
|
-
}
|
|
101
|
-
throw new Error(`Unknown tool: ${name}`);
|
|
102
|
-
},
|
|
103
|
-
|
|
104
|
-
// Required: Agent identification
|
|
105
|
-
agentBrief: "My MCP Server - Brief description for agent selection",
|
|
106
|
-
agentPrompt: "Detailed system prompt for the agent",
|
|
107
|
-
|
|
108
|
-
// Optional: Custom prompts and resources
|
|
109
|
-
customPrompts: [],
|
|
110
|
-
customResources: [],
|
|
111
|
-
|
|
112
|
-
// Optional: HTTP components
|
|
113
|
-
httpComponents: {
|
|
114
|
-
apiRouter, // Express router for custom endpoints
|
|
115
|
-
},
|
|
116
|
-
|
|
117
|
-
// Optional: Assets
|
|
118
|
-
assets: { favicon },
|
|
119
|
-
|
|
120
|
-
// Optional: Function to get Consul UI address
|
|
121
|
-
getConsulUIAddress: (serviceId: string) =>
|
|
122
|
-
`https://consul.my.ui/ui/dc-dev/services/${serviceId}/instances`,
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
// Start MCP server with assembled data
|
|
126
|
-
await initMcpServer(serverData);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
// Auto-start if this file is run directly
|
|
130
|
-
if (isMainModule(import.meta.url)) {
|
|
131
|
-
startProject().catch(error => {
|
|
132
|
-
console.error('Failed to start project:', error);
|
|
133
|
-
process.exit(1);
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
```
|
|
32
|
+
2) Run the CLI, specify the target directory, and follow the interactive prompts:
|
|
137
33
|
|
|
138
|
-
|
|
34
|
+
```bash
|
|
35
|
+
fa-mcp
|
|
36
|
+
```
|
|
139
37
|
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
38
|
+
3) Launching the template MCP server:
|
|
39
|
+
- Navigate to the target directory: `cd <targetPath>`
|
|
40
|
+
- Install dependencies: `npm install`
|
|
41
|
+
- Build the project: `npm run build`
|
|
42
|
+
- Start the server: `npm start`
|
|
144
43
|
|
|
145
|
-
|
|
44
|
+
4) Vibe-coding your MCP server logic:
|
|
45
|
+
- Create an instruction file (prompt) for your preferred AI coding assistant.
|
|
46
|
+
`fa-mcp-sdk` comes ready for use with `Claude Code`.
|
|
47
|
+
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`.
|
|
48
|
+
- Launch your AI coder and provide it with the instructions to build your new MCP server.
|
|
146
49
|
|
|
147
|
-
|
|
50
|
+
`
|
|
148
51
|
|
|
149
|
-
|
|
52
|
+
### Using Configuration File
|
|
150
53
|
|
|
151
54
|
```bash
|
|
152
|
-
|
|
153
|
-
mcp.transportType: stdio
|
|
154
|
-
|
|
155
|
-
# Or via command line
|
|
156
|
-
npm start stdio
|
|
55
|
+
fa-mcp config.yaml
|
|
157
56
|
```
|
|
158
57
|
|
|
159
|
-
|
|
58
|
+
## Configuration
|
|
160
59
|
|
|
161
|
-
|
|
60
|
+
The CLI collects required and optional parameters through interactive prompts or configuration file.
|
|
61
|
+
|
|
62
|
+
### Required Parameters
|
|
63
|
+
|
|
64
|
+
| Parameter | Description | Example |
|
|
65
|
+
|-----------------------|-------------|---------|
|
|
66
|
+
| `project.name` | Package.json name and MCP server identification | `"my-mcp-server"` |
|
|
67
|
+
| `project.description` | Package.json description | `"A custom MCP server"` |
|
|
68
|
+
| `project.productName` | Display name for UI and documentation | `"My MCP Server"` |
|
|
69
|
+
| `port` | Web server port for HTTP and MCP protocol | `"3000"` |
|
|
70
|
+
|
|
71
|
+
### Optional Parameters
|
|
72
|
+
|
|
73
|
+
| Parameter | Description | Default |
|
|
74
|
+
|-------------------------------------|-------------|---------|
|
|
75
|
+
| `author.name` | Package.json author name | `""` |
|
|
76
|
+
| `author.email` | Package.json author email | `""` |
|
|
77
|
+
| `git-base-url` | Git repository base URL | `"github.com/username"` |
|
|
78
|
+
| `consul.service.enable` | Enable Consul service registration | `"false"` |
|
|
79
|
+
| `consul.agent.reg.token` | Token for registering service with Consul | `"***"` |
|
|
80
|
+
| `consul.envCode.dev` | Development environment code | `"<envCode.dev>"` |
|
|
81
|
+
| `consul.envCode.prod` | Production environment code | `"<envCode.prod>"` |
|
|
82
|
+
| `consul.agent.dev.dc` | Development Consul datacenter | `""` |
|
|
83
|
+
| `consul.agent.dev.host` | Development Consul UI host | `"consul.my.ui"` |
|
|
84
|
+
| `consul.agent.dev.token` | Development Consul access token | `"***"` |
|
|
85
|
+
| `consul.agent.prd.dc` | Production Consul datacenter | `""` |
|
|
86
|
+
| `consul.agent.prd.host` | Production Consul UI host | `"consul.my.ui"` |
|
|
87
|
+
| `consul.agent.prd.token` | Production Consul access token | `"***"` |
|
|
88
|
+
| `mcp.domain` | Domain name for nginx configuration | `""` |
|
|
89
|
+
| `ssl-wildcard.conf.rel.path` | Relative path to SSL config in /etc/nginx | `"snippets/ssl-wildcard.conf"` |
|
|
90
|
+
| `webServer.auth.enabled` | Enable token authorization | `"false"` |
|
|
91
|
+
| `webServer.auth.token.checkMCPName` | Check MCP name in token | `"false"` |
|
|
92
|
+
| `isProduction` | Production mode flag | `"false"` |
|
|
93
|
+
| `SERVICE_INSTANCE` | Service name suffix for Consul and PM2 | `""` |
|
|
94
|
+
| `maintainerUrl` | Support/maintainer URL | `""` |
|
|
95
|
+
| `logger.useFileLogger` | Enable file logging | `""` |
|
|
96
|
+
|
|
97
|
+
### Configuration File Examples
|
|
98
|
+
|
|
99
|
+
The utility supports both **JSON** and **YAML** configuration formats.
|
|
100
|
+
Use either `.json`, `.yaml`, or `.yml` file extensions.
|
|
101
|
+
|
|
102
|
+
#### Usage:
|
|
103
|
+
```bash
|
|
104
|
+
# Interactive setup (will prompt for all parameters)
|
|
105
|
+
fa-mcp
|
|
162
106
|
|
|
163
|
-
|
|
107
|
+
# Using JSON configuration
|
|
108
|
+
fa-mcp config.json
|
|
109
|
+
fa-mcp --config=my-config.json
|
|
164
110
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
111
|
+
# Using YAML configuration (NEW!)
|
|
112
|
+
fa-mcp config.yaml
|
|
113
|
+
fa-mcp --config=my-config.yml
|
|
168
114
|
```
|
|
169
115
|
|
|
170
|
-
|
|
116
|
+
#### YAML Example (with detailed comments):
|
|
117
|
+
```yaml
|
|
118
|
+
# =============================================================================
|
|
119
|
+
# REQUIRED PARAMETERS
|
|
120
|
+
# =============================================================================
|
|
171
121
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
- `GET /sse` - Server-Sent Events for MCP communication
|
|
175
|
-
- `POST /mcp` - Direct MCP JSON-RPC endpoint
|
|
176
|
-
- `GET /docs` - Swagger API documentation
|
|
177
|
-
- `/api/*` - Custom API endpoints
|
|
122
|
+
# Project name used in package.json and for MCP server identification
|
|
123
|
+
project.name: "mcp-example"
|
|
178
124
|
|
|
179
|
-
|
|
125
|
+
# Project description displayed in package.json
|
|
126
|
+
project.description: "MCP Server example description"
|
|
180
127
|
|
|
181
|
-
|
|
128
|
+
# Product name displayed in UI and documentation
|
|
129
|
+
project.productName: "MCP Example"
|
|
182
130
|
|
|
183
|
-
|
|
131
|
+
# Web server port for HTTP endpoints and MCP protocol
|
|
132
|
+
port: "8888"
|
|
184
133
|
|
|
185
|
-
|
|
134
|
+
# =============================================================================
|
|
135
|
+
# PROJECT SETUP
|
|
136
|
+
# =============================================================================
|
|
186
137
|
|
|
138
|
+
# Absolute path where the project will be created
|
|
139
|
+
projectAbsPath: "/opt/node/mcp-example"
|
|
187
140
|
|
|
141
|
+
# Auto-accept configuration without confirmation prompts
|
|
142
|
+
forceAcceptConfig: "y"
|
|
188
143
|
|
|
189
|
-
|
|
144
|
+
# =============================================================================
|
|
145
|
+
# AUTHOR INFORMATION
|
|
146
|
+
# =============================================================================
|
|
190
147
|
|
|
191
|
-
|
|
148
|
+
# Author email for package.json
|
|
149
|
+
author.email: "author@company.com"
|
|
192
150
|
|
|
193
|
-
|
|
151
|
+
# Author name for package.json
|
|
152
|
+
author.name: "Author Name"
|
|
194
153
|
|
|
195
|
-
|
|
196
|
-
#
|
|
197
|
-
|
|
154
|
+
# =============================================================================
|
|
155
|
+
# CONSUL SERVICE DISCOVERY
|
|
156
|
+
# =============================================================================
|
|
198
157
|
|
|
199
|
-
#
|
|
200
|
-
|
|
158
|
+
# Enable service registration with Consul
|
|
159
|
+
consul.service.enable: "true"
|
|
201
160
|
|
|
202
|
-
#
|
|
203
|
-
|
|
204
|
-
|
|
161
|
+
# Development environment Consul settings
|
|
162
|
+
consul.agent.dev.dc: "dc-dev"
|
|
163
|
+
consul.agent.dev.host: "consul.my.ui"
|
|
164
|
+
consul.agent.dev.token: "12345678-90ab-cdef-cdef-90ab12345678"
|
|
205
165
|
|
|
206
|
-
|
|
166
|
+
# Production environment Consul settings
|
|
167
|
+
consul.agent.prd.dc: "dc-prod"
|
|
168
|
+
consul.agent.prd.host: "consul.my.ui"
|
|
169
|
+
consul.agent.prd.token: "21345678-90ab-cdef-cdef-90ab12345678"
|
|
207
170
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
- **Prompts**: `src/template/prompts/` - Agent system prompts
|
|
211
|
-
- **API**: `src/template/api/router.ts` - Custom HTTP endpoints
|
|
212
|
-
- **Config**: `config/` - Configuration files
|
|
171
|
+
# Consul service registration token
|
|
172
|
+
consul.agent.reg.token: "12345678-90ab-cdef-cdef-90ab12345678"
|
|
213
173
|
|
|
214
|
-
|
|
174
|
+
# Environment codes for service ID generation
|
|
175
|
+
consul.envCode.dev: "envCode-dev"
|
|
176
|
+
consul.envCode.prod: "envCode-prod"
|
|
215
177
|
|
|
216
|
-
|
|
178
|
+
# Affects how the Consul service ID is formed - as a product or development ID. Valid values: "" | "development" | "production"
|
|
179
|
+
NODE_CONSUL_ENV: ""
|
|
217
180
|
|
|
218
|
-
|
|
181
|
+
# =============================================================================
|
|
182
|
+
# WEB SERVER & DOMAIN CONFIGURATION
|
|
183
|
+
# =============================================================================
|
|
219
184
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
DB_NAME=mydb
|
|
223
|
-
DB_USER=user
|
|
224
|
-
DB_PASSWORD=password
|
|
225
|
-
MCP_TRANSPORT_TYPE=http
|
|
226
|
-
WS_PORT=9876
|
|
227
|
-
WS_AUTH_ENABLED=false
|
|
228
|
-
```
|
|
185
|
+
# Domain name for nginx configuration
|
|
186
|
+
mcp.domain: "mcp-example.company.com"
|
|
229
187
|
|
|
230
|
-
|
|
188
|
+
# Relative path to SSL certificate configuration
|
|
189
|
+
ssl-wildcard.conf.rel.path: "snippets/ssl-wildcard-company-com.conf"
|
|
231
190
|
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
3. `config/default.yaml`
|
|
235
|
-
4. Package.json metadata
|
|
191
|
+
# Nginx upstream name (auto-generated from domain)
|
|
192
|
+
upstream: "mcp-example-company-com"
|
|
236
193
|
|
|
237
|
-
|
|
194
|
+
# =============================================================================
|
|
195
|
+
# AUTHENTICATION & SECURITY
|
|
196
|
+
# =============================================================================
|
|
238
197
|
|
|
239
|
-
|
|
198
|
+
# Enable token-based authorization for MCP server
|
|
199
|
+
webServer.auth.enabled: "true"
|
|
240
200
|
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
npm run clean # Clean dist/
|
|
244
|
-
npm run cb # Clean + build
|
|
245
|
-
```
|
|
201
|
+
# Check MCP server name in authentication tokens
|
|
202
|
+
webServer.auth.token.checkMCPName: "true"
|
|
246
203
|
|
|
247
|
-
|
|
204
|
+
# Encryption key for MCP authentication tokens
|
|
205
|
+
webServer.auth.token.encryptKey: "b7cdde45-3896-46a3-868a-ff4fe4******"
|
|
248
206
|
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
npm run lint:fix # Fix automatically
|
|
252
|
-
```
|
|
207
|
+
# Enable "GOD Mode" for Claude Code (development only)
|
|
208
|
+
claude.isBypassPermissions: "false"
|
|
253
209
|
|
|
254
|
-
|
|
210
|
+
# =============================================================================
|
|
211
|
+
# ENVIRONMENT & DEPLOYMENT
|
|
212
|
+
# =============================================================================
|
|
255
213
|
|
|
256
|
-
|
|
257
|
-
|
|
214
|
+
# Git repository base URL
|
|
215
|
+
git-base-url: "gitlab.company.com/PROJ_NAME"
|
|
216
|
+
|
|
217
|
+
# File-based logging configuration
|
|
218
|
+
logger.useFileLogger: "false"
|
|
219
|
+
|
|
220
|
+
# Support/maintainer URL
|
|
221
|
+
maintainerUrl: "https://support.company.com/dept/1234"
|
|
222
|
+
|
|
223
|
+
# Environment settings (auto-configured)
|
|
224
|
+
NODE_ENV: "development"
|
|
225
|
+
SERVICE_INSTANCE: "dev"
|
|
226
|
+
PM2_NAMESPACE: "dev"
|
|
258
227
|
```
|
|
259
228
|
|
|
260
|
-
|
|
229
|
+
> **Note**: For a complete YAML example with detailed comments for every parameter, see [`cli-config.example.yaml`](./cli-config.example.yaml)
|
|
261
230
|
|
|
262
|
-
|
|
231
|
+
## Generated Project Features
|
|
263
232
|
|
|
264
|
-
|
|
265
|
-
|
|
233
|
+
- TypeScript MCP server with HTTP/STDIO transport
|
|
234
|
+
- Express.js web server with Swagger documentation
|
|
235
|
+
- JWT authentication support (optional)
|
|
236
|
+
- Consul service discovery integration (optional)
|
|
237
|
+
- File and console logging
|
|
238
|
+
- ESLint configuration and Jest testing
|
|
239
|
+
- PM2 deployment scripts
|
|
240
|
+
- Nginx configuration templates
|
|
266
241
|
|
|
267
|
-
|
|
268
|
-
const client = McpSseClient.createWithErrorHandler('http://localhost:3000');
|
|
242
|
+
## Project Structure
|
|
269
243
|
|
|
270
|
-
try {
|
|
271
|
-
const response = await client.callTool('tool_name', { param: 'value' });
|
|
272
|
-
console.log('Success:', response);
|
|
273
|
-
} catch (error) {
|
|
274
|
-
console.log('Error:', error.message); // Properly caught
|
|
275
|
-
} finally {
|
|
276
|
-
await client.close();
|
|
277
|
-
}
|
|
278
244
|
```
|
|
245
|
+
my-mcp-server/
|
|
246
|
+
├── .claude/ # Settings, Agents, Hooks for Claude Code
|
|
247
|
+
│ ├── agents/ # Folder with Claude Code agents. Including the agent fa-mcp-sdk
|
|
248
|
+
│ ├── hooks/ # Code formatting hook after changes made by Claude Code
|
|
249
|
+
│ └── settings.json # Claude Code settings
|
|
250
|
+
├── .run/ # JetBrains IDE run configurations
|
|
251
|
+
├── config/ # Environment configurations
|
|
252
|
+
│ ├── _local.yaml # Local configuration template
|
|
253
|
+
│ ├── custom-environment-variables.yaml # Environment mapping
|
|
254
|
+
│ ├── default.yaml # Base configuration
|
|
255
|
+
│ ├── development.yaml # Development settings
|
|
256
|
+
│ ├── local.yaml # Local configuration
|
|
257
|
+
│ ├── production.yaml # Production settings
|
|
258
|
+
│ └── test.yaml # Test environment
|
|
259
|
+
├── deploy/ # Deployment configurations
|
|
260
|
+
│ ├── .gitkeep # Git directory keeper
|
|
261
|
+
│ ├── NGINX/ # Nginx configuration templates
|
|
262
|
+
│ │ ├── sites-enabled/ # Nginx site configurations
|
|
263
|
+
│ │ └── snippets/ # Nginx configuration snippets
|
|
264
|
+
│ ├── config.example.yml # Deployment config example
|
|
265
|
+
│ ├── pm2.config.js # PM2 process manager config
|
|
266
|
+
│ ├── pm2reg.sh # PM2 registration script
|
|
267
|
+
│ ├── srv.cjs # Server management script
|
|
268
|
+
│ └── srv.sh.readme.md # Server script documentation
|
|
269
|
+
├── FA-MCP-SDK-DOC/ # FA-MCP-SDK Documentation
|
|
270
|
+
├── scripts/ # Utility scripts
|
|
271
|
+
│ ├── npm/ # NPM utility scripts
|
|
272
|
+
│ ├── kill-port.js # Port cleanup utility
|
|
273
|
+
│ ├── pre-commit # Git pre-commit hook
|
|
274
|
+
│ └── remove-nul.js # File cleanup utility
|
|
275
|
+
├── src/ # Source code
|
|
276
|
+
│ ├── _types_/ # TypeScript type definitions
|
|
277
|
+
│ ├── api/ # REST API routes
|
|
278
|
+
│ │ └── router.ts # Express router
|
|
279
|
+
│ ├── asset/ # Static assets
|
|
280
|
+
│ │ └── logo.svg # Application logo/favicon
|
|
281
|
+
│ ├── prompts/ # Agent prompts
|
|
282
|
+
│ │ ├── agent-brief.ts # Agent brief
|
|
283
|
+
│ │ ├── agent-prompt.ts # Main agent prompt
|
|
284
|
+
│ │ └── custom-prompts.ts # Custom prompts
|
|
285
|
+
│ ├── tools/ # MCP tool implementations
|
|
286
|
+
│ │ ├── handle-tool-call.ts # Tool execution handler
|
|
287
|
+
│ │ └── tools.ts # Tool definitions
|
|
288
|
+
│ ├── custom-resources.ts # Custom MCP resources
|
|
289
|
+
│ └── start.ts # Application entry point
|
|
290
|
+
├── swagger/
|
|
291
|
+
│ └── openapi.yaml # API description. Generated if none
|
|
292
|
+
├── tests/ # Test suites
|
|
293
|
+
│ ├── mcp/ # MCP protocol tests
|
|
294
|
+
│ ├── jest-simple-reporter.js # Custom Jest reporter
|
|
295
|
+
│ └── utils.ts # Test utilities
|
|
296
|
+
├── .editorconfig # Editor configuration
|
|
297
|
+
├── .env # Environment variables
|
|
298
|
+
├── .env.example # Environment variables template
|
|
299
|
+
├── .envrc # direnv configuration
|
|
300
|
+
├── .gitignore # Git ignore rules
|
|
301
|
+
├── eslint.config.js # ESLint configuration
|
|
302
|
+
├── jest.config.js # Jest test configuration
|
|
303
|
+
├── LICENSE # MIT license file
|
|
304
|
+
├── package.json # NPM package configuration
|
|
305
|
+
├── prompt-example-new-MCP.md # Example of instructions for Claude Code for vibe coding of a custom MCP server
|
|
306
|
+
├── README.md
|
|
307
|
+
├── tsconfig.json # TypeScript configuration
|
|
308
|
+
└── update.cjs # Project update script
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
Note: The `dist/` directory (compiled JavaScript) is created after running `npm run build`.
|
|
312
|
+
|
|
313
|
+
## Available Scripts
|
|
279
314
|
|
|
280
|
-
|
|
315
|
+
| Script | Description |
|
|
316
|
+
|--------|-------------|
|
|
317
|
+
| `npm start` | Start compiled MCP server |
|
|
318
|
+
| `npm run build` | Compile TypeScript |
|
|
319
|
+
| `npm run cb` | Clean and build |
|
|
320
|
+
| `npm run ci` | Install dependencies |
|
|
321
|
+
| `npm run reinstall` | Reinstall all dependencies |
|
|
322
|
+
| `npm run lint` | Run ESLint |
|
|
323
|
+
| `npm run lint:fix` | Fix ESLint issues |
|
|
324
|
+
| `npm run test:mcp` | Test MCP tools |
|
|
325
|
+
| `npm run test:mcp-http` | Test HTTP transport |
|
|
326
|
+
| `npm run test:mcp-sse` | Test SSE transport |
|
|
327
|
+
| `npm run test:mcp-stdio` | Test STDIO transport |
|
|
328
|
+
| `npm run generate-token` | Generate JWT tokens |
|
|
329
|
+
| `npm run consul:unreg` | Deregister from Consul |
|
|
281
330
|
|
|
282
|
-
## API Reference
|
|
283
331
|
|
|
284
|
-
|
|
332
|
+
## Server runs at
|
|
333
|
+
`http://localhost:3000` with:
|
|
334
|
+
- MCP endpoints at `/mcp/*`
|
|
335
|
+
- Swagger UI at `/swagger`
|
|
336
|
+
- Health check at `/health`
|
|
285
337
|
|
|
286
|
-
|
|
338
|
+
## Directory Requirements
|
|
287
339
|
|
|
288
|
-
|
|
340
|
+
- **Empty directories only** - CLI aborts if files exist
|
|
341
|
+
- Allowed files: `.git`, `.idea`, `.vscode`, `.DS_Store`, `node_modules`, `dist`, `__misc`, `_tmp`, `.swp`, `.swo`, `.sublime-project`, `.sublime-workspace`, `~last-cli-config.json`
|
|
342
|
+
- Use absolute paths for target directory
|
|
289
343
|
|
|
290
|
-
|
|
344
|
+
## Deployment
|
|
345
|
+
|
|
346
|
+
### PM2 Production
|
|
347
|
+
```bash
|
|
348
|
+
npm run build
|
|
349
|
+
pm2 start deploy/pm2.config.js
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
### Systemd Service
|
|
353
|
+
```bash
|
|
354
|
+
npm run build
|
|
355
|
+
chmod +x deploy/srv.cjs
|
|
356
|
+
./deploy/srv.cjs install
|
|
357
|
+
```
|
|
291
358
|
|
|
292
|
-
|
|
359
|
+
### Consul Registration
|
|
360
|
+
Set `consul.service.enable: true` and provide required tokens for automatic service registration.
|
|
293
361
|
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
- **PostgreSQL**: >= 12 (optional)
|
|
297
|
-
- **Consul**: Any version (optional)
|
|
362
|
+
### Nginx Configuration
|
|
363
|
+
Generated nginx configuration files in `deploy/NGINX/` for domain-based routing.
|
|
298
364
|
|
|
299
365
|
## License
|
|
300
366
|
|
|
301
|
-
MIT
|
|
367
|
+
MIT License
|
package/bin/fa-mcp.js
CHANGED
|
@@ -907,6 +907,7 @@ certificate's public and private keys`,
|
|
|
907
907
|
const scriptsTargetPath = path.join(targetPath, 'scripts');
|
|
908
908
|
await this.copyDirectory(path.join(PROJ_ROOT, 'scripts'), scriptsTargetPath);
|
|
909
909
|
await fs.rm(path.join(targetPath, 'scripts/copy-static.js'), { force: true });
|
|
910
|
+
await fs.rm(path.join(targetPath, 'scripts/publish.sh'), { force: true });
|
|
910
911
|
|
|
911
912
|
// Rename all .xml files in .run directory to .run.xml
|
|
912
913
|
const runDirPath = path.join(targetPath, '.run');
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# Goal
|
|
2
|
+
Write the code for MCP server tools that implement retrieving the current cross-rate for a specified pair of currencies.
|
|
3
|
+
|
|
4
|
+
## Instructions
|
|
5
|
+
|
|
6
|
+
### Currency Cross-Rate API
|
|
7
|
+
|
|
8
|
+
#### Available Currencies
|
|
9
|
+
Currency codes (ISO 4217 code Alpha-3): ALL, ARS, AUD, BGN, BRL, BYN, CAD, CHF, CLP, CNY, CZK, DKK, EUR, GBP, HKD, HRK, HUF, IDR, INR, ISK, JOD, JPY, KRW, KZT, LAK, LKR, MKD, MMK, MXN, MYR, NOK, NPR, NZD, PHP, PLN, RON, RSD, RUB, SEK, SGD, THB, TRY, TWD, UAH, USD, VND, ZAR
|
|
10
|
+
|
|
11
|
+
#### Endpoint
|
|
12
|
+
|
|
13
|
+
```http request
|
|
14
|
+
GET http://<appConfig.accessPoints.currencyService.host>:<appConfig.accessPoints.currencyService.port>/currency-service/?rate=<QUOTE_CURRENCY><BASE_CURRENCY>
|
|
15
|
+
Authorization: Bearer <appConfig.accessPoints.currencyService.token>
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Example:
|
|
19
|
+
|
|
20
|
+
```http request
|
|
21
|
+
GET http://smart-trade-ml.com:5002/currency-service/?rate=THBRUB
|
|
22
|
+
Authorization: Bearer <appConfig.accessPoints.currencyService.token>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Response:
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{"symbol": "THBRUB", "rate": 2.424167346170733}
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Possible error codes: 400, 401, 404, 502
|
|
32
|
+
|
|
33
|
+
### Addition to config/default.yaml
|
|
34
|
+
|
|
35
|
+
```yaml
|
|
36
|
+
accessPoints:
|
|
37
|
+
currencyService:
|
|
38
|
+
host: smart-trade-ml.com
|
|
39
|
+
port: 5002
|
|
40
|
+
token: '***'
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
### Create config/local.yaml
|
|
45
|
+
|
|
46
|
+
Create a file config/local.yaml with the following content:
|
|
47
|
+
|
|
48
|
+
```yaml
|
|
49
|
+
accessPoints:
|
|
50
|
+
currencyService:
|
|
51
|
+
token: '88888888-4444-4444-4444-bbbbbbbbbbbb'
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
### Code Style
|
|
56
|
+
Write code concisely. Avoid unnecessary logging.
|
|
57
|
+
Follow DRY and KISS principles.
|
|
58
|
+
|
|
59
|
+
### Use the fa-mcp-sdk agent
|
|
60
|
+
Follow the recommendations in the file FA-MCP-SDK-DOC/00-FA-MCP-SDK-index.md
|
|
61
|
+
|
|
62
|
+
# Task
|
|
63
|
+
|
|
64
|
+
1) Instead of the test tool 'example_tool', add a tool to get the current currency cross-rate.
|
|
65
|
+
Tool parameters:
|
|
66
|
+
- quoteCurrency - Currency code (ISO 4217 code Alpha-3) - required parameter
|
|
67
|
+
- baseCurrency - Currency code (ISO 4217 code Alpha-3) - optional parameter, default is USD
|
|
68
|
+
|
|
69
|
+
2) Copy the file __misc/asset/logo.svg to src/asset
|
|
70
|
+
|
|
71
|
+
3) Instead of the test resource 'custom-resource://resource1', add a resource to get the list of available currencies
|
|
72
|
+
|
|
73
|
+
4) Instead of the test examples in tests/mcp/test-cases.js, write tests for our case
|
|
74
|
+
|
|
75
|
+
5) Formulate the prompt AGENT_BRIEF in src/prompts/agent-brief.ts and AGENT_PROMPT in src/prompts/agent-prompt.ts
|
|
76
|
+
|
|
77
|
+
6) Instead of the endpoint /api/example (/example) in the file src/api/router.ts, create the endpoint get-curr-rate as a proxy to http://<appConfig.accessPoints.currencyService.host>:<appConfig.accessPoints.currencyService.port>/currency-service/?rate=<QUOTE_CURRENCY><BASE_CURRENCY>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapi.d.ts","sourceRoot":"","sources":["../../../src/core/web/openapi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAqB,MAAM,SAAS,CAAC;AAOpD;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE;QACJ,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,OAAO,CAAC,EAAE,KAAK,CAAC;QACd,GAAG,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ts'];
|
|
20
20
|
entryFile = './src/template/api/router.ts';
|
|
21
21
|
}
|
|
22
|
-
// перед generateSpec
|
|
23
22
|
const needsAuth = !!appConfig.webServer?.auth?.enabled;
|
|
24
|
-
const servers = buildServersArray();
|
|
23
|
+
const servers = buildServersArray();
|
|
25
24
|
// ExtendedSpecConfig structure for generateSpec
|
|
26
25
|
const specConfig = {
|
|
27
26
|
outputDirectory: specDir,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openapi.js","sourceRoot":"","sources":["../../../src/core/web/openapi.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACzD,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,IAAI,MAAM,SAAS,CAAC;AAChC,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AA8C1D;;GAEG;AACH,KAAK,UAAU,oBAAoB,CAAE,QAAgB;IACnD,IAAI,CAAC;QACH,0BAA0B;QAC1B,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QACvC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;YACzB,SAAS,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC1C,CAAC;QACD,IAAI,mBAAmB,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAC7C,IAAI,SAAS,GAAG,qBAAqB,CAAC;QACtC,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE,4BAA4B,CAAC,CAAC,EAAE,CAAC;YAC1E,mBAAmB,GAAG,CAAC,yBAAyB,CAAC,CAAC;YAClD,SAAS,GAAG,8BAA8B,CAAC;QAC7C,CAAC;QAED,
|
|
1
|
+
{"version":3,"file":"openapi.js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AAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACH,SAAS,mBAAmB,CAAE,MAAc,EAAE,IAAyB;IACrE,iCAAiC;IACjC,MAAM,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC,GAAY,EAAE,GAAa,EAAE,EAAE;QAC1D,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC,GAAY,EAAE,GAAa,EAAE,EAAE;QAC1D,GAAG,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,SAAS,yBAAyB,CAAE,IAAyB;IAC3D,MAAM,eAAe,GAAoB;QACvC,eAAe,EAAE,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,gBAAgB;QACnD,SAAS,EAAE,uCAAuC;QAClD,cAAc,EAAE;YACd,oBAAoB,EAAE,IAAI;YAC1B,sBAAsB,EAAE,IAAI;YAC5B,YAAY,EAAE,MAAM;YACpB,wBAAwB,EAAE,CAAC;YAC3B,IAAI,EAAE;gBACJ;oBACE,IAAI,EAAE,mBAAmB;oBACzB,GAAG,EAAE,mBAAmB;iBACzB;aACF;SACF;KACF,CAAC;IAEF,OAAO,gBAAgB,CAAC,KAAK,CAAC,IAAI,EAAE,eAAe,CAAC,CAAC;AACvD,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,+BAA+B;IAC7C,OAAO,gBAAgB,CAAC,KAAK,CAAC;AAChC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fa-mcp-sdk",
|
|
3
3
|
"productName": "FA MCP SDK",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.224",
|
|
5
5
|
"description": "Core infrastructure and templates for building Model Context Protocol (MCP) servers with TypeScript",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "dist/core/index.js",
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
expected_branch="master"
|
|
4
|
+
|
|
5
|
+
c='\033[0;35m'
|
|
6
|
+
y='\033[0;33m'
|
|
7
|
+
r='\033[0;31m'
|
|
8
|
+
c0='\033[0;0m'
|
|
9
|
+
g='\033[0;32m'
|
|
10
|
+
|
|
11
|
+
echo_r() { /bin/echo -e ${r}"$1"${c0}; };
|
|
12
|
+
|
|
13
|
+
# shellcheck disable=SC2120
|
|
14
|
+
exit_on_error(){
|
|
15
|
+
if [[ $? -ne 0 ]] ; then
|
|
16
|
+
if [[ -n "$1" ]]; then
|
|
17
|
+
echo_r "$1";
|
|
18
|
+
else
|
|
19
|
+
echo -e "${r}**** ERROR ****${c0}"
|
|
20
|
+
fi;
|
|
21
|
+
read -p "Press any key to resume ..."
|
|
22
|
+
exit 0
|
|
23
|
+
fi
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
set +e
|
|
27
|
+
|
|
28
|
+
branch_name=$(git symbolic-ref --short HEAD)
|
|
29
|
+
exit_on_error "$y**** Version will not be bumped since retcode is not equals 0 ****$c0"
|
|
30
|
+
|
|
31
|
+
if [[ "$branch_name" != "$expected_branch" ]] ; then
|
|
32
|
+
echo -e "${y}**** git branch should be ${c}{$expected_branch}${y}, current: ${c}${branch_name}${y} ****$c0"
|
|
33
|
+
read -p "Press any key to resume ..."
|
|
34
|
+
exit 0
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
npm run cb
|
|
38
|
+
exit_on_error "$y**** Typescript build failed ****$c0"
|
|
39
|
+
|
|
40
|
+
old_version=''
|
|
41
|
+
new_version=''
|
|
42
|
+
|
|
43
|
+
update_version(){
|
|
44
|
+
old_version=`cat package.json | grep version | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]'`
|
|
45
|
+
echo -e "$c**** Old version is $g$old_version$c ****$c0"
|
|
46
|
+
version_split=( ${old_version//./ } )
|
|
47
|
+
major=${version_split[0]:-0}
|
|
48
|
+
minor=${version_split[1]:-0}
|
|
49
|
+
patch=${version_split[2]:-0}
|
|
50
|
+
let "patch=patch+1"
|
|
51
|
+
new_version="${major}.${minor}.${patch}"
|
|
52
|
+
|
|
53
|
+
repo=`cat package.json | grep name | head -1 | awk -F: '{ print $2 }' | sed 's/[\",]//g' | tr -d '[[:space:]]'`
|
|
54
|
+
echo -e "$c**** Bumping version of $g$repo$c: $y$old_version$c -> $g$new_version$c ****$c0"
|
|
55
|
+
sed -i -e "0,/$old_version/s/$old_version/$new_version/" package.json
|
|
56
|
+
# Update the dependency version in cli-template/package.json: "fa-mcp-sdk": "^<new_version>"
|
|
57
|
+
# Version match is built on a regular expression that allows any current version (with an optional ^)
|
|
58
|
+
sed -i -E "s/(\"fa-mcp-sdk\":\s*\")\^?[^\"]+(\"[,\r\n\s]*)/\1^${new_version}\2/" cli-template/package.json
|
|
59
|
+
echo -e "$g"
|
|
60
|
+
npm version 2>&1 | head -2 | tail -1
|
|
61
|
+
echo -e "$c0"
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
update_version
|
|
66
|
+
exit_on_error
|
|
67
|
+
|
|
68
|
+
git add --all
|
|
69
|
+
exit_on_error
|
|
70
|
+
|
|
71
|
+
git commit --no-verify -m "$new_version"
|
|
72
|
+
exit_on_error
|
|
73
|
+
|
|
74
|
+
git push origin refs/heads/${expected_branch}:${expected_branch}
|
|
75
|
+
exit_on_error
|
|
76
|
+
# npm pack --dry-run
|
|
77
|
+
npm publish
|
|
78
|
+
read -p "Press any key to resume ..."
|
package/src/template/start.ts
CHANGED
|
@@ -48,8 +48,8 @@ const startProject = async (): Promise<void> => {
|
|
|
48
48
|
return '--consul-ui-not-configured--';
|
|
49
49
|
}
|
|
50
50
|
return `${isConsulProd
|
|
51
|
-
? `https://${agent.prd.host}/ui
|
|
52
|
-
: `https://${agent.dev.host}/ui
|
|
51
|
+
? `https://${agent.prd.host}/ui/${agent.prd.dc}`
|
|
52
|
+
: `https://${agent.dev.host}/ui/${agent.dev.dc}`
|
|
53
53
|
}/services/${serviceId}/instances`;
|
|
54
54
|
},
|
|
55
55
|
};
|