raiton 6.3.1-beta.11 → 6.5.0-beta.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/build/bin/index.mjs +20011 -1770
  3. package/docs/user-guide/README.md +17 -12
  4. package/docs/user-guide/decorators/README.md +2 -0
  5. package/docs/user-guide/decorators/mcp.md +70 -0
  6. package/docs/user-guide/https.md +337 -0
  7. package/docs/user-guide/mcp.md +120 -0
  8. package/docs/user-guide/plugins.md +1 -0
  9. package/docs/user-guide/security.md +2 -2
  10. package/package.json +1 -1
  11. package/source/core/application.ts +24 -3
  12. package/source/core/builder.ts +12 -0
  13. package/source/core/controller/builder.ts +8 -2
  14. package/source/core/index.ts +1 -0
  15. package/source/core/mcp/builder.ts +76 -0
  16. package/source/core/mcp/index.ts +3 -0
  17. package/source/core/mcp/metadata.ts +80 -0
  18. package/source/core/mcp/tracker.ts +28 -0
  19. package/source/core/thread.ts +19 -3
  20. package/source/framework/artifacts.ts +30 -0
  21. package/source/framework/constants/decorators.constant.ts +4 -0
  22. package/source/framework/decorators/index.ts +2 -1
  23. package/source/framework/decorators/mcp.decorator.ts +170 -0
  24. package/source/framework/index.ts +1 -0
  25. package/source/framework/mcp/handler.ts +369 -0
  26. package/source/framework/mcp/index.ts +3 -0
  27. package/source/framework/mcp/protocol.ts +50 -0
  28. package/source/framework/mcp/streamable-http.ts +94 -0
  29. package/source/framework/plugins/index.ts +2 -1
  30. package/source/framework/plugins/mcp.plugin.ts +87 -0
  31. package/source/framework/runtime/bun/server.ts +13 -2
  32. package/source/framework/runtime/node/server.ts +19 -4
  33. package/source/framework/utilities/artifact.util.ts +4 -0
  34. package/source/framework/utilities/https.ts +298 -0
  35. package/source/framework/utilities/index.ts +2 -1
  36. package/source/framework/utilities/openapi.utils.ts +112 -13
  37. package/source/types/application.ts +4 -0
  38. package/source/types/index.ts +2 -1
  39. package/source/types/mcp.ts +118 -0
  40. package/source/types/raiton.ts +1 -0
  41. package/source/types/runtime.ts +8 -0
