@frontmcp/sdk 0.3.1 → 0.4.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.
Files changed (148) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +192 -164
  3. package/package.json +7 -4
  4. package/src/__test-utils__/fixtures/hook.fixtures.d.ts +46 -0
  5. package/src/__test-utils__/fixtures/hook.fixtures.js +114 -0
  6. package/src/__test-utils__/fixtures/hook.fixtures.js.map +1 -0
  7. package/src/__test-utils__/fixtures/index.d.ts +7 -0
  8. package/src/__test-utils__/fixtures/index.js +11 -0
  9. package/src/__test-utils__/fixtures/index.js.map +1 -0
  10. package/src/__test-utils__/fixtures/plugin.fixtures.d.ts +46 -0
  11. package/src/__test-utils__/fixtures/plugin.fixtures.js +127 -0
  12. package/src/__test-utils__/fixtures/plugin.fixtures.js.map +1 -0
  13. package/src/__test-utils__/fixtures/provider.fixtures.d.ts +69 -0
  14. package/src/__test-utils__/fixtures/provider.fixtures.js +131 -0
  15. package/src/__test-utils__/fixtures/provider.fixtures.js.map +1 -0
  16. package/src/__test-utils__/fixtures/scope.fixtures.d.ts +14 -0
  17. package/src/__test-utils__/fixtures/scope.fixtures.js +59 -0
  18. package/src/__test-utils__/fixtures/scope.fixtures.js.map +1 -0
  19. package/src/__test-utils__/fixtures/tool.fixtures.d.ts +36 -0
  20. package/src/__test-utils__/fixtures/tool.fixtures.js +91 -0
  21. package/src/__test-utils__/fixtures/tool.fixtures.js.map +1 -0
  22. package/src/__test-utils__/helpers/assertion.helpers.d.ts +45 -0
  23. package/src/__test-utils__/helpers/assertion.helpers.js +153 -0
  24. package/src/__test-utils__/helpers/assertion.helpers.js.map +1 -0
  25. package/src/__test-utils__/helpers/async.helpers.d.ts +48 -0
  26. package/src/__test-utils__/helpers/async.helpers.js +112 -0
  27. package/src/__test-utils__/helpers/async.helpers.js.map +1 -0
  28. package/src/__test-utils__/helpers/index.d.ts +6 -0
  29. package/src/__test-utils__/helpers/index.js +10 -0
  30. package/src/__test-utils__/helpers/index.js.map +1 -0
  31. package/src/__test-utils__/helpers/setup.helpers.d.ts +54 -0
  32. package/src/__test-utils__/helpers/setup.helpers.js +106 -0
  33. package/src/__test-utils__/helpers/setup.helpers.js.map +1 -0
  34. package/src/__test-utils__/index.d.ts +9 -0
  35. package/src/__test-utils__/index.js +14 -0
  36. package/src/__test-utils__/index.js.map +1 -0
  37. package/src/__test-utils__/mocks/flow-instance.mock.d.ts +50 -0
  38. package/src/__test-utils__/mocks/flow-instance.mock.js +72 -0
  39. package/src/__test-utils__/mocks/flow-instance.mock.js.map +1 -0
  40. package/src/__test-utils__/mocks/hook-registry.mock.d.ts +25 -0
  41. package/src/__test-utils__/mocks/hook-registry.mock.js +65 -0
  42. package/src/__test-utils__/mocks/hook-registry.mock.js.map +1 -0
  43. package/src/__test-utils__/mocks/index.d.ts +8 -0
  44. package/src/__test-utils__/mocks/index.js +12 -0
  45. package/src/__test-utils__/mocks/index.js.map +1 -0
  46. package/src/__test-utils__/mocks/plugin-registry.mock.d.ts +43 -0
  47. package/src/__test-utils__/mocks/plugin-registry.mock.js +70 -0
  48. package/src/__test-utils__/mocks/plugin-registry.mock.js.map +1 -0
  49. package/src/__test-utils__/mocks/provider-registry.mock.d.ts +39 -0
  50. package/src/__test-utils__/mocks/provider-registry.mock.js +72 -0
  51. package/src/__test-utils__/mocks/provider-registry.mock.js.map +1 -0
  52. package/src/__test-utils__/mocks/tool-registry.mock.d.ts +43 -0
  53. package/src/__test-utils__/mocks/tool-registry.mock.js +79 -0
  54. package/src/__test-utils__/mocks/tool-registry.mock.js.map +1 -0
  55. package/src/app/app.utils.js.map +1 -1
  56. package/src/app/instances/app.local.instance.js +8 -11
  57. package/src/app/instances/app.local.instance.js.map +1 -1
  58. package/src/auth/flows/oauth.authorize.flow.d.ts +8 -8
  59. package/src/auth/flows/oauth.register.flow.d.ts +4 -4
  60. package/src/auth/flows/oauth.token.flow.d.ts +4 -4
  61. package/src/auth/flows/well-known.jwks.flow.d.ts +12 -12
  62. package/src/auth/flows/well-known.oauth-authorization-server.flow.d.ts +8 -8
  63. package/src/auth/flows/well-known.prm.flow.d.ts +4 -4
  64. package/src/common/decorators/tool.decorator.d.ts +97 -36
  65. package/src/common/decorators/tool.decorator.js +0 -1
  66. package/src/common/decorators/tool.decorator.js.map +1 -1
  67. package/src/common/entries/tool.entry.d.ts +54 -11
  68. package/src/common/entries/tool.entry.js +19 -0
  69. package/src/common/entries/tool.entry.js.map +1 -1
  70. package/src/common/interfaces/internal/registry.interface.d.ts +10 -2
  71. package/src/common/interfaces/internal/registry.interface.js.map +1 -1
  72. package/src/common/interfaces/plugin.interface.d.ts +1 -1
  73. package/src/common/interfaces/plugin.interface.js.map +1 -1
  74. package/src/common/interfaces/tool.interface.d.ts +12 -7
  75. package/src/common/interfaces/tool.interface.js +1 -1
  76. package/src/common/interfaces/tool.interface.js.map +1 -1
  77. package/src/common/metadata/front-mcp.metadata.d.ts +145 -145
  78. package/src/common/metadata/hook.metadata.d.ts +4 -2
  79. package/src/common/metadata/hook.metadata.js.map +1 -1
  80. package/src/common/metadata/prompt.metadata.d.ts +28 -28
  81. package/src/common/metadata/prompt.metadata.js.map +1 -1
  82. package/src/common/metadata/resource.metadata.d.ts +54 -54
  83. package/src/common/metadata/tool.metadata.d.ts +190 -7
  84. package/src/common/metadata/tool.metadata.js +41 -6
  85. package/src/common/metadata/tool.metadata.js.map +1 -1
  86. package/src/common/schemas/http-output.schema.d.ts +106 -106
  87. package/src/common/tokens/tool.tokens.js.map +1 -1
  88. package/src/common/types/options/logging.options.d.ts +1 -2
  89. package/src/common/types/options/logging.options.js +1 -9
  90. package/src/common/types/options/logging.options.js.map +1 -1
  91. package/src/common/types/options/server-info.options.d.ts +19 -19
  92. package/src/errors/error-handler.d.ts +65 -0
  93. package/src/errors/error-handler.js +107 -0
  94. package/src/errors/error-handler.js.map +1 -0
  95. package/src/errors/index.d.ts +2 -0
  96. package/src/errors/index.js +26 -0
  97. package/src/errors/index.js.map +1 -0
  98. package/src/errors/mcp.error.d.ts +156 -0
  99. package/src/errors/mcp.error.js +243 -0
  100. package/src/errors/mcp.error.js.map +1 -0
  101. package/src/flows/flow.instance.js +7 -6
  102. package/src/flows/flow.instance.js.map +1 -1
  103. package/src/flows/flow.registry.js +1 -1
  104. package/src/flows/flow.registry.js.map +1 -1
  105. package/src/front-mcp/front-mcp.providers.d.ts +20 -20
  106. package/src/hooks/hook.registry.d.ts +5 -3
  107. package/src/hooks/hook.registry.js +13 -1
  108. package/src/hooks/hook.registry.js.map +1 -1
  109. package/src/plugin/plugin.registry.d.ts +7 -2
  110. package/src/plugin/plugin.registry.js +23 -11
  111. package/src/plugin/plugin.registry.js.map +1 -1
  112. package/src/prompt/prompt.registry.js +1 -0
  113. package/src/prompt/prompt.registry.js.map +1 -1
  114. package/src/resource/resource.registry.js +1 -0
  115. package/src/resource/resource.registry.js.map +1 -1
  116. package/src/scope/scope.registry.js +1 -1
  117. package/src/scope/scope.registry.js.map +1 -1
  118. package/src/store/adapters/store.memory.adapter.js +3 -1
  119. package/src/store/adapters/store.memory.adapter.js.map +1 -1
  120. package/src/tool/flows/call-tool.flow.d.ts +1012 -676
  121. package/src/tool/flows/call-tool.flow.js +94 -61
  122. package/src/tool/flows/call-tool.flow.js.map +1 -1
  123. package/src/tool/flows/tools-list.flow.d.ts +347 -590
  124. package/src/tool/flows/tools-list.flow.js +76 -49
  125. package/src/tool/flows/tools-list.flow.js.map +1 -1
  126. package/src/tool/tool.instance.d.ts +27 -8
  127. package/src/tool/tool.instance.js +40 -5
  128. package/src/tool/tool.instance.js.map +1 -1
  129. package/src/tool/tool.registry.js +19 -21
  130. package/src/tool/tool.registry.js.map +1 -1
  131. package/src/tool/tool.utils.d.ts +3 -2
  132. package/src/tool/tool.utils.js +377 -14
  133. package/src/tool/tool.utils.js.map +1 -1
  134. package/src/transport/adapters/transport.sse.adapter.js.map +1 -1
  135. package/src/transport/adapters/transport.streamable-http.adapter.js.map +1 -1
  136. package/src/transport/flows/handle.sse.flow.js +6 -13
  137. package/src/transport/flows/handle.sse.flow.js.map +1 -1
  138. package/src/transport/flows/handle.streamable-http.flow.js +1 -0
  139. package/src/transport/flows/handle.streamable-http.flow.js.map +1 -1
  140. package/src/transport/mcp-handlers/call-tool-request.handler.d.ts +1 -1
  141. package/src/transport/mcp-handlers/call-tool-request.handler.js +10 -5
  142. package/src/transport/mcp-handlers/call-tool-request.handler.js.map +1 -1
  143. package/src/transport/mcp-handlers/index.d.ts +151 -268
  144. package/src/transport/mcp-handlers/list-tools-request.handler.d.ts +124 -216
  145. package/src/transport/transport.local.js +1 -0
  146. package/src/transport/transport.local.js.map +1 -1
  147. package/src/utils/string.utils.js +1 -1
  148. package/src/utils/string.utils.js.map +1 -1
