tmcp 1.17.0 → 1.18.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/README.md CHANGED
@@ -98,6 +98,125 @@ server.tool(
98
98
  server.receive(request);
99
99
  ```
100
100
 
101
+ ## Return helpers to skip boilerplate
102
+
103
+ Even the tiny calculator tool above ends with four near-identical `return { content: [{ type: 'text', text: ... }] }` blocks. Most MCP handlers have to build the same shapes: `CallToolResult`, `ReadResourceResult`, `GetPromptResult`, or `CompleteResult`. Writing them by hand is repetitive boilerplate. The `tmcp/utils` entry point ships a handful of factories that emit the correct shape for you.
104
+
105
+ ```ts
106
+ import { tool, resource, prompt, complete } from 'tmcp/utils';
107
+
108
+ // Without helpers – lots of envelope noise
109
+ server.tool(
110
+ { name: 'health-check', description: 'A health check tool' },
111
+ async () => ({
112
+ content: [{ type: 'text', text: 'ok' }],
113
+ }),
114
+ );
115
+
116
+ // With helpers – just describe the payload once
117
+ server.tool(
118
+ { name: 'health-check', description: 'A health check tool' },
119
+ async () => tool.text('ok'),
120
+ );
121
+
122
+ server.tool(
123
+ { name: 'profile-picture', description: 'Your profile picture' },
124
+ async () => tool.media('image', await loadPng(), 'image/png'),
125
+ );
126
+
127
+ server.tool(
128
+ {
129
+ name: 'get-images',
130
+ description:
131
+ 'Get the orders details and the images of all the products',
132
+ schema: v.object({
133
+ items: v.array(ItemsSchema),
134
+ }),
135
+ },
136
+ async () => {
137
+ const orders = await loadOrders();
138
+ const images = await loadImages(orders);
139
+
140
+ return tool.mix(
141
+ [
142
+ tool.text("Here's your images"),
143
+ ...images.map((img) => tool.media('image', img)),
144
+ ],
145
+ orders,
146
+ );
147
+ },
148
+ );
149
+
150
+ server.resource(
151
+ {
152
+ name: 'readme',
153
+ description: 'Top-level README',
154
+ uri: 'file://README.md',
155
+ },
156
+ async (uri) =>
157
+ resource.text(uri, await readFile(uri, 'utf8'), 'text/markdown'),
158
+ );
159
+
160
+ server.prompt(
161
+ {
162
+ name: 'explain',
163
+ description: '',
164
+ schema: v.object({ topic: v.string() }),
165
+ },
166
+ async ({ topic }) => prompt.message(`Explain ${topic} like I am five.`),
167
+ );
168
+
169
+ server.template(
170
+ {
171
+ name: 'users',
172
+ description: 'Supports completion',
173
+ uri: 'users/{id}',
174
+ complete: {
175
+ id: async (arg) =>
176
+ complete.values(await findMatchingIds(arg), false),
177
+ },
178
+ },
179
+ async (uri) => resource.blob(uri, await fetchUserBlob(uri)),
180
+ );
181
+ ```
182
+
183
+ you can also compose different kind of tools with `tool.mix`
184
+
185
+ ```ts
186
+ tool.mix([
187
+ tool.text('Indexed workspace'),
188
+ tool.media('image', png, 'image/png'),
189
+ ]);
190
+ ```
191
+
192
+ however be aware that
193
+
194
+ 1. you can't pass `tool.structured` to `tool.mix` (but you can pass a second argument that will be the structured content)
195
+ 2. if you pass even one `tool.error` to the `tool.mix` the whole return value will be an error
196
+
197
+ ```ts
198
+ const structuredContent = {
199
+ cool: true,
200
+ };
201
+
202
+ tool.mix(
203
+ [
204
+ tool.text(JSON.stringify(structuredContent)),
205
+ tool.media('image', png, 'image/png'),
206
+ ],
207
+ structuredContent,
208
+ );
209
+ ```
210
+
211
+ ### Helper catalog
212
+
213
+ - `tool` – build `CallToolResult` objects via `text`, `error`, `media`, `resource`, `resourceLink`, `structured`, and `mix` (merge multiple kind of tool response).
214
+ - `resource` – return `ReadResourceResult` through `text`, `blob`, or `mix` (merge `resource.text` and `resource.blob`).
215
+ - `prompt` – generate `GetPromptResult` using `message` (single string), `messages` (array of strings), or `various` (for prompts with string, audio, images, resources etc).
216
+ - `complete` – create `CompleteResult` payloads with `values(list, hasMore?, total?)`.
217
+
218
+ All helpers are typed, so TypeScript will prevent you from returning malformed payloads while cutting down the repetitive envelopes that used to appear in almost every handler.
219
+
101
220
  ## API Reference
102
221
 
103
222
  ### McpServer
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tmcp",
3
- "version": "1.17.0",
3
+ "version": "1.18.0",
4
4
  "description": "The main tmcp library",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -25,6 +25,10 @@
25
25
  "types": "./src/types/index.d.ts",
26
26
  "default": "./src/adapter.js"
27
27
  },
28
+ "./utils": {
29
+ "types": "./src/types/index.d.ts",
30
+ "default": "./src/utils/index.js"
31
+ },
28
32
  "./package.json": "./package.json"
29
33
  },
30
34
  "dependencies": {
@@ -1821,4 +1821,736 @@ declare module 'tmcp/adapter' {
1821
1821
  export {};
1822
1822
  }
1823
1823
 
1824
+ declare module 'tmcp/utils' {
1825
+ import * as v from 'valibot';
1826
+ export namespace tool {
1827
+
1828
+ function text(text: string): {
1829
+ content: {
1830
+ type: "text";
1831
+ text: string;
1832
+ }[];
1833
+ };
1834
+
1835
+ function error(text: string): {
1836
+ isError: true;
1837
+ content: {
1838
+ type: "text";
1839
+ text: string;
1840
+ }[];
1841
+ };
1842
+
1843
+ function media(type: "audio" | "image", data: string, mime_type: string): {
1844
+ content: {
1845
+ type: "audio" | "image";
1846
+ data: string;
1847
+ mimeType: string;
1848
+ }[];
1849
+ };
1850
+
1851
+ function resource(resource: EmbeddedResource["resource"]): {
1852
+ content: {
1853
+ type: "resource";
1854
+ resource: {
1855
+ text: string;
1856
+ uri: string;
1857
+ mimeType?: string | undefined;
1858
+ _meta?: ({} & {
1859
+ [key: string]: unknown;
1860
+ }) | undefined;
1861
+ } | {
1862
+ blob: string;
1863
+ uri: string;
1864
+ mimeType?: string | undefined;
1865
+ _meta?: ({} & {
1866
+ [key: string]: unknown;
1867
+ }) | undefined;
1868
+ };
1869
+ }[];
1870
+ };
1871
+
1872
+ function resourceLink(resource_link: Omit<ResourceLink, "type">): {
1873
+ content: {
1874
+ name: string;
1875
+ description?: string | undefined;
1876
+ title?: string | undefined;
1877
+ uri: string;
1878
+ _meta?: ({} & {
1879
+ [key: string]: unknown;
1880
+ }) | undefined;
1881
+ mimeType?: string | undefined;
1882
+ icons?: {
1883
+ src: string;
1884
+ mimeType?: string | undefined;
1885
+ sizes?: string[] | undefined;
1886
+ }[] | undefined;
1887
+ type: "resource_link";
1888
+ }[];
1889
+ };
1890
+
1891
+ function structured<T extends Record<string, unknown>>(obj: T): {
1892
+ readonly content: [{
1893
+ readonly type: "text";
1894
+ readonly text: string;
1895
+ }];
1896
+ readonly structuredContent: T;
1897
+ };
1898
+
1899
+ function mix<T extends Record<string, unknown> | undefined = undefined>(results: Array<CallToolResult<undefined>>, obj?: T): CallToolResult<T>;
1900
+ }
1901
+ export namespace resource {
1902
+
1903
+ function text(uri: string, text: string, mime_type?: string): {
1904
+ contents: {
1905
+ uri: string;
1906
+ text: string;
1907
+ mimeType: string | undefined;
1908
+ }[];
1909
+ };
1910
+
1911
+ function blob(uri: string, blob: string, mime_type?: string): {
1912
+ contents: {
1913
+ uri: string;
1914
+ blob: string;
1915
+ mimeType: string | undefined;
1916
+ }[];
1917
+ };
1918
+
1919
+ function mix(resources: Array<ReadResourceResult>): {
1920
+ contents: ({
1921
+ text: string;
1922
+ uri: string;
1923
+ mimeType?: string | undefined;
1924
+ _meta?: ({} & {
1925
+ [key: string]: unknown;
1926
+ }) | undefined;
1927
+ } | {
1928
+ blob: string;
1929
+ uri: string;
1930
+ mimeType?: string | undefined;
1931
+ _meta?: ({} & {
1932
+ [key: string]: unknown;
1933
+ }) | undefined;
1934
+ })[];
1935
+ };
1936
+ }
1937
+ export namespace prompt {
1938
+
1939
+ function message(text: string): {
1940
+ messages: {
1941
+ role: "user";
1942
+ content: {
1943
+ type: "text";
1944
+ text: string;
1945
+ };
1946
+ }[];
1947
+ };
1948
+
1949
+ function messages(messages: Array<string>): {
1950
+ messages: {
1951
+ role: "user";
1952
+ content: {
1953
+ type: "text";
1954
+ text: string;
1955
+ };
1956
+ }[];
1957
+ };
1958
+
1959
+ function various(messages: Array<GetPromptResult["messages"][number]["content"]>): {
1960
+ messages: {
1961
+ role: "user";
1962
+ content: {
1963
+ type: "text";
1964
+ text: string;
1965
+ _meta?: ({} & {
1966
+ [key: string]: unknown;
1967
+ }) | undefined;
1968
+ } | {
1969
+ type: "image";
1970
+ data: string;
1971
+ mimeType: string;
1972
+ _meta?: ({} & {
1973
+ [key: string]: unknown;
1974
+ }) | undefined;
1975
+ } | {
1976
+ type: "audio";
1977
+ data: string;
1978
+ mimeType: string;
1979
+ _meta?: ({} & {
1980
+ [key: string]: unknown;
1981
+ }) | undefined;
1982
+ } | {
1983
+ type: "resource_link";
1984
+ icons?: {
1985
+ src: string;
1986
+ mimeType?: string | undefined;
1987
+ sizes?: string[] | undefined;
1988
+ }[] | undefined;
1989
+ uri: string;
1990
+ description?: string | undefined;
1991
+ mimeType?: string | undefined;
1992
+ _meta?: ({} & {
1993
+ [key: string]: unknown;
1994
+ }) | undefined;
1995
+ name: string;
1996
+ title?: string | undefined;
1997
+ } | {
1998
+ type: "resource";
1999
+ resource: {
2000
+ text: string;
2001
+ uri: string;
2002
+ mimeType?: string | undefined;
2003
+ _meta?: ({} & {
2004
+ [key: string]: unknown;
2005
+ }) | undefined;
2006
+ } | {
2007
+ blob: string;
2008
+ uri: string;
2009
+ mimeType?: string | undefined;
2010
+ _meta?: ({} & {
2011
+ [key: string]: unknown;
2012
+ }) | undefined;
2013
+ };
2014
+ _meta?: ({} & {
2015
+ [key: string]: unknown;
2016
+ }) | undefined;
2017
+ };
2018
+ }[];
2019
+ };
2020
+ }
2021
+ export namespace complete {
2022
+
2023
+ function values(values: Array<string>, has_more?: boolean, total?: number): {
2024
+ completion: {
2025
+ values: string[];
2026
+ hasMore: boolean | undefined;
2027
+ total: number | undefined;
2028
+ };
2029
+ };
2030
+ }
2031
+ /**
2032
+ * The server's response to a resources/read request from the client.
2033
+ */
2034
+ const ReadResourceResultSchema: v.ObjectSchema<{
2035
+ readonly contents: v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
2036
+ /**
2037
+ * The text of the item. This must only be set if the item can actually be represented as text (not binary data).
2038
+ */
2039
+ readonly text: v.StringSchema<undefined>;
2040
+ /**
2041
+ * The URI of this resource.
2042
+ */
2043
+ readonly uri: v.StringSchema<undefined>;
2044
+ /**
2045
+ * The MIME type of this resource, if known.
2046
+ */
2047
+ readonly mimeType: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
2048
+ /**
2049
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
2050
+ * for notes on _meta usage.
2051
+ */
2052
+ readonly _meta: v.OptionalSchema<v.LooseObjectSchema<{}, undefined>, undefined>;
2053
+ }, undefined>, v.ObjectSchema<{
2054
+ /**
2055
+ * A base64-encoded string representing the binary data of the item.
2056
+ */
2057
+ readonly blob: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.Base64Action<string, undefined>]>;
2058
+ /**
2059
+ * The URI of this resource.
2060
+ */
2061
+ readonly uri: v.StringSchema<undefined>;
2062
+ /**
2063
+ * The MIME type of this resource, if known.
2064
+ */
2065
+ readonly mimeType: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
2066
+ /**
2067
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
2068
+ * for notes on _meta usage.
2069
+ */
2070
+ readonly _meta: v.OptionalSchema<v.LooseObjectSchema<{}, undefined>, undefined>;
2071
+ }, undefined>], undefined>, undefined>;
2072
+ /**
2073
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
2074
+ * for notes on _meta usage.
2075
+ */
2076
+ readonly _meta: v.OptionalSchema<v.LooseObjectSchema<{}, undefined>, undefined>;
2077
+ }, undefined>;
2078
+ /**
2079
+ * The contents of a resource, embedded into a prompt or tool call result.
2080
+ */
2081
+ const EmbeddedResourceSchema: v.ObjectSchema<{
2082
+ readonly type: v.LiteralSchema<"resource", undefined>;
2083
+ readonly resource: v.UnionSchema<[v.ObjectSchema<{
2084
+ /**
2085
+ * The text of the item. This must only be set if the item can actually be represented as text (not binary data).
2086
+ */
2087
+ readonly text: v.StringSchema<undefined>;
2088
+ /**
2089
+ * The URI of this resource.
2090
+ */
2091
+ readonly uri: v.StringSchema<undefined>;
2092
+ /**
2093
+ * The MIME type of this resource, if known.
2094
+ */
2095
+ readonly mimeType: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
2096
+ /**
2097
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
2098
+ * for notes on _meta usage.
2099
+ */
2100
+ readonly _meta: v.OptionalSchema<v.LooseObjectSchema<{}, undefined>, undefined>;
2101
+ }, undefined>, v.ObjectSchema<{
2102
+ /**
2103
+ * A base64-encoded string representing the binary data of the item.
2104
+ */
2105
+ readonly blob: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.Base64Action<string, undefined>]>;
2106
+ /**
2107
+ * The URI of this resource.
2108
+ */
2109
+ readonly uri: v.StringSchema<undefined>;
2110
+ /**
2111
+ * The MIME type of this resource, if known.
2112
+ */
2113
+ readonly mimeType: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
2114
+ /**
2115
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
2116
+ * for notes on _meta usage.
2117
+ */
2118
+ readonly _meta: v.OptionalSchema<v.LooseObjectSchema<{}, undefined>, undefined>;
2119
+ }, undefined>], undefined>;
2120
+ /**
2121
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
2122
+ * for notes on _meta usage.
2123
+ */
2124
+ readonly _meta: v.OptionalSchema<v.LooseObjectSchema<{}, undefined>, undefined>;
2125
+ }, undefined>;
2126
+ /**
2127
+ * A resource that the server is capable of reading, included in a prompt or tool call result.
2128
+ *
2129
+ * Note: resource links returned by tools are not guaranteed to appear in the results of `resources/list` requests.
2130
+ */
2131
+ const ResourceLinkSchema: v.ObjectSchema<{
2132
+ readonly type: v.LiteralSchema<"resource_link", undefined>;
2133
+ /**
2134
+ * Optional set of sized icons that the client can display in a user interface.
2135
+ *
2136
+ * Clients that support rendering icons MUST support at least the following MIME types:
2137
+ * - `image/png` - PNG images (safe, universal compatibility)
2138
+ * - `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)
2139
+ *
2140
+ * Clients that support rendering icons SHOULD also support:
2141
+ * - `image/svg+xml` - SVG images (scalable but requires security precautions)
2142
+ * - `image/webp` - WebP images (modern, efficient format)
2143
+ */
2144
+ readonly icons: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
2145
+ /**
2146
+ * URL or data URI for the icon.
2147
+ */
2148
+ readonly src: v.StringSchema<undefined>;
2149
+ /**
2150
+ * Optional MIME type for the icon.
2151
+ */
2152
+ readonly mimeType: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
2153
+ /**
2154
+ * Optional array of strings that specify sizes at which the icon can be used.
2155
+ * Each string should be in WxH format (e.g., `"48x48"`, `"96x96"`) or `"any"` for scalable formats like SVG.
2156
+ *
2157
+ * If not provided, the client should assume that the icon can be used at any size.
2158
+ */
2159
+ readonly sizes: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
2160
+ }, undefined>, undefined>, undefined>;
2161
+ /**
2162
+ * The URI of this resource.
2163
+ */
2164
+ readonly uri: v.StringSchema<undefined>;
2165
+ /**
2166
+ * A description of what this resource represents.
2167
+ *
2168
+ * This can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a "hint" to the model.
2169
+ */
2170
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
2171
+ /**
2172
+ * The MIME type of this resource, if known.
2173
+ */
2174
+ readonly mimeType: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
2175
+ /**
2176
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
2177
+ * for notes on _meta usage.
2178
+ */
2179
+ readonly _meta: v.OptionalSchema<v.LooseObjectSchema<{}, undefined>, undefined>;
2180
+ /** Intended for programmatic or logical use, but used as a display name in past specs or fallback */
2181
+ readonly name: v.StringSchema<undefined>;
2182
+ /**
2183
+ * Intended for UI and end-user contexts — optimized to be human-readable and easily understood,
2184
+ * even by those unfamiliar with domain-specific terminology.
2185
+ *
2186
+ * If not provided, the name should be used for display (except for Tool,
2187
+ * where `annotations.title` should be given precedence over using `name`,
2188
+ * if present).
2189
+ */
2190
+ readonly title: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
2191
+ }, undefined>;
2192
+ /**
2193
+ * The server's response to a prompts/get request from the client.
2194
+ */
2195
+ const GetPromptResultSchema: v.ObjectSchema<{
2196
+ /**
2197
+ * An optional description for the prompt.
2198
+ */
2199
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
2200
+ readonly messages: v.ArraySchema<v.ObjectSchema<{
2201
+ readonly role: v.PicklistSchema<["user", "assistant"], undefined>;
2202
+ readonly content: v.UnionSchema<[v.ObjectSchema<{
2203
+ readonly type: v.LiteralSchema<"text", undefined>;
2204
+ /**
2205
+ * The text content of the message.
2206
+ */
2207
+ readonly text: v.StringSchema<undefined>;
2208
+ /**
2209
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
2210
+ * for notes on _meta usage.
2211
+ */
2212
+ readonly _meta: v.OptionalSchema<v.LooseObjectSchema<{}, undefined>, undefined>;
2213
+ }, undefined>, v.ObjectSchema<{
2214
+ readonly type: v.LiteralSchema<"image", undefined>;
2215
+ /**
2216
+ * The base64-encoded image data.
2217
+ */
2218
+ readonly data: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.Base64Action<string, undefined>]>;
2219
+ /**
2220
+ * The MIME type of the image. Different providers may support different image types.
2221
+ */
2222
+ readonly mimeType: v.StringSchema<undefined>;
2223
+ /**
2224
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
2225
+ * for notes on _meta usage.
2226
+ */
2227
+ readonly _meta: v.OptionalSchema<v.LooseObjectSchema<{}, undefined>, undefined>;
2228
+ }, undefined>, v.ObjectSchema<{
2229
+ readonly type: v.LiteralSchema<"audio", undefined>;
2230
+ /**
2231
+ * The base64-encoded audio data.
2232
+ */
2233
+ readonly data: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.Base64Action<string, undefined>]>;
2234
+ /**
2235
+ * The MIME type of the audio. Different providers may support different audio types.
2236
+ */
2237
+ readonly mimeType: v.StringSchema<undefined>;
2238
+ /**
2239
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
2240
+ * for notes on _meta usage.
2241
+ */
2242
+ readonly _meta: v.OptionalSchema<v.LooseObjectSchema<{}, undefined>, undefined>;
2243
+ }, undefined>, v.ObjectSchema<{
2244
+ readonly type: v.LiteralSchema<"resource_link", undefined>;
2245
+ /**
2246
+ * Optional set of sized icons that the client can display in a user interface.
2247
+ *
2248
+ * Clients that support rendering icons MUST support at least the following MIME types:
2249
+ * - `image/png` - PNG images (safe, universal compatibility)
2250
+ * - `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)
2251
+ *
2252
+ * Clients that support rendering icons SHOULD also support:
2253
+ * - `image/svg+xml` - SVG images (scalable but requires security precautions)
2254
+ * - `image/webp` - WebP images (modern, efficient format)
2255
+ */
2256
+ readonly icons: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
2257
+ /**
2258
+ * URL or data URI for the icon.
2259
+ */
2260
+ readonly src: v.StringSchema<undefined>;
2261
+ /**
2262
+ * Optional MIME type for the icon.
2263
+ */
2264
+ readonly mimeType: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
2265
+ /**
2266
+ * Optional array of strings that specify sizes at which the icon can be used.
2267
+ * Each string should be in WxH format (e.g., `"48x48"`, `"96x96"`) or `"any"` for scalable formats like SVG.
2268
+ *
2269
+ * If not provided, the client should assume that the icon can be used at any size.
2270
+ */
2271
+ readonly sizes: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
2272
+ }, undefined>, undefined>, undefined>;
2273
+ /**
2274
+ * The URI of this resource.
2275
+ */
2276
+ readonly uri: v.StringSchema<undefined>;
2277
+ /**
2278
+ * A description of what this resource represents.
2279
+ *
2280
+ * This can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a "hint" to the model.
2281
+ */
2282
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
2283
+ /**
2284
+ * The MIME type of this resource, if known.
2285
+ */
2286
+ readonly mimeType: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
2287
+ /**
2288
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
2289
+ * for notes on _meta usage.
2290
+ */
2291
+ readonly _meta: v.OptionalSchema<v.LooseObjectSchema<{}, undefined>, undefined>;
2292
+ /** Intended for programmatic or logical use, but used as a display name in past specs or fallback */
2293
+ readonly name: v.StringSchema<undefined>;
2294
+ /**
2295
+ * Intended for UI and end-user contexts — optimized to be human-readable and easily understood,
2296
+ * even by those unfamiliar with domain-specific terminology.
2297
+ *
2298
+ * If not provided, the name should be used for display (except for Tool,
2299
+ * where `annotations.title` should be given precedence over using `name`,
2300
+ * if present).
2301
+ */
2302
+ readonly title: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
2303
+ }, undefined>, v.ObjectSchema<{
2304
+ readonly type: v.LiteralSchema<"resource", undefined>;
2305
+ readonly resource: v.UnionSchema<[v.ObjectSchema<{
2306
+ /**
2307
+ * The text of the item. This must only be set if the item can actually be represented as text (not binary data).
2308
+ */
2309
+ readonly text: v.StringSchema<undefined>;
2310
+ /**
2311
+ * The URI of this resource.
2312
+ */
2313
+ readonly uri: v.StringSchema<undefined>;
2314
+ /**
2315
+ * The MIME type of this resource, if known.
2316
+ */
2317
+ readonly mimeType: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
2318
+ /**
2319
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
2320
+ * for notes on _meta usage.
2321
+ */
2322
+ readonly _meta: v.OptionalSchema<v.LooseObjectSchema<{}, undefined>, undefined>;
2323
+ }, undefined>, v.ObjectSchema<{
2324
+ /**
2325
+ * A base64-encoded string representing the binary data of the item.
2326
+ */
2327
+ readonly blob: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.Base64Action<string, undefined>]>;
2328
+ /**
2329
+ * The URI of this resource.
2330
+ */
2331
+ readonly uri: v.StringSchema<undefined>;
2332
+ /**
2333
+ * The MIME type of this resource, if known.
2334
+ */
2335
+ readonly mimeType: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
2336
+ /**
2337
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
2338
+ * for notes on _meta usage.
2339
+ */
2340
+ readonly _meta: v.OptionalSchema<v.LooseObjectSchema<{}, undefined>, undefined>;
2341
+ }, undefined>], undefined>;
2342
+ /**
2343
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
2344
+ * for notes on _meta usage.
2345
+ */
2346
+ readonly _meta: v.OptionalSchema<v.LooseObjectSchema<{}, undefined>, undefined>;
2347
+ }, undefined>], undefined>;
2348
+ }, undefined>, undefined>;
2349
+ /**
2350
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
2351
+ * for notes on _meta usage.
2352
+ */
2353
+ readonly _meta: v.OptionalSchema<v.LooseObjectSchema<{}, undefined>, undefined>;
2354
+ }, undefined>;
2355
+ /**
2356
+ * The server's response to a tool call.
2357
+ */
2358
+ const CallToolResultSchema: v.ObjectSchema<{
2359
+ /**
2360
+ * A list of content objects that represent the result of the tool call.
2361
+ *
2362
+ * If the Tool does not define an outputSchema, this field MUST be present in the result.
2363
+ * For backwards compatibility, this field is always present, but it may be empty.
2364
+ */
2365
+ readonly content: v.OptionalSchema<v.ArraySchema<v.UnionSchema<[v.ObjectSchema<{
2366
+ readonly type: v.LiteralSchema<"text", undefined>;
2367
+ /**
2368
+ * The text content of the message.
2369
+ */
2370
+ readonly text: v.StringSchema<undefined>;
2371
+ /**
2372
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
2373
+ * for notes on _meta usage.
2374
+ */
2375
+ readonly _meta: v.OptionalSchema<v.LooseObjectSchema<{}, undefined>, undefined>;
2376
+ }, undefined>, v.ObjectSchema<{
2377
+ readonly type: v.LiteralSchema<"image", undefined>;
2378
+ /**
2379
+ * The base64-encoded image data.
2380
+ */
2381
+ readonly data: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.Base64Action<string, undefined>]>;
2382
+ /**
2383
+ * The MIME type of the image. Different providers may support different image types.
2384
+ */
2385
+ readonly mimeType: v.StringSchema<undefined>;
2386
+ /**
2387
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
2388
+ * for notes on _meta usage.
2389
+ */
2390
+ readonly _meta: v.OptionalSchema<v.LooseObjectSchema<{}, undefined>, undefined>;
2391
+ }, undefined>, v.ObjectSchema<{
2392
+ readonly type: v.LiteralSchema<"audio", undefined>;
2393
+ /**
2394
+ * The base64-encoded audio data.
2395
+ */
2396
+ readonly data: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.Base64Action<string, undefined>]>;
2397
+ /**
2398
+ * The MIME type of the audio. Different providers may support different audio types.
2399
+ */
2400
+ readonly mimeType: v.StringSchema<undefined>;
2401
+ /**
2402
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
2403
+ * for notes on _meta usage.
2404
+ */
2405
+ readonly _meta: v.OptionalSchema<v.LooseObjectSchema<{}, undefined>, undefined>;
2406
+ }, undefined>, v.ObjectSchema<{
2407
+ readonly type: v.LiteralSchema<"resource_link", undefined>;
2408
+ /**
2409
+ * Optional set of sized icons that the client can display in a user interface.
2410
+ *
2411
+ * Clients that support rendering icons MUST support at least the following MIME types:
2412
+ * - `image/png` - PNG images (safe, universal compatibility)
2413
+ * - `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)
2414
+ *
2415
+ * Clients that support rendering icons SHOULD also support:
2416
+ * - `image/svg+xml` - SVG images (scalable but requires security precautions)
2417
+ * - `image/webp` - WebP images (modern, efficient format)
2418
+ */
2419
+ readonly icons: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
2420
+ /**
2421
+ * URL or data URI for the icon.
2422
+ */
2423
+ readonly src: v.StringSchema<undefined>;
2424
+ /**
2425
+ * Optional MIME type for the icon.
2426
+ */
2427
+ readonly mimeType: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
2428
+ /**
2429
+ * Optional array of strings that specify sizes at which the icon can be used.
2430
+ * Each string should be in WxH format (e.g., `"48x48"`, `"96x96"`) or `"any"` for scalable formats like SVG.
2431
+ *
2432
+ * If not provided, the client should assume that the icon can be used at any size.
2433
+ */
2434
+ readonly sizes: v.OptionalSchema<v.ArraySchema<v.StringSchema<undefined>, undefined>, undefined>;
2435
+ }, undefined>, undefined>, undefined>;
2436
+ /**
2437
+ * The URI of this resource.
2438
+ */
2439
+ readonly uri: v.StringSchema<undefined>;
2440
+ /**
2441
+ * A description of what this resource represents.
2442
+ *
2443
+ * This can be used by clients to improve the LLM's understanding of available resources. It can be thought of like a "hint" to the model.
2444
+ */
2445
+ readonly description: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
2446
+ /**
2447
+ * The MIME type of this resource, if known.
2448
+ */
2449
+ readonly mimeType: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
2450
+ /**
2451
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
2452
+ * for notes on _meta usage.
2453
+ */
2454
+ readonly _meta: v.OptionalSchema<v.LooseObjectSchema<{}, undefined>, undefined>;
2455
+ /** Intended for programmatic or logical use, but used as a display name in past specs or fallback */
2456
+ readonly name: v.StringSchema<undefined>;
2457
+ /**
2458
+ * Intended for UI and end-user contexts — optimized to be human-readable and easily understood,
2459
+ * even by those unfamiliar with domain-specific terminology.
2460
+ *
2461
+ * If not provided, the name should be used for display (except for Tool,
2462
+ * where `annotations.title` should be given precedence over using `name`,
2463
+ * if present).
2464
+ */
2465
+ readonly title: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
2466
+ }, undefined>, v.ObjectSchema<{
2467
+ readonly type: v.LiteralSchema<"resource", undefined>;
2468
+ readonly resource: v.UnionSchema<[v.ObjectSchema<{
2469
+ /**
2470
+ * The text of the item. This must only be set if the item can actually be represented as text (not binary data).
2471
+ */
2472
+ readonly text: v.StringSchema<undefined>;
2473
+ /**
2474
+ * The URI of this resource.
2475
+ */
2476
+ readonly uri: v.StringSchema<undefined>;
2477
+ /**
2478
+ * The MIME type of this resource, if known.
2479
+ */
2480
+ readonly mimeType: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
2481
+ /**
2482
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
2483
+ * for notes on _meta usage.
2484
+ */
2485
+ readonly _meta: v.OptionalSchema<v.LooseObjectSchema<{}, undefined>, undefined>;
2486
+ }, undefined>, v.ObjectSchema<{
2487
+ /**
2488
+ * A base64-encoded string representing the binary data of the item.
2489
+ */
2490
+ readonly blob: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.Base64Action<string, undefined>]>;
2491
+ /**
2492
+ * The URI of this resource.
2493
+ */
2494
+ readonly uri: v.StringSchema<undefined>;
2495
+ /**
2496
+ * The MIME type of this resource, if known.
2497
+ */
2498
+ readonly mimeType: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
2499
+ /**
2500
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
2501
+ * for notes on _meta usage.
2502
+ */
2503
+ readonly _meta: v.OptionalSchema<v.LooseObjectSchema<{}, undefined>, undefined>;
2504
+ }, undefined>], undefined>;
2505
+ /**
2506
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
2507
+ * for notes on _meta usage.
2508
+ */
2509
+ readonly _meta: v.OptionalSchema<v.LooseObjectSchema<{}, undefined>, undefined>;
2510
+ }, undefined>], undefined>, undefined>, readonly []>;
2511
+ /**
2512
+ * An object containing structured tool output.
2513
+ *
2514
+ * If the Tool defines an outputSchema, this field MUST be present in the result, and contain a JSON object that matches the schema.
2515
+ */
2516
+ readonly structuredContent: v.OptionalSchema<v.LooseObjectSchema<{}, undefined>, undefined>;
2517
+ /**
2518
+ * Whether the tool call ended in an error.
2519
+ *
2520
+ * If not set, this is assumed to be false (the call was successful).
2521
+ *
2522
+ * Any errors that originate from the tool SHOULD be reported inside the result
2523
+ * object, with `isError` set to true, _not_ as an MCP protocol-level error
2524
+ * response. Otherwise, the LLM would not be able to see that an error occurred
2525
+ * and self-correct.
2526
+ *
2527
+ * However, any errors in _finding_ the tool, an error indicating that the
2528
+ * server does not support tool calls, or any other exceptional conditions,
2529
+ * should be reported as an MCP error response.
2530
+ */
2531
+ readonly isError: v.OptionalSchema<v.BooleanSchema<undefined>, undefined>;
2532
+ /**
2533
+ * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)
2534
+ * for notes on _meta usage.
2535
+ */
2536
+ readonly _meta: v.OptionalSchema<v.LooseObjectSchema<{}, undefined>, undefined>;
2537
+ }, undefined>;
2538
+ type CallToolResult<TStructuredContent extends Record<string, unknown> | undefined> = Omit<v.InferInput<typeof CallToolResultSchema>, "structuredContent" | "isError"> & (undefined extends TStructuredContent ? {
2539
+ structuredContent?: undefined;
2540
+ isError?: boolean;
2541
+ } : ({
2542
+ structuredContent: TStructuredContent;
2543
+ isError?: false;
2544
+ } | {
2545
+ isError: true;
2546
+ structuredContent?: TStructuredContent;
2547
+ }));
2548
+ type ReadResourceResult = v.InferInput<typeof ReadResourceResultSchema>;
2549
+ type GetPromptResult = v.InferInput<typeof GetPromptResultSchema>;
2550
+ type EmbeddedResource = v.InferInput<typeof EmbeddedResourceSchema>;
2551
+ type ResourceLink = v.InferInput<typeof ResourceLinkSchema>;
2552
+
2553
+ export {};
2554
+ }
2555
+
1824
2556
  //# sourceMappingURL=index.d.ts.map