@@ -0,0 +1,298 @@
1
+ import fs from 'node:fs'
2
+ import os from 'node:os'
3
+ import {execSync, execFileSync} from 'node:child_process'
4
+ import path from 'node:path'
5
+
6
+ export enum HttpsEnvironment {
7
+ Localhost = 'localhost',
8
+ LAN = 'lan',
9
+ Production = 'production',
10
+ }
11
+
12
+ export enum HttpsGenerator {
13
+ OpenSSL = 'openssl',
14
+ Mkcert = 'mkcert',
15
+ None = 'none',
16
+ }
17
+
18
+ export interface HttpsCertificateConfig {
19
+ cert: string
20
+ key: string
21
+ ca?: string
22
+ passphrase?: string
23
+ }
24
+
25
+ export interface HttpsConfigInterface {
26
+ enabled: boolean
27
+ environment: HttpsEnvironment
28
+ generator: HttpsGenerator
29
+ autoGenerate: boolean
30
+ port?: number
31
+ certificate?: HttpsCertificateConfig
32
+ certDir?: string
33
+ }
34
+
35
+ export interface HttpsDefinitionOptions {
36
+ environment?: HttpsEnvironment
37
+ generator?: HttpsGenerator
38
+ autoGenerate?: boolean
39
+ port?: number
40
+ cert?: string
41
+ key?: string
42
+ ca?: string
43
+ passphrase?: string
44
+ certPath?: string
45
+ keyPath?: string
46
+ caPath?: string
47
+ certDir?: string
48
+ }
49
+
50
+ // ── Helpers ────────────────────────────────────────────────────────
51
+
52
+ function ensureDirectorySync(dirPath: string): void {
53
+ if (!fs.existsSync(dirPath)) {
54
+ fs.mkdirSync(dirPath, {recursive: true})
55
+ }
56
+ }
57
+
58
+ function readFileSyncSafe(filePath: string): string | undefined {
59
+ try {
60
+ return fs.readFileSync(filePath, 'utf-8')
61
+ } catch {
62
+ return undefined
63
+ }
64
+ }
65
+
66
+ function resolveCertFromPaths(
67
+ certPath?: string,
68
+ keyPath?: string,
69
+ caPath?: string,
70
+ ): HttpsCertificateConfig | undefined {
71
+ if (!certPath || !keyPath) return undefined
72
+ const cert = readFileSyncSafe(certPath)
73
+ const key = readFileSyncSafe(keyPath)
74
+ const ca = caPath ? readFileSyncSafe(caPath) : undefined
75
+ if (!cert || !key) return undefined
76
+ return {cert, key, ca}
77
+ }
78
+
79
+ function getLanHostname(): string {
80
+ const interfaces = os.networkInterfaces()
81
+ for (const name of Object.keys(interfaces)) {
82
+ for (const iface of interfaces[name] || []) {
83
+ if (iface.family === 'IPv4' && !iface.internal) {
84
+ return iface.address
85
+ }
86
+ }
87
+ }
88
+ return 'localhost'
89
+ }
90
+
91
+ function isCommandAvailable(command: string): boolean {
92
+ try {
93
+ execSync(
94
+ process.platform === 'win32' ? `where ${command}` : `which ${command}`,
95
+ {stdio: 'pipe'}
96
+ )
97
+ return true
98
+ } catch {
99
+ return false
100
+ }
101
+ }
102
+
103
+ // ── Certificate generators ────────────────────────────────────────
104
+
105
+ function generateWithOpenSSL(domain: string, certDir: string): HttpsCertificateConfig {
106
+ const keyPath = path.join(certDir, `${domain}.key`)
107
+ const certPath = path.join(certDir, `${domain}.pem`)
108
+
109
+ const existingKey = readFileSyncSafe(keyPath)
110
+ const existingCert = readFileSyncSafe(certPath)
111
+ if (existingKey && existingCert) {
112
+ return {key: existingKey, cert: existingCert}
113
+ }
114
+
115
+ ensureDirectorySync(certDir)
116
+
117
+ const sanHosts = new Set<string>([domain])
118
+ sanHosts.add('localhost')
119
+ sanHosts.add('*.localhost')
120
+
121
+ const sans = [
122
+ ...[...sanHosts].map(d => `DNS:${d}`),
123
+ 'IP:127.0.0.1',
124
+ 'IP:::1',
125
+ ].join(',')
126
+
127
+ execSync(
128
+ `openssl req -x509 -newkey rsa:2048 -nodes ` +
129
+ `-keyout "${keyPath}" -out "${certPath}" ` +
130
+ `-days 365 -subj "/CN=${domain}/O=Raiton Dev/C=US" ` +
131
+ `-addext "subjectAltName=${sans}"`,
132
+ {stdio: 'pipe'}
133
+ )
134
+
135
+ return {key: fs.readFileSync(keyPath, 'utf-8'), cert: fs.readFileSync(certPath, 'utf-8')}
136
+ }
137
+
138
+ function generateWithMkcert(domain: string, certDir: string): HttpsCertificateConfig {
139
+ const keyPath = path.join(certDir, `${domain}.key`)
140
+ const certPath = path.join(certDir, `${domain}.pem`)
141
+
142
+ const existingKey = readFileSyncSafe(keyPath)
143
+ const existingCert = readFileSyncSafe(certPath)
144
+ if (existingKey && existingCert) {
145
+ return {key: existingKey, cert: existingCert}
146
+ }
147
+
148
+ ensureDirectorySync(certDir)
149
+
150
+ const hosts = new Set<string>([domain])
151
+ hosts.add('localhost')
152
+ hosts.add('127.0.0.1')
153
+
154
+ execSync(
155
+ `mkcert -cert-file "${certPath}" -key-file "${keyPath}" ` +
156
+ `${[...hosts].map(h => `"${h}"`).join(' ')}`,
157
+ {stdio: 'pipe'}
158
+ )
159
+
160
+ return {key: fs.readFileSync(keyPath, 'utf-8'), cert: fs.readFileSync(certPath, 'utf-8')}
161
+ }
162
+
163
+ function autoGenerateCert(
164
+ domain: string,
165
+ generator: HttpsGenerator,
166
+ certDir: string,
167
+ ): HttpsCertificateConfig {
168
+ if (generator === HttpsGenerator.Mkcert) {
169
+ if (!isCommandAvailable('mkcert')) {
170
+ throw new Error(
171
+ '[Raiton HTTPS] mkcert is not installed. ' +
172
+ 'Install it (https://github.com/FiloSottile/mkcert) or switch generator to HttpsGenerator.OpenSSL.'
173
+ )
174
+ }
175
+ return generateWithMkcert(domain, certDir)
176
+ }
177
+
178
+ if (generator === HttpsGenerator.OpenSSL) {
179
+ if (!isCommandAvailable('openssl')) {
180
+ throw new Error(
181
+ '[Raiton HTTPS] openssl is not installed. ' +
182
+ 'Install it or switch generator to HttpsGenerator.Mkcert.'
183
+ )
184
+ }
185
+ return generateWithOpenSSL(domain, certDir)
186
+ }
187
+
188
+ throw new Error(
189
+ '[Raiton HTTPS] autoGenerate is enabled but generator is set to "none". ' +
190
+ 'Set generator to HttpsGenerator.OpenSSL or HttpsGenerator.Mkcert, or provide certificates explicitly.'
191
+ )
192
+ }
193
+
194
+ // ── Core API ──────────────────────────────────────────────────────
195
+
196
+ export function defineHttps(options: HttpsDefinitionOptions = {}): HttpsConfigInterface {
197
+ const environment = options.environment ?? HttpsEnvironment.Localhost
198
+ const generator = options.generator ?? HttpsGenerator.OpenSSL
199
+ const autoGenerate = options.autoGenerate ?? true
200
+ const certDir = options.certDir ?? path.join(process.cwd(), '.raiton', 'certs')
201
+
202
+ let certificate: HttpsCertificateConfig | undefined
203
+
204
+ if (options.cert && options.key) {
205
+ certificate = {
206
+ cert: options.cert,
207
+ key: options.key,
208
+ ca: options.ca,
209
+ passphrase: options.passphrase,
210
+ }
211
+ } else if (options.certPath && options.keyPath) {
212
+ certificate = resolveCertFromPaths(options.certPath, options.keyPath, options.caPath)
213
+ }
214
+
215
+ if (!certificate) {
216
+ if (environment === HttpsEnvironment.Production && !autoGenerate) {
217
+ throw new Error(
218
+ '[Raiton HTTPS] Production environment requires explicit certificate configuration. ' +
219
+ 'Use cert/key strings, certPath/keyPath, or enable autoGenerate.'
220
+ )
221
+ }
222
+
223
+ if (autoGenerate && generator !== HttpsGenerator.None) {
224
+ const domain = environment === HttpsEnvironment.LAN ? getLanHostname() : 'localhost'
225
+ certificate = autoGenerateCert(domain, generator, certDir)
226
+ }
227
+ }
228
+
229
+ return {
230
+ enabled: true,
231
+ environment,
232
+ generator,
233
+ autoGenerate,
234
+ port: options.port,
235
+ certificate,
236
+ certDir,
237
+ }
238
+ }
239
+
240
+ // ── Presets ───────────────────────────────────────────────────────
241
+
242
+ export function httpsLocalhost(options?: Omit<HttpsDefinitionOptions, 'environment'>): HttpsConfigInterface {
243
+ return defineHttps({...options, environment: HttpsEnvironment.Localhost})
244
+ }
245
+
246
+ export function httpsLan(options?: Omit<HttpsDefinitionOptions, 'environment'>): HttpsConfigInterface {
247
+ return defineHttps({...options, environment: HttpsEnvironment.LAN})
248
+ }
249
+
250
+ export function httpsProduction(options: Omit<HttpsDefinitionOptions, 'environment'> & {
251
+ cert: string
252
+ key: string
253
+ }): HttpsConfigInterface {
254
+ return defineHttps({...options, environment: HttpsEnvironment.Production})
255
+ }
256
+
257
+ // ── Merge ─────────────────────────────────────────────────────────
258
+
259
+ export type HttpsConfigInput = HttpsConfigInterface | HttpsConfigInterface[]
260
+
261
+ export function resolveHttpsConfig(input: HttpsConfigInput | undefined): HttpsConfigInterface | undefined {
262
+ if (!input) return undefined
263
+
264
+ const configs = Array.isArray(input) ? input : [input]
265
+
266
+ if (configs.length === 0) return undefined
267
+ if (configs.length === 1) return configs[0]
268
+
269
+ return mergeHttps(...configs)
270
+ }
271
+
272
+ export function mergeHttps(...configs: HttpsConfigInterface[]): HttpsConfigInterface {
273
+ if (configs.length === 0) {
274
+ throw new Error('[Raiton HTTPS] mergeHttps requires at least one configuration.')
275
+ }
276
+
277
+ if (configs.length === 1) return configs[0]
278
+
279
+ const merged: HttpsConfigInterface = {
280
+ ...configs[0],
281
+ }
282
+
283
+ for (let i = 1; i < configs.length; i++) {
284
+ const next = configs[i]
285
+ if (!next) continue
286
+
287
+ merged.enabled = next.enabled
288
+ merged.environment = next.environment
289
+ merged.generator = next.generator
290
+ merged.autoGenerate = next.autoGenerate
291
+
292
+ if (next.port !== undefined) merged.port = next.port
293
+ if (next.certDir !== undefined) merged.certDir = next.certDir
294
+ if (next.certificate) merged.certificate = next.certificate
295
+ }
296
+
297
+ return merged
298
+ }
@@ -5,4 +5,5 @@ export * from "./json.util"
5
5
  export * from "./path.util"