@@ -56,15 +56,15 @@ export declare const frontMcpResourceMetadataSchema: z.ZodObject<{
56
56
  src: z.ZodString;
57
57
  mimeType: z.ZodOptional<z.ZodString>;
58
58
  sizes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
59
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
60
- src: z.ZodString;
61
- mimeType: z.ZodOptional<z.ZodString>;
62
- sizes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
63
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
64
- src: z.ZodString;
65
- mimeType: z.ZodOptional<z.ZodString>;
66
- sizes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
67
- }, z.ZodTypeAny, "passthrough">>, "many">>;
59
+ }, "strip", z.ZodTypeAny, {
60
+ src: string;
61
+ mimeType?: string | undefined;
62
+ sizes?: string[] | undefined;
63
+ }, {
64
+ src: string;
65
+ mimeType?: string | undefined;
66
+ sizes?: string[] | undefined;
67
+ }>, "many">>;
68
68
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
69
69
  name: z.ZodString;
70
70
  title: z.ZodOptional<z.ZodString>;
@@ -75,15 +75,15 @@ export declare const frontMcpResourceMetadataSchema: z.ZodObject<{
75
75
  src: z.ZodString;
76
76
  mimeType: z.ZodOptional<z.ZodString>;
77
77
  sizes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
78
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
79
- src: z.ZodString;
80
- mimeType: z.ZodOptional<z.ZodString>;
81
- sizes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
82
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
83
- src: z.ZodString;
84
- mimeType: z.ZodOptional<z.ZodString>;
85
- sizes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
86
- }, z.ZodTypeAny, "passthrough">>, "many">>;
78
+ }, "strip", z.ZodTypeAny, {
79
+ src: string;
80
+ mimeType?: string | undefined;
81
+ sizes?: string[] | undefined;
82
+ }, {
83
+ src: string;
84
+ mimeType?: string | undefined;
85
+ sizes?: string[] | undefined;
86
+ }>, "many">>;
87
87
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
88
88
  name: z.ZodString;
