Brunobkr/llama.cpp_AlgMor24_github
ΩFFFΣLLIa • llama.cpp • AlgMor24 ██████╗ ███████╗███████╗███████╗██╗ ██╗ ██╗ █████╗ ██╔═══██╗██╔════╝██╔════╝██╔════╝██║ ██║ ██║██╔══██╗ ██║ ██║█████╗ █████╗ █████╗ ██║ ██║ ██║███████║ ██║ ██║██╔══╝ ██╔══╝ ██╔══╝ ██║ ██║ ██║██╔══██║ ╚██████╔╝██║ ██║ ███████╗███████╗███████╗██║██║ ██║ ╚═════╝ ╚═╝ ╚═╝ ╚══════╝╚══════╝╚══════╝╚═╝╚═╝ ╚═╝ High-Performance LLM / VLM Inference & Autonomous Agentic Ecosystem… See the full description on the dataset page: https://huggingface.co/datasets/Brunobkr/llama.cpp_AlgMor24_github.
03.1k
1import * as v from 'valibot';2export const LATEST_PROTOCOL_VERSION = '2025-06-18';3export const DEFAULT_NEGOTIATED_PROTOCOL_VERSION = '2025-03-26';4export const SUPPORTED_PROTOCOL_VERSIONS = [5 LATEST_PROTOCOL_VERSION,6 '2025-03-26',7 '2024-11-05',8 '2024-10-07',9];10/* JSON-RPC types */11export const JSONRPC_VERSION = '2.0';12 13export class McpError extends Error {14 /**15 * @param {number} code16 * @param {string} message17 */18 constructor(code, message) {19 super(`MCP error ${code}: ${message}`);20 this.name = 'McpError';21 }22}23 24/**25 * A progress token, used to associate progress notifications with the original request.26 */27export const ProgressTokenSchema = v.union([28 v.string(),29 v.pipe(v.number(), v.integer()),30]);31 32/**33 * An opaque token used to represent a cursor for pagination.34 */35export const CursorSchema = v.string();36 37const RequestMetaSchema = v.looseObject({38 /**39 * If specified, the caller is requesting out-of-band progress notifications for this request (as represented by notifications/progress). The value of this parameter is an opaque token that will be attached to any subsequent notifications. The receiver is not obligated to provide these notifications.40 */41 progressToken: v.optional(ProgressTokenSchema),42});43 44const BaseRequestParamsSchema = v.looseObject({45 _meta: v.optional(RequestMetaSchema),46});47 48export const RequestSchema = v.object({49 method: v.string(),50 params: v.optional(BaseRequestParamsSchema),51});52 53const BaseNotificationParamsSchema = v.looseObject({54 /**55 * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)56 * for notes on _meta usage.57 */58 _meta: v.optional(v.looseObject({})),59});60export const NotificationSchema = v.object({61 method: v.string(),62 params: v.optional(BaseNotificationParamsSchema),63});64export const ResultSchema = v.looseObject({65 /**66 * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)67 * for notes on _meta usage.68 */69 _meta: v.optional(v.looseObject({})),70});71 72/**73 * A uniquely identifying ID for a request in JSON-RPC.74 */75export const RequestIdSchema = v.union([76 v.string(),77 v.pipe(v.number(), v.integer()),78]);79 80/**81 * A request that expects a response.82 */83export const JSONRPCRequestSchema = v.object({84 jsonrpc: v.literal(JSONRPC_VERSION),85 id: RequestIdSchema,86 ...RequestSchema.entries,87});88 89/**90 * A notification which does not expect a response.91 */92export const JSONRPCNotificationSchema = v.object({93 jsonrpc: v.literal(JSONRPC_VERSION),94 ...NotificationSchema.entries,95});96 97/**98 * A successful (non-error) response to a request.99 */100export const JSONRPCResponseSchema = v.strictObject({101 jsonrpc: v.literal(JSONRPC_VERSION),102 id: RequestIdSchema,103 result: ResultSchema,104});105 106/**107 * A response to a request that indicates an error occurred.108 */109export const JSONRPCErrorSchema = v.strictObject({110 jsonrpc: v.literal(JSONRPC_VERSION),111 id: RequestIdSchema,112 error: v.object({113 /**114 * The error type that occurred.115 */116 code: v.pipe(v.number(), v.integer()),117 118 /**119 * A short description of the error. The message SHOULD be limited to a concise single sentence.120 */121 message: v.string(),122 123 /**124 * Additional information about the error. The value of this member is defined by the sender (e.g. detailed error information, nested errors etc.).125 */126 data: v.optional(v.unknown()),127 }),128});129export const JSONRPCMessageSchema = v.union([130 JSONRPCRequestSchema,131 JSONRPCNotificationSchema,132 JSONRPCResponseSchema,133 JSONRPCErrorSchema,134]);135/* Empty result */136 137/**138 * A response that indicates success but carries no data.139 */140export const EmptyResultSchema = v.strictObject({ ...ResultSchema.entries });141/* Cancellation */142 143/**144 * This notification can be sent by either side to indicate that it is cancelling a previously-issued request.145 *146 * The request SHOULD still be in-flight, but due to communication latency, it is always possible that this notification MAY arrive after the request has already finished.147 *148 * This notification indicates that the result will be unused, so any associated processing SHOULD cease.149 *150 * A client MUST NOT attempt to cancel its `initialize` request.151 */152export const CancelledNotificationSchema = v.object({153 ...NotificationSchema.entries,154 method: v.literal('notifications/cancelled'),155 params: v.object({156 ...BaseNotificationParamsSchema.entries,157 158 /**159 * The ID of the request to cancel.160 *161 * This MUST correspond to the ID of a request previously issued in the same direction.162 */163 requestId: RequestIdSchema,164 165 /**166 * An optional string describing the reason for the cancellation. This MAY be logged or presented to the user.167 */168 reason: v.optional(v.string()),169 }),170});171/* Base Metadata */172 173/**174 * Base metadata interface for common properties across resources, tools, prompts, and implementations.175 */176export const BaseMetadataSchema = v.object({177 /** Intended for programmatic or logical use, but used as a display name in past specs or fallback */178 name: v.string(),179 180 /**181 * Intended for UI and end-user contexts — optimized to be human-readable and easily understood,182 * even by those unfamiliar with domain-specific terminology.183 *184 * If not provided, the name should be used for display (except for Tool,185 * where `annotations.title` should be given precedence over using `name`,186 * if present).187 */188 title: v.optional(v.string()),189});190 191/**192 * Icon schema for use in tools, prompts, resources, and implementations.193 */194export const IconSchema = v.object({195 /**196 * URL or data URI for the icon.197 */198 src: v.string(),199 /**200 * Optional MIME type for the icon.201 */202 mimeType: v.optional(v.string()),203 /**204 * Optional array of strings that specify sizes at which the icon can be used.205 * Each string should be in WxH format (e.g., `"48x48"`, `"96x96"`) or `"any"` for scalable formats like SVG.206 *207 * If not provided, the client should assume that the icon can be used at any size.208 */209 sizes: v.optional(v.array(v.string())),210});211 212export const IconsSchema = v.object({213 /**214 * Optional set of sized icons that the client can display in a user interface.215 *216 * Clients that support rendering icons MUST support at least the following MIME types:217 * - `image/png` - PNG images (safe, universal compatibility)218 * - `image/jpeg` (and `image/jpg`) - JPEG images (safe, universal compatibility)219 *220 * Clients that support rendering icons SHOULD also support:221 * - `image/svg+xml` - SVG images (scalable but requires security precautions)222 * - `image/webp` - WebP images (modern, efficient format)223 */224 icons: v.optional(v.array(IconSchema)),225});226 227/* Initialization */228 229/**230 * Describes the name and version of an MCP implementation.231 */232export const ImplementationSchema = v.object({233 ...BaseMetadataSchema.entries,234 version: v.string(),235 websiteUrl: v.optional(v.string()),236 ...IconsSchema.entries,237});238 239/**240 * Capabilities a client may support. Known capabilities are defined here, in this schema, but this is not a closed set: any client can define its own, additional capabilities.241 */242export const ClientCapabilitiesSchema = v.looseObject({243 /**244 * Experimental, non-standard capabilities that the client supports.245 */246 experimental: v.optional(v.object({})),247 248 /**249 * Present if the client supports sampling from an LLM.250 */251 sampling: v.optional(v.object({})),252 253 /**254 * Present if the client supports eliciting user input.255 */256 elicitation: v.optional(v.object({})),257 258 /**259 * Present if the client supports listing roots.260 */261 roots: v.optional(262 v.object({263 /**264 * Whether the client supports issuing notifications for changes to the roots list.265 */266 listChanged: v.optional(v.boolean()),267 }),268 ),269});270 271export const InitializeRequestParamsSchema = v.object({272 ...BaseRequestParamsSchema.entries,273 274 /**275 * The latest version of the Model Context Protocol that the client supports. The client MAY decide to support older versions as well.276 */277 protocolVersion: v.string(),278 capabilities: ClientCapabilitiesSchema,279 clientInfo: ImplementationSchema,280});281 282/**283 * This request is sent from the client to the server when it first connects, asking it to begin initialization.284 */285export const InitializeRequestSchema = v.object({286 ...RequestSchema.entries,287 method: v.literal('initialize'),288 params: InitializeRequestParamsSchema,289});290 291/**292 * Capabilities that a server may support. Known capabilities are defined here, in this schema, but this is not a closed set: any server can define its own, additional capabilities.293 */294export const ServerCapabilitiesSchema = v.object({295 /**296 * Experimental, non-standard capabilities that the server supports.297 */298 experimental: v.optional(v.object({})),299 300 /**301 * Present if the server supports sending log messages to the client.302 */303 logging: v.optional(v.object({})),304 305 /**306 * Present if the server supports sending completions to the client.307 */308 completions: v.optional(v.object({})),309 310 /**311 * Present if the server offers any prompt templates.312 */313 prompts: v.optional(314 v.object({315 /**316 * Whether this server supports issuing notifications for changes to the prompt list.317 */318 listChanged: v.optional(v.boolean()),319 }),320 ),321 322 /**323 * Present if the server offers any resources to read.324 */325 resources: v.optional(326 v.object({327 /**328 * Whether this server supports clients subscribing to resource updates.329 */330 subscribe: v.optional(v.boolean()),331 332 /**333 * Whether this server supports issuing notifications for changes to the resource list.334 */335 listChanged: v.optional(v.boolean()),336 }),337 ),338 339 /**340 * Present if the server offers any tools to call.341 */342 tools: v.optional(343 v.object({344 /**345 * Whether this server supports issuing notifications for changes to the tool list.346 */347 listChanged: v.optional(v.boolean()),348 }),349 ),350});351 352/**353 * After receiving an initialize request from the client, the server sends this response.354 */355export const InitializeResultSchema = v.object({356 ...ResultSchema.entries,357 358 /**359 * The version of the Model Context Protocol that the server wants to use. This may not match the version that the client requested. If the client cannot support this version, it MUST disconnect.360 */361 protocolVersion: v.string(),362 capabilities: ServerCapabilitiesSchema,363 serverInfo: ImplementationSchema,364 365 /**366 * Instructions describing how to use the server and its features.367 *368 * This can be used by clients to improve the LLM's understanding of available tools, resources, etc. It can be thought of like a "hint" to the model. For example, this information MAY be added to the system prompt.369 */370 instructions: v.optional(v.string()),371});372 373/**374 * This notification is sent from the client to the server after initialization has finished.375 */376export const InitializedNotificationSchema = v.object({377 ...NotificationSchema.entries,378 method: v.literal('notifications/initialized'),379});380/* Ping */381 382/**383 * A ping, issued by either the server or the client, to check that the other party is still alive. The receiver must promptly respond, or else may be disconnected.384 */385export const PingRequestSchema = v.object({386 ...RequestSchema.entries,387 method: v.literal('ping'),388});389/* Progress notifications */390export const ProgressSchema = v.object({391 /**392 * The progress thus far. This should increase every time progress is made, even if the total is unknown.393 */394 progress: v.number(),395 396 /**397 * Total number of items to process (or total progress required), if known.398 */399 total: v.optional(v.number()),400 401 /**402 * An optional message describing the current progress.403 */404 message: v.optional(v.string()),405});406 407/**408 * An out-of-band notification used to inform the receiver of a progress update for a long-running request.409 */410export const ProgressNotificationSchema = v.object({411 ...NotificationSchema.entries,412 method: v.literal('notifications/progress'),413 params: v.object({414 ...BaseNotificationParamsSchema.entries,415 ...ProgressSchema.entries,416 417 /**418 * The progress token which was given in the initial request, used to associate this notification with the request that is proceeding.419 */420 progressToken: ProgressTokenSchema,421 }),422});423/* Pagination */424export const PaginatedRequestSchema = v.object({425 ...RequestSchema.entries,426 params: v.optional(427 v.object({428 ...BaseRequestParamsSchema.entries,429 430 /**431 * An opaque token representing the current pagination position.432 * If provided, the server should return results starting after this cursor.433 */434 cursor: v.optional(CursorSchema),435 }),436 ),437});438export const PaginatedResultSchema = v.object({439 ...ResultSchema.entries,440 441 /**442 * An opaque token representing the pagination position after the last returned result.443 * If present, there may be more results available.444 */445 nextCursor: v.optional(CursorSchema),446});447/* Resources */448 449/**450 * The contents of a specific resource or sub-resource.451 */452export const ResourceContentsSchema = v.object({453 /**454 * The URI of this resource.455 */456 uri: v.string(),457 458 /**459 * The MIME type of this resource, if known.460 */461 mimeType: v.optional(v.string()),462 463 /**464 * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)465 * for notes on _meta usage.466 */467 _meta: v.optional(v.looseObject({})),468});469export const TextResourceContentsSchema = v.object({470 ...ResourceContentsSchema.entries,471 472 /**473 * The text of the item. This must only be set if the item can actually be represented as text (not binary data).474 */475 text: v.string(),476});477export const BlobResourceContentsSchema = v.object({478 ...ResourceContentsSchema.entries,479 480 /**481 * A base64-encoded string representing the binary data of the item.482 */483 blob: v.pipe(v.string(), v.base64()),484});485 486/**487 * A known resource that the server is capable of reading.488 */489export const ResourceSchema = v.object({490 ...BaseMetadataSchema.entries,491 492 /**493 * The URI of this resource.494 */495 uri: v.string(),496 497 /**498 * A description of what this resource represents.499 *500 * 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.501 */502 description: v.optional(v.string()),503 504 /**505 * The MIME type of this resource, if known.506 */507 mimeType: v.optional(v.string()),508 509 /**510 * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)511 * for notes on _meta usage.512 */513 _meta: v.optional(v.looseObject({})),514 ...IconsSchema.entries,515});516 517/**518 * A template description for resources available on the server.519 */520export const ResourceTemplateSchema = v.object({521 ...BaseMetadataSchema.entries,522 523 /**524 * A URI template (according to RFC 6570) that can be used to construct resource URIs.525 */526 uriTemplate: v.string(),527 528 /**529 * A description of what this template is for.530 *531 * 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.532 */533 description: v.optional(v.string()),534 535 /**536 * The MIME type for all resources that match this template. This should only be included if all resources matching this template have the same type.537 */538 mimeType: v.optional(v.string()),539 540 /**541 * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)542 * for notes on _meta usage.543 */544 _meta: v.optional(v.looseObject({})),545 ...IconsSchema.entries,546});547 548/**549 * Sent from the client to request a list of resources the server has.550 */551export const ListResourcesRequestSchema = v.object({552 ...PaginatedRequestSchema.entries,553 method: v.literal('resources/list'),554});555 556/**557 * The server's response to a resources/list request from the client.558 */559export const ListResourcesResultSchema = v.object({560 ...PaginatedResultSchema.entries,561 resources: v.array(ResourceSchema),562});563 564/**565 * Sent from the client to request a list of resource templates the server has.566 */567export const ListResourceTemplatesRequestSchema = v.object({568 ...PaginatedRequestSchema.entries,569 method: v.literal('resources/templates/list'),570});571 572/**573 * The server's response to a resources/templates/list request from the client.574 */575export const ListResourceTemplatesResultSchema = v.object({576 ...PaginatedResultSchema.entries,577 resourceTemplates: v.array(ResourceTemplateSchema),578});579 580/**581 * Sent from the client to the server, to read a specific resource URI.582 */583export const ReadResourceRequestSchema = v.object({584 ...RequestSchema.entries,585 method: v.literal('resources/read'),586 params: v.object({587 ...BaseRequestParamsSchema.entries,588 589 /**590 * The URI of the resource to read. The URI can use any protocol; it is up to the server how to interpret it.591 */592 uri: v.string(),593 }),594});595 596/**597 * The server's response to a resources/read request from the client.598 */599export const ReadResourceResultSchema = v.object({600 ...ResultSchema.entries,601 contents: v.array(602 v.union([TextResourceContentsSchema, BlobResourceContentsSchema]),603 ),604});605 606/**607 * An optional notification from the server to the client, informing it that the list of resources it can read from has changed. This may be issued by servers without any previous subscription from the client.608 */609export const ResourceListChangedNotificationSchema = v.object({610 ...NotificationSchema.entries,611 method: v.literal('notifications/resources/list_changed'),612});613 614/**615 * Sent from the client to request resources/updated notifications from the server whenever a particular resource changes.616 */617export const SubscribeRequestSchema = v.object({618 ...RequestSchema.entries,619 method: v.literal('resources/subscribe'),620 params: v.object({621 ...BaseRequestParamsSchema.entries,622 623 /**624 * The URI of the resource to subscribe to. The URI can use any protocol; it is up to the server how to interpret it.625 */626 uri: v.string(),627 }),628});629 630/**631 * Sent from the client to request cancellation of resources/updated notifications from the server. This should follow a previous resources/subscribe request.632 */633export const UnsubscribeRequestSchema = v.object({634 ...RequestSchema.entries,635 method: v.literal('resources/unsubscribe'),636 params: v.object({637 ...BaseRequestParamsSchema.entries,638 639 /**640 * The URI of the resource to unsubscribe from.641 */642 uri: v.string(),643 }),644});645 646/**647 * A notification from the server to the client, informing it that a resource has changed and may need to be read again. This should only be sent if the client previously sent a resources/subscribe request.648 */649export const ResourceUpdatedNotificationSchema = v.object({650 ...NotificationSchema.entries,651 method: v.literal('notifications/resources/updated'),652 params: v.object({653 ...BaseNotificationParamsSchema.entries,654 655 /**656 * The URI of the resource that has been updated. This might be a sub-resource of the one that the client actually subscribed to.657 */658 uri: v.string(),659 }),660});661/* Prompts */662 663/**664 * Describes an argument that a prompt can accept.665 */666export const PromptArgumentSchema = v.object({667 /**668 * The name of the argument.669 */670 name: v.string(),671 672 /**673 * A human-readable description of the argument.674 */675 description: v.optional(v.string()),676 677 /**678 * Whether this argument must be provided.679 */680 required: v.optional(v.boolean()),681});682 683/**684 * A prompt or prompt template that the server offers.685 */686export const PromptSchema = v.object({687 ...BaseMetadataSchema.entries,688 689 /**690 * An optional description of what this prompt provides691 */692 description: v.optional(v.string()),693 694 /**695 * A list of arguments to use for templating the prompt.696 */697 arguments: v.optional(v.array(PromptArgumentSchema)),698 699 /**700 * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)701 * for notes on _meta usage.702 */703 _meta: v.optional(v.looseObject({})),704 ...IconsSchema.entries,705});706 707/**708 * Sent from the client to request a list of prompts and prompt templates the server has.709 */710export const ListPromptsRequestSchema = v.object({711 ...PaginatedRequestSchema.entries,712 method: v.literal('prompts/list'),713});714 715/**716 * The server's response to a prompts/list request from the client.717 */718export const ListPromptsResultSchema = v.object({719 ...PaginatedResultSchema.entries,720 prompts: v.array(PromptSchema),721});722 723/**724 * Used by the client to get a prompt provided by the server.725 */726export const GetPromptRequestSchema = v.object({727 ...RequestSchema.entries,728 method: v.literal('prompts/get'),729 params: v.object({730 ...BaseRequestParamsSchema.entries,731 732 /**733 * The name of the prompt or prompt template.734 */735 name: v.string(),736 737 /**738 * Arguments to use for templating the prompt.739 */740 arguments: v.optional(v.record(v.string(), v.string())),741 }),742});743 744/**745 * Text provided to or from an LLM.746 */747export const TextContentSchema = v.object({748 type: v.literal('text'),749 750 /**751 * The text content of the message.752 */753 text: v.string(),754 755 /**756 * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)757 * for notes on _meta usage.758 */759 _meta: v.optional(v.looseObject({})),760});761 762/**763 * An image provided to or from an LLM.764 */765export const ImageContentSchema = v.object({766 type: v.literal('image'),767 768 /**769 * The base64-encoded image data.770 */771 data: v.pipe(v.string(), v.base64()),772 773 /**774 * The MIME type of the image. Different providers may support different image types.775 */776 mimeType: v.string(),777 778 /**779 * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)780 * for notes on _meta usage.781 */782 _meta: v.optional(v.looseObject({})),783});784 785/**786 * An Audio provided to or from an LLM.787 */788export const AudioContentSchema = v.object({789 type: v.literal('audio'),790 791 /**792 * The base64-encoded audio data.793 */794 data: v.pipe(v.string(), v.base64()),795 796 /**797 * The MIME type of the audio. Different providers may support different audio types.798 */799 mimeType: v.string(),800 801 /**802 * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)803 * for notes on _meta usage.804 */805 _meta: v.optional(v.looseObject({})),806});807 808/**809 * The contents of a resource, embedded into a prompt or tool call result.810 */811export const EmbeddedResourceSchema = v.object({812 type: v.literal('resource'),813 resource: v.union([TextResourceContentsSchema, BlobResourceContentsSchema]),814 815 /**816 * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)817 * for notes on _meta usage.818 */819 _meta: v.optional(v.looseObject({})),820});821 822/**823 * A resource that the server is capable of reading, included in a prompt or tool call result.824 *825 * Note: resource links returned by tools are not guaranteed to appear in the results of `resources/list` requests.826 */827export const ResourceLinkSchema = v.object({828 ...ResourceSchema.entries,829 type: v.literal('resource_link'),830});831 832/**833 * A content block that can be used in prompts and tool results.834 */835export const ContentBlockSchema = v.union([836 TextContentSchema,837 ImageContentSchema,838 AudioContentSchema,839 ResourceLinkSchema,840 EmbeddedResourceSchema,841]);842 843/**844 * Describes a message returned as part of a prompt.845 */846export const PromptMessageSchema = v.object({847 role: v.picklist(['user', 'assistant']),848 content: ContentBlockSchema,849});850 851/**852 * The server's response to a prompts/get request from the client.853 */854export const GetPromptResultSchema = v.object({855 ...ResultSchema.entries,856 857 /**858 * An optional description for the prompt.859 */860 description: v.optional(v.string()),861 messages: v.array(PromptMessageSchema),862});863 864/**865 * An optional notification from the server to the client, informing it that the list of prompts it offers has changed. This may be issued by servers without any previous subscription from the client.866 */867export const PromptListChangedNotificationSchema = v.object({868 ...NotificationSchema.entries,869 method: v.literal('notifications/prompts/list_changed'),870});871/* Tools */872 873/**874 * Additional properties describing a Tool to clients.875 *876 * NOTE: all properties in ToolAnnotations are **hints**.877 * They are not guaranteed to provide a faithful description of878 * tool behavior (including descriptive properties like `title`).879 *880 * Clients should never make tool use decisions based on ToolAnnotations881 * received from untrusted servers.882 */883export const ToolAnnotationsSchema = v.object({884 /**885 * A human-readable title for the tool.886 */887 title: v.optional(v.string()),888 889 /**890 * If true, the tool does not modify its environment.891 *892 * Default: false893 */894 readOnlyHint: v.optional(v.boolean()),895 896 /**897 * If true, the tool may perform destructive updates to its environment.898 * If false, the tool performs only additive updates.899 *900 * (This property is meaningful only when `readOnlyHint == false`)901 *902 * Default: true903 */904 destructiveHint: v.optional(v.boolean()),905 906 /**907 * If true, calling the tool repeatedly with the same arguments908 * will have no additional effect on the its environment.909 *910 * (This property is meaningful only when `readOnlyHint == false`)911 *912 * Default: false913 */914 idempotentHint: v.optional(v.boolean()),915 916 /**917 * If true, this tool may interact with an "open world" of external918 * entities. If false, the tool's domain of interaction is closed.919 * For example, the world of a web search tool is open, whereas that920 * of a memory tool is not.921 *922 * Default: true923 */924 openWorldHint: v.optional(v.boolean()),925});926 927/**928 * Definition for a tool the client can call.929 */930export const ToolSchema = v.object({931 ...BaseMetadataSchema.entries,932 933 /**934 * A human-readable description of the tool.935 */936 description: v.optional(v.string()),937 938 /**939 * A JSON Schema object defining the expected parameters for the tool.940 */941 inputSchema: v.object({942 type: v.literal('object'),943 properties: v.optional(v.object({})),944 required: v.optional(v.array(v.string())),945 }),946 947 /**948 * An optional JSON Schema object defining the structure of the tool's output returned in949 * the structuredContent field of a CallToolResult.950 */951 outputSchema: v.optional(952 v.object({953 type: v.literal('object'),954 properties: v.optional(v.object({})),955 required: v.optional(v.array(v.string())),956 }),957 ),958 959 /**960 * Optional additional tool information.961 */962 annotations: v.optional(ToolAnnotationsSchema),963 964 /**965 * See [MCP specification](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/47339c03c143bb4ec01a26e721a1b8fe66634ebe/docs/specification/draft/basic/index.mdx#general-fields)966 * for notes on _meta usage.967 */968 _meta: v.optional(v.looseObject({})),969 ...IconsSchema.entries,970});971 972/**973 * Sent from the client to request a list of tools the server has.974 */975export const ListToolsRequestSchema = v.object({976 ...PaginatedRequestSchema.entries,977 method: v.literal('tools/list'),978});979 980/**981 * The server's response to a tools/list request from the client.982 */983export const ListToolsResultSchema = v.object({984 ...PaginatedResultSchema.entries,985 tools: v.array(ToolSchema),986});987 988/**989 * The server's response to a tool call.990 */991export const CallToolResultSchema = v.object({992 ...ResultSchema.entries,993 994 /**995 * A list of content objects that represent the result of the tool call.996 *997 * If the Tool does not define an outputSchema, this field MUST be present in the result.998 * For backwards compatibility, this field is always present, but it may be empty.999 */1000 content: v.optional(v.array(ContentBlockSchema), []),1001 1002 /**1003 * An object containing structured tool output.1004 *1005 * If the Tool defines an outputSchema, this field MUST be present in the result, and contain a JSON object that matches the schema.1006 */1007 structuredContent: v.optional(v.looseObject({})),1008 1009 /**1010 * Whether the tool call ended in an error.1011 *1012 * If not set, this is assumed to be false (the call was successful).1013 *1014 * Any errors that originate from the tool SHOULD be reported inside the result1015 * object, with `isError` set to true, _not_ as an MCP protocol-level error1016 * response. Otherwise, the LLM would not be able to see that an error occurred1017 * and self-correct.1018 *1019 * However, any errors in _finding_ the tool, an error indicating that the1020 * server does not support tool calls, or any other exceptional conditions,1021 * should be reported as an MCP error response.1022 */1023 isError: v.optional(v.boolean()),1024});1025 1026/**1027 * CallToolResultSchema extended with backwards compatibility to protocol version 2024-10-07.1028 */1029export const CompatibilityCallToolResultSchema = v.union([1030 CallToolResultSchema,1031 v.object({ ...ResultSchema.entries, toolResult: v.unknown() }),1032]);1033 1034/**1035 * Used by the client to invoke a tool provided by the server.1036 */1037export const CallToolRequestSchema = v.object({1038 ...RequestSchema.entries,1039 method: v.literal('tools/call'),1040 params: v.object({1041 ...BaseRequestParamsSchema.entries,1042 name: v.string(),1043 arguments: v.optional(v.record(v.string(), v.unknown())),1044 }),1045});1046 1047/**1048 * An optional notification from the server to the client, informing it that the list of tools it offers has changed. This may be issued by servers without any previous subscription from the client.1049 */1050export const ToolListChangedNotificationSchema = v.object({1051 ...NotificationSchema.entries,1052 method: v.literal('notifications/tools/list_changed'),1053});1054/* Logging */1055 1056/**1057 * The severity of a log message.1058 */1059export const LoggingLevelSchema = v.picklist([1060 'debug',1061 'info',1062 'notice',1063 'warning',1064 'error',1065 'critical',1066 'alert',1067 'emergency',1068]);1069 1070/**1071 * A request from the client to the server, to enable or adjust logging.1072 */1073export const SetLevelRequestSchema = v.object({1074 ...RequestSchema.entries,1075 method: v.literal('logging/setLevel'),1076 params: v.object({1077 ...BaseRequestParamsSchema.entries,1078 1079 /**1080 * The level of logging that the client wants to receive from the server. The server should send all logs at this level and higher (i.e., more severe) to the client as notifications/logging/message.1081 */1082 level: LoggingLevelSchema,1083 }),1084});1085 1086/**1087 * Notification of a log message passed from server to client. If no logging/setLevel request has been sent from the client, the server MAY decide which messages to send automatically.1088 */1089export const LoggingMessageNotificationSchema = v.object({1090 ...NotificationSchema.entries,1091 method: v.literal('notifications/message'),1092 params: v.object({1093 ...BaseNotificationParamsSchema.entries,1094 1095 /**1096 * The severity of this log message.1097 */1098 level: LoggingLevelSchema,1099 1100 /**1101 * An optional name of the logger issuing this message.1102 */1103 logger: v.optional(v.string()),1104 1105 /**1106 * The data to be logged, such as a string message or an object. Any JSON serializable type is allowed here.1107 */1108 data: v.unknown(),1109 }),1110});1111/* Sampling */1112 1113/**1114 * Hints to use for model selection.1115 */1116export const ModelHintSchema = v.object({1117 /**1118 * A hint for a model name.1119 */1120 name: v.optional(v.string()),1121});1122 1123/**1124 * The server's preferences for model selection, requested of the client during sampling.1125 */1126export const ModelPreferencesSchema = v.object({1127 /**1128 * Optional hints to use for model selection.1129 */1130 hints: v.optional(v.array(ModelHintSchema)),1131 1132 /**1133 * How much to prioritize cost when selecting a model.1134 */1135 costPriority: v.optional(v.pipe(v.number(), v.minValue(0), v.maxValue(1))),1136 1137 /**1138 * How much to prioritize sampling speed (latency) when selecting a model.1139 */1140 speedPriority: v.optional(v.pipe(v.number(), v.minValue(0), v.maxValue(1))),1141 1142 /**1143 * How much to prioritize intelligence and capabilities when selecting a model.1144 */1145 intelligencePriority: v.optional(1146 v.pipe(v.number(), v.minValue(0), v.maxValue(1)),1147 ),1148});1149 1150/**1151 * Describes a message issued to or received from an LLM API.1152 */1153export const SamplingMessageSchema = v.object({1154 role: v.picklist(['user', 'assistant']),1155 content: v.union([1156 TextContentSchema,1157 ImageContentSchema,1158 AudioContentSchema,1159 ]),1160});1161 1162export const CreateMessageRequestParamsSchema = v.object({1163 ...BaseRequestParamsSchema.entries,1164 messages: v.array(SamplingMessageSchema),1165 1166 /**1167 * An optional system prompt the server wants to use for sampling. The client MAY modify or omit this prompt.1168 */1169 systemPrompt: v.optional(v.string()),1170 1171 /**1172 * A request to include context from one or more MCP servers (including the caller), to be attached to the prompt. The client MAY ignore this request.1173 */1174 includeContext: v.optional(1175 v.picklist(['none', 'thisServer', 'allServers']),1176 ),1177 temperature: v.optional(v.number()),1178 1179 /**1180 * The maximum number of tokens to sample, as requested by the server. The client MAY choose to sample fewer tokens than requested.1181 */1182 maxTokens: v.pipe(v.number(), v.integer()),1183 stopSequences: v.optional(v.array(v.string())),1184 1185 /**1186 * Optional metadata to pass through to the LLM provider. The format of this metadata is provider-specific.1187 */1188 metadata: v.optional(v.object({})),1189 1190 /**1191 * The server's preferences for which model to select.1192 */1193 modelPreferences: v.optional(ModelPreferencesSchema),1194});1195 1196/**1197 * A request from the server to sample an LLM via the client. The client has full discretion over which model to select. The client should also inform the user before beginning sampling, to allow them to inspect the request (human in the loop) and decide whether to approve it.1198 */1199export const CreateMessageRequestSchema = v.object({1200 ...RequestSchema.entries,