6
6
  export * from "./cookie.util"
7
7
  export * from "./openapi.utils"
8
- export * from "./ip.util"
8
+ export * from "./ip.util"
9
+ export * from "./https"
@@ -3,23 +3,39 @@ import {METADATA_KEYS, Parametrable} from "../index";
3
3
  import {PluginScope} from "../../core";
4
4
  import {RaitonConfig} from "../../core/config";
5
5
  import {getSocketRegistry} from "../../core/socket";
6
+ import {getMcpServerRegistry} from "../../core/mcp";
6
7
  import {RaitonThread} from "../../core/thread";
7
8
 
8
9
  /**
9
10
  * Generate the OpenAPI specification object
10
11
  */
11
12
  export async function generateOpenApiSpec(scope: PluginScope, opts: any): Promise<any> {
12
- // Load application config from RaitonConfig singleton
13
- // Ensure config is synced with current working directory (set by Application)
14
- await RaitonConfig.sync(process.cwd());
15
-
16
- const config: Map<keyof any, any> = RaitonConfig.current as any;
17
-
18
- // Build base URL
19
- const protocole = (config.get('protocole') as string) ?? 'http';
20
- const hostname = (config.get('hostname') as string) ?? 'localhost';
21
- const port = config.get('port') as number;
22
- const pathname = (config.get('pathname') as string) ?? '/';
13
+ // Use application config directly (includes HTTPS, port, hostname)
14
+ const appConfig = RaitonThread.current?.application?.config;
15
+ const appHttps = RaitonThread.current?.application?.https;
16
+
17
+ let protocole: string;
18
+ let hostname: string;
19
+ let port: number | undefined;
20
+ let pathname: string;
21
+ let prefix: string;
22
+
23
+ if (appConfig) {
24
+ protocole = appHttps?.enabled ? 'https' : (appConfig.protocole || 'http');
25
+ hostname = appConfig.hostname || 'localhost';
26
+ port = appConfig.port;
27
+ pathname = appConfig.pathname || '/';
28
+ prefix = appConfig.prefix || '';
29
+ } else {
30
+ // Fallback to RaitonConfig
31
+ await RaitonConfig.sync(process.cwd());
32
+ const config: Map<keyof any, any> = RaitonConfig.current as any;
33
+ protocole = (config.get('protocole') as string) ?? 'http';
34
+ hostname = (config.get('hostname') as string) ?? 'localhost';
35
+ port = config.get('port') as number;
36
+ pathname = (config.get('pathname') as string) ?? '/';
37
+ prefix = (config.get('prefix') as string) ?? '';
38
+ }
23
39
  const basePath = pathname.endsWith('/') ? pathname : pathname + '/';
24
40
 
25
41
  let baseUrl = `${protocole}://${hostname}`;
@@ -27,6 +43,10 @@ export async function generateOpenApiSpec(scope: PluginScope, opts: any): Promis
27
43
  baseUrl += `:${port}`;
28
44
  }