89
89
  title: z.ZodOptional<z.ZodString>;
@@ -94,15 +94,15 @@ export declare const frontMcpResourceMetadataSchema: z.ZodObject<{
94
94
  src: z.ZodString;
95
95
  mimeType: z.ZodOptional<z.ZodString>;
96
96
  sizes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
97
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
98
- src: z.ZodString;
99
- mimeType: z.ZodOptional<z.ZodString>;
100
- sizes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
101
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
102
- src: z.ZodString;
103
- mimeType: z.ZodOptional<z.ZodString>;
104
- sizes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
105
- }, z.ZodTypeAny, "passthrough">>, "many">>;
97
+ }, "strip", z.ZodTypeAny, {
98
+ src: string;
99
+ mimeType?: string | undefined;
100
+ sizes?: string[] | undefined;
101
+ }, {
102
+ src: string;
103
+ mimeType?: string | undefined;
104
+ sizes?: string[] | undefined;
105
+ }>, "many">>;
106
106
  }, z.ZodTypeAny, "passthrough">>;
107
107
  /**
108
108
  * A template description for resources available on the server.
@@ -148,15 +148,15 @@ export declare const frontMcpResourceTemplateMetadataSchema: z.ZodObject<{
148
148
  src: z.ZodString;
149
149
  mimeType: z.ZodOptional<z.ZodString>;
150
150
  sizes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
151
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
152
- src: z.ZodString;
153
- mimeType: z.ZodOptional<z.ZodString>;
154
- sizes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
155
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
156
- src: z.ZodString;
157
- mimeType: z.ZodOptional<z.ZodString>;
158
- sizes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
159
- }, z.ZodTypeAny, "passthrough">>, "many">>;
151
+ }, "strip", z.ZodTypeAny, {
152
+ src: string;
153
+ mimeType?: string | undefined;
154
+ sizes?: string[] | undefined;
155
+ }, {
156
+ src: string;
157
+ mimeType?: string | undefined;
158
+ sizes?: string[] | undefined;
159
+ }>, "many">>;
160
160
  }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
161
161
  name: z.ZodString;
162
162
  title: z.ZodOptional<z.ZodString>;
@@ -167,15 +167,15 @@ export declare const frontMcpResourceTemplateMetadataSchema: z.ZodObject<{
167
167
  src: z.ZodString;
168
168
  mimeType: z.ZodOptional<z.ZodString>;
169
169
  sizes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
170
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
171
- src: z.ZodString;
172
- mimeType: z.ZodOptional<z.ZodString>;
173
- sizes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
174
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
175
- src: z.ZodString;
176
- mimeType: z.ZodOptional<z.ZodString>;
177
- sizes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
178
- }, z.ZodTypeAny, "passthrough">>, "many">>;
170
+ }, "strip", z.ZodTypeAny, {
171
+ src: string;
172
+ mimeType?: string | undefined;
173
+ sizes?: string[] | undefined;
174
+ }, {
175
+ src: string;
176
+ mimeType?: string | undefined;
177
+ sizes?: string[] | undefined;
178
+ }>, "many">>;
179
179
  }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
180
180
  name: z.ZodString;
181
181
  title: z.ZodOptional<z.ZodString>;
@@ -186,14 +186,14 @@ export declare const frontMcpResourceTemplateMetadataSchema: z.ZodObject<{
186
186
  src: z.ZodString;
187
187
  mimeType: z.ZodOptional<z.ZodString>;
188
188
  sizes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
189
- }, "passthrough", z.ZodTypeAny, z.objectOutputType<{
190
- src: z.ZodString;
191
- mimeType: z.ZodOptional<z.ZodString>;
192
- sizes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
193
- }, z.ZodTypeAny, "passthrough">, z.objectInputType<{
194
- src: z.ZodString;
195
- mimeType: z.ZodOptional<z.ZodString>;
196
- sizes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
197
- }, z.ZodTypeAny, "passthrough">>, "many">>;
189
+ }, "strip", z.ZodTypeAny, {
190
+ src: string;
191
+ mimeType?: string | undefined;
192
+ sizes?: string[] | undefined;
193
+ }, {
194
+ src: string;
195
+ mimeType?: string | undefined;
196
+ sizes?: string[] | undefined;
197
+ }>, "many">>;
198
198
  }, z.ZodTypeAny, "passthrough">>;
199
199
  export { ResourceMetadata, ResourceMetadata as FrontMcpResourceMetadata, ResourceTemplateMetadata, ResourceTemplateMetadata as FrontMcpResourceTemplateMetadata, };
@@ -1,4 +1,4 @@
1
- import { z } from 'zod';
1
+ import { z, ZodObject } from 'zod';
2
2
  import type { JSONSchema7 } from 'json-schema';
3
3
  declare global {
4
4
  /**
@@ -47,10 +47,192 @@ export interface ToolAnnotations {
47
47
  */
48
48
  openWorldHint?: boolean;
49
49
  }