@@ -58,7 +58,11 @@
58
58
  "ExtractFromExpression",
59
59
  "ExtractVariablesFromTemplate",
60
60
  "ExtractURITemplateVariables",
61
- "JsonSchemaAdapter"
61
+ "JsonSchemaAdapter",
62
+ "EmbeddedResourceSchema",
63
+ "ResourceLinkSchema",
64
+ "EmbeddedResource",
65
+ "ResourceLink"
62
66
  ],
63
67
  "sources": [
64
68
  "../index.js",
@@ -74,6 +78,6 @@
74
78
  null,
75
79
  null
76
80
  ],
77
- "mappings": ";;;;;cAiLaA,SAASA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aCg0CyBC,KAAKA;aDn7CFC,aAAaA;;aC08CHC,kBAAkBA;aAGrBC,eAAeA;aAvBZC,kBAAkBA;aAUKC,UAAUA;aAmBzBC,0BAA0BA;aAGjCC,mBAAmBA;aAY9BC,QAAQA;aAYJC,YAAYA;aAlDVC,UAAUA;aAwDZC,YAAYA;aAGRC,gBAAgBA;aAGjBC,eAAeA;aAGbC,iBAAiBA;aAMPC,2BAA2BA;aAHnCC,mBAAmBA;aAhDxBC,cAAcA;MCj/C1DC,UAAUA;;;;;MAyCVC,aAAaA;;;;;;;;;;;;;;MAcbC,WAAWA;;;;;;;MAOlBC,oBAAoBA;;;;MAIbC,iBAAiBA;;MAEjBC,SAASA;;;;;;;;;;;OD+BRC,oBAAoBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmFpBC,WAAWA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAoBXC,oBAAoBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAUpBC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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA0iB2BrC,kBAAkBA;MAGrBC,eAAeA;MAyDduD,gBAAgBA;MAGpBC,YAAYA",
78
82
  "ignoreList": []