29
45
  baseUrl += basePath;
46
+ if (prefix) {
47
+ baseUrl += prefix.startsWith('/') ? prefix.slice(1) : prefix;
48
+ if (!baseUrl.endsWith('/')) baseUrl += '/';
49
+ }
30
50
 
31
51
  // Initialize OpenAPI document
32
52
  const spec: any = {
@@ -308,7 +328,6 @@ export async function generateOpenApiSpec(scope: PluginScope, opts: any): Promis
308
328
  }
309
329
 
310
330
  // Document registered WebSocket sockets as POST operations (one per event)
311
- const prefix = RaitonThread.current?.application?.config?.prefix ?? '';
312
331
  const sockets = getSocketRegistry();
313
332
 
314
333
  for (const [, socketEntry] of sockets) {
@@ -320,7 +339,7 @@ export async function generateOpenApiSpec(scope: PluginScope, opts: any): Promis
320
339
  if (event.type !== 'event' && event.type !== 'message') continue;
321
340
  if (!event.name) continue;
322
341
 
323
- const channelPath = `${prefix}${namespace}`.replace(/\/+/g, '/') || '/';
342
+ const channelPath = `${namespace}`.replace(/\/+/g, '/') || '/';
324
343
  const eventPath = `${channelPath}/${event.name}`.replace(/\/+/g, '/');
325
344
 
326
345
  if (!spec.paths[eventPath]) {
@@ -395,6 +414,86 @@ export async function generateOpenApiSpec(scope: PluginScope, opts: any): Promis
395
414
  }
396
415
  }