50
+ /**
51
+ * Tool response type text: include if outputSchema is zod primitive types
52
+ */
53
+ type PrimitiveOutputType = 'string' | 'number' | 'date' | 'boolean' | z.ZodString | z.ZodNumber | z.ZodBoolean | z.ZodBigInt | z.ZodDate;
54
+ /**
55
+ * Tool response type image, will use the ImageContentSchema from MCP types
56
+ */
57
+ type ImageOutputType = 'image';
58
+ export declare const ImageOutputSchema: z.ZodObject<{
59
+ type: z.ZodLiteral<"image">;
60
+ data: z.ZodEffects<z.ZodString, string, string>;
61
+ mimeType: z.ZodString;
62
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
63
+ }, "strip", z.ZodTypeAny, {
64
+ type: "image";
65
+ data: string;
66
+ mimeType: string;
67
+ _meta?: Record<string, unknown> | undefined;
68
+ }, {
69
+ type: "image";
70
+ data: string;
71
+ mimeType: string;
72
+ _meta?: Record<string, unknown> | undefined;
73
+ }>;
74
+ export type ImageOutput = z.output<typeof ImageOutputSchema>;
75
+ /**
76
+ * Tool response type audio, will use the AudioContentSchema from MCP types
77
+ */
78
+ type AudioOutputType = 'audio';
79
+ export declare const AudioOutputSchema: z.ZodObject<{
80
+ type: z.ZodLiteral<"audio">;
81
+ data: z.ZodEffects<z.ZodString, string, string>;
82
+ mimeType: z.ZodString;
83
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
84
+ }, "strip", z.ZodTypeAny, {
85
+ type: "audio";
86
+ data: string;
87
+ mimeType: string;
88
+ _meta?: Record<string, unknown> | undefined;
89
+ }, {
90
+ type: "audio";
91
+ data: string;
92
+ mimeType: string;
93
+ _meta?: Record<string, unknown> | undefined;
94
+ }>;
95
+ export type AudioOutput = z.output<typeof AudioOutputSchema>;
96
+ /**
97
+ * Tool response type resource, will use the EmbeddedResourceSchema from MCP types
98
+ */
99
+ type ResourceOutputType = 'resource';
100
+ export declare const ResourceOutputSchema: z.ZodObject<{
101
+ type: z.ZodLiteral<"resource">;
102
+ resource: z.ZodUnion<[z.ZodObject<z.objectUtil.extendShape<{
103
+ uri: z.ZodString;
104
+ mimeType: z.ZodOptional<z.ZodString>;
105
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
106
+ }, {
107
+ text: z.ZodString;
108
+ }>, "strip", z.ZodTypeAny, {
109
+ uri: string;
110
+ text: string;
111
+ _meta?: Record<string, unknown> | undefined;
112
+ mimeType?: string | undefined;
113
+ }, {
114
+ uri: string;
115
+ text: string;
116
+ _meta?: Record<string, unknown> | undefined;
117
+ mimeType?: string | undefined;
118
+ }>, z.ZodObject<z.objectUtil.extendShape<{
119
+ uri: z.ZodString;
120
+ mimeType: z.ZodOptional<z.ZodString>;
121
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
122
+ }, {
123
+ blob: z.ZodEffects<z.ZodString, string, string>;
124
+ }>, "strip", z.ZodTypeAny, {
125
+ uri: string;
126
+ blob: string;
127
+ _meta?: Record<string, unknown> | undefined;
128
+ mimeType?: string | undefined;
129
+ }, {
130
+ uri: string;
131
+ blob: string;
132
+ _meta?: Record<string, unknown> | undefined;
133
+ mimeType?: string | undefined;
134
+ }>]>;
135
+ _meta: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
136
+ }, "strip", z.ZodTypeAny, {
137
+ type: "resource";
138
+ resource: {
139
+ uri: string;
140
+ text: string;
141
+ _meta?: Record<string, unknown> | undefined;
142
+ mimeType?: string | undefined;
143
+ } | {
144
+ uri: string;
145
+ blob: string;
146
+ _meta?: Record<string, unknown> | undefined;
147
+ mimeType?: string | undefined;
148
+ };
149
+ _meta?: Record<string, unknown> | undefined;
150
+ }, {
151
+ type: "resource";
152
+ resource: {
153
+ uri: string;
154
+ text: string;
155
+ _meta?: Record<string, unknown> | undefined;
156
+ mimeType?: string | undefined;
157
+ } | {
158
+ uri: string;
159
+ blob: string;
160
+ _meta?: Record<string, unknown> | undefined;
161
+ mimeType?: string | undefined;
162
+ };
163
+ _meta?: Record<string, unknown> | undefined;
164
+ }>;
165
+ export type ResourceOutput = z.output<typeof ResourceOutputSchema>;
166
+ /**
167
+ * Tool response type resource_link, will use the ResourceLinkSchema from MCP types
168
+ */
169
+ type ResourceLinkOutputType = 'resource_link';
170
+ export declare const ResourceLinkOutputSchema: z.ZodObject<{
171
+ name: z.ZodString;
172
+ title: z.ZodOptional<z.ZodString>;
173
+ } & {
174
+ uri: z.ZodString;
175
+ description: z.ZodOptional<z.ZodString>;
176
+ mimeType: z.ZodOptional<z.ZodString>;
177
+ _meta: z.ZodOptional<z.ZodObject<{}, "passthrough", z.ZodTypeAny, z.objectOutputType<{}, z.ZodTypeAny, "passthrough">, z.objectInputType<{}, z.ZodTypeAny, "passthrough">>>;
178
+ } & {
179
+ icons: z.ZodOptional<z.ZodArray<z.ZodObject<{
180
+ src: z.ZodString;
181
+ mimeType: z.ZodOptional<z.ZodString>;
182
+ sizes: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
183
+ }, "strip", z.ZodTypeAny, {
184
+ src: string;
185
+ mimeType?: string | undefined;
186
+ sizes?: string[] | undefined;
187
+ }, {
188
+ src: string;
189
+ mimeType?: string | undefined;
190
+ sizes?: string[] | undefined;
191
+ }>, "many">>;
192
+ } & {
193
+ type: z.ZodLiteral<"resource_link">;
194
+ }, "strip", z.ZodTypeAny, {
195
+ type: "resource_link";
196
+ name: string;
197
+ uri: string;
198
+ _meta?: z.objectOutputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
199
+ mimeType?: string | undefined;
200
+ icons?: {
201
+ src: string;
202
+ mimeType?: string | undefined;
203
+ sizes?: string[] | undefined;
204
+ }[] | undefined;
205
+ title?: string | undefined;
206
+ description?: string | undefined;
207
+ }, {
208
+ type: "resource_link";
209
+ name: string;
210
+ uri: string;
211
+ _meta?: z.objectInputType<{}, z.ZodTypeAny, "passthrough"> | undefined;
212
+ mimeType?: string | undefined;
213
+ icons?: {
214
+ src: string;
215
+ mimeType?: string | undefined;
216
+ sizes?: string[] | undefined;
217
+ }[] | undefined;
218
+ title?: string | undefined;
219
+ description?: string | undefined;
220
+ }>;
221
+ export type ResourceLinkOutput = z.output<typeof ResourceLinkOutputSchema>;
222
+ /**
223
+ * Tool response type json, ZodRawShape for fast usage
224
+ */
225
+ type StructuredOutputType = z.ZodRawShape | z.ZodObject<any> | z.ZodArray<any> | z.ZodUnion<[ZodObject<any>, ...ZodObject<any>[]]> | z.ZodDiscriminatedUnion<any, any>;
226
+ export type ToolSingleOutputType = PrimitiveOutputType | ImageOutputType | AudioOutputType | ResourceOutputType | ResourceLinkOutputType | StructuredOutputType;
227
+ /**
228
+ * Default default tool schema is {}
229
+ */
230
+ export type ToolOutputType = ToolSingleOutputType | ToolSingleOutputType[] | undefined;
231
+ export type ToolInputType = z.ZodRawShape;
50
232
  /**
51
233
  * Declarative metadata describing what an McpTool contributes.
52
234
  */
