raiton 6.4.0-beta.12 → 6.6.0-beta.14

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 (55) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/build/bin/index.mjs +20449 -2153
  3. package/docs/contributors/framework/plugins/csrf.md +277 -0
  4. package/docs/contributors/framework/plugins/security.md +40 -6
  5. package/docs/user-guide/README.md +9 -4
  6. package/docs/user-guide/best-practices.md +1 -0
  7. package/docs/user-guide/csrf.md +557 -0
  8. package/docs/user-guide/decorators/README.md +4 -0
  9. package/docs/user-guide/decorators/health-check.md +125 -0
  10. package/docs/user-guide/decorators/mcp.md +70 -0
  11. package/docs/user-guide/health-check.md +117 -0
  12. package/docs/user-guide/mcp.md +120 -0
  13. package/docs/user-guide/plugins.md +1 -0
  14. package/docs/user-guide/security.md +8 -2
  15. package/package.json +1 -1
  16. package/source/core/application.ts +1 -1
  17. package/source/core/builder.ts +12 -0
  18. package/source/core/controller/builder.ts +31 -2
  19. package/source/core/index.ts +1 -0
  20. package/source/core/mcp/builder.ts +76 -0
  21. package/source/core/mcp/index.ts +3 -0
  22. package/source/core/mcp/metadata.ts +80 -0
  23. package/source/core/mcp/tracker.ts +28 -0
  24. package/source/core/thread.ts +5 -1
  25. package/source/framework/artifacts.ts +32 -0
  26. package/source/framework/constants/decorators.constant.ts +6 -0
  27. package/source/framework/decorators/csrf-guard.decorator.ts +60 -0
  28. package/source/framework/decorators/csrf-token.decorator.ts +20 -0
  29. package/source/framework/decorators/health-check.decorator.ts +50 -0
  30. package/source/framework/decorators/index.ts +5 -1
  31. package/source/framework/decorators/mcp.decorator.ts +170 -0
  32. package/source/framework/enums/csrf.enum.ts +4 -0
  33. package/source/framework/enums/index.ts +2 -1
  34. package/source/framework/health-check.ts +137 -0
  35. package/source/framework/index.ts +2 -0
  36. package/source/framework/mcp/handler.ts +369 -0
  37. package/source/framework/mcp/index.ts +3 -0
  38. package/source/framework/mcp/protocol.ts +50 -0
  39. package/source/framework/mcp/streamable-http.ts +94 -0
  40. package/source/framework/plugins/index.ts +2 -1
  41. package/source/framework/plugins/mcp.plugin.ts +87 -0
  42. package/source/framework/plugins/security/csrf.ts +145 -0
  43. package/source/framework/plugins/security/index.ts +2 -0
  44. package/source/framework/utilities/artifact.util.ts +8 -0
  45. package/source/framework/utilities/csrf.util.ts +162 -0
  46. package/source/framework/utilities/index.ts +2 -1
  47. package/source/framework/utilities/openapi.utils.ts +81 -0
  48. package/source/types/application.ts +1 -1
  49. package/source/types/csrf.ts +38 -0
  50. package/source/types/index.ts +3 -1
  51. package/source/types/mcp.ts +118 -0
  52. package/source/types/raiton.ts +1 -0
  53. package/source/types/runtime.ts +1 -1
  54. /package/source/framework/utilities/{https.ts → https.util.ts} +0 -0
  55. /package/source/framework/utilities/{url.ts → url.util.ts} +0 -0