397
416
 
417
+ // Document registered MCP servers as streamable HTTP (POST JSON-RPC) operations
418
+ const mcpServers = getMcpServerRegistry();
419
+
420
+ for (const [, mcpEntry] of mcpServers) {
421
+ const mcpPath = mcpEntry.path;
422
+ if (!spec.paths[mcpPath]) {
423
+ spec.paths[mcpPath] = {};
424
+ }
425
+
426
+ const elements = [
427
+ ...mcpEntry.metadata.tools.map(t => ({kind: 'tool', ...t})),
428
+ ...mcpEntry.metadata.prompts.map(p => ({kind: 'prompt', ...p})),
429
+ ...mcpEntry.metadata.resources.map(r => ({kind: 'resource', ...r})),
430
+ ...mcpEntry.metadata.resourceTemplates.map(r => ({kind: 'resource-template', ...r})),
431
+ ];
432
+
433
+ (spec.paths[mcpPath] as any).post = {
434
+ summary: `MCP server: ${mcpEntry.name} (${mcpEntry.version})`,
435
+ description: mcpEntry.metadata.description
436
+ || `Model Context Protocol server. Exposes ${
437
+ elements.map(e => `${e.kind}s`).filter((v, i, a) => a.indexOf(v) === i).join(', ') || 'no elements'
438
+ }.`,
439
+ parameters: [],
440
+ requestBody: {
441
+ required: true,
442
+ content: {
443
+ 'application/json': {
444
+ schema: {
445
+ type: 'object',
446
+ properties: {
447
+ jsonrpc: {type: 'string', const: '2.0'},
448
+ id: {type: ['number', 'string', 'null']},
449
+ method: {type: 'string', enum: [...new Set(elements.map(e => e.kind === 'tool' ? 'tools/call' : e.kind === 'prompt' ? 'prompts/get' : 'resources/read'))]},
450
+ params: {type: 'object'}
451
+ },
452
+ required: ['jsonrpc', 'method']
453
+ }
454
+ }
455
+ }
456
+ },
457
+ responses: {
458
+ '200': {
459
+ description: 'Successful JSON-RPC response',
460
+ content: {'application/json': {schema: {type: 'object'}}}
461
+ },
462
+ '202': {
463
+ description: 'Request accepted (notification)'
464
+ },
465
+ '406': {
466
+ description: 'Unsupported protocol version'
467
+ }
468
+ },
469
+ 'x-mcp': {
470
+ name: mcpEntry.name,
471
+ version: mcpEntry.version,
472
+ transport: 'streamable-http',
473
+ tools: mcpEntry.metadata.tools.map(t => ({
474
+ name: t.name,
475
+ description: t.description,
476
+ inputSchema: {
477
+ type: 'object',
478
+ properties: Object.fromEntries(
479
+ t.arguments.map(a => [a.name, {type: a.schema?.type || 'string', description: a.description}])
480
+ ),
481
+ ...(t.arguments.some(a => a.required) ? {required: t.arguments.filter(a => a.required).map(a => a.name)} : {})
482
+ }
483
+ })),
484
+ prompts: mcpEntry.metadata.prompts.map(p => ({
485
+ name: p.name,
486
+ description: p.description,
487
+ arguments: p.arguments.map(a => ({name: a.name, description: a.description, required: a.required}))
488
+ })),
489
+ resources: [
490
+ ...mcpEntry.metadata.resources.map(r => ({uri: r.uri, name: r.name, mimeType: r.mimeType})),
491
+ ...mcpEntry.metadata.resourceTemplates.map(r => ({uriTemplate: r.uri, name: r.name, mimeType: r.mimeType})),
492
+ ]
493
+ }
494
+ };
495
+ }
496
+
398
497
  return spec;
