cucumberstudio-mcp 1.1.0
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/.env.example +36 -0
- package/.github/workflows/pr-checks.yml +41 -0
- package/.github/workflows/release.yml +194 -0
- package/.prettierignore +26 -0
- package/.prettierrc +14 -0
- package/CLAUDE.md +140 -0
- package/Dockerfile +50 -0
- package/Dockerfile.dev +31 -0
- package/LICENSE +21 -0
- package/README.md +395 -0
- package/build/api/client.d.ts +49 -0
- package/build/api/client.d.ts.map +1 -0
- package/build/api/client.js +204 -0
- package/build/api/client.js.map +1 -0
- package/build/api/types.d.ts +113 -0
- package/build/api/types.d.ts.map +1 -0
- package/build/api/types.js +2 -0
- package/build/api/types.js.map +1 -0
- package/build/config/settings.d.ts +123 -0
- package/build/config/settings.d.ts.map +1 -0
- package/build/config/settings.js +97 -0
- package/build/config/settings.js.map +1 -0
- package/build/constants.d.ts +16 -0
- package/build/constants.d.ts.map +1 -0
- package/build/constants.js +24 -0
- package/build/constants.js.map +1 -0
- package/build/generated/version.d.ts +3 -0
- package/build/generated/version.d.ts.map +1 -0
- package/build/generated/version.js +5 -0
- package/build/generated/version.js.map +1 -0
- package/build/index.d.ts +3 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +81 -0
- package/build/index.js.map +1 -0
- package/build/mcp-server.d.ts +6 -0
- package/build/mcp-server.d.ts.map +1 -0
- package/build/mcp-server.js +263 -0
- package/build/mcp-server.js.map +1 -0
- package/build/tools/action-words.d.ts +18 -0
- package/build/tools/action-words.d.ts.map +1 -0
- package/build/tools/action-words.js +191 -0
- package/build/tools/action-words.js.map +1 -0
- package/build/tools/projects.d.ts +19 -0
- package/build/tools/projects.d.ts.map +1 -0
- package/build/tools/projects.js +123 -0
- package/build/tools/projects.js.map +1 -0
- package/build/tools/scenarios.d.ts +18 -0
- package/build/tools/scenarios.d.ts.map +1 -0
- package/build/tools/scenarios.js +194 -0
- package/build/tools/scenarios.js.map +1 -0
- package/build/tools/test-runs.d.ts +21 -0
- package/build/tools/test-runs.d.ts.map +1 -0
- package/build/tools/test-runs.js +324 -0
- package/build/tools/test-runs.js.map +1 -0
- package/build/transports/http.d.ts +38 -0
- package/build/transports/http.d.ts.map +1 -0
- package/build/transports/http.js +381 -0
- package/build/transports/http.js.map +1 -0
- package/build/transports/index.d.ts +22 -0
- package/build/transports/index.d.ts.map +1 -0
- package/build/transports/index.js +10 -0
- package/build/transports/index.js.map +1 -0
- package/build/transports/stdio.d.ts +13 -0
- package/build/transports/stdio.d.ts.map +1 -0
- package/build/transports/stdio.js +24 -0
- package/build/transports/stdio.js.map +1 -0
- package/build/utils/errors.d.ts +10 -0
- package/build/utils/errors.d.ts.map +1 -0
- package/build/utils/errors.js +35 -0
- package/build/utils/errors.js.map +1 -0
- package/build/utils/logger-constants.d.ts +15 -0
- package/build/utils/logger-constants.d.ts.map +1 -0
- package/build/utils/logger-constants.js +16 -0
- package/build/utils/logger-constants.js.map +1 -0
- package/build/utils/logger.d.ts +55 -0
- package/build/utils/logger.d.ts.map +1 -0
- package/build/utils/logger.js +113 -0
- package/build/utils/logger.js.map +1 -0
- package/build/utils/validation.d.ts +89 -0
- package/build/utils/validation.d.ts.map +1 -0
- package/build/utils/validation.js +78 -0
- package/build/utils/validation.js.map +1 -0
- package/docker-compose.yml +20 -0
- package/eslint.config.js +97 -0
- package/package.json +92 -0
- package/scripts/generate-version.js +31 -0
- package/src/api/client.ts +286 -0
- package/src/api/types.ts +137 -0
- package/src/config/settings.ts +113 -0
- package/src/constants.ts +29 -0
- package/src/index.ts +99 -0
- package/src/mcp-server.ts +342 -0
- package/src/tools/action-words.ts +240 -0
- package/src/tools/projects.ts +144 -0
- package/src/tools/scenarios.ts +231 -0
- package/src/tools/test-runs.ts +400 -0
- package/src/transports/http.ts +467 -0
- package/src/transports/index.ts +26 -0
- package/src/transports/stdio.ts +28 -0
- package/src/utils/errors.ts +45 -0
- package/src/utils/logger-constants.ts +18 -0
- package/src/utils/logger.ts +150 -0
- package/src/utils/validation.ts +94 -0
- package/test/api/client-with-msw.test.ts +122 -0
- package/test/api/client.test.ts +326 -0
- package/test/api/types.test.ts +88 -0
- package/test/config/settings.test.ts +204 -0
- package/test/mocks/data/action-words.ts +40 -0
- package/test/mocks/data/index.ts +13 -0
- package/test/mocks/data/projects.ts +38 -0
- package/test/mocks/data/scenarios.ts +53 -0
- package/test/mocks/data/test-runs.ts +101 -0
- package/test/mocks/handlers/action-words.ts +52 -0
- package/test/mocks/handlers/index.ts +10 -0
- package/test/mocks/handlers/projects.ts +45 -0
- package/test/mocks/handlers/scenarios.ts +72 -0
- package/test/mocks/handlers/test-runs.ts +106 -0
- package/test/mocks/server.ts +26 -0
- package/test/setup/vitest.setup.ts +18 -0
- package/test/tools/coverage-boost.test.ts +252 -0
- package/test/tools/projects.test.ts +290 -0
- package/test/tools/tools-basic.test.ts +146 -0
- package/test/transports/http-basic.test.ts +87 -0
- package/test/transports/http-simple.test.ts +33 -0
- package/test/transports/stdio.test.ts +73 -0
- package/test/utils/errors.test.ts +117 -0
- package/test/utils/validation.test.ts +261 -0
- package/tsconfig.build.json +8 -0
- package/tsconfig.json +27 -0
- package/vitest.config.ts +43 -0
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
import { randomUUID } from 'crypto';
|
|
2
|
+
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
3
|
+
import { isInitializeRequest } from '@modelcontextprotocol/sdk/types.js';
|
|
4
|
+
import cors from 'cors';
|
|
5
|
+
import express from 'express';
|
|
6
|
+
import { SERVER_NAME, SERVER_VERSION, PROTOCOL_VERSION, JSON_BODY_LIMIT, DEFAULT_CORS_ORIGINS } from '../constants.js';
|
|
7
|
+
/**
|
|
8
|
+
* Creates an HTTP server using MCP's official Streamable HTTP transport
|
|
9
|
+
*/
|
|
10
|
+
export class StreamableHttpTransport {
|
|
11
|
+
options;
|
|
12
|
+
logger;
|
|
13
|
+
app;
|
|
14
|
+
httpServer = null;
|
|
15
|
+
transports = new Map();
|
|
16
|
+
createMcpServer;
|
|
17
|
+
constructor(createMcpServer, options, logger) {
|
|
18
|
+
this.options = options;
|
|
19
|
+
this.logger = logger;
|
|
20
|
+
this.createMcpServer = createMcpServer;
|
|
21
|
+
this.app = express();
|
|
22
|
+
this.setupMiddleware();
|
|
23
|
+
this.setupRoutes();
|
|
24
|
+
}
|
|
25
|
+
setupMiddleware() {
|
|
26
|
+
// Request logging middleware
|
|
27
|
+
this.app.use((req, res, next) => {
|
|
28
|
+
const requestId = randomUUID().substring(0, 8);
|
|
29
|
+
req.requestId = requestId;
|
|
30
|
+
const logger = this.logger; // Capture logger reference for closure
|
|
31
|
+
logger.debug(`[${requestId}] ${req.method} ${req.path}`, {
|
|
32
|
+
headers: req.headers,
|
|
33
|
+
query: req.query,
|
|
34
|
+
ip: req.ip,
|
|
35
|
+
});
|
|
36
|
+
// Log response details
|
|
37
|
+
const originalSend = res.send;
|
|
38
|
+
res.send = function (body) {
|
|
39
|
+
logger.debug(`[${requestId}] Response ${res.statusCode}`, {
|
|
40
|
+
statusCode: res.statusCode,
|
|
41
|
+
headers: res.getHeaders(),
|
|
42
|
+
bodySize: typeof body === 'string' ? body.length : JSON.stringify(body).length,
|
|
43
|
+
});
|
|
44
|
+
// Log response body for errors or when explicitly requested
|
|
45
|
+
if (res.statusCode >= 400) {
|
|
46
|
+
logger.error(`[${requestId}] Error response body`, {
|
|
47
|
+
body: typeof body === 'string' ? body : JSON.stringify(body, null, 2),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
return originalSend.call(this, body);
|
|
51
|
+
};
|
|
52
|
+
next();
|
|
53
|
+
});
|
|
54
|
+
// Security: Validate Origin header to prevent DNS rebinding attacks
|
|
55
|
+
this.app.use((req, res, next) => {
|
|
56
|
+
const origin = req.get('Origin');
|
|
57
|
+
if (origin && !this.isValidOrigin(origin)) {
|
|
58
|
+
const requestId = req.requestId || 'unknown';
|
|
59
|
+
this.logger.warn(`[${requestId}] Invalid origin rejected`, { origin });
|
|
60
|
+
return res.status(403).json({
|
|
61
|
+
error: 'Invalid origin',
|
|
62
|
+
requestId,
|
|
63
|
+
timestamp: new Date().toISOString(),
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
next();
|
|
67
|
+
});
|
|
68
|
+
// Enable CORS with specific security considerations
|
|
69
|
+
this.app.use(cors({
|
|
70
|
+
origin: this.options.cors?.origin ?? true,
|
|
71
|
+
credentials: this.options.cors?.credentials ?? true,
|
|
72
|
+
methods: ['GET', 'POST', 'DELETE', 'OPTIONS'],
|
|
73
|
+
allowedHeaders: ['Content-Type', 'Authorization', 'Cache-Control', 'Accept', 'Mcp-Session-Id', 'Last-Event-ID'],
|
|
74
|
+
}));
|
|
75
|
+
// Parse JSON bodies with size limit
|
|
76
|
+
this.app.use(express.json({ limit: JSON_BODY_LIMIT }));
|
|
77
|
+
// Health check endpoint
|
|
78
|
+
this.app.get('/health', (req, res) => {
|
|
79
|
+
res.json({
|
|
80
|
+
status: 'healthy',
|
|
81
|
+
timestamp: new Date().toISOString(),
|
|
82
|
+
transport: 'streamable-http',
|
|
83
|
+
protocol: '2025-03-26',
|
|
84
|
+
activeSessions: this.transports.size,
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
setupRoutes() {
|
|
89
|
+
// Main MCP Streamable HTTP endpoint
|
|
90
|
+
this.app
|
|
91
|
+
.route('/mcp')
|
|
92
|
+
.post(this.handlePost.bind(this))
|
|
93
|
+
.get(this.handleGet.bind(this))
|
|
94
|
+
.delete(this.handleDelete.bind(this));
|
|
95
|
+
// Root endpoint for compatibility
|
|
96
|
+
this.app
|
|
97
|
+
.route('/')
|
|
98
|
+
.post(this.handlePost.bind(this))
|
|
99
|
+
.get(this.handleGet.bind(this))
|
|
100
|
+
.delete(this.handleDelete.bind(this));
|
|
101
|
+
// MCP server info endpoint
|
|
102
|
+
this.app.get('/mcp/info', (req, res) => {
|
|
103
|
+
res.json({
|
|
104
|
+
name: SERVER_NAME,
|
|
105
|
+
version: SERVER_VERSION,
|
|
106
|
+
transport: 'streamable-http',
|
|
107
|
+
protocol: PROTOCOL_VERSION,
|
|
108
|
+
capabilities: {
|
|
109
|
+
tools: true,
|
|
110
|
+
resources: false,
|
|
111
|
+
prompts: false,
|
|
112
|
+
sessionManagement: true,
|
|
113
|
+
streaming: true,
|
|
114
|
+
},
|
|
115
|
+
activeSessions: this.transports.size,
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
async handlePost(req, res) {
|
|
120
|
+
const requestId = req.requestId || randomUUID().substring(0, 8);
|
|
121
|
+
const sessionId = req.get('Mcp-Session-Id');
|
|
122
|
+
// Log incoming request details
|
|
123
|
+
this.logger.debug(`[${requestId}] POST request`, {
|
|
124
|
+
sessionId,
|
|
125
|
+
contentType: req.get('Content-Type'),
|
|
126
|
+
bodySize: JSON.stringify(req.body).length,
|
|
127
|
+
userAgent: req.get('User-Agent'),
|
|
128
|
+
});
|
|
129
|
+
try {
|
|
130
|
+
let transport = sessionId ? this.transports.get(sessionId) : undefined;
|
|
131
|
+
// If this is an initialize request and we don't have a transport, create one
|
|
132
|
+
if (!transport && Array.isArray(req.body) ? isInitializeRequest(req.body[0]) : isInitializeRequest(req.body)) {
|
|
133
|
+
const newSessionId = randomUUID();
|
|
134
|
+
this.logger.info(`[${requestId}] Creating new session: ${newSessionId}`);
|
|
135
|
+
// Create new MCP server instance for this session
|
|
136
|
+
const mcpServer = this.createMcpServer();
|
|
137
|
+
// Create streamable HTTP transport
|
|
138
|
+
transport = new StreamableHTTPServerTransport({
|
|
139
|
+
sessionIdGenerator: () => newSessionId,
|
|
140
|
+
});
|
|
141
|
+
this.transports.set(newSessionId, transport);
|
|
142
|
+
// Set session ID in response header
|
|
143
|
+
res.setHeader('Mcp-Session-Id', newSessionId);
|
|
144
|
+
// Connect transport to server
|
|
145
|
+
await mcpServer.connect(transport);
|
|
146
|
+
this.logger.info(`[${requestId}] New MCP session created: ${newSessionId}`);
|
|
147
|
+
// Handle the initial request
|
|
148
|
+
await transport.handleRequest(req, res, req.body);
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
// Use existing transport
|
|
152
|
+
if (!transport) {
|
|
153
|
+
const errorResponse = {
|
|
154
|
+
error: 'Session not found. Please initialize first.',
|
|
155
|
+
code: 'SESSION_NOT_FOUND',
|
|
156
|
+
requestId,
|
|
157
|
+
sessionId,
|
|
158
|
+
};
|
|
159
|
+
this.logger.warn(`[${requestId}] Session not found`, errorResponse);
|
|
160
|
+
res.status(400).json(errorResponse);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
this.logger.debug(`[${requestId}] Using existing session: ${sessionId}`);
|
|
164
|
+
// Handle the request through the existing transport
|
|
165
|
+
await transport.handleRequest(req, res, req.body);
|
|
166
|
+
this.logger.debug(`[${requestId}] Request handled successfully`);
|
|
167
|
+
}
|
|
168
|
+
catch (error) {
|
|
169
|
+
const errorDetails = {
|
|
170
|
+
requestId,
|
|
171
|
+
sessionId,
|
|
172
|
+
error: error instanceof Error
|
|
173
|
+
? {
|
|
174
|
+
name: error.name,
|
|
175
|
+
message: error.message,
|
|
176
|
+
stack: error.stack,
|
|
177
|
+
}
|
|
178
|
+
: String(error),
|
|
179
|
+
requestBody: req.body,
|
|
180
|
+
headers: req.headers,
|
|
181
|
+
timestamp: new Date().toISOString(),
|
|
182
|
+
};
|
|
183
|
+
this.logger.error(`[${requestId}] Error in POST handler`, errorDetails);
|
|
184
|
+
const errorResponse = {
|
|
185
|
+
error: 'Internal server error',
|
|
186
|
+
message: error instanceof Error ? error.message : String(error),
|
|
187
|
+
requestId,
|
|
188
|
+
timestamp: new Date().toISOString(),
|
|
189
|
+
};
|
|
190
|
+
this.logger.error(`[${requestId}] POST error response`, errorResponse);
|
|
191
|
+
res.status(500).json(errorResponse);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
async handleGet(req, res) {
|
|
195
|
+
const requestId = req.requestId || randomUUID().substring(0, 8);
|
|
196
|
+
const sessionId = req.get('Mcp-Session-Id');
|
|
197
|
+
this.logger.debug(`[${requestId}] GET request`, {
|
|
198
|
+
sessionId,
|
|
199
|
+
lastEventId: req.get('Last-Event-ID'),
|
|
200
|
+
userAgent: req.get('User-Agent'),
|
|
201
|
+
});
|
|
202
|
+
try {
|
|
203
|
+
if (sessionId) {
|
|
204
|
+
const transport = this.transports.get(sessionId);
|
|
205
|
+
if (transport) {
|
|
206
|
+
this.logger.debug(`[${requestId}] Using existing session for GET: ${sessionId}`);
|
|
207
|
+
// Handle GET request for existing session (e.g., resumable connections)
|
|
208
|
+
await transport.handleRequest(req, res);
|
|
209
|
+
this.logger.debug(`[${requestId}] GET request handled successfully`);
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
this.logger.warn(`[${requestId}] Session not found for GET: ${sessionId}`);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
// Return server information for GET requests without session
|
|
217
|
+
const infoResponse = {
|
|
218
|
+
name: SERVER_NAME,
|
|
219
|
+
version: SERVER_VERSION,
|
|
220
|
+
transport: 'streamable-http',
|
|
221
|
+
protocol: PROTOCOL_VERSION,
|
|
222
|
+
endpoint: '/mcp',
|
|
223
|
+
methods: ['POST', 'GET', 'DELETE'],
|
|
224
|
+
capabilities: {
|
|
225
|
+
tools: true,
|
|
226
|
+
resources: false,
|
|
227
|
+
prompts: false,
|
|
228
|
+
sessionManagement: true,
|
|
229
|
+
streaming: true,
|
|
230
|
+
},
|
|
231
|
+
activeSessions: this.transports.size,
|
|
232
|
+
usage: {
|
|
233
|
+
initialize: 'POST /mcp with initialize request',
|
|
234
|
+
communicate: 'POST /mcp with Mcp-Session-Id header',
|
|
235
|
+
cleanup: 'DELETE /mcp with Mcp-Session-Id header',
|
|
236
|
+
},
|
|
237
|
+
requestId,
|
|
238
|
+
timestamp: new Date().toISOString(),
|
|
239
|
+
};
|
|
240
|
+
this.logger.debug(`[${requestId}] Server info response`, infoResponse);
|
|
241
|
+
res.json(infoResponse);
|
|
242
|
+
}
|
|
243
|
+
catch (error) {
|
|
244
|
+
const errorDetails = {
|
|
245
|
+
requestId,
|
|
246
|
+
sessionId,
|
|
247
|
+
error: error instanceof Error
|
|
248
|
+
? {
|
|
249
|
+
name: error.name,
|
|
250
|
+
message: error.message,
|
|
251
|
+
stack: error.stack,
|
|
252
|
+
}
|
|
253
|
+
: String(error),
|
|
254
|
+
headers: req.headers,
|
|
255
|
+
timestamp: new Date().toISOString(),
|
|
256
|
+
};
|
|
257
|
+
this.logger.error(`[${requestId}] Error in GET handler`, errorDetails);
|
|
258
|
+
const errorResponse = {
|
|
259
|
+
error: 'Internal server error',
|
|
260
|
+
message: error instanceof Error ? error.message : String(error),
|
|
261
|
+
requestId,
|
|
262
|
+
timestamp: new Date().toISOString(),
|
|
263
|
+
};
|
|
264
|
+
this.logger.error(`[${requestId}] GET error response`, errorResponse);
|
|
265
|
+
res.status(500).json(errorResponse);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
async handleDelete(req, res) {
|
|
269
|
+
const requestId = req.requestId || randomUUID().substring(0, 8);
|
|
270
|
+
const sessionId = req.get('Mcp-Session-Id');
|
|
271
|
+
this.logger.debug(`[${requestId}] DELETE request`, {
|
|
272
|
+
sessionId,
|
|
273
|
+
userAgent: req.get('User-Agent'),
|
|
274
|
+
});
|
|
275
|
+
if (!sessionId) {
|
|
276
|
+
const errorResponse = {
|
|
277
|
+
error: 'Session ID required for DELETE requests',
|
|
278
|
+
requestId,
|
|
279
|
+
timestamp: new Date().toISOString(),
|
|
280
|
+
};
|
|
281
|
+
this.logger.warn(`[${requestId}] Missing session ID`, errorResponse);
|
|
282
|
+
res.status(400).json(errorResponse);
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
285
|
+
const transport = this.transports.get(sessionId);
|
|
286
|
+
if (transport) {
|
|
287
|
+
try {
|
|
288
|
+
this.logger.info(`[${requestId}] Closing session: ${sessionId}`);
|
|
289
|
+
await transport.close();
|
|
290
|
+
this.transports.delete(sessionId);
|
|
291
|
+
const successResponse = {
|
|
292
|
+
message: 'Session closed successfully',
|
|
293
|
+
sessionId,
|
|
294
|
+
requestId,
|
|
295
|
+
timestamp: new Date().toISOString(),
|
|
296
|
+
};
|
|
297
|
+
this.logger.info(`[${requestId}] MCP session closed: ${sessionId}`);
|
|
298
|
+
this.logger.debug(`[${requestId}] Success response`, successResponse);
|
|
299
|
+
res.json(successResponse);
|
|
300
|
+
}
|
|
301
|
+
catch (error) {
|
|
302
|
+
const errorDetails = {
|
|
303
|
+
requestId,
|
|
304
|
+
sessionId,
|
|
305
|
+
error: error instanceof Error
|
|
306
|
+
? {
|
|
307
|
+
name: error.name,
|
|
308
|
+
message: error.message,
|
|
309
|
+
stack: error.stack,
|
|
310
|
+
}
|
|
311
|
+
: String(error),
|
|
312
|
+
timestamp: new Date().toISOString(),
|
|
313
|
+
};
|
|
314
|
+
this.logger.error(`[${requestId}] Error closing session`, errorDetails);
|
|
315
|
+
const errorResponse = {
|
|
316
|
+
error: 'Error closing session',
|
|
317
|
+
message: error instanceof Error ? error.message : String(error),
|
|
318
|
+
requestId,
|
|
319
|
+
sessionId,
|
|
320
|
+
timestamp: new Date().toISOString(),
|
|
321
|
+
};
|
|
322
|
+
this.logger.error(`[${requestId}] DELETE error response`, errorResponse);
|
|
323
|
+
res.status(500).json(errorResponse);
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
const errorResponse = {
|
|
328
|
+
error: 'Session not found',
|
|
329
|
+
sessionId,
|
|
330
|
+
requestId,
|
|
331
|
+
timestamp: new Date().toISOString(),
|
|
332
|
+
};
|
|
333
|
+
this.logger.warn(`[${requestId}] Session not found`, errorResponse);
|
|
334
|
+
this.logger.debug(`[${requestId}] Not found response`, errorResponse);
|
|
335
|
+
res.status(404).json(errorResponse);
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
isValidOrigin(origin) {
|
|
339
|
+
// Implement your origin validation logic here
|
|
340
|
+
// For development, allow localhost and 127.0.0.1
|
|
341
|
+
const allowedOrigins = DEFAULT_CORS_ORIGINS;
|
|
342
|
+
return allowedOrigins.some((allowed) => origin.includes(allowed));
|
|
343
|
+
}
|
|
344
|
+
async start() {
|
|
345
|
+
return new Promise((resolve, reject) => {
|
|
346
|
+
try {
|
|
347
|
+
this.httpServer = this.app.listen(this.options.port, this.options.host || DEFAULT_CORS_ORIGINS[1], // Bind to localhost for security
|
|
348
|
+
() => {
|
|
349
|
+
this.logger.info(`Streamable HTTP transport listening on ${this.options.host || '127.0.0.1'}:${this.options.port}`);
|
|
350
|
+
this.logger.info(`MCP endpoint: http://${this.options.host || 'localhost'}:${this.options.port}/mcp`);
|
|
351
|
+
this.logger.info(`Protocol: MCP 2025-03-26 with Streamable HTTP`);
|
|
352
|
+
resolve();
|
|
353
|
+
});
|
|
354
|
+
this.httpServer?.on('error', (error) => {
|
|
355
|
+
reject(error);
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
catch (error) {
|
|
359
|
+
reject(error);
|
|
360
|
+
}
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
async close() {
|
|
364
|
+
// Close all active transports
|
|
365
|
+
const closePromises = Array.from(this.transports.values()).map((transport) => transport.close().catch((error) => this.logger.error('Error closing transport', error)));
|
|
366
|
+
await Promise.all(closePromises);
|
|
367
|
+
this.transports.clear();
|
|
368
|
+
return new Promise((resolve) => {
|
|
369
|
+
if (this.httpServer) {
|
|
370
|
+
this.httpServer?.close(() => {
|
|
371
|
+
this.logger.info('Streamable HTTP transport closed');
|
|
372
|
+
resolve();
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
else {
|
|
376
|
+
resolve();
|
|
377
|
+
}
|
|
378
|
+
});
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
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CAAC,CAAA;YACf,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,KAAK,CAAC,KAAK;QACT,8BAA8B;QAC9B,MAAM,aAAa,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAC3E,SAAS,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE,KAAK,CAAC,CAAC,CACxF,CAAA;QAED,MAAM,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAA;QAChC,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAA;QAEvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC7B,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;gBACpB,IAAI,CAAC,UAAU,EAAE,KAAK,CAAC,GAAG,EAAE;oBAC1B,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,kCAAkC,CAAC,CAAA;oBACpD,OAAO,EAAE,CAAA;gBACX,CAAC,CAAC,CAAA;YACJ,CAAC;iBAAM,CAAC;gBACN,OAAO,EAAE,CAAA;YACX,CAAC;QACH,CAAC,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export { StdioTransport } from './stdio.js';
|
|
2
|
+
export { StreamableHttpTransport } from './http.js';
|
|
3
|
+
export type { HttpTransportOptions } from './http.js';
|
|
4
|
+
export declare enum TransportType {
|
|
5
|
+
STDIO = "stdio",
|
|
6
|
+
HTTP = "http",
|
|
7
|
+
STREAMABLE_HTTP = "streamable-http"
|
|
8
|
+
}
|
|
9
|
+
export type TransportTypeString = 'stdio' | 'http' | 'streamable-http';
|
|
10
|
+
/**
|
|
11
|
+
* Transport configuration interface
|
|
12
|
+
*/
|
|
13
|
+
export interface TransportConfig {
|
|
14
|
+
type: TransportType;
|
|
15
|
+
port?: number;
|
|
16
|
+
host?: string;
|
|
17
|
+
cors?: {
|
|
18
|
+
origin?: string | string[] | boolean;
|
|
19
|
+
credentials?: boolean;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/transports/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAA;AACnD,YAAY,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAGrD,oBAAY,aAAa;IACvB,KAAK,UAAU;IACf,IAAI,SAAS;IACb,eAAe,oBAAoB;CACpC;AAGD,MAAM,MAAM,mBAAmB,GAAG,OAAO,GAAG,MAAM,GAAG,iBAAiB,CAAA;AAEtE;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,aAAa,CAAA;IACnB,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE;QACL,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,OAAO,CAAA;QACpC,WAAW,CAAC,EAAE,OAAO,CAAA;KACtB,CAAA;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { StdioTransport } from './stdio.js';
|
|
2
|
+
export { StreamableHttpTransport } from './http.js';
|
|
3
|
+
// Transport type enum
|
|
4
|
+
export var TransportType;
|
|
5
|
+
(function (TransportType) {
|
|
6
|
+
TransportType["STDIO"] = "stdio";
|
|
7
|
+
TransportType["HTTP"] = "http";
|
|
8
|
+
TransportType["STREAMABLE_HTTP"] = "streamable-http";
|
|
9
|
+
})(TransportType || (TransportType = {}));
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transports/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC3C,OAAO,EAAE,uBAAuB,EAAE,MAAM,WAAW,CAAA;AAGnD,sBAAsB;AACtB,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,gCAAe,CAAA;IACf,8BAAa,CAAA;IACb,oDAAmC,CAAA;AACrC,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a STDIO transport for MCP server
|
|
4
|
+
* This is the default transport for local MCP servers
|
|
5
|
+
*/
|
|
6
|
+
export declare class StdioTransport {
|
|
7
|
+
private transport;
|
|
8
|
+
private mcpServer;
|
|
9
|
+
constructor(mcpServer: Server);
|
|
10
|
+
start(): Promise<void>;
|
|
11
|
+
close(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=stdio.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["../../src/transports/stdio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAA;AAGlE;;;GAGG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,SAAS,CAAsB;IACvC,OAAO,CAAC,SAAS,CAAQ;gBAEb,SAAS,EAAE,MAAM;IAKvB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAOtB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAI7B"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a STDIO transport for MCP server
|
|
4
|
+
* This is the default transport for local MCP servers
|
|
5
|
+
*/
|
|
6
|
+
export class StdioTransport {
|
|
7
|
+
transport;
|
|
8
|
+
mcpServer;
|
|
9
|
+
constructor(mcpServer) {
|
|
10
|
+
this.mcpServer = mcpServer;
|
|
11
|
+
this.transport = new StdioServerTransport();
|
|
12
|
+
}
|
|
13
|
+
async start() {
|
|
14
|
+
await this.mcpServer.connect(this.transport);
|
|
15
|
+
console.error('🚀 Cucumber Studio MCP Server running on stdio');
|
|
16
|
+
console.error('📡 Transport: STDIO (standard input/output)');
|
|
17
|
+
console.error('🔄 Protocol: MCP 2025-03-26');
|
|
18
|
+
}
|
|
19
|
+
async close() {
|
|
20
|
+
await this.transport.close();
|
|
21
|
+
console.error('🛑 STDIO transport closed');
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=stdio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stdio.js","sourceRoot":"","sources":["../../src/transports/stdio.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAA;AAEhF;;;GAGG;AACH,MAAM,OAAO,cAAc;IACjB,SAAS,CAAsB;IAC/B,SAAS,CAAQ;IAEzB,YAAY,SAAiB;QAC3B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAA;IAC7C,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAA;QAC5C,OAAO,CAAC,KAAK,CAAC,gDAAgD,CAAC,CAAA;QAC/D,OAAO,CAAC,KAAK,CAAC,6CAA6C,CAAC,CAAA;QAC5D,OAAO,CAAC,KAAK,CAAC,6BAA6B,CAAC,CAAA;IAC9C,CAAC;IAED,KAAK,CAAC,KAAK;QACT,MAAM,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAA;QAC5B,OAAO,CAAC,KAAK,CAAC,2BAA2B,CAAC,CAAA;IAC5C,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { McpError } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Convert various error types into MCP-compatible errors
|
|
4
|
+
*/
|
|
5
|
+
export declare function createMcpError(error: unknown, context?: string): McpError;
|
|
6
|
+
/**
|
|
7
|
+
* Safely execute async operations with error handling
|
|
8
|
+
*/
|
|
9
|
+
export declare function safeExecute<T>(operation: () => Promise<T>, context?: string): Promise<T>;
|
|
10
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAa,MAAM,oCAAoC,CAAA;AAExE;;GAEG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,QAAQ,CA4BzE;AAED;;GAEG;AACH,wBAAsB,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAM9F"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { McpError, ErrorCode } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Convert various error types into MCP-compatible errors
|
|
4
|
+
*/
|
|
5
|
+
export function createMcpError(error, context) {
|
|
6
|
+
if (error instanceof McpError) {
|
|
7
|
+
return error;
|
|
8
|
+
}
|
|
9
|
+
if (error instanceof Error) {
|
|
10
|
+
// Handle API-specific errors
|
|
11
|
+
if (error.name === 'CucumberStudioApiError') {
|
|
12
|
+
return new McpError(ErrorCode.InternalError, `Cucumber Studio API error${context ? ` (${context})` : ''}: ${error.message}`);
|
|
13
|
+
}
|
|
14
|
+
// Handle validation errors
|
|
15
|
+
if (error.name === 'ZodError') {
|
|
16
|
+
return new McpError(ErrorCode.InvalidParams, `Validation error${context ? ` (${context})` : ''}: ${error.message}`);
|
|
17
|
+
}
|
|
18
|
+
// Handle general errors
|
|
19
|
+
return new McpError(ErrorCode.InternalError, `${context ? `${context}: ` : ''}${error.message}`);
|
|
20
|
+
}
|
|
21
|
+
// Handle unknown errors
|
|
22
|
+
return new McpError(ErrorCode.InternalError, `Unknown error${context ? ` (${context})` : ''}: ${String(error)}`);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Safely execute async operations with error handling
|
|
26
|
+
*/
|
|
27
|
+
export async function safeExecute(operation, context) {
|
|
28
|
+
try {
|
|
29
|
+
return await operation();
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
throw createMcpError(error, context);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAA;AAExE;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,KAAc,EAAE,OAAgB;IAC7D,IAAI,KAAK,YAAY,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAA;IACd,CAAC;IAED,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,6BAA6B;QAC7B,IAAI,KAAK,CAAC,IAAI,KAAK,wBAAwB,EAAE,CAAC;YAC5C,OAAO,IAAI,QAAQ,CACjB,SAAS,CAAC,aAAa,EACvB,4BAA4B,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,CAAC,OAAO,EAAE,CAC/E,CAAA;QACH,CAAC;QAED,2BAA2B;QAC3B,IAAI,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE,CAAC;YAC9B,OAAO,IAAI,QAAQ,CACjB,SAAS,CAAC,aAAa,EACvB,mBAAmB,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,KAAK,CAAC,OAAO,EAAE,CACtE,CAAA;QACH,CAAC;QAED,wBAAwB;QACxB,OAAO,IAAI,QAAQ,CAAC,SAAS,CAAC,aAAa,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;IAClG,CAAC;IAED,wBAAwB;IACxB,OAAO,IAAI,QAAQ,CAAC,SAAS,CAAC,aAAa,EAAE,gBAAgB,OAAO,CAAC,CAAC,CAAC,KAAK,OAAO,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAA;AAClH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,WAAW,CAAI,SAA2B,EAAE,OAAgB;IAChF,IAAI,CAAC;QACH,OAAO,MAAM,SAAS,EAAE,CAAA;IAC1B,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,cAAc,CAAC,KAAK,EAAE,OAAO,CAAC,CAAA;IACtC,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export declare const LOG_COLORS: {
|
|
2
|
+
readonly DEBUG: "\u001B[36m";
|
|
3
|
+
readonly INFO: "\u001B[32m";
|
|
4
|
+
readonly WARN: "\u001B[33m";
|
|
5
|
+
readonly ERROR: "\u001B[31m";
|
|
6
|
+
readonly RESET: "\u001B[0m";
|
|
7
|
+
};
|
|
8
|
+
export declare const LOG_LEVELS: {
|
|
9
|
+
readonly DEBUG: 0;
|
|
10
|
+
readonly INFO: 1;
|
|
11
|
+
readonly WARN: 2;
|
|
12
|
+
readonly ERROR: 3;
|
|
13
|
+
};
|
|
14
|
+
export type LogLevel = keyof typeof LOG_LEVELS;
|
|
15
|
+
//# sourceMappingURL=logger-constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger-constants.d.ts","sourceRoot":"","sources":["../../src/utils/logger-constants.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,UAAU;;;;;;CAMb,CAAA;AAGV,eAAO,MAAM,UAAU;;;;;CAKb,CAAA;AAEV,MAAM,MAAM,QAAQ,GAAG,MAAM,OAAO,UAAU,CAAA"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// ANSI color codes for console output
|
|
2
|
+
export const LOG_COLORS = {
|
|
3
|
+
DEBUG: '\x1b[36m', // Cyan
|
|
4
|
+
INFO: '\x1b[32m', // Green
|
|
5
|
+
WARN: '\x1b[33m', // Yellow
|
|
6
|
+
ERROR: '\x1b[31m', // Red
|
|
7
|
+
RESET: '\x1b[0m', // Reset
|
|
8
|
+
};
|
|
9
|
+
// Log level configuration
|
|
10
|
+
export const LOG_LEVELS = {
|
|
11
|
+
DEBUG: 0,
|
|
12
|
+
INFO: 1,
|
|
13
|
+
WARN: 2,
|
|
14
|
+
ERROR: 3,
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=logger-constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger-constants.js","sourceRoot":"","sources":["../../src/utils/logger-constants.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,KAAK,EAAE,UAAU,EAAE,OAAO;IAC1B,IAAI,EAAE,UAAU,EAAE,QAAQ;IAC1B,IAAI,EAAE,UAAU,EAAE,SAAS;IAC3B,KAAK,EAAE,UAAU,EAAE,MAAM;IACzB,KAAK,EAAE,SAAS,EAAE,QAAQ;CAClB,CAAA;AAEV,0BAA0B;AAC1B,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;CACA,CAAA"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export type LogLevel = 'error' | 'warn' | 'info' | 'debug' | 'trace';
|
|
2
|
+
export interface Logger {
|
|
3
|
+
error(message: string, meta?: Record<string, unknown>): void;
|
|
4
|
+
warn(message: string, meta?: Record<string, unknown>): void;
|
|
5
|
+
info(message: string, meta?: Record<string, unknown>): void;
|
|
6
|
+
debug(message: string, meta?: Record<string, unknown>): void;
|
|
7
|
+
trace(message: string, meta?: Record<string, unknown>): void;
|
|
8
|
+
}
|
|
9
|
+
export interface LoggerConfig {
|
|
10
|
+
level: LogLevel;
|
|
11
|
+
prefix?: string;
|
|
12
|
+
enableTimestamp?: boolean;
|
|
13
|
+
enableColors?: boolean;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* No-operation logger for testing - discards all log messages
|
|
17
|
+
*/
|
|
18
|
+
export declare class NoOpLogger implements Logger {
|
|
19
|
+
error(): void;
|
|
20
|
+
warn(): void;
|
|
21
|
+
info(): void;
|
|
22
|
+
debug(): void;
|
|
23
|
+
trace(): void;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Logger implementation that outputs to stderr
|
|
27
|
+
* Safe for use with STDIO MCP transport as it won't interfere with stdout protocol
|
|
28
|
+
*/
|
|
29
|
+
export declare class StderrLogger implements Logger {
|
|
30
|
+
private config;
|
|
31
|
+
constructor(config: LoggerConfig);
|
|
32
|
+
private shouldLog;
|
|
33
|
+
private formatMessage;
|
|
34
|
+
private writeLog;
|
|
35
|
+
error(message: string, meta?: Record<string, unknown>): void;
|
|
36
|
+
warn(message: string, meta?: Record<string, unknown>): void;
|
|
37
|
+
info(message: string, meta?: Record<string, unknown>): void;
|
|
38
|
+
debug(message: string, meta?: Record<string, unknown>): void;
|
|
39
|
+
trace(message: string, meta?: Record<string, unknown>): void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* No-op logger for testing or when logging is disabled
|
|
43
|
+
*/
|
|
44
|
+
export declare class NoopLogger implements Logger {
|
|
45
|
+
error(): void;
|
|
46
|
+
warn(): void;
|
|
47
|
+
info(): void;
|
|
48
|
+
debug(): void;
|
|
49
|
+
trace(): void;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Helper to get log level from environment
|
|
53
|
+
*/
|
|
54
|
+
export declare function getLogLevel(): LogLevel;
|
|
55
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAA;AAEpE,MAAM,WAAW,MAAM;IACrB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IAC5D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IAC3D,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IAC3D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IAC5D,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;CAC7D;AAED,MAAM,WAAW,YAAY;IAC3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