@@ -0,0 +1,145 @@
1
+ import crypto from "node:crypto";
2
+ import {definePlugin} from "../../../core/plugins";
3
+ import {MiddlewareParametersInterface} from "../../../types";
4
+ import {RaitonResponses, HttpStatus} from "../..";
5
+ import {CsrfUtil} from "../../utilities/csrf.util";
6
+ import {CSRFModeEnum} from "../../enums";
7
+ import type {CsrfOptions, CsrfCookieOptions} from "../../../types";
8
+
9
+ const DEFAULT_METHODS = ['POST', 'PUT', 'PATCH', 'DELETE']
10
+ const DEFAULT_COOKIE_NAME = '_csrf'
11
+ const DEFAULT_HEADER_NAME = 'X-CSRF-Token'
12
+ const DEFAULT_TTL = 3600_000
13
+
14
+ export const secureCsrf = (opts: CsrfOptions = {}) => {
15
+
16
+ return definePlugin((scope) => {
17
+ const mode = opts.mode ?? CSRF_MODE_DEFAULT
18
+ const secret = opts.secret ?? cryptoRandomSecret()
19
+ const cookieName = opts.cookieName ?? DEFAULT_COOKIE_NAME
20
+ const headerName = opts.headerName ?? DEFAULT_HEADER_NAME
21
+ const ttl = opts.ttl ?? DEFAULT_TTL
22
+ const methods = (opts.methods ?? DEFAULT_METHODS).map(m => m.toUpperCase())
23
+ const skipPaths = opts.skip ?? []
24
+ const cookieOpts: CsrfCookieOptions = {
25
+ httpOnly: false,
26
+ secure: false,
27
+ sameSite: 'lax',
28
+ path: '/',
29
+ ...opts.cookieOptions,
30
+ }
31
+
32
+ const tokenStore = mode === CSRF_MODE_SYNCHRONIZER
33
+ ? CsrfUtil.createTokenStore(ttl)
34
+ : undefined
35
+
36
+ const destroy = () => {
37
+ tokenStore?.destroy()
38
+ }
39
+
40
+ scope.addHook('onResponse', async (ctx: any) => {
41
+ if (ctx && typeof ctx === 'object' && 'reply' in ctx) {
42
+ const method = (ctx.req?.method ?? '').toUpperCase()
43
+ if (methods.includes(method)) {
44
+ const token = tokenStore
45
+ ? tokenStore.create()
46
+ : CsrfUtil.generateDoubleSubmitToken(secret)
47
+
48
+ ctx.state = ctx.state ?? {}
49
+ ctx.state.csrfToken = token
50
+
51
+ ctx.reply.header(
52
+ 'Set-Cookie',
53
+ CsrfUtil.serializeCookie(cookieName, token, cookieOpts)
54
+ )
55
+ }
56
+ }
57
+ })
58
+
59
+ scope.use(async ({context, next}: MiddlewareParametersInterface) => {
60
+ const method = (context.req.method ?? '').toUpperCase()
61
+
62
+ if (method === 'GET' || method === 'HEAD' || method === 'OPTIONS') {
63
+ const token = tokenStore
64
+ ? tokenStore.create()
65
+ : CsrfUtil.generateDoubleSubmitToken(secret)
66
+
67
+ context.state = context.state ?? {}
68
+ context.state.csrfToken = token
69
+
70
+ context.reply.header(
71
+ 'Set-Cookie',
72
+ CsrfUtil.serializeCookie(cookieName, token, cookieOpts)
73
+ )
74
+
75
+ return next()
76
+ }
77
+
78
+ if (!methods.includes(method)) {
79
+ return next()
80
+ }
81
+
82
+ const requestPath = new URL(context.req.url, 'http://localhost').pathname
83
+ if (skipPaths.some(p => requestPath.startsWith(p))) {
84
+ return next()
85
+ }
86
+
87
+ const isBrowser = CsrfUtil.isBrowserClient(context.req.headers, opts.client)
88
+ if (!isBrowser) {
89
+ return next()
90
+ }
91
+
92
+ const cookieHeader = context.req.headers.get('cookie') ?? ''
93
+ const cookieToken = CsrfUtil.extractCookieValue(cookieHeader, cookieName)
94
+ const headerToken = context.req.headers.get(headerName.toLowerCase())
95
+
96
+ if (!cookieToken || !headerToken) {
97
+ context.reply.status(HttpStatus.FORBIDDEN)
98
+ return context.reply.send(
99
+ RaitonResponses(
100
+ 'CSRF token missing',
101
+ null,
102
+ HttpStatus.FORBIDDEN,
103
+ {error: true}
104
+ )
105
+ )
106
+ }
107
+
108
+ let valid = false
109
+
110
+ if (mode === CSRF_MODE_DOUBLE_SUBMIT) {
111
+ valid = CsrfUtil.validateDoubleSubmitToken(secret, cookieToken, ttl)
112
+ && CsrfUtil.timingSafeEqual(cookieToken, headerToken)
113
+ } else {
114
+ const storeValid = tokenStore?.validate(cookieToken) ?? false
115
+ valid = storeValid && CsrfUtil.timingSafeEqual(cookieToken, headerToken)
116
+ }
117
+
118
+ if (!valid) {
119
+ context.reply.status(HttpStatus.FORBIDDEN)
120
+ return context.reply.send(
121
+ RaitonResponses(
122
+ 'CSRF token invalid',
123
+ null,
124
+ HttpStatus.FORBIDDEN,
125
+ {error: true}
126
+ )
127
+ )
128
+ }
129
+
130
+ context.state = context.state ?? {}
131
+ context.state.csrfValidated = true
132
+
133
+ await next()
134
+ })
135
+
136
+ }, 'csrf')
137
+ }
138
+
139
+ function cryptoRandomSecret(): string {
140
+ return crypto.randomBytes(32).toString('hex')
141
+ }
142
+
143
+ const CSRF_MODE_DEFAULT = CSRFModeEnum.DOUBLE_SUBMIT
144
+ const CSRF_MODE_SYNCHRONIZER = CSRFModeEnum.SYNCHRONIZER
145
+ const CSRF_MODE_DOUBLE_SUBMIT = CSRFModeEnum.DOUBLE_SUBMIT
@@ -3,6 +3,7 @@ import {secureCors} from './cors'
3
3
  import {secureRateLimit} from './rate-limit'