399
498
  }
400
499
 
@@ -1,4 +1,5 @@
1
1
  import {HttpMethod} from "../framework";
2
+ import {HttpsConfigInput, HttpsConfigInterface} from "../framework/utilities/https";
2
3
 
3
4
  export interface ApplicationConfigInterface {
4
5
  workdir?: string;
@@ -9,6 +10,7 @@ export interface ApplicationConfigInterface {
9
10
  prefix?: string;
10
11
  develop?: boolean;
11
12
  verbose?: boolean;
13
+ https?: HttpsConfigInput;
12
14
  }
13
15
 
14
16
  export interface ApplicationInterface {
@@ -16,6 +18,8 @@ export interface ApplicationInterface {
16
18
 
17
19
  get hostname(): string;
18
20
 
21
+ get https(): HttpsConfigInterface | undefined;
22
+
19
23
  setOption<K extends keyof ApplicationConfigInterface>(key: K, value: ApplicationConfigInterface[K]): this;
20
24
 
21
25
  setOptions(options: ApplicationConfigInterface): this;
@@ -21,4 +21,5 @@ export type * from "./injection"
21
21
  export type * from "./responses"
22
22
  export type * from "./server"
23
23
  export type * from "./raiton"
24
- export type * from "./lifecycle"
24
+ export type * from "./lifecycle"
25
+ export type * from "./mcp"
@@ -0,0 +1,118 @@
1
+ export type McpArgumentType = 'string' | 'number' | 'boolean' | 'integer' | 'array' | 'object' | 'null';
2
+
3
+ export interface McpArgumentSchema {
4
+ type?: McpArgumentType;
5
+ description?: string;
6
+ required?: boolean;
7
+ enum?: any[];
8
+ default?: any;
9
+ items?: McpArgumentSchema;
10
+ properties?: Record<string, McpArgumentSchema>;
11
+ }
12
+
13
+ export interface McpArgumentMetaInterface {
14
+ name: string;
15
+ description?: string;
16
+ schema?: McpArgumentSchema;
17
+ required?: boolean;
18
+ metatype?: any;
19
+ }
20
+
21
+ export type McpElementType = 'tool' | 'prompt' | 'resource' | 'resource-template' | 'read';
22
+
23
+ export interface McpElementMetaInterface {
24
+ type: McpElementType;
25
+ name: string;
26
+ description?: string;
27
+ propertyKey: string;
28
+ arguments: McpArgumentMetaInterface[];
29
+ uri?: string;
30
+ mimeType?: string;
31
+ title?: string;
32
+ }
33
+
34
+ export interface McpServerMetaInterface {
35
+ name?: string;
36
+ version?: string;
37
+ description?: string;
38
+ path: string;
39
+ instructions?: string;
40
+ tools: McpElementMetaInterface[];
41
+ prompts: McpElementMetaInterface[];
42
+ resources: McpElementMetaInterface[];
43
+ resourceTemplates: McpElementMetaInterface[];
44
+ }
45
+
46
+ export interface McpServerOptionsInterface {
47
+ name?: string;
48
+ version?: string;
49
+ description?: string;
50
+ path?: string;
51
+ instructions?: string;
52
+ }
53
+
54
+ export type McpNodeMethod =
55
+ | 'initialize'
56
+ | 'ping'
57
+ | 'tools/list'
58
+ | 'tools/call'
59
+ | 'prompts/list'
60
+ | 'prompts/get'
61
+ | 'resources/list'
62
+ | 'resources/templates/list'
63
+ | 'resources/read'
64
+ | 'logging/setLevel';
65
+
66
+ export type McpTransportType = 'streamable-http' | 'stdio';
67
+
68
+ export interface McpServerRegistrationInterface {
69
+ path: string;
70
+ name: string;
71
+ version: string;
72
+ description?: string;
73
+ construct: any;
74
+ metadata: McpServerMetaInterface;
75
+ }
76
+
77
+ export interface McpRouteDescriptorInterface {
78
+ path: string;
79
+ propertyKey: string;
80
+ serverName: string;
81
+ }
82
+
83
+ export interface JsonRpcRequest {
84
+ jsonrpc?: string;
85
+ method: string;
86
+ params?: any;
87
+ id?: number | string | null;
88
+ }
89
+
90
+ export interface JsonRpcError {
91
+ code: number;
92
+ message: string;
93
+ data?: any;
94
+ }
95
+
96
+ export interface JsonRpcResponse {
97
+ jsonrpc: string;
98
+ id: number | string | null;
99
+ result?: any;
100
+ error?: JsonRpcError;
101
+ }
102
+
103
+ export type McpArgumentDecorator =
104
+ | string
105
+ | McpArgumentMetaInterface;
106
+
107
+ export interface McpToolResultContent {
108
+ type: 'text' | 'image' | 'resource';
109
+ text?: string;
110
+ data?: string;
111
+ mimeType?: string;
112
+ resource?: any;
113
+ }
114
+
115
+ export interface McpTextContent {
116
+ type: 'text';
117
+ text: string;
118
+ }
@@ -9,4 +9,5 @@ export interface RaitonSignalMapInterface {
9
9
  'hmr:socket': BuilderHMRDeclarationInterface;
10
10
  'hmr:middleware': BuilderHMRDeclarationInterface;
11
11
  'hmr:hook': BuilderHMRDeclarationInterface;
12
+ 'hmr:mcp': BuilderHMRDeclarationInterface;
12
13
  }
@@ -1,4 +1,5 @@
1
1
  import {RuntimeType} from "../framework/enums/runtime.enum";
2
+ import {HttpsCertificateConfig, HttpsEnvironment} from "../framework/utilities/https";
2
3
 
3
4
  export interface RuntimeServerInterface {
4
5
  listen(port: number, hostname?: string): Promise<void>
@@ -8,8 +9,15 @@ export interface RuntimeServerInterface {
8
9
  handle?(request: Request): Promise<Response>
9
10
  }
10
11
 
12
+ export interface RuntimeServerHttpsInterface {
13
+ enabled: boolean
14
+ environment?: HttpsEnvironment
15
+ certificate: HttpsCertificateConfig
16
+ }
17
+
11
18
  export interface RuntimeServerOptionsInterface {
12
19
  prefix?: string;
20
+ https?: RuntimeServerHttpsInterface;
13
21
  }
14
22
 
15
23
  export interface RuntimeRequestInterface {