| 1 | /** |
| 2 | * Exact MCP v2025-03-26 wire schemas. |
| 3 | * |
| 4 | * This revision is expressed as a frozen delta from the exact 2024-11-05 |
| 5 | * schemas. Transport envelopes (including JSON-RPC batches) are owned by the |
| 6 | * transport codec rather than Effect RPC payload schemas. |
| 7 | * |
| 8 | * @internal |
| 9 | */ |
| 10 | import * as Rpc from "../../../rpc/Rpc.ts" |
| 11 | import * as RpcGroup from "../../../rpc/RpcGroup.ts" |
| 12 | import * as Schema from "../../../Schema.ts" |
| 13 | import * as Previous from "./v2024_11_05.ts" |
| 14 | |
| 15 | export * from "./v2024_11_05.ts" |
| 16 | |
| 17 | /** |
| 18 | * @internal |
| 19 | */ |
| 20 | export const protocolVersion = "2025-03-26" |
| 21 | |
| 22 | const optional = Previous.optional |
| 23 | |
| 24 | /** |
| 25 | * @internal |
| 26 | */ |
| 27 | export const ServerCapabilities = Schema.Struct({ |
| 28 | ...Previous.ServerCapabilities.fields, |
| 29 | completions: optional(Schema.Struct({})) |
| 30 | }) |
| 31 | |
| 32 | /** |
| 33 | * @internal |
| 34 | */ |
| 35 | export const AudioContent = Schema.Struct({ |
| 36 | type: Schema.Literal("audio"), |
| 37 | data: Schema.String, |
| 38 | mimeType: Schema.String, |
| 39 | annotations: optional(Previous.Annotation) |
| 40 | }) |
| 41 | |
| 42 | /** |
| 43 | * @internal |
| 44 | */ |
| 45 | export const PromptOrToolContent = Schema.Union([ |
| 46 | Previous.TextContent, |
| 47 | Previous.ImageContent, |
| 48 | AudioContent, |
| 49 | Previous.EmbeddedResource |
| 50 | ]) |
| 51 | |
| 52 | /** |
| 53 | * @internal |
| 54 | */ |
| 55 | export const SamplingContent = Schema.Union([ |
| 56 | Previous.TextContent, |
| 57 | Previous.ImageContent, |
| 58 | AudioContent |
| 59 | ]) |
| 60 | |
| 61 | /** |
| 62 | * @internal |
| 63 | */ |
| 64 | export const PromptMessage = Schema.Struct({ |
| 65 | role: Previous.Role, |
| 66 | content: PromptOrToolContent |
| 67 | }) |
| 68 | |
| 69 | /** |
| 70 | * @internal |
| 71 | */ |
| 72 | export const SamplingMessage = Schema.Struct({ |
| 73 | role: Previous.Role, |
| 74 | content: SamplingContent |
| 75 | }) |
| 76 | |
| 77 | /** |
| 78 | * @internal |
| 79 | */ |
| 80 | export const ToolAnnotations = Schema.Struct({ |
| 81 | title: optional(Schema.String), |
| 82 | readOnlyHint: optional(Schema.Boolean), |
| 83 | destructiveHint: optional(Schema.Boolean), |
| 84 | idempotentHint: optional(Schema.Boolean), |
| 85 | openWorldHint: optional(Schema.Boolean) |
| 86 | }) |
| 87 | |
| 88 | /** |
| 89 | * @internal |
| 90 | */ |
| 91 | export const Tool = Schema.Struct({ |
| 92 | ...Previous.Tool.fields, |
| 93 | annotations: optional(ToolAnnotations) |
| 94 | }) |
| 95 | |
| 96 | /** |
| 97 | * @internal |
| 98 | */ |
| 99 | export const InitializeResult = Schema.Struct({ |
| 100 | ...Previous.ResultMeta.fields, |
| 101 | protocolVersion: Schema.String, |
| 102 | capabilities: ServerCapabilities, |
| 103 | serverInfo: Previous.Implementation, |
| 104 | instructions: optional(Schema.String) |
| 105 | }) |
| 106 | |
| 107 | /** |
| 108 | * @internal |
| 109 | */ |
| 110 | export const GetPromptResult = Schema.Struct({ |
| 111 | ...Previous.ResultMeta.fields, |
| 112 | description: optional(Schema.String), |
| 113 | messages: Schema.Array(PromptMessage) |
| 114 | }) |
| 115 | |
| 116 | /** |
| 117 | * @internal |
| 118 | */ |
| 119 | export const ListToolsResult = Schema.Struct({ |
| 120 | ...Previous.PaginatedResult.fields, |
| 121 | tools: Schema.Array(Tool) |
| 122 | }) |
| 123 | |
| 124 | /** |
| 125 | * @internal |
| 126 | */ |
| 127 | export const CallToolResult = Schema.Struct({ |
| 128 | ...Previous.ResultMeta.fields, |
| 129 | content: Schema.Array(PromptOrToolContent), |
| 130 | isError: optional(Schema.Boolean) |
| 131 | }) |
| 132 | |
| 133 | /** |
| 134 | * @internal |
| 135 | */ |
| 136 | export const CreateMessageResult = Schema.Struct({ |
| 137 | ...Previous.ResultMeta.fields, |
| 138 | role: Previous.Role, |
| 139 | content: SamplingContent, |
| 140 | model: Schema.String, |
| 141 | stopReason: optional(Schema.String) |
| 142 | }) |
| 143 | |
| 144 | /** |
| 145 | * @internal |
| 146 | */ |
| 147 | export class Initialize extends Rpc.make("initialize", { |
| 148 | success: InitializeResult, |
| 149 | error: Previous.McpError, |
| 150 | payload: { |
| 151 | ...Previous.RequestMeta.fields, |
| 152 | protocolVersion: Schema.String, |
| 153 | capabilities: Previous.ClientCapabilities, |
| 154 | clientInfo: Previous.Implementation |
| 155 | } |
| 156 | }) {} |
| 157 | |
| 158 | /** |
| 159 | * @internal |
| 160 | */ |
| 161 | export class GetPrompt extends Rpc.make("prompts/get", { |
| 162 | success: GetPromptResult, |
| 163 | error: Previous.McpError, |
| 164 | payload: { |
| 165 | ...Previous.RequestMeta.fields, |
| 166 | name: Schema.String, |
| 167 | arguments: optional(Schema.Record(Schema.String, Schema.String)) |
| 168 | } |
| 169 | }) {} |
| 170 | |
| 171 | /** |
| 172 | * @internal |
| 173 | */ |
| 174 | export class ListTools extends Rpc.make("tools/list", { |
| 175 | success: ListToolsResult, |
| 176 | error: Previous.McpError, |
| 177 | payload: Schema.UndefinedOr(Previous.PaginatedRequest) |
| 178 | }) {} |
| 179 | |
| 180 | /** |
| 181 | * @internal |
| 182 | */ |
| 183 | export class CallTool extends Rpc.make("tools/call", { |
| 184 | success: CallToolResult, |
| 185 | error: Previous.McpError, |
| 186 | payload: { |
| 187 | ...Previous.RequestMeta.fields, |
| 188 | name: Schema.String, |
| 189 | arguments: optional(Schema.JsonObject) |
| 190 | } |
| 191 | }) {} |
| 192 | |
| 193 | /** |
| 194 | * @internal |
| 195 | */ |
| 196 | export class CreateMessage extends Rpc.make("sampling/createMessage", { |
| 197 | success: CreateMessageResult, |
| 198 | error: Previous.McpError, |
| 199 | payload: { |
| 200 | ...Previous.RequestMeta.fields, |
| 201 | messages: Schema.Array(SamplingMessage), |
| 202 | modelPreferences: optional(Previous.ModelPreferences), |
| 203 | systemPrompt: optional(Schema.String), |
| 204 | includeContext: optional(Schema.Literals(["none", "thisServer", "allServers"])), |
| 205 | temperature: optional(Schema.Finite), |
| 206 | maxTokens: Schema.Finite, |
| 207 | stopSequences: optional(Schema.Array(Schema.String)), |
| 208 | metadata: optional(Schema.JsonObject) |
| 209 | } |
| 210 | }) {} |
| 211 | |
| 212 | /** |
| 213 | * @internal |
| 214 | */ |
| 215 | export class ProgressNotification extends Rpc.make("notifications/progress", { |
| 216 | payload: { |
| 217 | ...Previous.NotificationMeta.fields, |
| 218 | progressToken: Previous.ProgressToken, |
| 219 | progress: Schema.Finite, |
| 220 | total: optional(Schema.Finite), |
| 221 | message: optional(Schema.String) |
| 222 | } |
| 223 | }) {} |
| 224 | |
| 225 | /** |
| 226 | * @internal |
| 227 | */ |
| 228 | export class ClientRequestRpcs extends RpcGroup.make( |
| 229 | Previous.Ping, |
| 230 | Initialize, |
| 231 | Previous.Complete, |
| 232 | Previous.SetLevel, |
| 233 | GetPrompt, |
| 234 | Previous.ListPrompts, |
| 235 | Previous.ListResources, |
| 236 | Previous.ListResourceTemplates, |
| 237 | Previous.ReadResource, |
| 238 | Previous.Subscribe, |
| 239 | Previous.Unsubscribe, |
| 240 | CallTool, |
| 241 | ListTools |
| 242 | ) {} |
| 243 | |
| 244 | /** |
| 245 | * @internal |
| 246 | */ |
| 247 | export class ClientNotificationRpcs extends RpcGroup.make( |
| 248 | Previous.CancelledNotification, |
| 249 | ProgressNotification, |
| 250 | Previous.InitializedNotification, |
| 251 | Previous.RootsListChangedNotification |
| 252 | ) {} |
| 253 | |
| 254 | /** |
| 255 | * @internal |
| 256 | */ |
| 257 | export class ServerRequestRpcs extends RpcGroup.make( |
| 258 | Previous.Ping, |
| 259 | CreateMessage, |
| 260 | Previous.ListRoots |
| 261 | ) {} |
| 262 | |
| 263 | /** |
| 264 | * @internal |
| 265 | */ |
| 266 | export class ServerNotificationRpcs extends RpcGroup.make( |
| 267 | Previous.CancelledNotification, |
| 268 | ProgressNotification, |
| 269 | Previous.LoggingMessageNotification, |
| 270 | Previous.ResourceUpdatedNotification, |
| 271 | Previous.ResourceListChangedNotification, |
| 272 | Previous.ToolListChangedNotification, |
| 273 | Previous.PromptListChangedNotification |
| 274 | ) {} |