79
83
  }
@@ -0,0 +1,228 @@
1
+ /**
2
+ * @import { EmbeddedResource, ResourceLink, CallToolResult, ReadResourceResult, GetPromptResult, CompleteResult } from "../validation/index.js";
3
+ */
4
+
5
+ /**
6
+ * @satisfies {Record<string, (...args: any[])=>CallToolResult<any>>}
7
+ */
8
+ export const tool = {
9
+ /**
10
+ * @param {string} text
11
+ */
12
+ text(text) {
13
+ return {
14
+ content: [
15
+ {
16
+ type: /** @type {const} */ ('text'),
17
+ text,
18
+ },
19
+ ],
20
+ };
21
+ },
22
+ /**
23
+ * @param {string} text
24
+ */
25
+ error(text) {
26
+ return {
27
+ isError: true,
28
+ content: [
29
+ {
30
+ type: /** @type {const} */ ('text'),
31
+ text,
32
+ },
33
+ ],
34
+ };
35
+ },
36
+ /**
37
+ * @param {"audio" | "image"} type
38
+ * @param {string} data
39
+ * @param {string} mime_type
40
+ */
41
+ media(type, data, mime_type) {
42
+ return {
43
+ content: [
44
+ {
45
+ type,
46
+ data,
47
+ mimeType: mime_type,
48
+ },
49
+ ],
50
+ };
51
+ },
52
+ /**
53
+ * @param {EmbeddedResource["resource"]} resource
54
+ */
55
+ resource(resource) {
56
+ return {
57
+ content: [
58
+ {
59
+ type: /** @type {const} */ ('resource'),
60
+ resource,
61
+ },
62
+ ],
63
+ };
64
+ },
65
+
66
+ /**
67
+ * @param {Omit<ResourceLink, "type">} resource_link
68
+ */
69
+ resourceLink(resource_link) {
70
+ return {
71
+ content: [
72
+ {
73
+ type: /** @type {const} */ ('resource_link'),
74
+ ...resource_link,
75
+ },
76
+ ],
77
+ };
78
+ },
79
+ /**
80
+ * @template {Record<string, unknown>} T
81
+ * @param {T} obj
82
+ */
83
+ structured(obj) {
84
+ return /** @type {const} */ ({
85
+ content: [
86
+ {
87
+ type: 'text',
88
+ text: JSON.stringify(obj),
89
+ },
90
+ ],
91
+ structuredContent: obj,
92
+ });
93
+ },
94
+ /**
95
+ * @template {Record<string, unknown> | undefined} [T=undefined]
96
+ * @param {Array<CallToolResult<undefined>>} results
97
+ * @param {T} [obj]
98
+ */
99
+ mix(results, obj) {
100
+ return /** @type {CallToolResult<T>} */ ({
101
+ isError: results.some((r) => r.isError),
102
+ content: results.flatMap((r) => (r.content ? r.content : [])),
103
+ structuredContent: obj,
104
+ });
105
+ },
106
+ };
107
+ /**
108
+ * @satisfies {Record<string, (...args: any[])=>ReadResourceResult>}
109
+ */
110
+ export const resource = {
111
+ /**
112
+ * @param {string} uri
113
+ * @param {string} text
114
+ * @param {string} [mime_type]
115
+ */
116
+ text(uri, text, mime_type) {
117
+ return {
118
+ contents: [
119
+ {
120
+ uri,
121
+ text,
122
+ mimeType: mime_type,
123
+ },
124
+ ],
125
+ };
126
+ },
127
+ /**
128
+ * @param {string} uri
129
+ * @param {string} blob
130
+ * @param {string} [mime_type]
131
+ */
132
+ blob(uri, blob, mime_type) {
133
+ return {
134
+ contents: [
135
+ {
136
+ uri,
137
+ blob,
138
+ mimeType: mime_type,
139
+ },
140
+ ],
141
+ };
142
+ },
143
+ /**
144
+ *
145
+ * @param {Array<ReadResourceResult>} resources
146
+ */
147
+ mix(resources) {
148
+ return {
149
+ contents: resources.flatMap((resource) => resource.contents),
150
+ };
151
+ },
152
+ };
153
+
154
+ /**
155
+ * @satisfies {Record<string, (...args: any[])=>GetPromptResult>}
156
+ */
157
+ export const prompt = {
158
+ /**
159
+ *
160
+ * @param {string} text
161
+ */
162
+ message(text) {
163
+ return {
164
+ messages: [
165
+ {
166
+ role: 'user',
167
+ content: {
168
+ type: 'text',
169
+ text,
170
+ },
171
+ },
172
+ ],
173
+ };
174
+ },
175
+ /**
176
+ *
177
+ * @param {Array<string>} messages
178
+ * @returns
179
+ */
180
+ messages(messages) {
181
+ return {
182
+ messages: messages.map((message) => {
183
+ return {
184
+ role: 'user',
185
+ content: {
186
+ type: 'text',
187
+ text: message,
188
+ },
189
+ };
190
+ }),
191
+ };
192
+ },
193
+ /**
194
+ *
195
+ * @param {Array<GetPromptResult["messages"][number]["content"]>} messages
196
+ * @returns
197
+ */
198
+ various(messages) {
199
+ return {
200
+ messages: messages.map((content) => {
201
+ return {
202
+ role: 'user',
203
+ content,
204
+ };
205
+ }),
206
+ };
207
+ },
208
+ };
209
+ /**
210
+ * @satisfies {Record<string, (...args: any[])=>CompleteResult>}
211
+ */
212
+ export const complete = {
213
+ /**
214
+ *
215
+ * @param {Array<string>} values
216
+ * @param {boolean} [has_more]
217
+ * @param {number} [total]
218
+ */
219
+ values(values, has_more, total) {
220
+ return {
221
+ completion: {
222
+ values,
223
+ hasMore: has_more,
224
+ total,
225
+ },
226
+ };
227
+ },
228
+ };
@@ -1601,3 +1601,9 @@ export const ServerResultSchema = v.union([
1601
1601
  /**
1602
1602
  * @typedef {v.InferInput<typeof ListResourceTemplatesResultSchema>} ListResourceTemplatesResult
1603
1603
  */
1604
+ /**
1605
+ * @typedef {v.InferInput<typeof EmbeddedResourceSchema>} EmbeddedResource
1606
+ */
1607
+ /**
1608
+ * @typedef {v.InferInput<typeof ResourceLinkSchema>} ResourceLink
1609
+ */