4
4
  import {secureBodyLimit} from './body-limit'
5
5
  import {secureMethodGuard} from './method-guard'
6
+ import {secureCsrf} from './csrf'
6
7
 
7
8
  export class Security {
8
9
  static headers = secureHeaders
@@ -10,4 +11,5 @@ export class Security {
10
11
  static rateLimit = secureRateLimit
11
12
  static bodyLimit = secureBodyLimit
12
13
  static methodGuard = secureMethodGuard
14
+ static csrf = secureCsrf
13
15
  }
@@ -10,6 +10,14 @@ export function isServiceArtifact(filename: string) {
10
10
  return isArtifact(filename, 'service')
11
11
  }
12
12
 
13
+ export function isMcpArtifact(filename: string) {
14
+ return isArtifact(filename, 'mcp')
15
+ }
16
+
17
+ export function isHealthCheckArtifact(filename: string) {
18
+ return isArtifact(filename, 'health-check')
19
+ }
20
+
13
21
  export function isArtifact(filename: string, artifact: string) {
14
22
  return [
15
23
  filename.endsWith(`.${artifact}.ts`),
@@ -0,0 +1,162 @@
1
+ import crypto from "node:crypto";
2
+ import {CsrfTokenPayload} from "../../types";
3
+
4
+ const DEFAULT_TTL = 3600_000
5
+
6
+ export class CsrfUtil {
7
+
8
+ static generateDoubleSubmitToken(secret: string): string {
9
+ const timestamp = Date.now().toString(36)
10
+ const nonce = crypto.randomBytes(16).toString('hex')
11
+ const payload = `${timestamp}.${nonce}`
12
+ const signature = crypto
13
+ .createHmac('sha256', secret)
14
+ .update(payload)
15
+ .digest('hex')
16
+ return `${payload}.${signature}`
17
+ }
18
+
19
+ static validateDoubleSubmitToken(secret: string, token: string, maxAge?: number): boolean {
20
+ if (!token || typeof token !== 'string') return false
21
+
22
+ const parts = token.split('.')
23
+ if (parts.length !== 3) return false
24
+
25
+ const [timestampB36, nonce, signature] = parts
26
+ const payload = `${timestampB36}.${nonce}`
27
+
28
+ const expectedSignature = crypto
29
+ .createHmac('sha256', secret)
30
+ .update(payload)
31
+ .digest('hex')
32
+
33
+ if (!crypto.timingSafeEqual(Buffer.from(signature), Buffer.from(expectedSignature))) {
34
+ return false
35
+ }
36
+
37
+ if (maxAge !== undefined) {
38
+ const timestamp = parseInt(timestampB36, 36)
39
+ if (isNaN(timestamp)) return false
40
+ if (Date.now() - timestamp > maxAge) return false
41
+ }
42
+
43
+ return true
44
+ }
45
+
46
+ static generateSynchronizerToken(): string {
47
+ return crypto.randomBytes(32).toString('hex')
48
+ }
49
+
50
+ static createTokenStore(ttl: number = DEFAULT_TTL) {
51
+ const store = new Map<string, CsrfTokenPayload>()
52
+
53
+ const cleanup = () => {
54
+ const now = Date.now()
55
+ for (const [key, entry] of store) {
56
+ if (now > entry.expiresAt) {
57
+ store.delete(key)
58
+ }
59
+ }
60
+ }
61
+
62
+ const interval = setInterval(cleanup, Math.min(ttl, 60_000))
63
+ if (typeof interval === 'object' && 'unref' in interval) {
64
+ interval.unref()
65
+ }
66
+
67
+ return {
68
+ create(): string {
69
+ const token = CsrfUtil.generateSynchronizerToken()
70
+ store.set(token, {
71
+ token,
72
+ expiresAt: Date.now() + ttl
73
+ })
74
+ return token
75
+ },
76
+
77
+ validate(token: string): boolean {
78
+ if (!token || typeof token !== 'string') return false
79
+ const entry = store.get(token)
80
+ if (!entry) return false
81
+ if (Date.now() > entry.expiresAt) {
82
+ store.delete(token)
83
+ return false
84
+ }
85
+ return true
86
+ },
87
+
88
+ revoke(token: string): boolean {
89
+ return store.delete(token)
90
+ },
91
+
92
+ get size(): number {
93
+ return store.size
94
+ },
95
+
96
+ destroy(): void {
97
+ clearInterval(interval)
98
+ store.clear()
99
+ }
100
+ }
101
+ }
102
+
103
+ static isBrowserClient(headers: Headers, config?: {
104
+ headerName?: string
105
+ skipClients?: string[]
106
+ }): boolean {
107
+ const clientTypeHeader = config?.headerName ?? 'X-Client-Type'
108
+ const skipClients = config?.skipClients ?? ['mobile', 'desktop']
109
+
110
+ const clientType = headers.get(clientTypeHeader)
111
+ if (clientType && skipClients.includes(clientType.toLowerCase())) {
112
+ return false
113
+ }
114
+
115
+ const authorization = headers.get('authorization')
116
+ const hasCookie = headers.get('cookie')?.includes('_csrf') ?? false
117
+
118
+ if (authorization && !hasCookie) {
119
+ return false
120
+ }
121
+
122
+ return true
123
+ }
124
+
125
+ static serializeCookie(name: string, value: string, options?: {
126
+ httpOnly?: boolean
127
+ secure?: boolean
128
+ sameSite?: 'strict' | 'lax' | 'none'
129
+ path?: string
130
+ domain?: string
131
+ maxAge?: number
132
+ }): string {
133
+ let cookie = `${name}=${value}`
134
+
135
+ if (options?.httpOnly) cookie += '; HttpOnly'
136
+ if (options?.secure) cookie += '; Secure'
137
+ if (options?.sameSite) {
138
+ cookie += `; SameSite=${options.sameSite.charAt(0).toUpperCase() + options.sameSite.slice(1)}`
139
+ }
140
+ if (options?.path) cookie += `; Path=${options.path}`
141
+ if (options?.domain) cookie += `; Domain=${options.domain}`
142
+ if (options?.maxAge) cookie += `; Max-Age=${options.maxAge}`
143
+
144
+ return cookie
145
+ }
146
+
147
+ static extractCookieValue(cookieHeader: string, name: string): string | undefined {
148
+ const cookies = cookieHeader.split(';')
149
+ for (const cookie of cookies) {
150
+ const [key, ...valueParts] = cookie.trim().split('=')
151
+ if (key === name) {
152
+ return valueParts.join('=')
153
+ }
154
+ }
155
+ return undefined
156
+ }
157
+
158
+ static timingSafeEqual(a: string, b: string): boolean {
159
+ if (a.length !== b.length) return false
160
+ return crypto.timingSafeEqual(Buffer.from(a), Buffer.from(b))
161
+ }
162
+ }
@@ -6,4 +6,5 @@ export * from "./path.util"
6
6
  export * from "./cookie.util"
7
7
  export * from "./openapi.utils"
8
8
  export * from "./ip.util"
9
- export * from "./https"
9
+ export * from "./https.util"
10
+ export * from "./csrf.util"
@@ -3,6 +3,7 @@ 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
  /**
@@ -413,6 +414,86 @@ export async function generateOpenApiSpec(scope: PluginScope, opts: any): Promis
413
414
  }
414
415
  }
415
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
+
416
497
  return spec;
417
498
  }
418
499
 
@@ -1,5 +1,5 @@
1
1
  import {HttpMethod} from "../framework";
2
- import {HttpsConfigInput, HttpsConfigInterface} from "../framework/utilities/https";
2
+ import {HttpsConfigInput, HttpsConfigInterface} from "../framework/utilities/https.util";
3
3
 
4
4
  export interface ApplicationConfigInterface {
5
5
  workdir?: string;
@@ -0,0 +1,38 @@
1
+ import {CSRFModeEnum} from "../framework/enums";
2
+
3
+ export interface CsrfClientDetectionConfig {
4
+ headerName?: string
5
+ skipClients?: string[]
6
+ }
7
+
8
+ export interface CsrfOptions {
9
+ mode?: CSRFModeEnum
10
+ secret?: string
11
+ cookieName?: string
12
+ headerName?: string
13
+ ttl?: number
14
+ methods?: string[]
15
+ skip?: string[]
16
+ client?: CsrfClientDetectionConfig
17
+ cookieOptions?: CsrfCookieOptions
18
+ }
19
+
20
+ export interface CsrfCookieOptions {
21
+ httpOnly?: boolean
22
+ secure?: boolean
23
+ sameSite?: 'strict' | 'lax' | 'none'
24
+ path?: string
25
+ domain?: string
26
+ maxAge?: number
27
+ }
28
+
29
+ export interface CsrfTokenPayload {
30
+ token: string
31
+ expiresAt: number
32
+ }
33
+
34
+ export interface CsrfGuardOptions {
35
+ mode?: CSRFModeEnum
36
+ methods?: string[]
37
+ skipPaths?: string[]
38
+ }
@@ -21,4 +21,6 @@ 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"
26
+ export type * from "./csrf"
@@ -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,5 +1,5 @@
1
1
  import {RuntimeType} from "../framework/enums/runtime.enum";
2
- import {HttpsCertificateConfig, HttpsEnvironment} from "../framework/utilities/https";
2
+ import {HttpsCertificateConfig, HttpsEnvironment} from "../framework/utilities/https.util";
3
3
 
4
4
  export interface RuntimeServerInterface {
5
5
  listen(port: number, hostname?: string): Promise<void>