53
- export interface ToolMetadata<In = z.ZodRawShape, Out = z.ZodRawShape> extends ExtendFrontMcpToolMetadata {
235
+ export interface ToolMetadata<InSchema = ToolInputType, OutSchema extends ToolOutputType = ToolOutputType> extends ExtendFrontMcpToolMetadata {
54
236
  /**
55
237
  * Optional unique identifier for the tool.
56
238
  * If omitted, a consumer may derive an ID from the class or file name.
@@ -68,7 +250,7 @@ export interface ToolMetadata<In = z.ZodRawShape, Out = z.ZodRawShape> extends E
68
250
  * Zod schema describing the expected input payload for the tool.
69
251
  * Used for validation and for generating automatic docs/UX.
70
252
  */
71
- inputSchema: In;
253
+ inputSchema: InSchema;
72
254
  /**
73
255
  * Zod schema describing the expected input payload for the tool.
74
256
  * Used for validation and for generating automatic docs/UX.
@@ -77,7 +259,7 @@ export interface ToolMetadata<In = z.ZodRawShape, Out = z.ZodRawShape> extends E
77
259
  /**
78
260
  * Zod schema describing the structure of the tool's successful output.
79
261
  */
80
- outputSchema?: Out;
262
+ outputSchema?: OutSchema;
81
263
  /**
82
264
  * Optional list of tags/labels that categorize the tool for discovery and filtering.
83
265
  */
@@ -97,7 +279,7 @@ export declare const frontMcpToolMetadataSchema: z.ZodObject<{
97
279
  description: z.ZodOptional<z.ZodString>;
98
280
  inputSchema: z.ZodType<Object, z.ZodTypeDef, Object>;
99
281
  rawInputSchema: z.ZodOptional<z.ZodAny>;
100
- outputSchema: z.ZodOptional<z.ZodType<Object, z.ZodTypeDef, Object>>;
282
+ outputSchema: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodEnum<["string", "number", "date", "boolean"]>, z.ZodEnum<["image", "audio", "resource", "resource_link"]>]>, z.ZodType<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeDef, z.ZodType<unknown, z.ZodTypeDef, unknown>>, z.ZodRecord<z.ZodString, z.ZodType<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeDef, z.ZodType<unknown, z.ZodTypeDef, unknown>>>]>, z.ZodArray<z.ZodUnion<[z.ZodUnion<[z.ZodEnum<["string", "number", "date", "boolean"]>, z.ZodEnum<["image", "audio", "resource", "resource_link"]>]>, z.ZodType<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeDef, z.ZodType<unknown, z.ZodTypeDef, unknown>>, z.ZodRecord<z.ZodString, z.ZodType<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeDef, z.ZodType<unknown, z.ZodTypeDef, unknown>>>]>, "many">]>>;
101
283
  tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
102
284
  annotations: z.ZodOptional<z.ZodObject<{
103
285
  title: z.ZodOptional<z.ZodString>;
@@ -125,7 +307,7 @@ export declare const frontMcpToolMetadataSchema: z.ZodObject<{
125
307
  description: z.ZodOptional<z.ZodString>;
126
308
  inputSchema: z.ZodType<Object, z.ZodTypeDef, Object>;
127
309
  rawInputSchema: z.ZodOptional<z.ZodAny>;
128
- outputSchema: z.ZodOptional<z.ZodType<Object, z.ZodTypeDef, Object>>;
310
+ outputSchema: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodEnum<["string", "number", "date", "boolean"]>, z.ZodEnum<["image", "audio", "resource", "resource_link"]>]>, z.ZodType<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeDef, z.ZodType<unknown, z.ZodTypeDef, unknown>>, z.ZodRecord<z.ZodString, z.ZodType<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeDef, z.ZodType<unknown, z.ZodTypeDef, unknown>>>]>, z.ZodArray<z.ZodUnion<[z.ZodUnion<[z.ZodEnum<["string", "number", "date", "boolean"]>, z.ZodEnum<["image", "audio", "resource", "resource_link"]>]>, z.ZodType<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeDef, z.ZodType<unknown, z.ZodTypeDef, unknown>>, z.ZodRecord<z.ZodString, z.ZodType<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeDef, z.ZodType<unknown, z.ZodTypeDef, unknown>>>]>, "many">]>>;
129
311
  tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
