fa-mcp-sdk 0.2.3
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/LICENSE +21 -0
- package/README.md +283 -0
- package/dist/core/_types_/types.d.ts +67 -0
- package/dist/core/_types_/types.d.ts.map +1 -0
- package/dist/core/_types_/types.js +2 -0
- package/dist/core/_types_/types.js.map +1 -0
- package/dist/core/bootstrap/dotenv.d.ts +3 -0
- package/dist/core/bootstrap/dotenv.d.ts.map +1 -0
- package/dist/core/bootstrap/dotenv.js +3 -0
- package/dist/core/bootstrap/dotenv.js.map +1 -0
- package/dist/core/bootstrap/init-config.d.ts +11 -0
- package/dist/core/bootstrap/init-config.d.ts.map +1 -0
- package/dist/core/bootstrap/init-config.js +52 -0
- package/dist/core/bootstrap/init-config.js.map +1 -0
- package/dist/core/bootstrap/startup-info.d.ts +6 -0
- package/dist/core/bootstrap/startup-info.d.ts.map +1 -0
- package/dist/core/bootstrap/startup-info.js +43 -0
- package/dist/core/bootstrap/startup-info.js.map +1 -0
- package/dist/core/constants.d.ts +2 -0
- package/dist/core/constants.d.ts.map +1 -0
- package/dist/core/constants.js +2 -0
- package/dist/core/constants.js.map +1 -0
- package/dist/core/consul/access-points-updater.d.ts +5 -0
- package/dist/core/consul/access-points-updater.d.ts.map +1 -0
- package/dist/core/consul/access-points-updater.js +11 -0
- package/dist/core/consul/access-points-updater.js.map +1 -0
- package/dist/core/consul/deregister.d.ts +2 -0
- package/dist/core/consul/deregister.d.ts.map +1 -0
- package/dist/core/consul/deregister.js +21 -0
- package/dist/core/consul/deregister.js.map +1 -0
- package/dist/core/consul/get-consul-api.d.ts +2 -0
- package/dist/core/consul/get-consul-api.d.ts.map +1 -0
- package/dist/core/consul/get-consul-api.js +18 -0
- package/dist/core/consul/get-consul-api.js.map +1 -0
- package/dist/core/consul/register.d.ts +2 -0
- package/dist/core/consul/register.d.ts.map +1 -0
- package/dist/core/consul/register.js +6 -0
- package/dist/core/consul/register.js.map +1 -0
- package/dist/core/db/pg-db.d.ts +50 -0
- package/dist/core/db/pg-db.d.ts.map +1 -0
- package/dist/core/db/pg-db.js +89 -0
- package/dist/core/db/pg-db.js.map +1 -0
- package/dist/core/debug.d.ts +5 -0
- package/dist/core/debug.d.ts.map +1 -0
- package/dist/core/debug.js +32 -0
- package/dist/core/debug.js.map +1 -0
- package/dist/core/ee.d.ts +3 -0
- package/dist/core/ee.d.ts.map +1 -0
- package/dist/core/ee.js +4 -0
- package/dist/core/ee.js.map +1 -0
- package/dist/core/errors/BaseMcpError.d.ts +19 -0
- package/dist/core/errors/BaseMcpError.d.ts.map +1 -0
- package/dist/core/errors/BaseMcpError.js +47 -0
- package/dist/core/errors/BaseMcpError.js.map +1 -0
- package/dist/core/errors/ValidationError.d.ts +5 -0
- package/dist/core/errors/ValidationError.d.ts.map +1 -0
- package/dist/core/errors/ValidationError.js +7 -0
- package/dist/core/errors/ValidationError.js.map +1 -0
- package/dist/core/errors/errors.d.ts +24 -0
- package/dist/core/errors/errors.d.ts.map +1 -0
- package/dist/core/errors/errors.js +49 -0
- package/dist/core/errors/errors.js.map +1 -0
- package/dist/core/index.d.ts +19 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +16 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/init-mcp-server.d.ts +8 -0
- package/dist/core/init-mcp-server.d.ts.map +1 -0
- package/dist/core/init-mcp-server.js +101 -0
- package/dist/core/init-mcp-server.js.map +1 -0
- package/dist/core/logger.d.ts +6 -0
- package/dist/core/logger.d.ts.map +1 -0
- package/dist/core/logger.js +53 -0
- package/dist/core/logger.js.map +1 -0
- package/dist/core/mcp/create-mcp-server.d.ts +6 -0
- package/dist/core/mcp/create-mcp-server.d.ts.map +1 -0
- package/dist/core/mcp/create-mcp-server.js +44 -0
- package/dist/core/mcp/create-mcp-server.js.map +1 -0
- package/dist/core/mcp/prompts.d.ts +10 -0
- package/dist/core/mcp/prompts.d.ts.map +1 -0
- package/dist/core/mcp/prompts.js +56 -0
- package/dist/core/mcp/prompts.js.map +1 -0
- package/dist/core/mcp/resources.d.ts +14 -0
- package/dist/core/mcp/resources.d.ts.map +1 -0
- package/dist/core/mcp/resources.js +72 -0
- package/dist/core/mcp/resources.js.map +1 -0
- package/dist/core/mcp/server-stdio.d.ts +5 -0
- package/dist/core/mcp/server-stdio.d.ts.map +1 -0
- package/dist/core/mcp/server-stdio.js +13 -0
- package/dist/core/mcp/server-stdio.js.map +1 -0
- package/dist/core/token/gen-token-app/gen-token-server.d.ts +2 -0
- package/dist/core/token/gen-token-app/gen-token-server.d.ts.map +1 -0
- package/dist/core/token/gen-token-app/gen-token-server.js +115 -0
- package/dist/core/token/gen-token-app/gen-token-server.js.map +1 -0
- package/dist/core/token/gen-token-app/html.d.ts +2 -0
- package/dist/core/token/gen-token-app/html.d.ts.map +1 -0
- package/dist/core/token/gen-token-app/html.js +500 -0
- package/dist/core/token/gen-token-app/html.js.map +1 -0
- package/dist/core/token/i-token.d.ts +13 -0
- package/dist/core/token/i-token.d.ts.map +1 -0
- package/dist/core/token/i-token.js +2 -0
- package/dist/core/token/i-token.js.map +1 -0
- package/dist/core/token/token-core.d.ts +24 -0
- package/dist/core/token/token-core.d.ts.map +1 -0
- package/dist/core/token/token-core.js +130 -0
- package/dist/core/token/token-core.js.map +1 -0
- package/dist/core/token/token.d.ts +17 -0
- package/dist/core/token/token.d.ts.map +1 -0
- package/dist/core/token/token.js +62 -0
- package/dist/core/token/token.js.map +1 -0
- package/dist/core/utils/formatToolResult.d.ts +7 -0
- package/dist/core/utils/formatToolResult.d.ts.map +1 -0
- package/dist/core/utils/formatToolResult.js +68 -0
- package/dist/core/utils/formatToolResult.js.map +1 -0
- package/dist/core/utils/rate-limit.d.ts +17 -0
- package/dist/core/utils/rate-limit.d.ts.map +1 -0
- package/dist/core/utils/rate-limit.js +56 -0
- package/dist/core/utils/rate-limit.js.map +1 -0
- package/dist/core/utils/utils.d.ts +6 -0
- package/dist/core/utils/utils.d.ts.map +1 -0
- package/dist/core/utils/utils.js +12 -0
- package/dist/core/utils/utils.js.map +1 -0
- package/dist/core/web/about-page/css.d.ts +2 -0
- package/dist/core/web/about-page/css.d.ts.map +1 -0
- package/dist/core/web/about-page/css.js +534 -0
- package/dist/core/web/about-page/css.js.map +1 -0
- package/dist/core/web/about-page/render.d.ts +2 -0
- package/dist/core/web/about-page/render.d.ts.map +1 -0
- package/dist/core/web/about-page/render.js +679 -0
- package/dist/core/web/about-page/render.js.map +1 -0
- package/dist/core/web/cors.d.ts +5 -0
- package/dist/core/web/cors.d.ts.map +1 -0
- package/dist/core/web/cors.js +22 -0
- package/dist/core/web/cors.js.map +1 -0
- package/dist/core/web/favicon-svg.d.ts +7 -0
- package/dist/core/web/favicon-svg.d.ts.map +1 -0
- package/dist/core/web/favicon-svg.js +44 -0
- package/dist/core/web/favicon-svg.js.map +1 -0
- package/dist/core/web/server-http.d.ts +5 -0
- package/dist/core/web/server-http.d.ts.map +1 -0
- package/dist/core/web/server-http.js +275 -0
- package/dist/core/web/server-http.js.map +1 -0
- package/package.json +88 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Michael Makarov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
# fa-mcp-sdk
|
|
2
|
+
|
|
3
|
+
Production-ready core framework for building MCP (Model Context Protocol) servers with comprehensive
|
|
4
|
+
infrastructure support.
|
|
5
|
+
|
|
6
|
+
## Overview
|
|
7
|
+
|
|
8
|
+
This framework provides complete infrastructure for building enterprise-grade MCP servers with support for:
|
|
9
|
+
|
|
10
|
+
- **Dual Transport**: STDIO (Claude Desktop) and HTTP/SSE (web clients)
|
|
11
|
+
- **Database Integration**: PostgreSQL with pgvector for vector operations
|
|
12
|
+
- **Service Discovery**: Consul integration for microservices
|
|
13
|
+
- **Authentication**: Token-based security with configurable endpoints
|
|
14
|
+
- **Rate Limiting**: Configurable rate limiting for all endpoints
|
|
15
|
+
- **API Documentation**: Automatic Swagger generation
|
|
16
|
+
- **Production Logging**: Structured logging with data masking
|
|
17
|
+
- **Configuration Management**: YAML-based with environment overrides
|
|
18
|
+
|
|
19
|
+
The framework uses dependency injection to keep the core completely agnostic of project-specific implementations.
|
|
20
|
+
|
|
21
|
+
## Project Structure
|
|
22
|
+
|
|
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
|
+
│ ├── consul/ # Service discovery
|
|
31
|
+
│ ├── token/ # Authentication
|
|
32
|
+
│ ├── errors/ # Error handling
|
|
33
|
+
│ ├── utils/ # Utilities
|
|
34
|
+
│ └── index.ts # Public API
|
|
35
|
+
│
|
|
36
|
+
└── src/template/ # Reference implementation
|
|
37
|
+
├── tools/ # Example MCP tools
|
|
38
|
+
├── prompts/ # Agent prompts
|
|
39
|
+
├── api/ # Custom HTTP endpoints
|
|
40
|
+
└── start.ts # Entry point
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Quick Start
|
|
44
|
+
|
|
45
|
+
### 1. Install Dependencies
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### 2. Configure
|
|
52
|
+
|
|
53
|
+
Create configuration files in `config/`:
|
|
54
|
+
|
|
55
|
+
See [config/default.yaml](config/default.yaml) for all available options.
|
|
56
|
+
See [config/_local.yaml](config/_local.yaml) for template of local configuration.
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
### 3. Basic Usage
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
import { initMcpServer, isMainModule, McpServerData } from '../core/index.js';
|
|
63
|
+
import { readFileSync } from 'fs';
|
|
64
|
+
import { join } from 'path';
|
|
65
|
+
|
|
66
|
+
export async function startProject(): Promise<void> {
|
|
67
|
+
// Read favicon from assets
|
|
68
|
+
const faviconPath = join(process.cwd(), 'src/template/asset/favicon.svg');
|
|
69
|
+
let favicon: string;
|
|
70
|
+
|
|
71
|
+
try {
|
|
72
|
+
favicon = readFileSync(faviconPath, 'utf-8');
|
|
73
|
+
} catch (_error) {
|
|
74
|
+
// Fallback if favicon not found
|
|
75
|
+
favicon = `<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16">
|
|
76
|
+
<rect width="16" height="16" fill="#007ACC"/>
|
|
77
|
+
</svg>`;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Assemble all data to pass to the core
|
|
81
|
+
const serverData: McpServerData = {
|
|
82
|
+
// Required: MCP components
|
|
83
|
+
tools: [
|
|
84
|
+
{
|
|
85
|
+
name: 'example_tool',
|
|
86
|
+
description: 'Example tool',
|
|
87
|
+
inputSchema: {
|
|
88
|
+
type: 'object',
|
|
89
|
+
properties: {
|
|
90
|
+
query: { type: 'string', description: 'Query parameter' }
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
],
|
|
95
|
+
toolHandler: async (params) => {
|
|
96
|
+
const { name, arguments: args } = params;
|
|
97
|
+
if (name === 'example_tool') {
|
|
98
|
+
return `Result: ${args.query}`;
|
|
99
|
+
}
|
|
100
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
// Required: Agent identification
|
|
104
|
+
agentBrief: "My MCP Server - Brief description for agent selection",
|
|
105
|
+
agentPrompt: "Detailed system prompt for the agent",
|
|
106
|
+
|
|
107
|
+
// Optional: Custom prompts and resources
|
|
108
|
+
customPrompts: [],
|
|
109
|
+
customResources: [],
|
|
110
|
+
|
|
111
|
+
// Optional: HTTP components
|
|
112
|
+
httpComponents: {
|
|
113
|
+
apiRouter, // Express router for custom endpoints
|
|
114
|
+
endpointsOn404, // 404 handler
|
|
115
|
+
swagger: {
|
|
116
|
+
swaggerSpecs: swaggerSpecs, // OpenAPI specs
|
|
117
|
+
swaggerUi: swaggerUi, // Swagger UI configuration
|
|
118
|
+
},
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
// Optional: Assets
|
|
122
|
+
assets: { favicon },
|
|
123
|
+
|
|
124
|
+
// Optional: Function to get Consul UI address
|
|
125
|
+
getConsulUIAddress: (serviceId: string) =>
|
|
126
|
+
`https://consul.my.ui/ui/dc-dev/services/${serviceId}/instances`,
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
// Start MCP server with assembled data
|
|
130
|
+
await initMcpServer(serverData);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// Auto-start if this file is run directly
|
|
134
|
+
if (isMainModule(import.meta.url)) {
|
|
135
|
+
startProject().catch(error => {
|
|
136
|
+
console.error('Failed to start project:', error);
|
|
137
|
+
process.exit(1);
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
For NPM package usage:
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
import { initMcpServer, McpServerData } from '@mcp-staff/server-core';
|
|
146
|
+
// Rest of the code is similar, but with package imports
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Transport Modes
|
|
150
|
+
|
|
151
|
+
### STDIO Mode (Claude Desktop)
|
|
152
|
+
|
|
153
|
+
For integration with Claude Desktop:
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
# Set transport in config
|
|
157
|
+
mcp.transportType: stdio
|
|
158
|
+
|
|
159
|
+
# Or via command line
|
|
160
|
+
npm start stdio
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Communication happens via stdin/stdout using JSON-RPC protocol.
|
|
164
|
+
|
|
165
|
+
### HTTP Mode (Web Integration)
|
|
166
|
+
|
|
167
|
+
For web applications and API access:
|
|
168
|
+
|
|
169
|
+
```bash
|
|
170
|
+
# Default mode
|
|
171
|
+
npm start
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Provides endpoints:
|
|
175
|
+
|
|
176
|
+
- `GET /` - About page with server info
|
|
177
|
+
- `GET /health` - Health check
|
|
178
|
+
- `GET /sse` - Server-Sent Events for MCP communication
|
|
179
|
+
- `POST /mcp` - Direct MCP JSON-RPC endpoint
|
|
180
|
+
- `GET /docs` - Swagger API documentation
|
|
181
|
+
- `/api/*` - Custom API endpoints
|
|
182
|
+
|
|
183
|
+
## Core Features
|
|
184
|
+
|
|
185
|
+
### Database Integration
|
|
186
|
+
|
|
187
|
+
Built-in PostgreSQL support with connection pooling:
|
|
188
|
+
|
|
189
|
+
All available functions see [src/core/db/pg-db.ts](src/core/db/pg-db.ts)
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
## Template Project
|
|
194
|
+
|
|
195
|
+
The `src/template/` directory contains a complete reference implementation:
|
|
196
|
+
|
|
197
|
+
### Running the Template
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
# Development mode (watch for changes)
|
|
201
|
+
npm run template:dev
|
|
202
|
+
|
|
203
|
+
# Production mode
|
|
204
|
+
npm run template:start
|
|
205
|
+
|
|
206
|
+
# STDIO mode for Claude Desktop
|
|
207
|
+
npm run template:stdio
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
### Template Structure
|
|
211
|
+
|
|
212
|
+
- **Tools**: `src/template/tools/tools.ts` - Define your MCP tools
|
|
213
|
+
- **Handlers**: `src/template/tools/handle-tool-call.ts` - Implement tool logic
|
|
214
|
+
- **Prompts**: `src/template/prompts/` - Agent system prompts
|
|
215
|
+
- **API**: `src/template/api/router.ts` - Custom HTTP endpoints
|
|
216
|
+
- **Config**: `config/` - Configuration files
|
|
217
|
+
|
|
218
|
+
## Configuration
|
|
219
|
+
|
|
220
|
+
### Environment Variables
|
|
221
|
+
|
|
222
|
+
Set via `config/custom-environment-variables.yaml`:
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
DB_HOST=localhost # To exclude the use of the database, you need to set host = ''
|
|
226
|
+
DB_NAME=mydb
|
|
227
|
+
DB_USER=user
|
|
228
|
+
DB_PASSWORD=password
|
|
229
|
+
MCP_TRANSPORT_TYPE=http
|
|
230
|
+
WS_PORT=9020
|
|
231
|
+
WS_AUTH_ENABLED=false
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### Configuration Priority
|
|
235
|
+
|
|
236
|
+
1. Environment variables
|
|
237
|
+
2. Environment-specific YAML (`development.yaml`, `production.yaml`)
|
|
238
|
+
3. `config/default.yaml`
|
|
239
|
+
4. Package.json metadata
|
|
240
|
+
|
|
241
|
+
## Development
|
|
242
|
+
|
|
243
|
+
### Building
|
|
244
|
+
|
|
245
|
+
```bash
|
|
246
|
+
npm run build # Build TypeScript
|
|
247
|
+
npm run clean # Clean dist/
|
|
248
|
+
npm run cb # Clean + build
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Linting
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
npm run lint # Check code style
|
|
255
|
+
npm run lint:fix # Fix automatically
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### Type Checking
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
npm run typecheck
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
## API Reference
|
|
265
|
+
|
|
266
|
+
### McpServerData Interface
|
|
267
|
+
|
|
268
|
+
See: [src/core/_types_/types.ts](src/core/_types_/types.ts)
|
|
269
|
+
|
|
270
|
+
### Core Exports
|
|
271
|
+
|
|
272
|
+
See: [src/core/index.ts](src/core/index.ts)
|
|
273
|
+
|
|
274
|
+
## Requirements
|
|
275
|
+
|
|
276
|
+
- **Node.js**: >= 18.0.0
|
|
277
|
+
- **TypeScript**: >= 5.0.0
|
|
278
|
+
- **PostgreSQL**: >= 12 (optional)
|
|
279
|
+
- **Consul**: Any version (optional)
|
|
280
|
+
|
|
281
|
+
## License
|
|
282
|
+
|
|
283
|
+
MIT
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { Tool } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import { Router } from 'express';
|
|
3
|
+
export interface IPromptData {
|
|
4
|
+
name: string;
|
|
5
|
+
description: string;
|
|
6
|
+
arguments: [];
|
|
7
|
+
content: IPromptContent;
|
|
8
|
+
}
|
|
9
|
+
export interface IRequiredHttpHeader {
|
|
10
|
+
name: string;
|
|
11
|
+
description: string;
|
|
12
|
+
}
|
|
13
|
+
export interface IResourceData {
|
|
14
|
+
uri: string;
|
|
15
|
+
name: string;
|
|
16
|
+
description: string;
|
|
17
|
+
mimeType: string;
|
|
18
|
+
content: string | IRequiredHttpHeader[];
|
|
19
|
+
}
|
|
20
|
+
export type IEndpointsOn404 = Record<string, string | string[]>;
|
|
21
|
+
export interface ISwaggerData {
|
|
22
|
+
swaggerSpecs: any;
|
|
23
|
+
swaggerUi: any;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* All data that needs to be passed to initialize the MCP server
|
|
27
|
+
*/
|
|
28
|
+
export interface McpServerData {
|
|
29
|
+
tools: Tool[];
|
|
30
|
+
toolHandler: (params: {
|
|
31
|
+
name: string;
|
|
32
|
+
arguments?: any;
|
|
33
|
+
}) => Promise<any>;
|
|
34
|
+
agentBrief: string;
|
|
35
|
+
agentPrompt: string;
|
|
36
|
+
customPrompts?: IPromptData[];
|
|
37
|
+
requiredHttpHeaders?: IRequiredHttpHeader[] | null;
|
|
38
|
+
customResources?: IResourceData[] | null;
|
|
39
|
+
httpComponents?: {
|
|
40
|
+
apiRouter?: Router | null;
|
|
41
|
+
endpointsOn404?: IEndpointsOn404;
|
|
42
|
+
swagger?: ISwaggerData | null;
|
|
43
|
+
};
|
|
44
|
+
assets?: {
|
|
45
|
+
favicon?: string;
|
|
46
|
+
maintainerHtml?: string;
|
|
47
|
+
};
|
|
48
|
+
getConsulUIAddress?: (serviceId: string) => string;
|
|
49
|
+
}
|
|
50
|
+
export interface IGetPromptRequest {
|
|
51
|
+
id?: string | number;
|
|
52
|
+
method: 'prompts/get' | 'prompts/content';
|
|
53
|
+
params: IGetPromptParams;
|
|
54
|
+
}
|
|
55
|
+
export type IPromptContent = string | ((request: IGetPromptRequest) => string | Promise<string>);
|
|
56
|
+
export interface IGetPromptParams {
|
|
57
|
+
name: string;
|
|
58
|
+
arguments?: Record<string, string>;
|
|
59
|
+
}
|
|
60
|
+
export interface IReadResourceRequest {
|
|
61
|
+
method: 'resources/read';
|
|
62
|
+
params: {
|
|
63
|
+
uri: string;
|
|
64
|
+
};
|
|
65
|
+
id?: string | number;
|
|
66
|
+
}
|
|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I,CAAC;IACnD,eAAe,CAAC,EAAE,aAAa,EAAE,GAAG,IAAI,CAAC;IAEzC,cAAc,CAAC,EAAE;QACf,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC1B,cAAc,CAAC,EAAE,eAAe,CAAC;QACjC,OAAO,CAAC,EAAE,YAAY,GAAG,IAAI,CAAC;KAC/B,CAAC;IAEF,MAAM,CAAC,EAAE;QACP,OAAO,CAAC,EAAE,MAAM,CAAC;QAEjB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,CAAC;IAGF,kBAAkB,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,MAAM,CAAC;CACpD;AAGD,MAAM,WAAW,iBAAiB;IAChC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACrB,MAAM,EAAE,aAAa,GAAG,iBAAiB,CAAC;IAC1C,MAAM,EAAE,gBAAgB,CAAC;CAC1B;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,CAAC,CAAC,OAAO,EAAE,iBAAiB,KAAK,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC;AAEjG,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,gBAAgB,CAAC;IACzB,MAAM,EAAE;QACN,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/core/_types_/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dotenv.d.ts","sourceRoot":"","sources":["../../../src/core/bootstrap/dotenv.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,eAAO,MAAM,YAAY,2BAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dotenv.js","sourceRoot":"","sources":["../../../src/core/bootstrap/dotenv.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import './dotenv.js';
|
|
2
|
+
import { AppConfig } from '../_types_/config.js';
|
|
3
|
+
export declare const config: AppConfig;
|
|
4
|
+
import { McpServerData } from '../_types_/types.js';
|
|
5
|
+
export declare const appConfig: AppConfig;
|
|
6
|
+
/**
|
|
7
|
+
* Returns configuration with sensitive data masked for safe display
|
|
8
|
+
*/
|
|
9
|
+
export declare function getSafeAppConfig(): any;
|
|
10
|
+
export declare function getProjectData(): McpServerData;
|
|
11
|
+
//# sourceMappingURL=init-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-config.d.ts","sourceRoot":"","sources":["../../../src/core/bootstrap/init-config.ts"],"names":[],"mappings":"AAEA,OAAO,aAAa,CAAC;AAErB,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD,eAAO,MAAM,MAAM,EAAE,SAAwC,CAAC;AAK9D,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAiCpD,eAAO,MAAM,SAAS,EAAE,SAAyB,CAAC;AAElD;;GAEG;AACH,wBAAgB,gBAAgB,IAAK,GAAG,CASvC;AAED,wBAAgB,cAAc,IAAK,aAAa,CAE/C"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// noinspection UnnecessaryLocalVariableJS
|
|
2
|
+
import './dotenv.js'; // Load environment variables first
|
|
3
|
+
import configModule from 'config';
|
|
4
|
+
export const config = configModule.util.toObject();
|
|
5
|
+
import { readFileSync } from 'fs';
|
|
6
|
+
import * as path from 'path';
|
|
7
|
+
import { trim } from '../utils/utils.js';
|
|
8
|
+
const { name, productName, version, description, keywords, repository, homepage } = JSON.parse(readFileSync(path.join(process.cwd(), 'package.json'), 'utf-8'));
|
|
9
|
+
/**
|
|
10
|
+
* Build application configuration from YAML and environment variables
|
|
11
|
+
* Priority: environment variables > config.yaml > defaults
|
|
12
|
+
*/
|
|
13
|
+
function buildConfig() {
|
|
14
|
+
const shortName = name.replace(/[\s\-]*\bmcp\b[\s\-]*/ig, '');
|
|
15
|
+
const cfg = {
|
|
16
|
+
...config,
|
|
17
|
+
// Package metadata from package.json
|
|
18
|
+
name,
|
|
19
|
+
shortName,
|
|
20
|
+
productName,
|
|
21
|
+
version,
|
|
22
|
+
description,
|
|
23
|
+
};
|
|
24
|
+
cfg.consul.service = { ...cfg.consul.service, name, version, description };
|
|
25
|
+
cfg.consul.service.tags = keywords;
|
|
26
|
+
cfg.mcp.transportType = process.argv[2] === 'stdio' ? 'stdio' : config.mcp.transportType;
|
|
27
|
+
cfg.isMainDBUsed = !!config.db.postgres?.dbs.main?.host;
|
|
28
|
+
const urlRe = /\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i;
|
|
29
|
+
if (urlRe.test(trim(repository?.url))) {
|
|
30
|
+
cfg.repo = urlRe.exec(repository.url)?.[0] || '';
|
|
31
|
+
}
|
|
32
|
+
else if (urlRe.test(trim(homepage))) {
|
|
33
|
+
cfg.repo = urlRe.exec(homepage)?.[0] || '';
|
|
34
|
+
}
|
|
35
|
+
return cfg;
|
|
36
|
+
}
|
|
37
|
+
export const appConfig = buildConfig();
|
|
38
|
+
/**
|
|
39
|
+
* Returns configuration with sensitive data masked for safe display
|
|
40
|
+
*/
|
|
41
|
+
export function getSafeAppConfig() {
|
|
42
|
+
const config = JSON.parse(JSON.stringify(appConfig)); // Deep clone
|
|
43
|
+
// Mask database password
|
|
44
|
+
if (config.db?.postgres?.dbs?.main?.password) {
|
|
45
|
+
config.db.postgres.dbs.main.password = '[MASKED]';
|
|
46
|
+
}
|
|
47
|
+
return config;
|
|
48
|
+
}
|
|
49
|
+
export function getProjectData() {
|
|
50
|
+
return global.__MCP_PROJECT_DATA__;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=init-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-config.js","sourceRoot":"","sources":["../../../src/core/bootstrap/init-config.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAE1C,OAAO,aAAa,CAAC,CAAE,mCAAmC;AAC1D,OAAO,YAAY,MAAM,QAAQ,CAAC;AAGlC,MAAM,CAAC,MAAM,MAAM,GAAc,YAAY,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;AAE9D,OAAO,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAClC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAGzC,MAAM,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;AAEhK;;;GAGG;AACH,SAAS,WAAW;IAClB,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,yBAAyB,EAAE,EAAE,CAAC,CAAC;IAC9D,MAAM,GAAG,GAAc;QACrB,GAAG,MAAM;QACT,qCAAqC;QACrC,IAAI;QACJ,SAAS;QACT,WAAW;QACX,OAAO;QACP,WAAW;KACZ,CAAC;IAEF,GAAG,CAAC,MAAM,CAAC,OAAO,GAAG,EAAE,GAAG,GAAG,CAAC,MAAM,C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CAAC,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC;IACpD,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,OAAQ,MAAc,CAAC,oBAAoB,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"startup-info.d.ts","sourceRoot":"","sources":["../../../src/core/bootstrap/startup-info.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAWjD,eAAO,MAAM,WAAW,GAAU,MAAM;IAAE,YAAY,EAAE,GAAG,CAAC;IAAC,GAAG,EAAE,SAAS,CAAA;CAAE,kBAuC5E,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Output of startup diagnostics to the console
|
|
3
|
+
*/
|
|
4
|
+
import { configInfo, consulInfo, databasesInfo, infoBlock, nodeConfigEnvInfo } from 'af-tools-ts';
|
|
5
|
+
import { yellow } from 'af-color';
|
|
6
|
+
import { fileLogger, useFileLogger, logger as lgr } from '../logger.js';
|
|
7
|
+
import { getConsulAPI } from '../consul/get-consul-api.js';
|
|
8
|
+
import chalk from 'chalk';
|
|
9
|
+
import { appConfig } from './init-config.js';
|
|
10
|
+
const logger = lgr.getSubLogger({ name: chalk.cyan('config') });
|
|
11
|
+
export const startupInfo = async (args) => {
|
|
12
|
+
const { cfg, dotEnvResult } = args;
|
|
13
|
+
let consulInfoItem = '';
|
|
14
|
+
const s = cfg.consul.service;
|
|
15
|
+
if (!s.noRegOnStart) {
|
|
16
|
+
const consulApi = await getConsulAPI();
|
|
17
|
+
const r = consulApi.registerConfig;
|
|
18
|
+
s.meta = r.meta;
|
|
19
|
+
s.tags = r.tags;
|
|
20
|
+
s.id = r.id;
|
|
21
|
+
s.host = r.address || null;
|
|
22
|
+
s.port = r.port || null;
|
|
23
|
+
consulInfoItem = ['Consul serviceId', consulApi.serviceId];
|
|
24
|
+
}
|
|
25
|
+
configInfo({ dotEnvResult, cfg: JSON.parse(JSON.stringify(cfg)) }); // To display you must set ENV DEBUG=config-info
|
|
26
|
+
const dbInfo = appConfig.isMainDBUsed ? [...databasesInfo(cfg, ['main'])] : [['DB', 'not used']];
|
|
27
|
+
const info = [
|
|
28
|
+
`${yellow}${cfg.productName || cfg.name} (v ${cfg.version})`,
|
|
29
|
+
nodeConfigEnvInfo(),
|
|
30
|
+
['NODE VERSION', process.version],
|
|
31
|
+
['NODE_ENV', process.env.NODE_ENV],
|
|
32
|
+
['Logging level', cfg.logger.level],
|
|
33
|
+
['DEBUG', (process.env.DEBUG || '')],
|
|
34
|
+
useFileLogger ? ['Logs dir', fileLogger?.logDir] : '',
|
|
35
|
+
...dbInfo,
|
|
36
|
+
consulInfoItem,
|
|
37
|
+
].filter(Boolean);
|
|
38
|
+
const infoStr = infoBlock({ info });
|
|
39
|
+
logger.info(`\n${infoStr}`);
|
|
40
|
+
// Info about Access points
|
|
41
|
+
consulInfo(cfg);
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=startup-info.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"startup-info.js","sourceRoot":"","sources":["../../../src/core/bootstrap/startup-info.ts"],"names":[],"mappings":"AAAA;;EAEE;AACF,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,aAAa,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAClG,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,IAAI,GAAG,EAAE,MAAM,cAAc,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAG3D,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,MAAM,MAA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AAG,MAAM,GAAG,GAAG,CAAC,WAAW,IAAI,GAAG,CAAC,IAAI,OAAO,GAAG,CAAC,OAAO,GAAG;QAC5D,iBAAiB,EAAE;QACnB,CAAC,cAAc,EAAE,OAAO,CAAC,OAAO,CAAC;QACjC,CAAC,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;QAClC,CAAC,eAAe,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC;QACnC,CAAC,OAAO,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;QACpC,aAAa,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE;QACrD,GAAG,MAAM;QACT,cAAc;KACf,CAAC,MAAM,CAAC,OAAO,CAAgB,CAAC;IAEjC,MAAM,OAAO,GAAG,SAAS,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IAEpC,MAAM,CAAC,IAAI,CAAC,KAAK,OAAO,EAAE,CAAC,CAAC;IAE5B,2BAA2B;IAC3B,UAAU,CAAC,GAAG,CAAC,CAAC;AAClB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/core/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB,QAAgB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/core/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access-points-updater.d.ts","sourceRoot":"","sources":["../../../src/core/consul/access-points-updater.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,kBAAkB;;;CAG9B,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { accessPointsUpdater } from 'af-consul-ts';
|
|
2
|
+
import { logger as lgr } from '../logger.js';
|
|
3
|
+
import { eventEmitter } from '../ee.js';
|
|
4
|
+
import { appConfig } from '../bootstrap/init-config.js';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
const logger = lgr.getSubLogger({ name: chalk.bgBlue('consul') });
|
|
7
|
+
export const accessPointUpdater = {
|
|
8
|
+
start: () => accessPointsUpdater.start({ config: appConfig, logger, em: eventEmitter }, 10_000),
|
|
9
|
+
stop: () => accessPointsUpdater.stop(),
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=access-points-updater.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"access-points-updater.js","sourceRoot":"","sources":["../../../src/core/consul/access-points-updater.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EAAE,MAAM,IAAI,GAAG,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,6BAA6B,CAAC;AACxD,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,GAAG,GAAG,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AAElE,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,KAAK,EAAE,GAAG,EAAE,CAAC,mBAAmB,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,MAAM,CAAC;IAC/F,IAAI,EAAE,GAAG,EAAE,CAAC,mBAAmB,CAAC,IAAI,EAAE;CACvC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deregister.d.ts","sourceRoot":"","sources":["../../../src/core/consul/deregister.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,2BAA2B,qBAcvC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as dotenv from 'dotenv';
|
|
2
|
+
import { getConsulAPI } from './get-consul-api.js';
|
|
3
|
+
import { isMainModule } from '../utils/utils.js';
|
|
4
|
+
dotenv.config();
|
|
5
|
+
export const deregisterServiceFromConsul = async () => {
|
|
6
|
+
const [, , svcId, agentHost, agentPort] = process.argv;
|
|
7
|
+
if (!svcId) {
|
|
8
|
+
throw new Error('Service ID (svcId) is required');
|
|
9
|
+
}
|
|
10
|
+
const { deregister } = await getConsulAPI();
|
|
11
|
+
try {
|
|
12
|
+
await deregister(svcId, agentHost, agentPort);
|
|
13
|
+
}
|
|
14
|
+
catch (err) {
|
|
15
|
+
console.error(err);
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
if (isMainModule(import.meta.url)) {
|
|
19
|
+
deregisterServiceFromConsul().then(() => 0);
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=deregister.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deregister.js","sourceRoot":"","sources":["../../../src/core/consul/deregister.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,MAAM,CAAC,MAAM,EAAE,CAAC;AAEhB,MAAM,CAAC,MAAM,2BAA2B,GAAG,KAAK,IAAI,EAAE;IACpD,MAAM,CAAC,EAAE,AAAD,EAAG,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAEvD,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IAED,MAAM,EAAE,UAAU,EAAE,GAAG,MAAM,YAAY,EAAE,CAAC;IAE5C,IAAI,CAAC;QACH,MAAM,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IAChD,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;AACH,CAAC,CAAC;AAEF,IAAI,YAAY,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;IAClC,2BAA2B,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,CAAC;AAC9C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-consul-api.d.ts","sourceRoot":"","sources":["../../../src/core/consul/get-consul-api.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,YAAY,oDAUxB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { getAPI } from 'af-consul-ts';
|
|
2
|
+
import { logger as lgr } from '../logger.js';
|
|
3
|
+
import { eventEmitter } from '../ee.js';
|
|
4
|
+
import { appConfig, getProjectData } from '../bootstrap/init-config.js';
|
|
5
|
+
import chalk from 'chalk';
|
|
6
|
+
const isProd = (process.env.NODE_CONSUL_ENV || process.env.NODE_ENV) === 'production';
|
|
7
|
+
const logger = lgr.getSubLogger({ name: chalk.bgBlue('consul') });
|
|
8
|
+
export const getConsulAPI = async () => {
|
|
9
|
+
return getAPI({
|
|
10
|
+
config: appConfig,
|
|
11
|
+
logger,
|
|
12
|
+
em: eventEmitter,
|
|
13
|
+
envCode: isProd ? appConfig.consul.envCode.prod : appConfig.consul.envCode.dev,
|
|
14
|
+
getConsulUIAddress: getProjectData().getConsulUIAddress ||
|
|
15
|
+
((serviceId) => `Consul service id: ${serviceId}. Can not construct UI url because custom getConsulUIAddress function was not provided`),
|
|
16
|
+
});
|
|
17
|
+
};
|
|
18
|
+
//# sourceMappingURL=get-consul-api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-consul-api.js","sourceRoot":"","sources":["../../../src/core/consul/get-consul-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,MAAM,IAAI,GAAG,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,MAAM,MAAM,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,YAAY,CAAC;AACtF,MAAM,MAAM,GAAG,GAAG,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;AAElE,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,IAAI,EAAE;IACrC,OAAO,MAAM,CAAC;QACZ,MAAM,EAAE,SAAS;QACjB,MAAM;QACN,EAAE,EAAE,YAAY;QAChB,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG;QAC9E,kBAAkB,EAChB,cAAc,EAAE,CAAC,kBAAkB;YACnC,CAAC,CAAC,SAAiB,EAAE,EAAE,CAAC,sBAAsB,SAAS,wFAAwF,CAAC;KACnJ,CAAC,CAAC;AACL,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../../src/core/consul/register.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,uDAG1B,CAAC"}
|