130
312
  annotations: z.ZodOptional<z.ZodObject<{
131
313
  title: z.ZodOptional<z.ZodString>;
@@ -153,7 +335,7 @@ export declare const frontMcpToolMetadataSchema: z.ZodObject<{
153
335
  description: z.ZodOptional<z.ZodString>;
154
336
  inputSchema: z.ZodType<Object, z.ZodTypeDef, Object>;
155
337
  rawInputSchema: z.ZodOptional<z.ZodAny>;
156
- outputSchema: z.ZodOptional<z.ZodType<Object, z.ZodTypeDef, Object>>;
338
+ outputSchema: z.ZodOptional<z.ZodUnion<[z.ZodUnion<[z.ZodUnion<[z.ZodEnum<["string", "number", "date", "boolean"]>, z.ZodEnum<["image", "audio", "resource", "resource_link"]>]>, z.ZodType<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeDef, z.ZodType<unknown, z.ZodTypeDef, unknown>>, z.ZodRecord<z.ZodString, z.ZodType<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeDef, z.ZodType<unknown, z.ZodTypeDef, unknown>>>]>, z.ZodArray<z.ZodUnion<[z.ZodUnion<[z.ZodEnum<["string", "number", "date", "boolean"]>, z.ZodEnum<["image", "audio", "resource", "resource_link"]>]>, z.ZodType<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeDef, z.ZodType<unknown, z.ZodTypeDef, unknown>>, z.ZodRecord<z.ZodString, z.ZodType<z.ZodType<unknown, z.ZodTypeDef, unknown>, z.ZodTypeDef, z.ZodType<unknown, z.ZodTypeDef, unknown>>>]>, "many">]>>;
157
339
  tags: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
158
340
  annotations: z.ZodOptional<z.ZodObject<{
159
341
  title: z.ZodOptional<z.ZodString>;
@@ -176,3 +358,4 @@ export declare const frontMcpToolMetadataSchema: z.ZodObject<{
176
358
  }, z.ZodTypeAny, "passthrough">>>;
177
359
  hideFromDiscovery: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
178
360
  }, z.ZodTypeAny, "passthrough">>;
361
+ export {};
@@ -1,23 +1,58 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.frontMcpToolMetadataSchema = void 0;
3
+ exports.frontMcpToolMetadataSchema = exports.ResourceLinkOutputSchema = exports.ResourceOutputSchema = exports.AudioOutputSchema = exports.ImageOutputSchema = void 0;
4
4
  const zod_1 = require("zod");
5
- const mcpToolAnnotationsSchema = zod_1.z.object({
5
+ const types_js_1 = require("@modelcontextprotocol/sdk/types.js");
6
+ const mcpToolAnnotationsSchema = zod_1.z
7
+ .object({
6
8
  title: zod_1.z.string().optional(),
7
9
  readOnlyHint: zod_1.z.boolean().optional(),
8
10
  destructiveHint: zod_1.z.boolean().optional(),
9
11
  idempotentHint: zod_1.z.boolean().optional(),
10
12
  openWorldHint: zod_1.z.boolean().optional(),
11
- }).passthrough();
12
- exports.frontMcpToolMetadataSchema = zod_1.z.object({
13
+ })
14
+ .passthrough();
15
+ exports.ImageOutputSchema = types_js_1.ImageContentSchema;
16
+ exports.AudioOutputSchema = types_js_1.AudioContentSchema;
17
+ exports.ResourceOutputSchema = types_js_1.EmbeddedResourceSchema;
18
+ exports.ResourceLinkOutputSchema = types_js_1.ResourceLinkSchema;
19
+ /**
20
+ * Runtime schema for ToolSingleOutputType:
21
+ * - literals ('string', 'image', ...)
22
+ * - any Zod schema (ZodObject, ZodArray, etc.)
23
+ * - raw shapes (Record<string, ZodTypeAny>)
24
+ */
25
+ const primitiveOutputLiteralSchema = zod_1.z.enum(['string', 'number', 'date', 'boolean']);
26
+ const specialOutputLiteralSchema = zod_1.z.enum(['image', 'audio', 'resource', 'resource_link']);
27
+ const outputLiteralSchema = zod_1.z.union([
28
+ primitiveOutputLiteralSchema,
29
+ specialOutputLiteralSchema,
30
+ ]);
31
+ // Any Zod schema instance (object, array, union, etc.)
32
+ const zodSchemaInstanceSchema = zod_1.z.instanceof(zod_1.z.ZodType);
33
+ // Raw shape: { field: z.string(), ... }
34
+ const zodRawShapeSchema = zod_1.z.record(zodSchemaInstanceSchema);
35
+ const toolSingleOutputSchema = zod_1.z.union([
36
+ outputLiteralSchema,
37
+ zodSchemaInstanceSchema,
38
+ zodRawShapeSchema,
39
+ ]);
40
+ // ToolOutputType = ToolSingleOutputType | ToolSingleOutputType[]
41
+ const toolOutputSchema = zod_1.z.union([
42
+ toolSingleOutputSchema,
43
+ zod_1.z.array(toolSingleOutputSchema),
44
+ ]);
45
+ exports.frontMcpToolMetadataSchema = zod_1.z
46
+ .object({
13
47
  id: zod_1.z.string().optional(),
14
48
  name: zod_1.z.string().min(1),
15
49
  description: zod_1.z.string().optional(),
16
50
  inputSchema: zod_1.z.instanceof(Object),
17
51
  rawInputSchema: zod_1.z.any().optional(),
18
- outputSchema: zod_1.z.instanceof(Object).optional(),
52
+ outputSchema: toolOutputSchema.optional(),
19
53
  tags: zod_1.z.array(zod_1.z.string().min(1)).optional(),
20
54
  annotations: mcpToolAnnotationsSchema.optional(),
21
55
  hideFromDiscovery: zod_1.z.boolean().optional().default(false),
22
- }).passthrough();
56
+ })
57
+ .passthrough();
23
58
  //# sourceMappingURL=tool.metadata.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tool.metadata.js","sourceRoot":"","sources":["../../../../src/common/metadata/tool.metadata.ts"],"names":[],"mappings":";;;AAAA,6BAAsB;AAyDtB,MAAM,wBAAwB,GAAG,OAAC,CAAC,MAAM,CAAC;IACxC,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,YAAY,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACpC,eAAe,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACvC,cAAc,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACtC,aAAa,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CACC,CAAC,CAAC,WAAW,EAAE,CAAC;AAwD3C,QAAA,0BAA0B,GAAG,OAAC,CAAC,MAAM,CAAC;IACjD,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACzB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,WAAW,EAAE,OAAC,CAAC,UAAU,CAAC,MAAM,CAAC;IACjC,cAAc,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAClC,YAAY,EAAE,OAAC,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE;IAC7C,IAAI,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC3C,WAAW,EAAE,wBAAwB,CAAC,QAAQ,EAAE;IAChD,iBAAiB,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;CACO,CAAC,CAAC,WAAW,EAAE,CAAC","sourcesContent":["import {z} from 'zod';\nimport {RawZodShape} from '../types';\nimport type {JSONSchema7} from 'json-schema';\n\ndeclare global {\n /**\n * Declarative metadata extends to the an McpTool decorator.\n */\n interface ExtendFrontMcpToolMetadata {\n\n }\n}\n\n\nexport interface ToolAnnotations {\n [x: string]: unknown;\n\n /**\n * A human-readable title for the tool.\n */\n title?: string;\n /**\n * If true, the tool does not modify its environment.\n *\n * Default: false\n */\n readOnlyHint?: boolean;\n /**\n * If true, the tool may perform destructive updates to its environment.\n * If false, the tool performs only additive updates.\n *\n * (This property is meaningful only when `readOnlyHint == false`)\n *\n * Default: true\n */\n destructiveHint?: boolean;\n /**\n * If true, calling the tool repeatedly with the same arguments\n * will have no additional effect on the its environment.\n *\n * (This property is meaningful only when `readOnlyHint == false`)\n *\n * Default: false\n */\n idempotentHint?: boolean;\n /**\n * If true, this tool may interact with an \"open world\" of external\n * entities. If false, the tool's domain of interaction is closed.\n * For example, the world of a web search tool is open, whereas that\n * of a memory tool is not.\n *\n * Default: true\n */\n openWorldHint?: boolean;\n}\n\n\nconst mcpToolAnnotationsSchema = z.object({\n title: z.string().optional(),\n readOnlyHint: z.boolean().optional(),\n destructiveHint: z.boolean().optional(),\n idempotentHint: z.boolean().optional(),\n openWorldHint: z.boolean().optional(),\n} satisfies RawZodShape<ToolAnnotations>).passthrough();\n\n\n/**\n * Declarative metadata describing what an McpTool contributes.\n */\nexport interface ToolMetadata<In = z.ZodRawShape, Out = z.ZodRawShape> extends ExtendFrontMcpToolMetadata {\n /**\n * Optional unique identifier for the tool.\n * If omitted, a consumer may derive an ID from the class or file name.\n */\n id?: string;\n\n /**\n * Human‑readable name of the tool, used in UIs, logs, and discovery.\n */\n name: string;\n\n /**\n * Short summary describing what the tool does and when to use it.\n */\n description?: string;\n\n /**\n * Zod schema describing the expected input payload for the tool.\n * Used for validation and for generating automatic docs/UX.\n */\n inputSchema: In;\n /**\n * Zod schema describing the expected input payload for the tool.\n * Used for validation and for generating automatic docs/UX.\n */\n rawInputSchema?: JSONSchema7;\n\n /**\n * Zod schema describing the structure of the tool's successful output.\n */\n outputSchema?: Out;\n\n /**\n * Optional list of tags/labels that categorize the tool for discovery and filtering.\n */\n tags?: string[];\n\n annotations?: ToolAnnotations;\n\n /**\n * If true, the tool will not be shown in the tool/list action results.\n * this method can still be called directly with tool/call even if hidden.\n * use case: tools that are intended to be private or internal. (usually for testing / private apis)\n * Default: false\n */\n hideFromDiscovery?: boolean;\n}\n\n\nexport const frontMcpToolMetadataSchema = z.object({\n id: z.string().optional(),\n name: z.string().min(1),\n description: z.string().optional(),\n inputSchema: z.instanceof(Object),\n rawInputSchema: z.any().optional(),\n outputSchema: z.instanceof(Object).optional(),\n tags: z.array(z.string().min(1)).optional(),\n annotations: mcpToolAnnotationsSchema.optional(),\n hideFromDiscovery: z.boolean().optional().default(false),\n} satisfies RawZodShape<ToolMetadata, ExtendFrontMcpToolMetadata>).passthrough();\n"]}
1
+ {"version":3,"file":"tool.metadata.js","sourceRoot":"","sources":["../../../../src/common/metadata/tool.metadata.ts"],"names":[],"mappings":";;;AAAA,6BAAmC;AAGnC,iEAK4C;AAmD5C,MAAM,wBAAwB,GAAG,OAAC;KAC/B,MAAM,CAAC;IACN,KAAK,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC5B,YAAY,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACpC,eAAe,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACvC,cAAc,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IACtC,aAAa,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CACC,CAAC;KACxC,WAAW,EAAE,CAAC;AAmBJ,QAAA,iBAAiB,GAAG,6BAAkB,CAAC;AAOvC,QAAA,iBAAiB,GAAG,6BAAkB,CAAC;AAOvC,QAAA,oBAAoB,GAAG,iCAAsB,CAAC;AAO9C,QAAA,wBAAwB,GAAG,6BAAkB,CAAC;AAkF3D;;;;;GAKG;AAEH,MAAM,4BAA4B,GAAG,OAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;AACrF,MAAM,0BAA0B,GAAG,OAAC,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,eAAe,CAAC,CAAC,CAAC;AAE3F,MAAM,mBAAmB,GAAG,OAAC,CAAC,KAAK,CAAC;IAClC,4BAA4B;IAC5B,0BAA0B;CAC3B,CAAC,CAAC;AAEH,uDAAuD;AACvD,MAAM,uBAAuB,GAAG,OAAC,CAAC,UAAU,CAAC,OAAC,CAAC,OAAO,CAAC,CAAC;AAExD,wCAAwC;AACxC,MAAM,iBAAiB,GAAG,OAAC,CAAC,MAAM,CAAC,uBAAuB,CAAC,CAAC;AAE5D,MAAM,sBAAsB,GAAG,OAAC,CAAC,KAAK,CAAC;IACrC,mBAAmB;IACnB,uBAAuB;IACvB,iBAAiB;CAClB,CAAC,CAAC;AAEH,iEAAiE;AACjE,MAAM,gBAAgB,GAAG,OAAC,CAAC,KAAK,CAAC;IAC/B,sBAAsB;IACtB,OAAC,CAAC,KAAK,CAAC,sBAAsB,CAAC;CAChC,CAAC,CAAC;AACU,QAAA,0BAA0B,GAAG,OAAC;KACxC,MAAM,CAAC;IACN,EAAE,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACzB,IAAI,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,WAAW,EAAE,OAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,WAAW,EAAE,OAAC,CAAC,UAAU,CAAC,MAAM,CAAC;IACjC,cAAc,EAAE,OAAC,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;IAClC,YAAY,EAAE,gBAAgB,CAAC,QAAQ,EAAE;IACzC,IAAI,EAAE,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IAC3C,WAAW,EAAE,wBAAwB,CAAC,QAAQ,EAAE;IAChD,iBAAiB,EAAE,OAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;CACO,CAAC;KACjE,WAAW,EAAE,CAAC","sourcesContent":["import { z, ZodObject } from 'zod';\nimport { RawZodShape } from '../types';\nimport type { JSONSchema7 } from 'json-schema';\nimport {\n ImageContentSchema,\n AudioContentSchema,\n ResourceLinkSchema,\n EmbeddedResourceSchema,\n} from '@modelcontextprotocol/sdk/types.js';\n\ndeclare global {\n /**\n * Declarative metadata extends to the an McpTool decorator.\n */\n interface ExtendFrontMcpToolMetadata {}\n}\n\nexport interface ToolAnnotations {\n [x: string]: unknown;\n\n /**\n * A human-readable title for the tool.\n */\n title?: string;\n /**\n * If true, the tool does not modify its environment.\n *\n * Default: false\n */\n readOnlyHint?: boolean;\n /**\n * If true, the tool may perform destructive updates to its environment.\n * If false, the tool performs only additive updates.\n *\n * (This property is meaningful only when `readOnlyHint == false`)\n *\n * Default: true\n */\n destructiveHint?: boolean;\n /**\n * If true, calling the tool repeatedly with the same arguments\n * will have no additional effect on the its environment.\n *\n * (This property is meaningful only when `readOnlyHint == false`)\n *\n * Default: false\n */\n idempotentHint?: boolean;\n /**\n * If true, this tool may interact with an \"open world\" of external\n * entities. If false, the tool's domain of interaction is closed.\n * For example, the world of a web search tool is open, whereas that\n * of a memory tool is not.\n *\n * Default: true\n */\n openWorldHint?: boolean;\n}\n\nconst mcpToolAnnotationsSchema = z\n .object({\n title: z.string().optional(),\n readOnlyHint: z.boolean().optional(),\n destructiveHint: z.boolean().optional(),\n idempotentHint: z.boolean().optional(),\n openWorldHint: z.boolean().optional(),\n } satisfies RawZodShape<ToolAnnotations>)\n .passthrough();\n\n/**\n * Tool response type text: include if outputSchema is zod primitive types\n */\ntype PrimitiveOutputType =\n | 'string'\n | 'number'\n | 'date'\n | 'boolean'\n | z.ZodString\n | z.ZodNumber\n | z.ZodBoolean\n | z.ZodBigInt\n | z.ZodDate;\n/**\n * Tool response type image, will use the ImageContentSchema from MCP types\n */\ntype ImageOutputType = 'image';\nexport const ImageOutputSchema = ImageContentSchema;\nexport type ImageOutput = z.output<typeof ImageOutputSchema>;\n\n/**\n * Tool response type audio, will use the AudioContentSchema from MCP types\n */\ntype AudioOutputType = 'audio';\nexport const AudioOutputSchema = AudioContentSchema;\nexport type AudioOutput = z.output<typeof AudioOutputSchema>;\n\n/**\n * Tool response type resource, will use the EmbeddedResourceSchema from MCP types\n */\ntype ResourceOutputType = 'resource';\nexport const ResourceOutputSchema = EmbeddedResourceSchema;\nexport type ResourceOutput = z.output<typeof ResourceOutputSchema>;\n\n/**\n * Tool response type resource_link, will use the ResourceLinkSchema from MCP types\n */\ntype ResourceLinkOutputType = 'resource_link';\nexport const ResourceLinkOutputSchema = ResourceLinkSchema;\nexport type ResourceLinkOutput = z.output<typeof ResourceLinkOutputSchema>;\n\n/**\n * Tool response type json, ZodRawShape for fast usage\n */\ntype StructuredOutputType =\n | z.ZodRawShape\n | z.ZodObject<any>\n | z.ZodArray<any>\n | z.ZodUnion<[ZodObject<any>, ...ZodObject<any>[]]>\n | z.ZodDiscriminatedUnion<any, any>;\n\nexport type ToolSingleOutputType =\n | PrimitiveOutputType\n | ImageOutputType\n | AudioOutputType\n | ResourceOutputType\n | ResourceLinkOutputType\n | StructuredOutputType;\n\n/**\n * Default default tool schema is {}\n */\nexport type ToolOutputType = ToolSingleOutputType | ToolSingleOutputType[] | undefined;\nexport type ToolInputType = z.ZodRawShape;\n\n/**\n * Declarative metadata describing what an McpTool contributes.\n */\nexport interface ToolMetadata<InSchema = ToolInputType, OutSchema extends ToolOutputType = ToolOutputType>\n extends ExtendFrontMcpToolMetadata {\n /**\n * Optional unique identifier for the tool.\n * If omitted, a consumer may derive an ID from the class or file name.\n */\n id?: string;\n\n /**\n * Human‑readable name of the tool, used in UIs, logs, and discovery.\n */\n name: string;\n\n /**\n * Short summary describing what the tool does and when to use it.\n */\n description?: string;\n\n /**\n * Zod schema describing the expected input payload for the tool.\n * Used for validation and for generating automatic docs/UX.\n */\n inputSchema: InSchema;\n /**\n * Zod schema describing the expected input payload for the tool.\n * Used for validation and for generating automatic docs/UX.\n */\n rawInputSchema?: JSONSchema7;\n\n /**\n * Zod schema describing the structure of the tool's successful output.\n */\n outputSchema?: OutSchema;\n\n /**\n * Optional list of tags/labels that categorize the tool for discovery and filtering.\n */\n tags?: string[];\n\n annotations?: ToolAnnotations;\n\n /**\n * If true, the tool will not be shown in the tool/list action results.\n * this method can still be called directly with tool/call even if hidden.\n * use case: tools that are intended to be private or internal. (usually for testing / private apis)\n * Default: false\n */\n hideFromDiscovery?: boolean;\n}\n\n\n\n/**\n * Runtime schema for ToolSingleOutputType:\n * - literals ('string', 'image', ...)\n * - any Zod schema (ZodObject, ZodArray, etc.)\n * - raw shapes (Record<string, ZodTypeAny>)\n */\n\nconst primitiveOutputLiteralSchema = z.enum(['string', 'number', 'date', 'boolean']);\nconst specialOutputLiteralSchema = z.enum(['image', 'audio', 'resource', 'resource_link']);\n\nconst outputLiteralSchema = z.union([\n primitiveOutputLiteralSchema,\n specialOutputLiteralSchema,\n]);\n\n// Any Zod schema instance (object, array, union, etc.)\nconst zodSchemaInstanceSchema = z.instanceof(z.ZodType);\n\n// Raw shape: { field: z.string(), ... }\nconst zodRawShapeSchema = z.record(zodSchemaInstanceSchema);\n\nconst toolSingleOutputSchema = z.union([\n outputLiteralSchema,\n zodSchemaInstanceSchema,\n zodRawShapeSchema,\n]);\n\n// ToolOutputType = ToolSingleOutputType | ToolSingleOutputType[]\nconst toolOutputSchema = z.union([\n toolSingleOutputSchema,\n z.array(toolSingleOutputSchema),\n]);\nexport const frontMcpToolMetadataSchema = z\n .object({\n id: z.string().optional(),\n name: z.string().min(1),\n description: z.string().optional(),\n inputSchema: z.instanceof(Object),\n rawInputSchema: z.any().optional(),\n outputSchema: toolOutputSchema.optional(),\n tags: z.array(z.string().min(1)).optional(),\n annotations: mcpToolAnnotationsSchema.optional(),\n hideFromDiscovery: z.boolean().optional().default(false),\n } satisfies RawZodShape<ToolMetadata, ExtendFrontMcpToolMetadata>)\n .passthrough();\n"]}