This is page 6 of 11. Use http://codebase.md/tuananh/hyper-mcp?lines=true&page={x} to view the full context.
# Directory Structure
```
├── .cursor
│ └── rules
│ └── print-ctx-size.mdc
├── .dockerignore
├── .github
│ ├── renovate.json5
│ └── workflows
│ ├── ci.yml
│ ├── nightly.yml
│ └── release.yml
├── .gitignore
├── .gitmodules
├── .hadolint.yaml
├── .pre-commit-config.yaml
├── .windsurf
│ └── rules
│ ├── print-ctx-size.md
│ └── think.md
├── assets
│ ├── cursor-mcp-1.png
│ ├── cursor-mcp.png
│ ├── eval-py.jpg
│ └── logo.png
├── Cargo.lock
├── Cargo.toml
├── config.example.json
├── config.example.yaml
├── CREATING_PLUGINS.md
├── DEPLOYMENT.md
├── Dockerfile
├── examples
│ └── plugins
│ ├── v1
│ │ ├── arxiv
│ │ │ ├── .cargo
│ │ │ │ └── config.toml
│ │ │ ├── .gitignore
│ │ │ ├── Cargo.toml
│ │ │ ├── Dockerfile
│ │ │ ├── README.md
│ │ │ └── src
│ │ │ ├── lib.rs
│ │ │ └── pdk.rs
│ │ ├── context7
│ │ │ ├── .cargo
│ │ │ │ └── config.toml
│ │ │ ├── .gitignore
│ │ │ ├── Cargo.toml
│ │ │ ├── Dockerfile
│ │ │ ├── README.md
│ │ │ └── src
│ │ │ ├── lib.rs
│ │ │ └── pdk.rs
│ │ ├── crates-io
│ │ │ ├── .cargo
│ │ │ │ └── config.toml
│ │ │ ├── .gitignore
│ │ │ ├── Cargo.toml
│ │ │ ├── Dockerfile
│ │ │ ├── README.md
│ │ │ └── src
│ │ │ ├── lib.rs
│ │ │ └── pdk.rs
│ │ ├── crypto-price
│ │ │ ├── Dockerfile
│ │ │ ├── go.mod
│ │ │ ├── go.sum
│ │ │ ├── main.go
│ │ │ ├── pdk.gen.go
│ │ │ └── README.md
│ │ ├── eval-py
│ │ │ ├── .cargo
│ │ │ │ └── config.toml
│ │ │ ├── .gitignore
│ │ │ ├── Cargo.toml
│ │ │ ├── Dockerfile
│ │ │ ├── README.md
│ │ │ └── src
│ │ │ ├── lib.rs
│ │ │ └── pdk.rs
│ │ ├── fetch
│ │ │ ├── .cargo
│ │ │ │ └── config.toml
│ │ │ ├── .gitignore
│ │ │ ├── Cargo.toml
│ │ │ ├── Dockerfile
│ │ │ ├── README.md
│ │ │ └── src
│ │ │ ├── lib.rs
│ │ │ └── pdk.rs
│ │ ├── fs
│ │ │ ├── .cargo
│ │ │ │ └── config.toml
│ │ │ ├── .gitignore
│ │ │ ├── Cargo.toml
│ │ │ ├── Dockerfile
│ │ │ ├── README.md
│ │ │ └── src
│ │ │ ├── lib.rs
│ │ │ └── pdk.rs
│ │ ├── github
│ │ │ ├── .gitignore
│ │ │ ├── branches.go
│ │ │ ├── Dockerfile
│ │ │ ├── files.go
│ │ │ ├── gists.go
│ │ │ ├── go.mod
│ │ │ ├── go.sum
│ │ │ ├── issues.go
│ │ │ ├── main.go
│ │ │ ├── pdk.gen.go
│ │ │ ├── README.md
│ │ │ └── repo.go
│ │ ├── gitlab
│ │ │ ├── .cargo
│ │ │ │ └── config.toml
│ │ │ ├── .gitignore
│ │ │ ├── Cargo.toml
│ │ │ ├── Dockerfile
│ │ │ ├── README.md
│ │ │ └── src
│ │ │ ├── lib.rs
│ │ │ └── pdk.rs
│ │ ├── gomodule
│ │ │ ├── .cargo
│ │ │ │ └── config.toml
│ │ │ ├── .gitignore
│ │ │ ├── Cargo.toml
│ │ │ ├── Dockerfile
│ │ │ ├── README.md
│ │ │ └── src
│ │ │ ├── lib.rs
│ │ │ └── pdk.rs
│ │ ├── hash
│ │ │ ├── .gitignore
│ │ │ ├── Cargo.lock
│ │ │ ├── Cargo.toml
│ │ │ ├── Dockerfile
│ │ │ ├── README.md
│ │ │ └── src
│ │ │ ├── lib.rs
│ │ │ └── pdk.rs
│ │ ├── maven
│ │ │ ├── .cargo
│ │ │ │ └── config.toml
│ │ │ ├── .gitignore
│ │ │ ├── Cargo.toml
│ │ │ ├── Dockerfile
│ │ │ ├── README.md
│ │ │ └── src
│ │ │ ├── lib.rs
│ │ │ └── pdk.rs
│ │ ├── meme-generator
│ │ │ ├── .cargo
│ │ │ │ └── config.toml
│ │ │ ├── .gitignore
│ │ │ ├── Cargo.toml
│ │ │ ├── Dockerfile
│ │ │ ├── generate_embedded.py
│ │ │ ├── README.md
│ │ │ ├── src
│ │ │ │ ├── embedded.rs
│ │ │ │ ├── lib.rs
│ │ │ │ └── pdk.rs
│ │ │ └── templates.json
│ │ ├── memory
│ │ │ ├── .cargo
│ │ │ │ └── config.toml
│ │ │ ├── .gitignore
│ │ │ ├── Cargo.toml
│ │ │ ├── Dockerfile
│ │ │ ├── README.md
│ │ │ └── src
│ │ │ ├── lib.rs
│ │ │ └── pdk.rs
│ │ ├── myip
│ │ │ ├── .gitignore
│ │ │ ├── Cargo.lock
│ │ │ ├── Cargo.toml
│ │ │ ├── Dockerfile
│ │ │ ├── README.md
│ │ │ └── src
│ │ │ ├── lib.rs
│ │ │ └── pdk.rs
│ │ ├── qdrant
│ │ │ ├── .cargo
│ │ │ │ └── config.toml
│ │ │ ├── .gitignore
│ │ │ ├── Cargo.toml
│ │ │ ├── Dockerfile
│ │ │ ├── README.md
│ │ │ └── src
│ │ │ ├── lib.rs
│ │ │ ├── pdk.rs
│ │ │ └── qdrant_client.rs
│ │ ├── qr-code
│ │ │ ├── .gitignore
│ │ │ ├── Cargo.lock
│ │ │ ├── Cargo.toml
│ │ │ ├── Dockerfile
│ │ │ ├── README.md
│ │ │ └── src
│ │ │ ├── lib.rs
│ │ │ └── pdk.rs
│ │ ├── serper
│ │ │ ├── .cargo
│ │ │ │ └── config.toml
│ │ │ ├── .gitignore
│ │ │ ├── Cargo.toml
│ │ │ ├── Dockerfile
│ │ │ ├── README.md
│ │ │ └── src
│ │ │ ├── lib.rs
│ │ │ └── pdk.rs
│ │ ├── sqlite
│ │ │ ├── .cargo
│ │ │ │ └── config.toml
│ │ │ ├── .gitignore
│ │ │ ├── Cargo.toml
│ │ │ ├── Dockerfile
│ │ │ ├── README.md
│ │ │ └── src
│ │ │ ├── lib.rs
│ │ │ └── pdk.rs
│ │ ├── think
│ │ │ ├── .cargo
│ │ │ │ └── config.toml
│ │ │ ├── .gitignore
│ │ │ ├── Cargo.toml
│ │ │ ├── Dockerfile
│ │ │ ├── README.md
│ │ │ └── src
│ │ │ ├── lib.rs
│ │ │ └── pdk.rs
│ │ ├── time
│ │ │ ├── .cargo
│ │ │ │ └── config.toml
│ │ │ ├── .gitignore
│ │ │ ├── Cargo.toml
│ │ │ ├── Dockerfile
│ │ │ ├── README.md
│ │ │ ├── src
│ │ │ │ ├── lib.rs
│ │ │ │ └── pdk.rs
│ │ │ └── time.wasm
│ │ └── tool-list-changed
│ │ ├── .gitignore
│ │ ├── Cargo.toml
│ │ ├── Dockerfile
│ │ ├── README.md
│ │ ├── src
│ │ │ ├── lib.rs
│ │ │ └── pdk.rs
│ │ └── tool_list_changed.wasm
│ └── v2
│ └── rstime
│ ├── .cargo
│ │ └── config.toml
│ ├── .gitignore
│ ├── Cargo.toml
│ ├── Dockerfile
│ ├── README.md
│ ├── rstime.wasm
│ └── src
│ ├── lib.rs
│ └── pdk
│ ├── exports.rs
│ ├── imports.rs
│ ├── mod.rs
│ └── types.rs
├── iac
│ ├── .terraform.lock.hcl
│ ├── main.tf
│ ├── outputs.tf
│ └── variables.tf
├── justfile
├── LICENSE
├── README.md
├── RUNTIME_CONFIG.md
├── rust-toolchain.toml
├── server.json
├── SKIP_TOOLS_GUIDE.md
├── src
│ ├── cli.rs
│ ├── config.rs
│ ├── https_auth.rs
│ ├── logging.rs
│ ├── main.rs
│ ├── naming.rs
│ ├── plugin.rs
│ ├── service.rs
│ └── wasm
│ ├── http.rs
│ ├── mod.rs
│ ├── oci.rs
│ └── s3.rs
├── templates
│ └── plugins
│ ├── go
│ │ ├── .gitignore
│ │ ├── Dockerfile
│ │ ├── exports.go
│ │ ├── go.mod
│ │ ├── go.sum
│ │ ├── imports.go
│ │ ├── main.go
│ │ ├── README.md
│ │ └── types.go
│ ├── README.md
│ └── rust
│ ├── .cargo
│ │ └── config.toml
│ ├── .gitignore
│ ├── Cargo.toml
│ ├── Dockerfile
│ ├── README.md
│ └── src
│ ├── lib.rs
│ └── pdk
│ ├── exports.rs
│ ├── imports.rs
│ ├── mod.rs
│ └── types.rs
├── tests
│ └── fixtures
│ ├── config_with_auths.json
│ ├── config_with_auths.yaml
│ ├── documentation_example.json
│ ├── documentation_example.yaml
│ ├── invalid_auth_config.yaml
│ ├── invalid_plugin_name.yaml
│ ├── invalid_structure.yaml
│ ├── invalid_url.yaml
│ ├── keyring_auth_config.yaml
│ ├── skip_tools_examples.yaml
│ ├── unsupported_config.txt
│ ├── valid_config.json
│ └── valid_config.yaml
└── xtp-plugin-schema.json
```
# Files
--------------------------------------------------------------------------------
/templates/plugins/go/types.go:
--------------------------------------------------------------------------------
```go
1 | package main
2 |
3 | import (
4 | "encoding/json"
5 | "fmt"
6 | "time"
7 | )
8 |
9 | // Annotations represents metadata annotations for resources and content
10 | type Annotations struct {
11 | Audience []Role `json:"audience,omitempty"`
12 | LastModified *time.Time `json:"lastModified,omitempty"`
13 | Priority float32 `json:"priority,omitempty"`
14 | }
15 |
16 | // AudioContent represents audio content in a message
17 | type AudioContent struct {
18 | Meta Meta `json:"_meta,omitempty"`
19 | Annotations *Annotations `json:"annotations,omitempty"`
20 | Data string `json:"data"`
21 | MimeType string `json:"mimeType"`
22 | }
23 |
24 | func (a AudioContent) MarshalJSON() ([]byte, error) {
25 | type alias AudioContent
26 | return json.Marshal(&struct {
27 | Type string `json:"type"`
28 | alias
29 | }{
30 | Type: "audio",
31 | alias: (alias)(a),
32 | })
33 | }
34 |
35 | func (a *AudioContent) UnmarshalJSON(data []byte) error {
36 | type alias AudioContent
37 | aux := struct {
38 | Type string `json:"type"`
39 | alias
40 | }{}
41 |
42 | if err := json.Unmarshal(data, &aux); err != nil {
43 | return err
44 | }
45 |
46 | // Optional: validate `type`
47 | if aux.Type != "audio" && aux.Type != "" { // allow empty if missing
48 | return fmt.Errorf("invalid type %q, expected \"audio\"", aux.Type)
49 | }
50 |
51 | *a = AudioContent(aux.alias)
52 | return nil
53 | }
54 |
55 | // BlobResourceContents represents binary resource contents
56 | type BlobResourceContents struct {
57 | Meta Meta `json:"_meta,omitempty"`
58 | Blob string `json:"blob"`
59 | MimeType *string `json:"mimeType,omitempty"`
60 | URI string `json:"uri"`
61 | }
62 |
63 | // BooleanSchema represents a boolean input schema
64 | type BooleanSchema struct {
65 | Default *bool `json:"default,omitempty"`
66 | Description *string `json:"description,omitempty"`
67 | Title *string `json:"title,omitempty"`
68 | }
69 |
70 | func (b BooleanSchema) MarshalJSON() ([]byte, error) {
71 | type alias BooleanSchema
72 | return json.Marshal(&struct {
73 | Type string `json:"type"`
74 | alias
75 | }{
76 | Type: "boolean",
77 | alias: (alias)(b),
78 | })
79 | }
80 |
81 | func (b *BooleanSchema) UnmarshalJSON(data []byte) error {
82 | type alias BooleanSchema
83 | aux := struct {
84 | Type string `json:"type"`
85 | alias
86 | }{}
87 |
88 | if err := json.Unmarshal(data, &aux); err != nil {
89 | return err
90 | }
91 |
92 | // Optional: validate `type`
93 | if aux.Type != "boolean" && aux.Type != "" { // allow empty if missing
94 | return fmt.Errorf("invalid type %q, expected \"boolean\"", aux.Type)
95 | }
96 |
97 | *b = BooleanSchema(aux.alias)
98 | return nil
99 | }
100 |
101 | // CallToolRequest represents a request to call a tool
102 | type CallToolRequest struct {
103 | Context PluginRequestContext `json:"context"`
104 | Request CallToolRequestParam `json:"request"`
105 | }
106 |
107 | // CallToolRequestParam represents parameters for calling a tool
108 | type CallToolRequestParam struct {
109 | Arguments map[string]any `json:"arguments,omitempty"`
110 | Name string `json:"name"`
111 | }
112 |
113 | // CallToolResult represents the result of calling a tool
114 | type CallToolResult struct {
115 | Meta Meta `json:"_meta,omitempty"`
116 | Content []ContentBlock `json:"content"`
117 | IsError *bool `json:"isError,omitempty"`
118 | StructuredContent map[string]any `json:"structuredContent,omitempty"`
119 | }
120 |
121 | // CompleteRequest represents a request for completion suggestions
122 | type CompleteRequest struct {
123 | Context PluginRequestContext `json:"context"`
124 | Request CompleteRequestParam `json:"request"`
125 | }
126 |
127 | // CompleteRequestParam represents parameters for completion
128 | type CompleteRequestParam struct {
129 | Argument CompleteRequestParamArgument `json:"argument"`
130 | Context *CompleteRequestParamContext `json:"context,omitempty"`
131 | Ref Reference `json:"ref"`
132 | }
133 |
134 | // CompleteRequestParamArgument represents an argument for completion
135 | type CompleteRequestParamArgument struct {
136 | Name string `json:"name"`
137 | Value string `json:"value"`
138 | }
139 |
140 | // CompleteRequestParamContext represents context for completion
141 | type CompleteRequestParamContext struct {
142 | Arguments map[string]string `json:"arguments,omitempty"`
143 | }
144 |
145 | // CompleteResult represents completion suggestions
146 | type CompleteResult struct {
147 | Completion CompleteResultCompletion `json:"completion"`
148 | }
149 |
150 | // CompleteResultCompletion represents completion values
151 | type CompleteResultCompletion struct {
152 | HasMore *bool `json:"hasMore,omitempty"`
153 | Total *int64 `json:"total,omitempty"`
154 | Values []string `json:"values"`
155 | }
156 |
157 | type ContentBlock struct {
158 | Audio *AudioContent
159 | EmbeddedResource *EmbeddedResource
160 | Image *ImageContent
161 | ResourceLink *ResourceLinkContent
162 | Text *TextContent
163 | }
164 |
165 | func (c ContentBlock) MarshalJSON() ([]byte, error) {
166 | switch {
167 | case c.Audio != nil:
168 | return json.Marshal(c.Audio)
169 | case c.EmbeddedResource != nil:
170 | return json.Marshal(c.EmbeddedResource)
171 | case c.Image != nil:
172 | return json.Marshal(c.Image)
173 | case c.ResourceLink != nil:
174 | return json.Marshal(c.ResourceLink)
175 | case c.Text != nil:
176 | return json.Marshal(c.Text)
177 | default:
178 | return nil, fmt.Errorf("empty ContentItem")
179 | }
180 | }
181 |
182 | func (c *ContentBlock) UnmarshalJSON(data []byte) error {
183 | var head struct {
184 | Type string `json:"type"`
185 | }
186 | if err := json.Unmarshal(data, &head); err != nil {
187 | return err
188 | }
189 |
190 | switch head.Type {
191 | case "audio":
192 | var a AudioContent
193 | if err := json.Unmarshal(data, &a); err != nil {
194 | return err
195 | }
196 | c.Audio = &a
197 | case "resource":
198 | var r EmbeddedResource
199 | if err := json.Unmarshal(data, &r); err != nil {
200 | return err
201 | }
202 | c.EmbeddedResource = &r
203 | case "image":
204 | var i ImageContent
205 | if err := json.Unmarshal(data, &i); err != nil {
206 | return err
207 | }
208 | c.Image = &i
209 | case "resource_link":
210 | var rl ResourceLinkContent
211 | if err := json.Unmarshal(data, &rl); err != nil {
212 | return err
213 | }
214 | c.ResourceLink = &rl
215 | case "text":
216 | var t TextContent
217 | if err := json.Unmarshal(data, &t); err != nil {
218 | return err
219 | }
220 | c.Text = &t
221 | default:
222 | return fmt.Errorf("unknown content type %q", head.Type)
223 | }
224 |
225 | return nil
226 | }
227 |
228 | // CreateMessageRequestParam represents a request to create a message
229 | type CreateMessageRequestParam struct {
230 | IncludeContext *CreateMessageRequestParamIncludeContext `json:"includeContext,omitempty"`
231 | MaxTokens int64 `json:"maxTokens"`
232 | Messages []SamplingMessage `json:"messages"`
233 | ModelPreferences *ModelPreferences `json:"modelPreferences,omitempty"`
234 | StopSequences []string `json:"stopSequences,omitempty"`
235 | SystemPrompt *string `json:"systemPrompt,omitempty"`
236 | Temperature *float64 `json:"temperature,omitempty"`
237 | }
238 |
239 | // CreateMessageRequestParamIncludeContext represents context inclusion options
240 | type CreateMessageRequestParamIncludeContext string
241 |
242 | const (
243 | AllServers CreateMessageRequestParamIncludeContext = "allServers"
244 | None CreateMessageRequestParamIncludeContext = "none"
245 | ThisServer CreateMessageRequestParamIncludeContext = "thisServer"
246 | )
247 |
248 | func (t *CreateMessageRequestParamIncludeContext) UnmarshalJSON(data []byte) error {
249 | var s string
250 | if err := json.Unmarshal(data, &s); err != nil {
251 | return err
252 | }
253 |
254 | ct := CreateMessageRequestParamIncludeContext(s)
255 | if !ct.Valid() {
256 | return fmt.Errorf("invalid CreateMessageRequestParamIncludeContext %q", s)
257 | }
258 |
259 | *t = ct
260 | return nil
261 | }
262 |
263 | func (t CreateMessageRequestParamIncludeContext) Valid() bool {
264 | switch t {
265 | case AllServers, None, ThisServer:
266 | return true
267 | default:
268 | return false
269 | }
270 | }
271 |
272 | // CreateMessageResult represents the result of creating a message
273 | type CreateMessageResult struct {
274 | Content CreateMessageResultContent `json:"content"`
275 | Model string `json:"model"`
276 | Role Role `json:"role"`
277 | StopReason *string `json:"stopReason,omitempty"`
278 | }
279 |
280 | type CreateMessageResultContent SamplingMessage
281 |
282 | // ElicitRequestParamWithTimeout represents a request for user elicitation
283 | type ElicitRequestParamWithTimeout struct {
284 | Message string `json:"message"`
285 | RequestedSchema Schema `json:"requestedSchema"`
286 | Timeout *int64 `json:"timeout,omitempty"`
287 | }
288 |
289 | // ElicitResult represents the result of an elicitation
290 | type ElicitResult struct {
291 | Action ElicitResultAction `json:"action"`
292 | Content map[string]ElicitResultContentValue `json:"content,omitempty"`
293 | }
294 |
295 | // ElicitResultAction represents the action taken in elicitation
296 | type ElicitResultAction string
297 |
298 | const (
299 | Accept ElicitResultAction = "accept"
300 | Cancel ElicitResultAction = "cancel"
301 | Decline ElicitResultAction = "decline"
302 | )
303 |
304 | func (e *ElicitResultAction) UnmarshalJSON(data []byte) error {
305 | var s string
306 | if err := json.Unmarshal(data, &s); err != nil {
307 | return err
308 | }
309 |
310 | ea := ElicitResultAction(s)
311 | if !ea.Valid() {
312 | return fmt.Errorf("invalid ElicitResultAction %q", s)
313 | }
314 |
315 | *e = ea
316 | return nil
317 | }
318 |
319 | func (e ElicitResultAction) Valid() bool {
320 | switch e {
321 | case Accept, Cancel, Decline:
322 | return true
323 | default:
324 | return false
325 | }
326 | }
327 |
328 | type ElicitResultContentValue struct {
329 | String *string
330 | Number *json.Number
331 | Boolean *bool
332 | }
333 |
334 | func (v ElicitResultContentValue) MarshalJSON() ([]byte, error) {
335 | switch {
336 | case v.String != nil:
337 | return json.Marshal(v.String)
338 | case v.Number != nil:
339 | return json.Marshal(v.Number)
340 | case v.Boolean != nil:
341 | return json.Marshal(v.Boolean)
342 | default:
343 | return nil, fmt.Errorf("ElicitResultContentValue has no value set")
344 | }
345 | }
346 |
347 | func (v *ElicitResultContentValue) UnmarshalJSON(data []byte) error {
348 | // Clear existing values
349 | *v = ElicitResultContentValue{}
350 |
351 | // Try string first
352 | var s string
353 | if err := json.Unmarshal(data, &s); err == nil {
354 | v.String = &s
355 | return nil
356 | }
357 |
358 | // Then bool
359 | var b bool
360 | if err := json.Unmarshal(data, &b); err == nil {
361 | v.Boolean = &b
362 | return nil
363 | }
364 |
365 | // Then number
366 | var n json.Number
367 | if err := json.Unmarshal(data, &n); err == nil {
368 | v.Number = &n
369 | return nil
370 | }
371 |
372 | // If all fail, it's not a valid primitive for this type
373 | return fmt.Errorf("ElicitResultContentValue: unsupported JSON value: %s", string(data))
374 | }
375 |
376 | // EmbeddedResource represents an embedded resource
377 | type EmbeddedResource struct {
378 | Meta Meta `json:"_meta,omitempty"`
379 | Annotations *Annotations `json:"annotations,omitempty"`
380 | Resource ResourceContents `json:"resource"`
381 | }
382 |
383 | func (e EmbeddedResource) MarshalJSON() ([]byte, error) {
384 | type alias EmbeddedResource
385 |
386 | return json.Marshal(&struct {
387 | Type string `json:"type"`
388 | alias
389 | }{
390 | Type: "resource",
391 | alias: (alias)(e),
392 | })
393 | }
394 |
395 | func (e *EmbeddedResource) UnmarshalJSON(data []byte) error {
396 | type alias EmbeddedResource
397 | aux := struct {
398 | Type string `json:"type"`
399 | alias
400 | }{}
401 |
402 | if err := json.Unmarshal(data, &aux); err != nil {
403 | return err
404 | }
405 |
406 | if aux.Type != "resource" && aux.Type != "" {
407 | return fmt.Errorf("invalid type %q, expected \"resource\"", aux.Type)
408 | }
409 |
410 | *e = EmbeddedResource(aux.alias)
411 | return nil
412 | }
413 |
414 | // EnumSchema represents an enum input schema
415 | type EnumSchema struct {
416 | Description *string `json:"description,omitempty"`
417 | Enum []string `json:"enum"`
418 | EnumNames []string `json:"enumNames,omitempty"`
419 | Title *string `json:"title,omitempty"`
420 | }
421 |
422 | func (e EnumSchema) MarshallJSON() ([]byte, error) {
423 | type alias EnumSchema
424 |
425 | return json.Marshal(&struct {
426 | Type string `json:"type"`
427 | alias
428 | }{
429 | Type: "resource",
430 | alias: (alias)(e),
431 | })
432 | }
433 |
434 | func (e *EnumSchema) UnmarshalJSON(data []byte) error {
435 | type alias EnumSchema
436 | aux := struct {
437 | Type string `json:"type"`
438 | alias
439 | }{}
440 |
441 | if err := json.Unmarshal(data, &aux); err != nil {
442 | return err
443 | }
444 |
445 | if aux.Type != "string" && aux.Type != "" {
446 | return fmt.Errorf("invalid type %q, expected \"string\"", aux.Type)
447 | }
448 |
449 | *e = EnumSchema(aux.alias)
450 | return nil
451 | }
452 |
453 | // GetPromptRequest represents a request to get a prompt
454 | type GetPromptRequest struct {
455 | Context PluginRequestContext `json:"context"`
456 | Request GetPromptRequestParam `json:"request"`
457 | }
458 |
459 | // GetPromptRequestParam represents parameters for getting a prompt
460 | type GetPromptRequestParam struct {
461 | Arguments map[string]string `json:"arguments,omitempty"`
462 | Name string `json:"name"`
463 | }
464 |
465 | // GetPromptResult represents the result of getting a prompt
466 | type GetPromptResult struct {
467 | Description *string `json:"description,omitempty"`
468 | Messages []PromptMessage `json:"messages"`
469 | }
470 |
471 | // ImageContent represents image content
472 | type ImageContent struct {
473 | Meta Meta `json:"_meta,omitempty"`
474 | Annotations *Annotations `json:"annotations,omitempty"`
475 | Data string `json:"data"`
476 | MimeType string `json:"mimeType"`
477 | }
478 |
479 | func (i ImageContent) MarshallJSON() ([]byte, error) {
480 | type alias ImageContent
481 |
482 | return json.Marshal(&struct {
483 | Type string `json:"type"`
484 | alias
485 | }{
486 | Type: "image",
487 | alias: (alias)(i),
488 | })
489 | }
490 |
491 | func (i *ImageContent) UnmarshalJSON(data []byte) error {
492 | type alias ImageContent
493 | aux := struct {
494 | Type string `json:"type"`
495 | alias
496 | }{}
497 |
498 | if err := json.Unmarshal(data, &aux); err != nil {
499 | return err
500 | }
501 |
502 | if aux.Type != "image" && aux.Type != "" { // allow empty if missing
503 | return fmt.Errorf("invalid type %q, expected \"image\"", aux.Type)
504 | }
505 |
506 | *i = ImageContent(aux.alias)
507 | return nil
508 | }
509 |
510 | // ListPromptsRequest represents a request to list prompts
511 | type ListPromptsRequest struct {
512 | Context PluginRequestContext `json:"context"`
513 | }
514 |
515 | // ListPromptsResult represents the result of listing prompts
516 | type ListPromptsResult struct {
517 | Prompts []Prompt `json:"prompts"`
518 | }
519 |
520 | // ListResourcesRequest represents a request to list resources
521 | type ListResourcesRequest struct {
522 | Context PluginRequestContext `json:"context"`
523 | }
524 |
525 | // ListResourcesResult represents the result of listing resources
526 | type ListResourcesResult struct {
527 | Resources []Resource `json:"resources"`
528 | }
529 |
530 | // ListResourceTemplatesRequest represents a request to list resource templates
531 | type ListResourceTemplatesRequest struct {
532 | Context PluginRequestContext `json:"context"`
533 | }
534 |
535 | // ListResourceTemplatesResult represents the result of listing resource templates
536 | type ListResourceTemplatesResult struct {
537 | ResourceTemplates []ResourceTemplate `json:"resourceTemplates"`
538 | }
539 |
540 | // ListRootsResult represents the result of listing roots
541 | type ListRootsResult struct {
542 | Roots []Root `json:"roots"`
543 | }
544 |
545 | // ListToolsRequest represents a request to list tools
546 | type ListToolsRequest struct {
547 | Context PluginRequestContext `json:"context"`
548 | }
549 |
550 | // ListToolsResult represents the result of listing tools
551 | type ListToolsResult struct {
552 | Tools []Tool `json:"tools"`
553 | }
554 |
555 | // LoggingLevel represents the severity level of a log message
556 | type LoggingLevel string
557 |
558 | const (
559 | Debug LoggingLevel = "debug"
560 | Info LoggingLevel = "info"
561 | Notice LoggingLevel = "notice"
562 | Warning LoggingLevel = "warning"
563 | Error LoggingLevel = "error"
564 | Critical LoggingLevel = "critical"
565 | Alert LoggingLevel = "alert"
566 | Emergency LoggingLevel = "emergency"
567 | )
568 |
569 | func (l *LoggingLevel) UnmarshalJSON(data []byte) error {
570 | var s string
571 | if err := json.Unmarshal(data, &s); err != nil {
572 | return err
573 | }
574 |
575 | ll := LoggingLevel(s)
576 | if !ll.Validate() {
577 | return fmt.Errorf("invalid LoggingLevel %q", s)
578 | }
579 |
580 | *l = ll
581 | return nil
582 | }
583 |
584 | func (l LoggingLevel) Validate() bool {
585 | switch l {
586 | case Debug, Info, Notice, Warning, Error, Critical, Alert, Emergency:
587 | return true
588 | default:
589 | return false
590 | }
591 | }
592 |
593 | // LoggingMessageNotificationParam represents a logging message notification
594 | type LoggingMessageNotificationParam struct {
595 | Data any `json:"data"`
596 | Level LoggingLevel `json:"level"`
597 | Logger *string `json:"logger,omitempty"`
598 | }
599 |
600 | // Meta represents metadata as a generic JSON object
601 | type Meta map[string]any
602 |
603 | // ModelHint represents a hint for model selection
604 | type ModelHint struct {
605 | Name string `json:"name"`
606 | }
607 |
608 | // ModelPreferences represents preferences for model selection
609 | type ModelPreferences struct {
610 | CostPriority float32 `json:"costPriority,omitempty"`
611 | Hints []ModelHint `json:"hints,omitempty"`
612 | IntelligencePriority float32 `json:"intelligencePriority,omitempty"`
613 | SpeedPriority float32 `json:"speedPriority,omitempty"`
614 | }
615 |
616 | // NumberSchema represents a number input schema
617 | type NumberSchema struct {
618 | Description *string `json:"description,omitempty"`
619 | Maximum *float64 `json:"maximum,omitempty"`
620 | Minimum *float64 `json:"minimum,omitempty"`
621 | Title *string `json:"title,omitempty"`
622 | Type NumberType `json:"type"` // "number" or "integer"
623 | }
624 |
625 | // NumberType represents the type of a number schema
626 | type NumberType string
627 |
628 | const (
629 | Number NumberType = "number"
630 | Integer NumberType = "integer"
631 | )
632 |
633 | func (n *NumberType) UnmarshalJSON(data []byte) error {
634 | var s string
635 | if err := json.Unmarshal(data, &s); err != nil {
636 | return err
637 | }
638 |
639 | nt := NumberType(s)
640 | if !nt.Valid() {
641 | return fmt.Errorf("invalid NumberType %q", s)
642 | }
643 |
644 | *n = nt
645 | return nil
646 | }
647 |
648 | func (n NumberType) Valid() bool {
649 | switch n {
650 | case Number, Integer:
651 | return true
652 | default:
653 | return false
654 | }
655 | }
656 |
657 | // PluginNotificationContext represents the context for a plugin notification
658 | type PluginNotificationContext struct {
659 | Meta Meta `json:"meta"`
660 | }
661 |
662 | // PluginRequestContext represents the context for a plugin request
663 | type PluginRequestContext struct {
664 | Meta Meta `json:"_meta"`
665 | ID PluginRequestId `json:"id"`
666 | }
667 |
668 | type PluginRequestId struct {
669 | String *string
670 | Number *int64
671 | }
672 |
673 | func (p PluginRequestId) MarshalJSON() ([]byte, error) {
674 | switch {
675 | case p.String != nil:
676 | return json.Marshal(p.String)
677 | case p.Number != nil:
678 | return json.Marshal(p.Number)
679 | default:
680 | return nil, fmt.Errorf("empty PluginRequestId")
681 | }
682 | }
683 |
684 | func (p *PluginRequestId) UnmarshalJSON(data []byte) error {
685 | *p = PluginRequestId{}
686 |
687 | // Try string first
688 | var s string
689 | if err := json.Unmarshal(data, &s); err == nil {
690 | p.String = &s
691 | return nil
692 | }
693 |
694 | // Then number
695 | var n int64
696 | if err := json.Unmarshal(data, &n); err == nil {
697 | p.Number = &n
698 | return nil
699 | }
700 |
701 | // If all fail, it's not a valid primitive for this type
702 | return fmt.Errorf("PluginRequestId: unsupported JSON value: %s", string(data))
703 | }
704 |
705 | // PrimitiveSchemaDefinition is a union type for schema definitions
706 | type PrimitiveSchemaDefinition struct {
707 | Boolean *BooleanSchema
708 | Enum *EnumSchema
709 | Number *NumberSchema
710 | String *StringSchema
711 | }
712 |
713 | func (p PrimitiveSchemaDefinition) MarshalJSON() ([]byte, error) {
714 | switch {
715 | case p.Boolean != nil:
716 | return json.Marshal(p.Boolean)
717 | case p.Enum != nil:
718 | return json.Marshal(p.Enum)
719 | case p.Number != nil:
720 | return json.Marshal(p.Number)
721 | case p.String != nil:
722 | return json.Marshal(p.String)
723 | default:
724 | return nil, fmt.Errorf("empty PrimitiveSchemaDefinition")
725 | }
726 | }
727 |
728 | func (p *PrimitiveSchemaDefinition) UnmarshalJSON(data []byte) error {
729 | var head struct {
730 | Type string `json:"type"`
731 | }
732 | if err := json.Unmarshal(data, &head); err != nil {
733 | return err
734 | }
735 |
736 | switch head.Type {
737 | case "boolean":
738 | var b BooleanSchema
739 | if err := json.Unmarshal(data, &b); err != nil {
740 | return err
741 | }
742 | p.Boolean = &b
743 | case "string":
744 | var e EnumSchema
745 | if err := json.Unmarshal(data, &e); err != nil {
746 | var s StringSchema
747 | if err := json.Unmarshal(data, &s); err != nil {
748 | return err
749 | }
750 | p.String = &s
751 | } else {
752 | p.Enum = &e
753 | }
754 | case "number", "integer":
755 | var n NumberSchema
756 | if err := json.Unmarshal(data, &n); err != nil {
757 | return err
758 | }
759 | p.Number = &n
760 | }
761 |
762 | return nil
763 | }
764 |
765 | // ProgressNotificationParam represents a progress notification
766 | type ProgressNotificationParam struct {
767 | Message *string `json:"message,omitempty"`
768 | Progress float64 `json:"progress"`
769 | ProgressToken string `json:"progressToken"`
770 | Total *float64 `json:"total,omitempty"`
771 | }
772 |
773 | // Prompt represents a prompt
774 | type Prompt struct {
775 | Arguments []PromptArgument `json:"arguments,omitempty"`
776 | Description *string `json:"description,omitempty"`
777 | Name string `json:"name"`
778 | Title *string `json:"title,omitempty"`
779 | }
780 |
781 | // PromptArgument represents an argument for a prompt
782 | type PromptArgument struct {
783 | Description *string `json:"description,omitempty"`
784 | Name string `json:"name"`
785 | Required *bool `json:"required,omitempty"`
786 | Title *string `json:"title,omitempty"`
787 | }
788 |
789 | // PromptMessage represents a message in a prompt
790 | type PromptMessage struct {
791 | Content ContentBlock `json:"content"`
792 | Role Role `json:"role"`
793 | }
794 |
795 | // PromptReference represents a reference to a prompt
796 | type PromptReference struct {
797 | Name string `json:"name"`
798 | Title *string `json:"title,omitempty"`
799 | }
800 |
801 | func (p PromptReference) MarshalJSON() ([]byte, error) {
802 | type alias PromptReference
803 | return json.Marshal(&struct {
804 | Type string `json:"type"`
805 | alias
806 | }{
807 | Type: "prompt",
808 | alias: (alias)(p),
809 | })
810 | }
811 |
812 | func (p *PromptReference) UnmarshalJSON(data []byte) error {
813 | type alias PromptReference
814 | aux := struct {
815 | Type string `json:"type"`
816 | alias
817 | }{}
818 |
819 | if err := json.Unmarshal(data, &aux); err != nil {
820 | return err
821 | }
822 |
823 | if aux.Type != "prompt" && aux.Type != "" { // allow empty if missing
824 | return fmt.Errorf("invalid type %q, expected \"prompt\"", aux.Type)
825 | }
826 |
827 | *p = PromptReference(aux.alias)
828 | return nil
829 | }
830 |
831 | // ReadResourceRequest represents a request to read a resource
832 | type ReadResourceRequest struct {
833 | Context PluginRequestContext `json:"context"`
834 | Request ReadResourceRequestParam `json:"request"`
835 | }
836 |
837 | // ReadResourceRequestParam represents parameters for reading a resource
838 | type ReadResourceRequestParam struct {
839 | URI string `json:"uri"`
840 | }
841 |
842 | // ReadResourceResult represents the result of reading a resource
843 | type ReadResourceResult struct {
844 | Contents []ResourceContents `json:"contents"`
845 | }
846 |
847 | type Reference struct {
848 | Prompt *PromptReference
849 | ResourceTemplate *ResourceTemplateReference
850 | }
851 |
852 | func (r Reference) MarshalJSON() ([]byte, error) {
853 | switch {
854 | case r.Prompt != nil:
855 | return json.Marshal(r.Prompt)
856 | case r.ResourceTemplate != nil:
857 | return json.Marshal(r.ResourceTemplate)
858 | default:
859 | return nil, fmt.Errorf("empty Reference")
860 | }
861 | }
862 |
863 | func (r *Reference) UnmarshalJSON(data []byte) error {
864 | var head struct {
865 | Type string `json:"type"`
866 | }
867 | if err := json.Unmarshal(data, &head); err != nil {
868 | return err
869 | }
870 |
871 | switch head.Type {
872 | case "prompt":
873 | var p PromptReference
874 | if err := json.Unmarshal(data, &p); err != nil {
875 | return err
876 | }
877 | r.Prompt = &p
878 | case "resource":
879 | var rt ResourceTemplateReference
880 | if err := json.Unmarshal(data, &rt); err != nil {
881 | return err
882 | }
883 | r.ResourceTemplate = &rt
884 | default:
885 | return fmt.Errorf("unknown reference type %q", head.Type)
886 | }
887 |
888 | return nil
889 | }
890 |
891 | // Resource represents a resource
892 | type Resource struct {
893 | Annotations *Annotations `json:"annotations,omitempty"`
894 | Description *string `json:"description,omitempty"`
895 | MimeType *string `json:"mimeType,omitempty"`
896 | Name string `json:"name"`
897 | Size *int64 `json:"size,omitempty"`
898 | Title *string `json:"title,omitempty"`
899 | URI string `json:"uri"`
900 | }
901 |
902 | type ResourceContents struct {
903 | Blob *BlobResourceContents
904 | Text *TextResourceContents
905 | }
906 |
907 | func (R ResourceContents) MarshalJSON() ([]byte, error) {
908 | switch {
909 | case R.Blob != nil:
910 | return json.Marshal(R.Blob)
911 | case R.Text != nil:
912 | return json.Marshal(R.Text)
913 | default:
914 | return nil, fmt.Errorf("empty ResourceContents")
915 | }
916 | }
917 |
918 | func (r *ResourceContents) UnmarshalJSON(data []byte) error {
919 | // Clear existing values
920 | *r = ResourceContents{}
921 |
922 | // Try blob first
923 | var b BlobResourceContents
924 | if err := json.Unmarshal(data, &b); err == nil {
925 | r.Blob = &b
926 | return nil
927 | }
928 |
929 | // Then text
930 | var t TextResourceContents
931 | if err := json.Unmarshal(data, &t); err == nil {
932 | r.Text = &t
933 | return nil
934 | }
935 |
936 | // If all fail, it's not a valid ResourceContents
937 | return fmt.Errorf("ResourceContents: unsupported JSON value: %s", string(data))
938 | }
939 |
940 | // ResourceLinkContent represents a link to a resource
941 | type ResourceLinkContent struct {
942 | Meta Meta `json:"_meta,omitempty"`
943 | Annotations *Annotations `json:"annotations,omitempty"`
944 | Description *string `json:"description,omitempty"`
945 | MimeType *string `json:"mimeType,omitempty"`
946 | Name string `json:"name"`
947 | Size *int64 `json:"size,omitempty"`
948 | Title *string `json:"title,omitempty"`
949 | URI string `json:"uri"`
950 | }
951 |
952 | func (r ResourceLinkContent) MarshallJSON() ([]byte, error) {
953 | type alias ResourceLinkContent
954 | return json.Marshal(&struct {
955 | Type string `json:"type"`
956 | alias
957 | }{
958 | Type: "resource_link",
959 | alias: (alias)(r),
960 | })
961 | }
962 |
963 | func (r *ResourceLinkContent) UnmarshalJSON(data []byte) error {
964 | type alias ResourceLinkContent
965 | aux := struct {
966 | Type string `json:"type"`
967 | alias
968 | }{}
969 |
970 | if err := json.Unmarshal(data, &aux); err != nil {
971 | return err
972 | }
973 |
974 | if aux.Type != "resource_link" && aux.Type != "" { // allow empty if missing
975 | return fmt.Errorf("invalid type %q, expected \"resource_link\"", aux.Type)
976 | }
977 |
978 | *r = ResourceLinkContent(aux.alias)
979 | return nil
980 | }
981 |
982 | // ResourceTemplate represents a resource template
983 | type ResourceTemplate struct {
984 | Annotations *Annotations `json:"annotations,omitempty"`
985 | Description *string `json:"description,omitempty"`
986 | MimeType *string `json:"mimeType,omitempty"`
987 | Name string `json:"name"`
988 | Title *string `json:"title,omitempty"`
989 | URITemplate string `json:"uriTemplate"`
990 | }
991 |
992 | // ResourceTemplateReference represents a reference to a resource template
993 | type ResourceTemplateReference struct {
994 | URI string `json:"uri"`
995 | }
996 |
997 | func (r ResourceTemplateReference) MarshallJSON() ([]byte, error) {
998 | type alias ResourceTemplateReference
999 | return json.Marshal(&struct {
1000 | Type string `json:"type"`
1001 | alias
1002 | }{
1003 | Type: "resource",
1004 | alias: (alias)(r),
1005 | })
1006 | }
1007 |
1008 | func (r *ResourceTemplateReference) UnmarshalJSON(data []byte) error {
1009 | type alias ResourceTemplateReference
1010 | aux := struct {
1011 | Type string `json:"type"`
1012 | alias
1013 | }{}
1014 |
1015 | if err := json.Unmarshal(data, &aux); err != nil {
1016 | return err
1017 | }
1018 |
1019 | if aux.Type != "resource" && aux.Type != "" { // allow empty if missing
1020 | return fmt.Errorf("invalid type %q, expected \"resource\"", aux.Type)
1021 | }
1022 |
1023 | *r = ResourceTemplateReference(aux.alias)
1024 | return nil
1025 | }
1026 |
1027 | // ResourceUpdatedNotificationParam represents a resource update notification
1028 | type ResourceUpdatedNotificationParam struct {
1029 | URI string `json:"uri"`
1030 | }
1031 |
1032 | // Role represents the role of a message sender
1033 | type Role string
1034 |
1035 | const (
1036 | Assistant Role = "assistant"
1037 | User Role = "user"
1038 | )
1039 |
1040 | func (r *Role) UnmarshalJSON(data []byte) error {
1041 | var s string
1042 | if err := json.Unmarshal(data, &s); err != nil {
1043 | return err
1044 | }
1045 |
1046 | rr := Role(s)
1047 | if !rr.Valid() {
1048 | return fmt.Errorf("invalid Role %q", s)
1049 | }
1050 |
1051 | *r = rr
1052 | return nil
1053 | }
1054 |
1055 | func (r Role) Valid() bool {
1056 | switch r {
1057 | case Assistant, User:
1058 | return true
1059 | default:
1060 | return false
1061 | }
1062 | }
1063 |
1064 | // Root represents a root directory or resource
1065 | type Root struct {
1066 | Name *string `json:"name,omitempty"`
1067 | URI string `json:"uri"`
1068 | }
1069 |
1070 | type SamplingMessage struct {
1071 | Audio *AudioContent
1072 | Image *ImageContent
1073 | Text *TextContent
1074 | }
1075 |
1076 | func (s SamplingMessage) MarshalJSON() ([]byte, error) {
1077 | switch {
1078 | case s.Audio != nil:
1079 | return json.Marshal(s.Audio)
1080 | case s.Image != nil:
1081 | return json.Marshal(s.Image)
1082 | case s.Text != nil:
1083 | return json.Marshal(s.Text)
1084 | default:
1085 | return nil, fmt.Errorf("empty SamplingMessage")
1086 | }
1087 | }
1088 |
1089 | func (s *SamplingMessage) UnmarshalJSON(data []byte) error {
1090 | var head struct {
1091 | Type string `json:"type"`
1092 | }
1093 | if err := json.Unmarshal(data, &head); err != nil {
1094 | return err
1095 | }
1096 |
1097 | switch head.Type {
1098 | case "audio":
1099 | var a AudioContent
1100 | if err := json.Unmarshal(data, &a); err != nil {
1101 | return err
1102 | }
1103 | s.Audio = &a
1104 | case "image":
1105 | var i ImageContent
1106 | if err := json.Unmarshal(data, &i); err != nil {
1107 | return err
1108 | }
1109 | s.Image = &i
1110 | case "text":
1111 | var t TextContent
1112 | if err := json.Unmarshal(data, &t); err != nil {
1113 | return err
1114 | }
1115 | s.Text = &t
1116 | default:
1117 | return fmt.Errorf("unknown content type %q", head.Type)
1118 | }
1119 |
1120 | return nil
1121 | }
1122 |
1123 | // Schema represents a JSON schema
1124 | type Schema struct {
1125 | Properties map[string]PrimitiveSchemaDefinition `json:"properties,omitempty"`
1126 | Required []string `json:"required,omitempty"`
1127 | }
1128 |
1129 | func (s Schema) MarshallJSON() ([]byte, error) {
1130 | type alias Schema
1131 | return json.Marshal(&struct {
1132 | Type string `json:"type"`
1133 | alias
1134 | }{
1135 | Type: "object",
1136 | alias: (alias)(s),
1137 | })
1138 | }
1139 |
1140 | func (s *Schema) UnmarshalJSON(data []byte) error {
1141 | type alias Schema
1142 | aux := struct {
1143 | Type string `json:"type"`
1144 | alias
1145 | }{}
1146 |
1147 | if err := json.Unmarshal(data, &aux); err != nil {
1148 | return err
1149 | }
1150 |
1151 | // Optional: validate `type`
1152 | if aux.Type != "object" && aux.Type != "" { // allow empty if missing
1153 | return fmt.Errorf("invalid type %q, expected \"object\"", aux.Type)
1154 | }
1155 |
1156 | *s = Schema(aux.alias)
1157 | return nil
1158 | }
1159 |
1160 | // StringSchema represents a string input schema
1161 | type StringSchema struct {
1162 | Description *string `json:"description,omitempty"`
1163 | Format *StringSchemaFormat `json:"format,omitempty"`
1164 | MaxLength *int64 `json:"maxLength,omitempty"`
1165 | MinLength *int64 `json:"minLength,omitempty"`
1166 | Title *string `json:"title,omitempty"`
1167 | }
1168 |
1169 | func (s StringSchema) MarshallJSON() ([]byte, error) {
1170 | type alias StringSchema
1171 | return json.Marshal(&struct {
1172 | Type string `json:"type"`
1173 | alias
1174 | }{
1175 | Type: "string",
1176 | alias: (alias)(s),
1177 | })
1178 | }
1179 |
1180 | func (s *StringSchema) UnmarshalJSON(data []byte) error {
1181 | type alias StringSchema
1182 | aux := struct {
1183 | Type string `json:"type"`
1184 | alias
1185 | }{}
1186 |
1187 | if err := json.Unmarshal(data, &aux); err != nil {
1188 | return err
1189 | }
1190 |
1191 | // Optional: validate `type`
1192 | if aux.Type != "string" && aux.Type != "" { // allow empty if missing
1193 | return fmt.Errorf("invalid type %q, expected \"string\"", aux.Type)
1194 | }
1195 |
1196 | *s = StringSchema(aux.alias)
1197 | return nil
1198 | }
1199 |
1200 | // StringSchemaFormat represents the format of a string schema
1201 | type StringSchemaFormat string
1202 |
1203 | const (
1204 | Email StringSchemaFormat = "email"
1205 | URI StringSchemaFormat = "uri"
1206 | Date StringSchemaFormat = "date"
1207 | DateTime StringSchemaFormat = "date_time"
1208 | )
1209 |
1210 | func (s *StringSchemaFormat) UnmarshalJSON(data []byte) error {
1211 | var str string
1212 | if err := json.Unmarshal(data, &str); err != nil {
1213 | return err
1214 | }
1215 |
1216 | sf := StringSchemaFormat(str)
1217 | if !sf.Valid() {
1218 | return fmt.Errorf("invalid StringSchemaFormat %q", str)
1219 | }
1220 |
1221 | *s = sf
1222 | return nil
1223 | }
1224 |
1225 | func (s StringSchemaFormat) Valid() bool {
1226 | switch s {
1227 | case Email, URI, Date, DateTime:
1228 | return true
1229 | default:
1230 | return false
1231 | }
1232 | }
1233 |
1234 | // TextContent represents text content
1235 | type TextContent struct {
1236 | Meta Meta `json:"_meta,omitempty"`
1237 | Annotations *Annotations `json:"annotations,omitempty"`
1238 | Text string `json:"text"`
1239 | }
1240 |
1241 | func (t TextContent) MarshallJSON() ([]byte, error) {
1242 | type alias TextContent
1243 | return json.Marshal(&struct {
1244 | Type string `json:"type"`
1245 | alias
1246 | }{
1247 | Type: "text",
1248 | alias: (alias)(t),
1249 | })
1250 | }
1251 |
1252 | func (t *TextContent) UnmarshalJSON(data []byte) error {
1253 | type alias TextContent
1254 | aux := struct {
1255 | Type string `json:"type"`
1256 | alias
1257 | }{}
1258 |
1259 | if err := json.Unmarshal(data, &aux); err != nil {
1260 | return err
1261 | }
1262 |
1263 | if aux.Type != "text" && aux.Type != "" { // allow empty if missing
1264 | return fmt.Errorf("invalid type %q, expected \"text\"", aux.Type)
1265 | }
1266 |
1267 | *t = TextContent(aux.alias)
1268 | return nil
1269 | }
1270 |
1271 | // TextResourceContents represents text resource contents
1272 | type TextResourceContents struct {
1273 | Meta Meta `json:"_meta,omitempty"`
1274 | MimeType *string `json:"mimeType,omitempty"`
1275 | Text string `json:"text"`
1276 | URI string `json:"uri"`
1277 | }
1278 |
1279 | // Tool represents a tool
1280 | type Tool struct {
1281 | Annotations *Annotations `json:"annotations,omitempty"`
1282 | Description *string `json:"description,omitempty"`
1283 | InputSchema ToolSchema `json:"inputSchema"`
1284 | Name string `json:"name"`
1285 | OutputSchema *ToolSchema `json:"outputSchema,omitempty"`
1286 | Title *string `json:"title,omitempty"`
1287 | }
1288 |
1289 | // ToolSchema represents the schema for tool input or output
1290 | type ToolSchema struct {
1291 | Properties map[string]any `json:"properties,omitempty"`
1292 | Required []string `json:"required,omitempty"`
1293 | Type string `json:"type"` // "object"
1294 | }
1295 |
```
--------------------------------------------------------------------------------
/examples/plugins/v2/rstime/src/pdk/types.rs:
--------------------------------------------------------------------------------
```rust
1 | #![allow(unused)]
2 | use base64::engine::general_purpose::STANDARD;
3 | use base64_serde::base64_serde_type;
4 | use extism_pdk::{FromBytes, Json, ToBytes};
5 | use serde::{Deserialize, Serialize};
6 | use serde_json::{Map, Number, Value};
7 | use std::collections::HashMap;
8 |
9 | base64_serde_type!(Base64Standard, STANDARD);
10 |
11 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
12 | #[encoding(Json)]
13 | pub struct Annotations {
14 | /// Intended audience for the resource
15 | #[serde(rename = "audience")]
16 | pub audience: Vec<Role>,
17 |
18 | /// Last modified timestamp for the resource
19 | #[serde(rename = "lastModified")]
20 | pub last_modified: chrono::DateTime<chrono::Utc>,
21 |
22 | /// Priority level indicating the importance of the resource
23 | #[serde(rename = "priority")]
24 | pub priority: f32,
25 | }
26 |
27 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
28 | #[encoding(Json)]
29 | pub struct AudioContent {
30 | /// Optional additional metadata about the content block
31 | #[serde(rename = "_meta")]
32 | #[serde(skip_serializing_if = "Option::is_none")]
33 | #[serde(default)]
34 | pub meta: Option<Meta>,
35 |
36 | /// Optional content annotations
37 | #[serde(rename = "annotations")]
38 | #[serde(skip_serializing_if = "Option::is_none")]
39 | #[serde(default)]
40 | pub annotations: Option<Annotations>,
41 |
42 | /// Base64-encoded audio data
43 | #[serde(rename = "data")]
44 | pub data: String,
45 |
46 | /// MIME type of the audio (e.g. 'audio/mpeg')
47 | #[serde(rename = "mimeType")]
48 | pub mime_type: String,
49 |
50 | #[serde(rename = "type")]
51 | pub r#type: AudioType,
52 | }
53 |
54 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
55 | #[encoding(Json)]
56 | pub enum AudioType {
57 | #[default]
58 | #[serde(rename = "audio")]
59 | Audio,
60 | }
61 |
62 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
63 | #[encoding(Json)]
64 | pub struct BlobResourceContents {
65 | /// Optional additional metadata about the blob resource
66 | #[serde(rename = "_meta")]
67 | #[serde(skip_serializing_if = "Option::is_none")]
68 | #[serde(default)]
69 | pub meta: Option<Meta>,
70 |
71 | /// Base64-encoded binary data of the resource
72 | #[serde(rename = "blob")]
73 | pub blob: String,
74 |
75 | /// MIME type of the binary content (e.g. 'application/pdf')
76 | #[serde(rename = "mimeType")]
77 | #[serde(skip_serializing_if = "Option::is_none")]
78 | #[serde(default)]
79 | pub mime_type: Option<String>,
80 |
81 | /// URI of the resource
82 | #[serde(rename = "uri")]
83 | pub uri: String,
84 | }
85 |
86 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
87 | #[encoding(Json)]
88 | pub struct BooleanSchema {
89 | /// Optional default value
90 | #[serde(rename = "default")]
91 | #[serde(skip_serializing_if = "Option::is_none")]
92 | #[serde(default)]
93 | pub default: Option<bool>,
94 |
95 | /// Description of the boolean input
96 | #[serde(rename = "description")]
97 | #[serde(skip_serializing_if = "Option::is_none")]
98 | #[serde(default)]
99 | pub description: Option<String>,
100 |
101 | /// Optional human-readable title
102 | #[serde(rename = "title")]
103 | #[serde(skip_serializing_if = "Option::is_none")]
104 | #[serde(default)]
105 | pub title: Option<String>,
106 |
107 | #[serde(rename = "type")]
108 | pub r#type: BooleanType,
109 | }
110 |
111 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
112 | #[encoding(Json)]
113 | pub enum BooleanType {
114 | #[default]
115 | #[serde(rename = "boolean")]
116 | Boolean,
117 | }
118 |
119 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
120 | #[encoding(Json)]
121 | pub struct CallToolRequest {
122 | #[serde(rename = "context")]
123 | pub context: PluginRequestContext,
124 |
125 | #[serde(rename = "request")]
126 | pub request: CallToolRequestParam,
127 | }
128 |
129 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
130 | #[encoding(Json)]
131 | pub struct CallToolRequestParam {
132 | /// Arguments to pass to the tool
133 | #[serde(rename = "arguments")]
134 | #[serde(skip_serializing_if = "Option::is_none")]
135 | #[serde(default)]
136 | pub arguments: Option<Map<String, Value>>,
137 |
138 | /// The name of the tool to call
139 | #[serde(rename = "name")]
140 | pub name: String,
141 | }
142 |
143 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
144 | #[encoding(Json)]
145 | pub struct CallToolResult {
146 | /// Optional additional metadata about the tool call result
147 | #[serde(rename = "_meta")]
148 | #[serde(skip_serializing_if = "Option::is_none")]
149 | #[serde(default)]
150 | pub meta: Option<Meta>,
151 |
152 | /// Array of TextContent, ImageContent, AudioContent, EmbeddedResource, or ResourceLinks representing the result
153 | #[serde(rename = "content")]
154 | pub content: Vec<ContentBlock>,
155 |
156 | /// Whether the tool call ended in an error. If not set, defaults to false.
157 | #[serde(rename = "isError")]
158 | #[serde(skip_serializing_if = "Option::is_none")]
159 | #[serde(default)]
160 | pub is_error: Option<bool>,
161 |
162 | /// Optional structured JSON result from the tool
163 | #[serde(rename = "structuredContent")]
164 | #[serde(skip_serializing_if = "Option::is_none")]
165 | #[serde(default)]
166 | pub structured_content: Option<Map<String, Value>>,
167 | }
168 |
169 | #[derive(Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
170 | #[encoding(Json)]
171 | pub struct CompleteRequest {
172 | #[serde(rename = "context")]
173 | pub context: PluginRequestContext,
174 |
175 | #[serde(rename = "request")]
176 | pub request: CompleteRequestParam,
177 | }
178 |
179 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
180 | #[encoding(Json)]
181 | pub struct CompleteRequestParam {
182 | #[serde(rename = "argument")]
183 | pub argument: CompleteRequestParamArgument,
184 |
185 | /// Optional completion context with previously-resolved arguments
186 | #[serde(rename = "context")]
187 | #[serde(skip_serializing_if = "Option::is_none")]
188 | pub context: Option<CompleteRequestParamContext>,
189 |
190 | /// Reference to either a PromptReference or ResourceTemplateReference
191 | #[serde(rename = "ref")]
192 | pub r#ref: Reference,
193 | }
194 |
195 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
196 | #[encoding(Json)]
197 | pub struct CompleteRequestParamArgument {
198 | /// Name of the argument
199 | #[serde(rename = "name")]
200 | pub name: String,
201 |
202 | /// Current value to complete
203 | #[serde(rename = "value")]
204 | pub value: String,
205 | }
206 |
207 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
208 | #[encoding(Json)]
209 | pub struct CompleteRequestParamContext {
210 | /// Previously-resolved argument values
211 | #[serde(rename = "arguments")]
212 | #[serde(skip_serializing_if = "Option::is_none")]
213 | #[serde(default)]
214 | pub arguments: Option<HashMap<String, String>>,
215 | }
216 |
217 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
218 | #[encoding(Json)]
219 | pub struct CompleteResult {
220 | #[serde(rename = "completion")]
221 | pub completion: CompleteResultCompletion,
222 | }
223 |
224 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
225 | #[encoding(Json)]
226 | pub struct CompleteResultCompletion {
227 | /// Whether there are more completions available
228 | #[serde(rename = "hasMore")]
229 | #[serde(skip_serializing_if = "Option::is_none")]
230 | #[serde(default)]
231 | pub has_more: Option<bool>,
232 |
233 | /// Total number of available completions
234 | #[serde(rename = "total")]
235 | #[serde(skip_serializing_if = "Option::is_none")]
236 | #[serde(default)]
237 | pub total: Option<i64>,
238 |
239 | /// Array of completion values (max 100 items)
240 | #[serde(rename = "values")]
241 | pub values: Vec<String>,
242 | }
243 |
244 | #[derive(Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
245 | #[encoding(Json)]
246 | #[serde(untagged)]
247 | pub enum ContentBlock {
248 | Audio(AudioContent),
249 | EmbeddedResource(EmbeddedResource),
250 | Image(ImageContent),
251 | ResourceLink(ResourceLink),
252 | Text(TextContent),
253 | Empty(Empty),
254 | }
255 |
256 | impl Default for ContentBlock {
257 | fn default() -> Self {
258 | ContentBlock::Empty(Empty::default())
259 | }
260 | }
261 |
262 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
263 | #[encoding(Json)]
264 | pub struct CreateMessageRequestParam {
265 | #[serde(rename = "includeContext")]
266 | #[serde(skip_serializing_if = "Option::is_none")]
267 | #[serde(default)]
268 | pub include_context: Option<CreateMessageRequestParamIncludeContext>,
269 |
270 | /// Maximum tokens to sample
271 | #[serde(rename = "maxTokens")]
272 | pub max_tokens: i64,
273 |
274 | /// Conversation messages of of TextContent, ImageContent or AudioContent
275 | #[serde(rename = "messages")]
276 | pub messages: Vec<SamplingMessage>,
277 |
278 | /// Preferences for model selection
279 | #[serde(rename = "modelPreferences")]
280 | #[serde(skip_serializing_if = "Option::is_none")]
281 | #[serde(default)]
282 | pub model_preferences: Option<ModelPreferences>,
283 |
284 | /// Stop sequences
285 | #[serde(rename = "stopSequences")]
286 | #[serde(skip_serializing_if = "Option::is_none")]
287 | #[serde(default)]
288 | pub stop_sequences: Option<Vec<String>>,
289 |
290 | /// Optional system prompt
291 | #[serde(rename = "systemPrompt")]
292 | #[serde(skip_serializing_if = "Option::is_none")]
293 | #[serde(default)]
294 | pub system_prompt: Option<String>,
295 |
296 | /// Sampling temperature
297 | #[serde(rename = "temperature")]
298 | #[serde(skip_serializing_if = "Option::is_none")]
299 | #[serde(default)]
300 | pub temperature: Option<f64>,
301 | }
302 |
303 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
304 | #[encoding(Json)]
305 | pub enum CreateMessageRequestParamIncludeContext {
306 | #[default]
307 | #[serde(rename = "none")]
308 | None,
309 | #[serde(rename = "thisServer")]
310 | ThisServer,
311 | #[serde(rename = "allServers")]
312 | AllServers,
313 | }
314 |
315 | #[derive(Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
316 | #[encoding(Json)]
317 | pub struct CreateMessageResult {
318 | /// One of TextContent, ImageContent or AudioContent
319 | #[serde(rename = "content")]
320 | pub content: CreateMessageResultContent,
321 |
322 | /// Name of the model used
323 | #[serde(rename = "model")]
324 | pub model: String,
325 |
326 | #[serde(rename = "role")]
327 | pub role: Role,
328 |
329 | /// Optional reason sampling stopped
330 | #[serde(rename = "stopReason")]
331 | #[serde(skip_serializing_if = "Option::is_none")]
332 | #[serde(default)]
333 | pub stop_reason: Option<String>,
334 | }
335 |
336 | type CreateMessageResultContent = SamplingMessage;
337 |
338 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
339 | #[encoding(Json)]
340 | pub struct ElicitRequestParamWithTimeout {
341 | /// Message to present to the user
342 | #[serde(rename = "message")]
343 | pub message: String,
344 |
345 | #[serde(rename = "requestedSchema")]
346 | pub requested_schema: Schema,
347 |
348 | /// Optional timeout in milliseconds
349 | #[serde(rename = "timeout")]
350 | #[serde(skip_serializing_if = "Option::is_none")]
351 | #[serde(default)]
352 | pub timeout: Option<i64>,
353 | }
354 |
355 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
356 | #[encoding(Json)]
357 | pub struct ElicitResult {
358 | #[serde(rename = "action")]
359 | pub action: ElicitResultAction,
360 |
361 | /// Form data submitted by user (only present when action is accept)
362 | #[serde(rename = "content")]
363 | #[serde(skip_serializing_if = "Option::is_none")]
364 | #[serde(default)]
365 | pub content: Option<HashMap<String, ElicitResultContentValue>>,
366 | }
367 |
368 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
369 | #[encoding(Json)]
370 | pub enum ElicitResultAction {
371 | #[default]
372 | #[serde(rename = "accept")]
373 | Accept,
374 | #[serde(rename = "decline")]
375 | Decline,
376 | #[serde(rename = "cancel")]
377 | Cancel,
378 | }
379 |
380 | #[derive(Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
381 | #[encoding(Json)]
382 | #[serde(untagged)]
383 | pub enum ElicitResultContentValue {
384 | String(String),
385 | Number(Number), // or serde_json::Number if you want exactness
386 | Bool(bool),
387 | }
388 |
389 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
390 | #[encoding(Json)]
391 | pub struct EmbeddedResource {
392 | /// Optional additional metadata about the embedded resource
393 | #[serde(rename = "_meta")]
394 | #[serde(skip_serializing_if = "Option::is_none")]
395 | #[serde(default)]
396 | pub meta: Option<Meta>,
397 |
398 | /// Optional resource annotations
399 | #[serde(rename = "annotations")]
400 | #[serde(skip_serializing_if = "Option::is_none")]
401 | #[serde(default)]
402 | pub annotations: Option<Annotations>,
403 |
404 | /// The embedded TextResourceContents or BlobResourceContents
405 | #[serde(rename = "resource")]
406 | pub resource: ResourceContents,
407 |
408 | #[serde(rename = "type")]
409 | pub r#type: ResourceType,
410 | }
411 |
412 | #[derive(Default, Debug, Clone, Serialize, Deserialize)]
413 | #[serde(deny_unknown_fields)]
414 | pub struct Empty {}
415 |
416 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
417 | #[encoding(Json)]
418 | pub struct EnumSchema {
419 | /// Description of the enum input
420 | #[serde(rename = "description")]
421 | #[serde(skip_serializing_if = "Option::is_none")]
422 | #[serde(default)]
423 | pub description: Option<String>,
424 |
425 | /// Array of allowed string values
426 | #[serde(rename = "enum")]
427 | pub r#enum: Vec<String>,
428 |
429 | /// Optional array of human-readable names for the enum values
430 | #[serde(rename = "enumNames")]
431 | #[serde(skip_serializing_if = "Option::is_none")]
432 | #[serde(default)]
433 | pub enum_names: Option<Vec<String>>,
434 |
435 | /// Optional human-readable title
436 | #[serde(rename = "title")]
437 | #[serde(skip_serializing_if = "Option::is_none")]
438 | #[serde(default)]
439 | pub title: Option<String>,
440 |
441 | #[serde(rename = "type")]
442 | pub r#type: StringType,
443 | }
444 |
445 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
446 | #[encoding(Json)]
447 | pub struct GetPromptRequest {
448 | #[serde(rename = "context")]
449 | pub context: PluginRequestContext,
450 |
451 | #[serde(rename = "request")]
452 | pub request: GetPromptRequestParam,
453 | }
454 |
455 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
456 | #[encoding(Json)]
457 | pub struct GetPromptRequestParam {
458 | /// Arguments for templating the prompt
459 | #[serde(rename = "arguments")]
460 | #[serde(skip_serializing_if = "Option::is_none")]
461 | #[serde(default)]
462 | pub arguments: Option<HashMap<String, String>>,
463 |
464 | /// Name of the prompt to retrieve
465 | #[serde(rename = "name")]
466 | pub name: String,
467 | }
468 |
469 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
470 | #[encoding(Json)]
471 | pub struct GetPromptResult {
472 | /// Optional description of the prompt
473 | #[serde(rename = "description")]
474 | #[serde(skip_serializing_if = "Option::is_none")]
475 | #[serde(default)]
476 | pub description: Option<String>,
477 |
478 | /// Array of prompt messages
479 | #[serde(rename = "messages")]
480 | pub messages: Vec<PromptMessage>,
481 | }
482 |
483 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
484 | #[encoding(Json)]
485 | pub struct ImageContent {
486 | /// Optional additional metadata about the content block
487 | #[serde(rename = "_meta")]
488 | #[serde(skip_serializing_if = "Option::is_none")]
489 | #[serde(default)]
490 | pub meta: Option<Meta>,
491 |
492 | /// Optional content annotations
493 | #[serde(rename = "annotations")]
494 | #[serde(skip_serializing_if = "Option::is_none")]
495 | #[serde(default)]
496 | pub annotations: Option<Annotations>,
497 |
498 | /// Base64-encoded image data
499 | #[serde(rename = "data")]
500 | pub data: String,
501 |
502 | /// MIME type of the image (e.g. 'image/png')
503 | #[serde(rename = "mimeType")]
504 | pub mime_type: String,
505 |
506 | #[serde(rename = "type")]
507 | pub r#type: ImageType,
508 | }
509 |
510 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
511 | #[encoding(Json)]
512 | pub enum ImageType {
513 | #[default]
514 | #[serde(rename = "image")]
515 | Image,
516 | }
517 |
518 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
519 | #[encoding(Json)]
520 | pub struct ListPromptsRequest {
521 | #[serde(rename = "context")]
522 | pub context: PluginRequestContext,
523 | }
524 |
525 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
526 | #[encoding(Json)]
527 | pub struct ListPromptsResult {
528 | /// Array of available prompts
529 | #[serde(rename = "prompts")]
530 | pub prompts: Vec<Prompt>,
531 | }
532 |
533 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
534 | #[encoding(Json)]
535 | pub struct ListResourcesRequest {
536 | #[serde(rename = "context")]
537 | pub context: PluginRequestContext,
538 | }
539 |
540 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
541 | #[encoding(Json)]
542 | pub struct ListResourcesResult {
543 | /// Array of available resources
544 | #[serde(rename = "resources")]
545 | pub resources: Vec<Resource>,
546 | }
547 |
548 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
549 | #[encoding(Json)]
550 | pub struct ListResourceTemplatesRequest {
551 | #[serde(rename = "context")]
552 | pub context: PluginRequestContext,
553 | }
554 |
555 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
556 | #[encoding(Json)]
557 | pub struct ListResourceTemplatesResult {
558 | /// Array of resource templates
559 | #[serde(rename = "resourceTemplates")]
560 | pub resource_templates: Vec<ResourceTemplate>,
561 | }
562 |
563 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
564 | #[encoding(Json)]
565 | pub struct ListRootsResult {
566 | /// Array of root directories/resources
567 | #[serde(rename = "roots")]
568 | pub roots: Vec<Root>,
569 | }
570 |
571 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
572 | #[encoding(Json)]
573 | pub struct ListToolsRequest {
574 | #[serde(rename = "context")]
575 | pub context: PluginRequestContext,
576 | }
577 |
578 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
579 | #[encoding(Json)]
580 | pub struct ListToolsResult {
581 | /// Array of available tools
582 | #[serde(rename = "tools")]
583 | pub tools: Vec<Tool>,
584 | }
585 |
586 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
587 | #[encoding(Json)]
588 | pub enum LoggingLevel {
589 | #[default]
590 | #[serde(rename = "debug")]
591 | Debug,
592 | #[serde(rename = "info")]
593 | Info,
594 | #[serde(rename = "notice")]
595 | Notice,
596 | #[serde(rename = "warning")]
597 | Warning,
598 | #[serde(rename = "error")]
599 | Error,
600 | #[serde(rename = "critical")]
601 | Critical,
602 | #[serde(rename = "alert")]
603 | Alert,
604 | #[serde(rename = "emergency")]
605 | Emergency,
606 | }
607 |
608 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
609 | #[encoding(Json)]
610 | pub struct LoggingMessageNotificationParam {
611 | /// Data to log (any JSON-serializable type)
612 | #[serde(rename = "data")]
613 | pub data: Value,
614 |
615 | #[serde(rename = "level")]
616 | pub level: LoggingLevel,
617 |
618 | /// Optional logger name
619 | #[serde(rename = "logger")]
620 | #[serde(skip_serializing_if = "Option::is_none")]
621 | #[serde(default)]
622 | pub logger: Option<String>,
623 | }
624 |
625 | type Meta = Map<String, Value>;
626 |
627 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
628 | #[encoding(Json)]
629 | pub struct ModelHint {
630 | /// Suggested model name or family
631 | #[serde(rename = "name")]
632 | pub name: String,
633 | }
634 |
635 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
636 | #[encoding(Json)]
637 | pub struct ModelPreferences {
638 | /// Priority for cost (0-1)
639 | #[serde(rename = "costPriority")]
640 | pub cost_priority: f32,
641 |
642 | /// Model name hints
643 | #[serde(rename = "hints")]
644 | pub hints: Vec<ModelHint>,
645 |
646 | /// Priority for intelligence (0-1)
647 | #[serde(rename = "intelligencePriority")]
648 | pub intelligence_priority: f32,
649 |
650 | /// Priority for speed (0-1)
651 | #[serde(rename = "speedPriority")]
652 | pub speed_priority: f32,
653 | }
654 |
655 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
656 | #[encoding(Json)]
657 | pub struct NumberSchema {
658 | /// Description of the number input
659 | #[serde(rename = "description")]
660 | #[serde(skip_serializing_if = "Option::is_none")]
661 | #[serde(default)]
662 | pub description: Option<String>,
663 |
664 | /// Maximum value
665 | #[serde(rename = "maximum")]
666 | #[serde(skip_serializing_if = "Option::is_none")]
667 | #[serde(default)]
668 | pub maximum: Option<f64>,
669 |
670 | /// Minimum value
671 | #[serde(rename = "minimum")]
672 | #[serde(skip_serializing_if = "Option::is_none")]
673 | #[serde(default)]
674 | pub minimum: Option<f64>,
675 |
676 | /// Optional human-readable title
677 | #[serde(rename = "title")]
678 | #[serde(skip_serializing_if = "Option::is_none")]
679 | #[serde(default)]
680 | pub title: Option<String>,
681 |
682 | #[serde(rename = "type")]
683 | pub r#type: NumberType,
684 | }
685 |
686 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
687 | #[encoding(Json)]
688 | pub enum NumberType {
689 | #[default]
690 | #[serde(rename = "number")]
691 | Number,
692 | #[serde(rename = "integer")]
693 | Integer,
694 | }
695 |
696 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
697 | #[encoding(Json)]
698 | pub enum ObjectType {
699 | #[default]
700 | #[serde(rename = "object")]
701 | Object,
702 | }
703 |
704 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
705 | #[encoding(Json)]
706 | pub struct PluginNotificationContext {
707 | /// Additional metadata about the notification
708 | #[serde(rename = "meta")]
709 | pub meta: Meta,
710 | }
711 |
712 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
713 | #[encoding(Json)]
714 | pub struct PluginRequestContext {
715 | /// Additional metadata about the request
716 | #[serde(rename = "_meta")]
717 | pub meta: Meta,
718 |
719 | /// Unique identifier for this request
720 | #[serde(rename = "id")]
721 | pub id: PluginRequestId,
722 | }
723 |
724 | #[derive(Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
725 | #[encoding(Json)]
726 | #[serde(untagged)]
727 | pub enum PluginRequestId {
728 | String(String),
729 | Number(i64),
730 | }
731 |
732 | impl Default for PluginRequestId {
733 | fn default() -> Self {
734 | PluginRequestId::String(String::new())
735 | }
736 | }
737 |
738 | #[derive(Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
739 | #[encoding(Json)]
740 | #[serde(untagged)]
741 | pub enum PrimitiveSchemaDefinition {
742 | Boolean(BooleanSchema),
743 | Enum(EnumSchema),
744 | Number(NumberSchema),
745 | String(StringSchema),
746 | Empty(Empty),
747 | }
748 |
749 | impl Default for PrimitiveSchemaDefinition {
750 | fn default() -> Self {
751 | PrimitiveSchemaDefinition::Empty(Empty::default())
752 | }
753 | }
754 |
755 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
756 | #[encoding(Json)]
757 | pub struct ProgressNotificationParam {
758 | /// Optional progress message describing current operation
759 | #[serde(rename = "message")]
760 | #[serde(skip_serializing_if = "Option::is_none")]
761 | #[serde(default)]
762 | pub message: Option<String>,
763 |
764 | /// The progress thus far
765 | #[serde(rename = "progress")]
766 | pub progress: f64,
767 |
768 | /// A token identifying the progress context
769 | #[serde(rename = "progressToken")]
770 | pub progress_token: String,
771 |
772 | /// Optional total units of work
773 | #[serde(rename = "total")]
774 | #[serde(skip_serializing_if = "Option::is_none")]
775 | #[serde(default)]
776 | pub total: Option<f64>,
777 | }
778 |
779 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
780 | #[encoding(Json)]
781 | pub struct Prompt {
782 | /// Optional prompt arguments
783 | #[serde(rename = "arguments")]
784 | #[serde(skip_serializing_if = "Option::is_none")]
785 | #[serde(default)]
786 | pub arguments: Option<Vec<PromptArgument>>,
787 |
788 | /// Description of what the prompt does
789 | #[serde(rename = "description")]
790 | #[serde(skip_serializing_if = "Option::is_none")]
791 | #[serde(default)]
792 | pub description: Option<String>,
793 |
794 | /// Unique name of the prompt
795 | #[serde(rename = "name")]
796 | pub name: String,
797 |
798 | /// Human-readable title
799 | #[serde(rename = "title")]
800 | #[serde(skip_serializing_if = "Option::is_none")]
801 | #[serde(default)]
802 | pub title: Option<String>,
803 | }
804 |
805 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
806 | #[encoding(Json)]
807 | pub struct PromptArgument {
808 | /// Description of the argument
809 | #[serde(rename = "description")]
810 | #[serde(skip_serializing_if = "Option::is_none")]
811 | #[serde(default)]
812 | pub description: Option<String>,
813 |
814 | /// Name of the argument
815 | #[serde(rename = "name")]
816 | pub name: String,
817 |
818 | /// Whether this argument is required
819 | #[serde(rename = "required")]
820 | #[serde(skip_serializing_if = "Option::is_none")]
821 | #[serde(default)]
822 | pub required: Option<bool>,
823 |
824 | /// Human-readable title
825 | #[serde(rename = "title")]
826 | #[serde(skip_serializing_if = "Option::is_none")]
827 | #[serde(default)]
828 | pub title: Option<String>,
829 | }
830 |
831 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
832 | #[encoding(Json)]
833 | pub struct PromptMessage {
834 | /// One of TextContent, ImageContent, AudioContent, EmbeddedResource, or ResourceLink
835 | #[serde(rename = "content")]
836 | pub content: ContentBlock,
837 |
838 | #[serde(rename = "role")]
839 | pub role: Role,
840 | }
841 |
842 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
843 | #[encoding(Json)]
844 | pub struct PromptReference {
845 | /// Name of the prompt
846 | #[serde(rename = "name")]
847 | pub name: String,
848 |
849 | /// Optional human-readable title
850 | #[serde(rename = "title")]
851 | #[serde(skip_serializing_if = "Option::is_none")]
852 | #[serde(default)]
853 | pub title: Option<String>,
854 |
855 | #[serde(rename = "type")]
856 | pub r#type: PromptReferenceType,
857 | }
858 |
859 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
860 | #[encoding(Json)]
861 | pub enum PromptReferenceType {
862 | #[default]
863 | #[serde(rename = "prompt")]
864 | Prompt,
865 | }
866 |
867 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
868 | #[encoding(Json)]
869 | pub struct ReadResourceRequest {
870 | #[serde(rename = "context")]
871 | pub context: PluginRequestContext,
872 |
873 | #[serde(rename = "request")]
874 | pub request: ReadResourceRequestParam,
875 | }
876 |
877 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
878 | #[encoding(Json)]
879 | pub struct ReadResourceRequestParam {
880 | /// URI of the resource to read
881 | #[serde(rename = "uri")]
882 | pub uri: String,
883 | }
884 |
885 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
886 | #[encoding(Json)]
887 | pub struct ReadResourceResult {
888 | /// Array of TextResourceContents or BlobResourceContents
889 | #[serde(rename = "contents")]
890 | pub contents: Vec<ResourceContents>,
891 | }
892 |
893 | #[derive(Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
894 | #[encoding(Json)]
895 | #[serde(untagged)]
896 | pub enum Reference {
897 | Prompt(PromptReference),
898 | ResourceTemplate(ResourceTemplateReference),
899 | Empty(Empty),
900 | }
901 |
902 | impl Default for Reference {
903 | fn default() -> Self {
904 | Reference::Empty(Empty::default())
905 | }
906 | }
907 |
908 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
909 | #[encoding(Json)]
910 | pub struct Resource {
911 | /// Optional resource annotations
912 | #[serde(rename = "annotations")]
913 | #[serde(skip_serializing_if = "Option::is_none")]
914 | #[serde(default)]
915 | pub annotations: Option<Annotations>,
916 |
917 | /// Description of the resource
918 | #[serde(rename = "description")]
919 | #[serde(skip_serializing_if = "Option::is_none")]
920 | #[serde(default)]
921 | pub description: Option<String>,
922 |
923 | /// MIME type of the resource
924 | #[serde(rename = "mimeType")]
925 | #[serde(skip_serializing_if = "Option::is_none")]
926 | #[serde(default)]
927 | pub mime_type: Option<String>,
928 |
929 | /// Human-readable name
930 | #[serde(rename = "name")]
931 | pub name: String,
932 |
933 | /// Size in bytes
934 | #[serde(rename = "size")]
935 | #[serde(skip_serializing_if = "Option::is_none")]
936 | #[serde(default)]
937 | pub size: Option<i64>,
938 |
939 | /// Human-readable title
940 | #[serde(rename = "title")]
941 | #[serde(skip_serializing_if = "Option::is_none")]
942 | #[serde(default)]
943 | pub title: Option<String>,
944 |
945 | /// URI of the resource
946 | #[serde(rename = "uri")]
947 | pub uri: String,
948 | }
949 |
950 | #[derive(Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
951 | #[encoding(Json)]
952 | #[serde(untagged)]
953 | pub enum ResourceContents {
954 | Blob(BlobResourceContents),
955 | Text(TextResourceContents),
956 | Empty(Empty),
957 | }
958 |
959 | impl Default for ResourceContents {
960 | fn default() -> Self {
961 | ResourceContents::Empty(Empty::default())
962 | }
963 | }
964 |
965 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
966 | #[encoding(Json)]
967 | pub struct ResourceLink {
968 | /// Optional additional metadata about the resource link
969 | #[serde(rename = "_meta")]
970 | #[serde(skip_serializing_if = "Option::is_none")]
971 | #[serde(default)]
972 | pub meta: Option<Meta>,
973 |
974 | /// Optional resource annotations
975 | #[serde(rename = "annotations")]
976 | #[serde(skip_serializing_if = "Option::is_none")]
977 | #[serde(default)]
978 | pub annotations: Option<Annotations>,
979 |
980 | /// Optional description of the resource
981 | #[serde(rename = "description")]
982 | #[serde(skip_serializing_if = "Option::is_none")]
983 | #[serde(default)]
984 | pub description: Option<String>,
985 |
986 | /// Optional MIME type of the resource
987 | #[serde(rename = "mimeType")]
988 | #[serde(skip_serializing_if = "Option::is_none")]
989 | #[serde(default)]
990 | pub mime_type: Option<String>,
991 |
992 | /// Optional human-readable name
993 | #[serde(rename = "name")]
994 | pub name: String,
995 |
996 | /// Optional size in bytes
997 | #[serde(rename = "size")]
998 | #[serde(skip_serializing_if = "Option::is_none")]
999 | #[serde(default)]
1000 | pub size: Option<i64>,
1001 |
1002 | /// Optional human-readable title
1003 | #[serde(rename = "title")]
1004 | #[serde(skip_serializing_if = "Option::is_none")]
1005 | #[serde(default)]
1006 | pub title: Option<String>,
1007 |
1008 | #[serde(rename = "type")]
1009 | pub r#type: ResourceLinkType,
1010 |
1011 | /// URI of the resource
1012 | #[serde(rename = "uri")]
1013 | pub uri: String,
1014 | }
1015 |
1016 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1017 | #[encoding(Json)]
1018 | pub enum ResourceLinkType {
1019 | #[default]
1020 | #[serde(rename = "resource_link")]
1021 | ResourceLink,
1022 | }
1023 |
1024 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1025 | #[encoding(Json)]
1026 | pub enum ResourceReferenceType {
1027 | #[default]
1028 | #[serde(rename = "resource")]
1029 | Resource,
1030 | }
1031 |
1032 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1033 | #[encoding(Json)]
1034 | pub struct ResourceTemplate {
1035 | #[serde(rename = "annotations")]
1036 | #[serde(skip_serializing_if = "Option::is_none")]
1037 | #[serde(default)]
1038 | pub annotations: Option<Annotations>,
1039 |
1040 | /// Description of the template
1041 | #[serde(rename = "description")]
1042 | #[serde(skip_serializing_if = "Option::is_none")]
1043 | #[serde(default)]
1044 | pub description: Option<String>,
1045 |
1046 | /// MIME type for resources matching this template
1047 | #[serde(rename = "mimeType")]
1048 | #[serde(skip_serializing_if = "Option::is_none")]
1049 | #[serde(default)]
1050 | pub mime_type: Option<String>,
1051 |
1052 | /// Human-readable name
1053 | #[serde(rename = "name")]
1054 | pub name: String,
1055 |
1056 | /// Human-readable title
1057 | #[serde(rename = "title")]
1058 | #[serde(skip_serializing_if = "Option::is_none")]
1059 | #[serde(default)]
1060 | pub title: Option<String>,
1061 |
1062 | /// RFC 6570 URI template pattern
1063 | #[serde(rename = "uriTemplate")]
1064 | pub uri_template: String,
1065 | }
1066 |
1067 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1068 | #[encoding(Json)]
1069 | pub struct ResourceTemplateReference {
1070 | #[serde(rename = "type")]
1071 | pub r#type: ResourceReferenceType,
1072 |
1073 | /// URI or URI template pattern of the resource
1074 | #[serde(rename = "uri")]
1075 | pub uri: String,
1076 | }
1077 |
1078 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1079 | #[encoding(Json)]
1080 | pub enum ResourceType {
1081 | #[default]
1082 | #[serde(rename = "resource")]
1083 | Resource,
1084 | }
1085 |
1086 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1087 | #[encoding(Json)]
1088 | pub struct ResourceUpdatedNotificationParam {
1089 | /// URI of the updated resource
1090 | #[serde(rename = "uri")]
1091 | pub uri: String,
1092 | }
1093 |
1094 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1095 | #[encoding(Json)]
1096 | pub enum Role {
1097 | #[default]
1098 | #[serde(rename = "assistant")]
1099 | Assistant,
1100 | #[serde(rename = "user")]
1101 | User,
1102 | }
1103 |
1104 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1105 | #[encoding(Json)]
1106 | pub struct Root {
1107 | /// Optional human-readable name
1108 | #[serde(rename = "name")]
1109 | #[serde(skip_serializing_if = "Option::is_none")]
1110 | #[serde(default)]
1111 | pub name: Option<String>,
1112 |
1113 | /// URI of the root (typically file://)
1114 | #[serde(rename = "uri")]
1115 | pub uri: String,
1116 | }
1117 |
1118 | #[derive(Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1119 | #[encoding(Json)]
1120 | #[serde(untagged)]
1121 | pub enum SamplingMessage {
1122 | Audio(AudioContent),
1123 | Image(ImageContent),
1124 | Text(TextContent),
1125 | Empty(Empty),
1126 | }
1127 |
1128 | impl Default for SamplingMessage {
1129 | fn default() -> Self {
1130 | SamplingMessage::Empty(Empty::default())
1131 | }
1132 | }
1133 |
1134 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1135 | #[encoding(Json)]
1136 | pub struct Schema {
1137 | /// A map of StringSchema, NumberSchema, BooleanSchema or EnumSchema definitions (no nesting)
1138 | #[serde(rename = "properties")]
1139 | pub properties: HashMap<String, PrimitiveSchemaDefinition>,
1140 |
1141 | /// Required property names
1142 | #[serde(rename = "required")]
1143 | #[serde(skip_serializing_if = "Option::is_none")]
1144 | #[serde(default)]
1145 | pub required: Option<Vec<String>>,
1146 |
1147 | #[serde(rename = "type")]
1148 | pub r#type: ObjectType,
1149 | }
1150 |
1151 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1152 | #[encoding(Json)]
1153 | pub struct StringSchema {
1154 | /// Description of the string input
1155 | #[serde(rename = "description")]
1156 | #[serde(skip_serializing_if = "Option::is_none")]
1157 | #[serde(default)]
1158 | pub description: Option<String>,
1159 |
1160 | #[serde(rename = "format")]
1161 | #[serde(skip_serializing_if = "Option::is_none")]
1162 | #[serde(default)]
1163 | pub format: Option<StringSchemaFormat>,
1164 |
1165 | /// Maximum length of the string
1166 | #[serde(rename = "maxLength")]
1167 | #[serde(skip_serializing_if = "Option::is_none")]
1168 | #[serde(default)]
1169 | pub max_length: Option<i64>,
1170 |
1171 | /// Minimum length of the string
1172 | #[serde(rename = "minLength")]
1173 | #[serde(skip_serializing_if = "Option::is_none")]
1174 | #[serde(default)]
1175 | pub min_length: Option<i64>,
1176 |
1177 | /// Optional human-readable title
1178 | #[serde(rename = "title")]
1179 | #[serde(skip_serializing_if = "Option::is_none")]
1180 | #[serde(default)]
1181 | pub title: Option<String>,
1182 |
1183 | #[serde(rename = "type")]
1184 | pub r#type: StringType,
1185 | }
1186 |
1187 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1188 | #[encoding(Json)]
1189 | pub enum StringSchemaFormat {
1190 | #[default]
1191 | #[serde(rename = "email")]
1192 | Email,
1193 | #[serde(rename = "uri")]
1194 | Uri,
1195 | #[serde(rename = "date")]
1196 | Date,
1197 | #[serde(rename = "date_time")]
1198 | Datetime,
1199 | }
1200 |
1201 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1202 | #[encoding(Json)]
1203 | pub enum StringType {
1204 | #[default]
1205 | #[serde(rename = "string")]
1206 | String,
1207 | }
1208 |
1209 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1210 | #[encoding(Json)]
1211 | pub struct TextContent {
1212 | /// Optional additional metadata about the content block
1213 | #[serde(rename = "_meta")]
1214 | #[serde(skip_serializing_if = "Option::is_none")]
1215 | #[serde(default)]
1216 | pub meta: Option<Meta>,
1217 |
1218 | /// Optional content annotations
1219 | #[serde(rename = "annotations")]
1220 | #[serde(skip_serializing_if = "Option::is_none")]
1221 | #[serde(default)]
1222 | pub annotations: Option<Annotations>,
1223 |
1224 | /// The text content
1225 | #[serde(rename = "text")]
1226 | pub text: String,
1227 |
1228 | #[serde(rename = "type")]
1229 | pub r#type: TextType,
1230 | }
1231 |
1232 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1233 | #[encoding(Json)]
1234 | pub struct TextResourceContents {
1235 | /// Optional additional metadata about the text resource
1236 | #[serde(rename = "_meta")]
1237 | #[serde(skip_serializing_if = "Option::is_none")]
1238 | #[serde(default)]
1239 | pub meta: Option<Meta>,
1240 |
1241 | /// MIME type of the text content (e.g. 'text/plain')
1242 | #[serde(rename = "mimeType")]
1243 | #[serde(skip_serializing_if = "Option::is_none")]
1244 | #[serde(default)]
1245 | pub mime_type: Option<String>,
1246 |
1247 | /// Text content of the resource
1248 | #[serde(rename = "text")]
1249 | pub text: String,
1250 |
1251 | /// URI of the resource
1252 | #[serde(rename = "uri")]
1253 | pub uri: String,
1254 | }
1255 |
1256 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1257 | #[encoding(Json)]
1258 | pub enum TextType {
1259 | #[default]
1260 | #[serde(rename = "text")]
1261 | Text,
1262 | }
1263 |
1264 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1265 | #[encoding(Json)]
1266 | pub struct Tool {
1267 | /// Optional tool annotations
1268 | #[serde(rename = "annotations")]
1269 | #[serde(skip_serializing_if = "Option::is_none")]
1270 | #[serde(default)]
1271 | pub annotations: Option<Annotations>,
1272 |
1273 | /// Description of what the tool does
1274 | #[serde(rename = "description")]
1275 | #[serde(skip_serializing_if = "Option::is_none")]
1276 | #[serde(default)]
1277 | pub description: Option<String>,
1278 |
1279 | #[serde(rename = "inputSchema")]
1280 | pub input_schema: ToolSchema,
1281 |
1282 | /// Unique name of the tool
1283 | #[serde(rename = "name")]
1284 | pub name: String,
1285 |
1286 | #[serde(rename = "outputSchema")]
1287 | #[serde(skip_serializing_if = "Option::is_none")]
1288 | #[serde(default)]
1289 | pub output_schema: Option<ToolSchema>,
1290 |
1291 | /// Human-readable title
1292 | #[serde(rename = "title")]
1293 | #[serde(skip_serializing_if = "Option::is_none")]
1294 | #[serde(default)]
1295 | pub title: Option<String>,
1296 | }
1297 |
1298 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1299 | #[encoding(Json)]
1300 | pub struct ToolSchema {
1301 | /// Schema properties
1302 | #[serde(rename = "properties")]
1303 | #[serde(skip_serializing_if = "Option::is_none")]
1304 | #[serde(default)]
1305 | pub properties: Option<Map<String, Value>>,
1306 |
1307 | /// Required properties
1308 | #[serde(rename = "required")]
1309 | #[serde(skip_serializing_if = "Option::is_none")]
1310 | #[serde(default)]
1311 | pub required: Option<Vec<String>>,
1312 |
1313 | #[serde(rename = "type")]
1314 | pub r#type: ObjectType,
1315 | }
1316 |
```
--------------------------------------------------------------------------------
/templates/plugins/rust/src/pdk/types.rs:
--------------------------------------------------------------------------------
```rust
1 | #![allow(unused)]
2 | use base64::engine::general_purpose::STANDARD;
3 | use base64_serde::base64_serde_type;
4 | use extism_pdk::{FromBytes, Json, ToBytes};
5 | use serde::{Deserialize, Serialize};
6 | use serde_json::{Map, Number, Value};
7 | use std::collections::HashMap;
8 |
9 | base64_serde_type!(Base64Standard, STANDARD);
10 |
11 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
12 | #[encoding(Json)]
13 | pub struct Annotations {
14 | /// Intended audience for the resource
15 | #[serde(rename = "audience")]
16 | pub audience: Vec<Role>,
17 |
18 | /// Last modified timestamp for the resource
19 | #[serde(rename = "lastModified")]
20 | pub last_modified: chrono::DateTime<chrono::Utc>,
21 |
22 | /// Priority level indicating the importance of the resource
23 | #[serde(rename = "priority")]
24 | pub priority: f32,
25 | }
26 |
27 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
28 | #[encoding(Json)]
29 | pub struct AudioContent {
30 | /// Optional additional metadata about the content block
31 | #[serde(rename = "_meta")]
32 | #[serde(skip_serializing_if = "Option::is_none")]
33 | #[serde(default)]
34 | pub meta: Option<Meta>,
35 |
36 | /// Optional content annotations
37 | #[serde(rename = "annotations")]
38 | #[serde(skip_serializing_if = "Option::is_none")]
39 | #[serde(default)]
40 | pub annotations: Option<Annotations>,
41 |
42 | /// Base64-encoded audio data
43 | #[serde(rename = "data")]
44 | pub data: String,
45 |
46 | /// MIME type of the audio (e.g. 'audio/mpeg')
47 | #[serde(rename = "mimeType")]
48 | pub mime_type: String,
49 |
50 | #[serde(rename = "type")]
51 | pub r#type: AudioType,
52 | }
53 |
54 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
55 | #[encoding(Json)]
56 | pub enum AudioType {
57 | #[default]
58 | #[serde(rename = "audio")]
59 | Audio,
60 | }
61 |
62 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
63 | #[encoding(Json)]
64 | pub struct BlobResourceContents {
65 | /// Optional additional metadata about the blob resource
66 | #[serde(rename = "_meta")]
67 | #[serde(skip_serializing_if = "Option::is_none")]
68 | #[serde(default)]
69 | pub meta: Option<Meta>,
70 |
71 | /// Base64-encoded binary data of the resource
72 | #[serde(rename = "blob")]
73 | pub blob: String,
74 |
75 | /// MIME type of the binary content (e.g. 'application/pdf')
76 | #[serde(rename = "mimeType")]
77 | #[serde(skip_serializing_if = "Option::is_none")]
78 | #[serde(default)]
79 | pub mime_type: Option<String>,
80 |
81 | /// URI of the resource
82 | #[serde(rename = "uri")]
83 | pub uri: String,
84 | }
85 |
86 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
87 | #[encoding(Json)]
88 | pub struct BooleanSchema {
89 | /// Optional default value
90 | #[serde(rename = "default")]
91 | #[serde(skip_serializing_if = "Option::is_none")]
92 | #[serde(default)]
93 | pub default: Option<bool>,
94 |
95 | /// Description of the boolean input
96 | #[serde(rename = "description")]
97 | #[serde(skip_serializing_if = "Option::is_none")]
98 | #[serde(default)]
99 | pub description: Option<String>,
100 |
101 | /// Optional human-readable title
102 | #[serde(rename = "title")]
103 | #[serde(skip_serializing_if = "Option::is_none")]
104 | #[serde(default)]
105 | pub title: Option<String>,
106 |
107 | #[serde(rename = "type")]
108 | pub r#type: BooleanType,
109 | }
110 |
111 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
112 | #[encoding(Json)]
113 | pub enum BooleanType {
114 | #[default]
115 | #[serde(rename = "boolean")]
116 | Boolean,
117 | }
118 |
119 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
120 | #[encoding(Json)]
121 | pub struct CallToolRequest {
122 | #[serde(rename = "context")]
123 | pub context: PluginRequestContext,
124 |
125 | #[serde(rename = "request")]
126 | pub request: CallToolRequestParam,
127 | }
128 |
129 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
130 | #[encoding(Json)]
131 | pub struct CallToolRequestParam {
132 | /// Arguments to pass to the tool
133 | #[serde(rename = "arguments")]
134 | #[serde(skip_serializing_if = "Option::is_none")]
135 | #[serde(default)]
136 | pub arguments: Option<Map<String, Value>>,
137 |
138 | /// The name of the tool to call
139 | #[serde(rename = "name")]
140 | pub name: String,
141 | }
142 |
143 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
144 | #[encoding(Json)]
145 | pub struct CallToolResult {
146 | /// Optional additional metadata about the tool call result
147 | #[serde(rename = "_meta")]
148 | #[serde(skip_serializing_if = "Option::is_none")]
149 | #[serde(default)]
150 | pub meta: Option<Meta>,
151 |
152 | /// Array of TextContent, ImageContent, AudioContent, EmbeddedResource, or ResourceLinks representing the result
153 | #[serde(rename = "content")]
154 | pub content: Vec<ContentBlock>,
155 |
156 | /// Whether the tool call ended in an error. If not set, defaults to false.
157 | #[serde(rename = "isError")]
158 | #[serde(skip_serializing_if = "Option::is_none")]
159 | #[serde(default)]
160 | pub is_error: Option<bool>,
161 |
162 | /// Optional structured JSON result from the tool
163 | #[serde(rename = "structuredContent")]
164 | #[serde(skip_serializing_if = "Option::is_none")]
165 | #[serde(default)]
166 | pub structured_content: Option<Map<String, Value>>,
167 | }
168 |
169 | #[derive(Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
170 | #[encoding(Json)]
171 | pub struct CompleteRequest {
172 | #[serde(rename = "context")]
173 | pub context: PluginRequestContext,
174 |
175 | #[serde(rename = "request")]
176 | pub request: CompleteRequestParam,
177 | }
178 |
179 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
180 | #[encoding(Json)]
181 | pub struct CompleteRequestParam {
182 | #[serde(rename = "argument")]
183 | pub argument: CompleteRequestParamArgument,
184 |
185 | /// Optional completion context with previously-resolved arguments
186 | #[serde(rename = "context")]
187 | #[serde(skip_serializing_if = "Option::is_none")]
188 | pub context: Option<CompleteRequestParamContext>,
189 |
190 | /// Reference to either a PromptReference or ResourceTemplateReference
191 | #[serde(rename = "ref")]
192 | pub r#ref: Reference,
193 | }
194 |
195 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
196 | #[encoding(Json)]
197 | pub struct CompleteRequestParamArgument {
198 | /// Name of the argument
199 | #[serde(rename = "name")]
200 | pub name: String,
201 |
202 | /// Current value to complete
203 | #[serde(rename = "value")]
204 | pub value: String,
205 | }
206 |
207 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
208 | #[encoding(Json)]
209 | pub struct CompleteRequestParamContext {
210 | /// Previously-resolved argument values
211 | #[serde(rename = "arguments")]
212 | #[serde(skip_serializing_if = "Option::is_none")]
213 | #[serde(default)]
214 | pub arguments: Option<HashMap<String, String>>,
215 | }
216 |
217 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
218 | #[encoding(Json)]
219 | pub struct CompleteResult {
220 | #[serde(rename = "completion")]
221 | pub completion: CompleteResultCompletion,
222 | }
223 |
224 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
225 | #[encoding(Json)]
226 | pub struct CompleteResultCompletion {
227 | /// Whether there are more completions available
228 | #[serde(rename = "hasMore")]
229 | #[serde(skip_serializing_if = "Option::is_none")]
230 | #[serde(default)]
231 | pub has_more: Option<bool>,
232 |
233 | /// Total number of available completions
234 | #[serde(rename = "total")]
235 | #[serde(skip_serializing_if = "Option::is_none")]
236 | #[serde(default)]
237 | pub total: Option<i64>,
238 |
239 | /// Array of completion values (max 100 items)
240 | #[serde(rename = "values")]
241 | pub values: Vec<String>,
242 | }
243 |
244 | #[derive(Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
245 | #[encoding(Json)]
246 | #[serde(untagged)]
247 | pub enum ContentBlock {
248 | Audio(AudioContent),
249 | EmbeddedResource(EmbeddedResource),
250 | Image(ImageContent),
251 | ResourceLink(ResourceLink),
252 | Text(TextContent),
253 | Empty(Empty),
254 | }
255 |
256 | impl Default for ContentBlock {
257 | fn default() -> Self {
258 | ContentBlock::Empty(Empty::default())
259 | }
260 | }
261 |
262 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
263 | #[encoding(Json)]
264 | pub struct CreateMessageRequestParam {
265 | #[serde(rename = "includeContext")]
266 | #[serde(skip_serializing_if = "Option::is_none")]
267 | #[serde(default)]
268 | pub include_context: Option<CreateMessageRequestParamIncludeContext>,
269 |
270 | /// Maximum tokens to sample
271 | #[serde(rename = "maxTokens")]
272 | pub max_tokens: i64,
273 |
274 | /// Conversation messages of of TextContent, ImageContent or AudioContent
275 | #[serde(rename = "messages")]
276 | pub messages: Vec<SamplingMessage>,
277 |
278 | /// Preferences for model selection
279 | #[serde(rename = "modelPreferences")]
280 | #[serde(skip_serializing_if = "Option::is_none")]
281 | #[serde(default)]
282 | pub model_preferences: Option<ModelPreferences>,
283 |
284 | /// Stop sequences
285 | #[serde(rename = "stopSequences")]
286 | #[serde(skip_serializing_if = "Option::is_none")]
287 | #[serde(default)]
288 | pub stop_sequences: Option<Vec<String>>,
289 |
290 | /// Optional system prompt
291 | #[serde(rename = "systemPrompt")]
292 | #[serde(skip_serializing_if = "Option::is_none")]
293 | #[serde(default)]
294 | pub system_prompt: Option<String>,
295 |
296 | /// Sampling temperature
297 | #[serde(rename = "temperature")]
298 | #[serde(skip_serializing_if = "Option::is_none")]
299 | #[serde(default)]
300 | pub temperature: Option<f64>,
301 | }
302 |
303 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
304 | #[encoding(Json)]
305 | pub enum CreateMessageRequestParamIncludeContext {
306 | #[default]
307 | #[serde(rename = "none")]
308 | None,
309 | #[serde(rename = "thisServer")]
310 | ThisServer,
311 | #[serde(rename = "allServers")]
312 | AllServers,
313 | }
314 |
315 | #[derive(Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
316 | #[encoding(Json)]
317 | pub struct CreateMessageResult {
318 | /// One of TextContent, ImageContent or AudioContent
319 | #[serde(rename = "content")]
320 | pub content: CreateMessageResultContent,
321 |
322 | /// Name of the model used
323 | #[serde(rename = "model")]
324 | pub model: String,
325 |
326 | #[serde(rename = "role")]
327 | pub role: Role,
328 |
329 | /// Optional reason sampling stopped
330 | #[serde(rename = "stopReason")]
331 | #[serde(skip_serializing_if = "Option::is_none")]
332 | #[serde(default)]
333 | pub stop_reason: Option<String>,
334 | }
335 |
336 | type CreateMessageResultContent = SamplingMessage;
337 |
338 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
339 | #[encoding(Json)]
340 | pub struct ElicitRequestParamWithTimeout {
341 | /// Message to present to the user
342 | #[serde(rename = "message")]
343 | pub message: String,
344 |
345 | #[serde(rename = "requestedSchema")]
346 | pub requested_schema: Schema,
347 |
348 | /// Optional timeout in milliseconds
349 | #[serde(rename = "timeout")]
350 | #[serde(skip_serializing_if = "Option::is_none")]
351 | #[serde(default)]
352 | pub timeout: Option<i64>,
353 | }
354 |
355 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
356 | #[encoding(Json)]
357 | pub struct ElicitResult {
358 | #[serde(rename = "action")]
359 | pub action: ElicitResultAction,
360 |
361 | /// Form data submitted by user (only present when action is accept)
362 | #[serde(rename = "content")]
363 | #[serde(skip_serializing_if = "Option::is_none")]
364 | #[serde(default)]
365 | pub content: Option<HashMap<String, ElicitResultContentValue>>,
366 | }
367 |
368 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
369 | #[encoding(Json)]
370 | pub enum ElicitResultAction {
371 | #[default]
372 | #[serde(rename = "accept")]
373 | Accept,
374 | #[serde(rename = "decline")]
375 | Decline,
376 | #[serde(rename = "cancel")]
377 | Cancel,
378 | }
379 |
380 | #[derive(Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
381 | #[encoding(Json)]
382 | #[serde(untagged)]
383 | pub enum ElicitResultContentValue {
384 | String(String),
385 | Number(Number), // or serde_json::Number if you want exactness
386 | Bool(bool),
387 | }
388 |
389 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
390 | #[encoding(Json)]
391 | pub struct EmbeddedResource {
392 | /// Optional additional metadata about the embedded resource
393 | #[serde(rename = "_meta")]
394 | #[serde(skip_serializing_if = "Option::is_none")]
395 | #[serde(default)]
396 | pub meta: Option<Meta>,
397 |
398 | /// Optional resource annotations
399 | #[serde(rename = "annotations")]
400 | #[serde(skip_serializing_if = "Option::is_none")]
401 | #[serde(default)]
402 | pub annotations: Option<Annotations>,
403 |
404 | /// The embedded TextResourceContents or BlobResourceContents
405 | #[serde(rename = "resource")]
406 | pub resource: ResourceContents,
407 |
408 | #[serde(rename = "type")]
409 | pub r#type: ResourceType,
410 | }
411 |
412 | #[derive(Default, Debug, Clone, Serialize, Deserialize)]
413 | #[serde(deny_unknown_fields)]
414 | pub struct Empty {}
415 |
416 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
417 | #[encoding(Json)]
418 | pub struct EnumSchema {
419 | /// Description of the enum input
420 | #[serde(rename = "description")]
421 | #[serde(skip_serializing_if = "Option::is_none")]
422 | #[serde(default)]
423 | pub description: Option<String>,
424 |
425 | /// Array of allowed string values
426 | #[serde(rename = "enum")]
427 | pub r#enum: Vec<String>,
428 |
429 | /// Optional array of human-readable names for the enum values
430 | #[serde(rename = "enumNames")]
431 | #[serde(skip_serializing_if = "Option::is_none")]
432 | #[serde(default)]
433 | pub enum_names: Option<Vec<String>>,
434 |
435 | /// Optional human-readable title
436 | #[serde(rename = "title")]
437 | #[serde(skip_serializing_if = "Option::is_none")]
438 | #[serde(default)]
439 | pub title: Option<String>,
440 |
441 | #[serde(rename = "type")]
442 | pub r#type: StringType,
443 | }
444 |
445 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
446 | #[encoding(Json)]
447 | pub struct GetPromptRequest {
448 | #[serde(rename = "context")]
449 | pub context: PluginRequestContext,
450 |
451 | #[serde(rename = "request")]
452 | pub request: GetPromptRequestParam,
453 | }
454 |
455 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
456 | #[encoding(Json)]
457 | pub struct GetPromptRequestParam {
458 | /// Arguments for templating the prompt
459 | #[serde(rename = "arguments")]
460 | #[serde(skip_serializing_if = "Option::is_none")]
461 | #[serde(default)]
462 | pub arguments: Option<HashMap<String, String>>,
463 |
464 | /// Name of the prompt to retrieve
465 | #[serde(rename = "name")]
466 | pub name: String,
467 | }
468 |
469 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
470 | #[encoding(Json)]
471 | pub struct GetPromptResult {
472 | /// Optional description of the prompt
473 | #[serde(rename = "description")]
474 | #[serde(skip_serializing_if = "Option::is_none")]
475 | #[serde(default)]
476 | pub description: Option<String>,
477 |
478 | /// Array of prompt messages
479 | #[serde(rename = "messages")]
480 | pub messages: Vec<PromptMessage>,
481 | }
482 |
483 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
484 | #[encoding(Json)]
485 | pub struct ImageContent {
486 | /// Optional additional metadata about the content block
487 | #[serde(rename = "_meta")]
488 | #[serde(skip_serializing_if = "Option::is_none")]
489 | #[serde(default)]
490 | pub meta: Option<Meta>,
491 |
492 | /// Optional content annotations
493 | #[serde(rename = "annotations")]
494 | #[serde(skip_serializing_if = "Option::is_none")]
495 | #[serde(default)]
496 | pub annotations: Option<Annotations>,
497 |
498 | /// Base64-encoded image data
499 | #[serde(rename = "data")]
500 | pub data: String,
501 |
502 | /// MIME type of the image (e.g. 'image/png')
503 | #[serde(rename = "mimeType")]
504 | pub mime_type: String,
505 |
506 | #[serde(rename = "type")]
507 | pub r#type: ImageType,
508 | }
509 |
510 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
511 | #[encoding(Json)]
512 | pub enum ImageType {
513 | #[default]
514 | #[serde(rename = "image")]
515 | Image,
516 | }
517 |
518 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
519 | #[encoding(Json)]
520 | pub struct ListPromptsRequest {
521 | #[serde(rename = "context")]
522 | pub context: PluginRequestContext,
523 | }
524 |
525 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
526 | #[encoding(Json)]
527 | pub struct ListPromptsResult {
528 | /// Array of available prompts
529 | #[serde(rename = "prompts")]
530 | pub prompts: Vec<Prompt>,
531 | }
532 |
533 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
534 | #[encoding(Json)]
535 | pub struct ListResourcesRequest {
536 | #[serde(rename = "context")]
537 | pub context: PluginRequestContext,
538 | }
539 |
540 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
541 | #[encoding(Json)]
542 | pub struct ListResourcesResult {
543 | /// Array of available resources
544 | #[serde(rename = "resources")]
545 | pub resources: Vec<Resource>,
546 | }
547 |
548 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
549 | #[encoding(Json)]
550 | pub struct ListResourceTemplatesRequest {
551 | #[serde(rename = "context")]
552 | pub context: PluginRequestContext,
553 | }
554 |
555 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
556 | #[encoding(Json)]
557 | pub struct ListResourceTemplatesResult {
558 | /// Array of resource templates
559 | #[serde(rename = "resourceTemplates")]
560 | pub resource_templates: Vec<ResourceTemplate>,
561 | }
562 |
563 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
564 | #[encoding(Json)]
565 | pub struct ListRootsResult {
566 | /// Array of root directories/resources
567 | #[serde(rename = "roots")]
568 | pub roots: Vec<Root>,
569 | }
570 |
571 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
572 | #[encoding(Json)]
573 | pub struct ListToolsRequest {
574 | #[serde(rename = "context")]
575 | pub context: PluginRequestContext,
576 | }
577 |
578 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
579 | #[encoding(Json)]
580 | pub struct ListToolsResult {
581 | /// Array of available tools
582 | #[serde(rename = "tools")]
583 | pub tools: Vec<Tool>,
584 | }
585 |
586 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
587 | #[encoding(Json)]
588 | pub enum LoggingLevel {
589 | #[default]
590 | #[serde(rename = "debug")]
591 | Debug,
592 | #[serde(rename = "info")]
593 | Info,
594 | #[serde(rename = "notice")]
595 | Notice,
596 | #[serde(rename = "warning")]
597 | Warning,
598 | #[serde(rename = "error")]
599 | Error,
600 | #[serde(rename = "critical")]
601 | Critical,
602 | #[serde(rename = "alert")]
603 | Alert,
604 | #[serde(rename = "emergency")]
605 | Emergency,
606 | }
607 |
608 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
609 | #[encoding(Json)]
610 | pub struct LoggingMessageNotificationParam {
611 | /// Data to log (any JSON-serializable type)
612 | #[serde(rename = "data")]
613 | pub data: Value,
614 |
615 | #[serde(rename = "level")]
616 | pub level: LoggingLevel,
617 |
618 | /// Optional logger name
619 | #[serde(rename = "logger")]
620 | #[serde(skip_serializing_if = "Option::is_none")]
621 | #[serde(default)]
622 | pub logger: Option<String>,
623 | }
624 |
625 | type Meta = Map<String, Value>;
626 |
627 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
628 | #[encoding(Json)]
629 | pub struct ModelHint {
630 | /// Suggested model name or family
631 | #[serde(rename = "name")]
632 | pub name: String,
633 | }
634 |
635 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
636 | #[encoding(Json)]
637 | pub struct ModelPreferences {
638 | /// Priority for cost (0-1)
639 | #[serde(rename = "costPriority")]
640 | pub cost_priority: f32,
641 |
642 | /// Model name hints
643 | #[serde(rename = "hints")]
644 | pub hints: Vec<ModelHint>,
645 |
646 | /// Priority for intelligence (0-1)
647 | #[serde(rename = "intelligencePriority")]
648 | pub intelligence_priority: f32,
649 |
650 | /// Priority for speed (0-1)
651 | #[serde(rename = "speedPriority")]
652 | pub speed_priority: f32,
653 | }
654 |
655 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
656 | #[encoding(Json)]
657 | pub struct NumberSchema {
658 | /// Description of the number input
659 | #[serde(rename = "description")]
660 | #[serde(skip_serializing_if = "Option::is_none")]
661 | #[serde(default)]
662 | pub description: Option<String>,
663 |
664 | /// Maximum value
665 | #[serde(rename = "maximum")]
666 | #[serde(skip_serializing_if = "Option::is_none")]
667 | #[serde(default)]
668 | pub maximum: Option<f64>,
669 |
670 | /// Minimum value
671 | #[serde(rename = "minimum")]
672 | #[serde(skip_serializing_if = "Option::is_none")]
673 | #[serde(default)]
674 | pub minimum: Option<f64>,
675 |
676 | /// Optional human-readable title
677 | #[serde(rename = "title")]
678 | #[serde(skip_serializing_if = "Option::is_none")]
679 | #[serde(default)]
680 | pub title: Option<String>,
681 |
682 | #[serde(rename = "type")]
683 | pub r#type: NumberType,
684 | }
685 |
686 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
687 | #[encoding(Json)]
688 | pub enum NumberType {
689 | #[default]
690 | #[serde(rename = "number")]
691 | Number,
692 | #[serde(rename = "integer")]
693 | Integer,
694 | }
695 |
696 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
697 | #[encoding(Json)]
698 | pub enum ObjectType {
699 | #[default]
700 | #[serde(rename = "object")]
701 | Object,
702 | }
703 |
704 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
705 | #[encoding(Json)]
706 | pub struct PluginNotificationContext {
707 | /// Additional metadata about the notification
708 | #[serde(rename = "meta")]
709 | pub meta: Meta,
710 | }
711 |
712 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
713 | #[encoding(Json)]
714 | pub struct PluginRequestContext {
715 | /// Additional metadata about the request
716 | #[serde(rename = "_meta")]
717 | pub meta: Meta,
718 |
719 | /// Unique identifier for this request
720 | #[serde(rename = "id")]
721 | pub id: PluginRequestId,
722 | }
723 |
724 | #[derive(Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
725 | #[encoding(Json)]
726 | #[serde(untagged)]
727 | pub enum PluginRequestId {
728 | String(String),
729 | Number(i64),
730 | }
731 |
732 | impl Default for PluginRequestId {
733 | fn default() -> Self {
734 | PluginRequestId::String(String::new())
735 | }
736 | }
737 |
738 | #[derive(Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
739 | #[encoding(Json)]
740 | #[serde(untagged)]
741 | pub enum PrimitiveSchemaDefinition {
742 | Boolean(BooleanSchema),
743 | Enum(EnumSchema),
744 | Number(NumberSchema),
745 | String(StringSchema),
746 | Empty(Empty),
747 | }
748 |
749 | impl Default for PrimitiveSchemaDefinition {
750 | fn default() -> Self {
751 | PrimitiveSchemaDefinition::Empty(Empty::default())
752 | }
753 | }
754 |
755 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
756 | #[encoding(Json)]
757 | pub struct ProgressNotificationParam {
758 | /// Optional progress message describing current operation
759 | #[serde(rename = "message")]
760 | #[serde(skip_serializing_if = "Option::is_none")]
761 | #[serde(default)]
762 | pub message: Option<String>,
763 |
764 | /// The progress thus far
765 | #[serde(rename = "progress")]
766 | pub progress: f64,
767 |
768 | /// A token identifying the progress context
769 | #[serde(rename = "progressToken")]
770 | pub progress_token: String,
771 |
772 | /// Optional total units of work
773 | #[serde(rename = "total")]
774 | #[serde(skip_serializing_if = "Option::is_none")]
775 | #[serde(default)]
776 | pub total: Option<f64>,
777 | }
778 |
779 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
780 | #[encoding(Json)]
781 | pub struct Prompt {
782 | /// Optional prompt arguments
783 | #[serde(rename = "arguments")]
784 | #[serde(skip_serializing_if = "Option::is_none")]
785 | #[serde(default)]
786 | pub arguments: Option<Vec<PromptArgument>>,
787 |
788 | /// Description of what the prompt does
789 | #[serde(rename = "description")]
790 | #[serde(skip_serializing_if = "Option::is_none")]
791 | #[serde(default)]
792 | pub description: Option<String>,
793 |
794 | /// Unique name of the prompt
795 | #[serde(rename = "name")]
796 | pub name: String,
797 |
798 | /// Human-readable title
799 | #[serde(rename = "title")]
800 | #[serde(skip_serializing_if = "Option::is_none")]
801 | #[serde(default)]
802 | pub title: Option<String>,
803 | }
804 |
805 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
806 | #[encoding(Json)]
807 | pub struct PromptArgument {
808 | /// Description of the argument
809 | #[serde(rename = "description")]
810 | #[serde(skip_serializing_if = "Option::is_none")]
811 | #[serde(default)]
812 | pub description: Option<String>,
813 |
814 | /// Name of the argument
815 | #[serde(rename = "name")]
816 | pub name: String,
817 |
818 | /// Whether this argument is required
819 | #[serde(rename = "required")]
820 | #[serde(skip_serializing_if = "Option::is_none")]
821 | #[serde(default)]
822 | pub required: Option<bool>,
823 |
824 | /// Human-readable title
825 | #[serde(rename = "title")]
826 | #[serde(skip_serializing_if = "Option::is_none")]
827 | #[serde(default)]
828 | pub title: Option<String>,
829 | }
830 |
831 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
832 | #[encoding(Json)]
833 | pub struct PromptMessage {
834 | /// One of TextContent, ImageContent, AudioContent, EmbeddedResource, or ResourceLink
835 | #[serde(rename = "content")]
836 | pub content: ContentBlock,
837 |
838 | #[serde(rename = "role")]
839 | pub role: Role,
840 | }
841 |
842 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
843 | #[encoding(Json)]
844 | pub struct PromptReference {
845 | /// Name of the prompt
846 | #[serde(rename = "name")]
847 | pub name: String,
848 |
849 | /// Optional human-readable title
850 | #[serde(rename = "title")]
851 | #[serde(skip_serializing_if = "Option::is_none")]
852 | #[serde(default)]
853 | pub title: Option<String>,
854 |
855 | #[serde(rename = "type")]
856 | pub r#type: PromptReferenceType,
857 | }
858 |
859 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
860 | #[encoding(Json)]
861 | pub enum PromptReferenceType {
862 | #[default]
863 | #[serde(rename = "prompt")]
864 | Prompt,
865 | }
866 |
867 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
868 | #[encoding(Json)]
869 | pub struct ReadResourceRequest {
870 | #[serde(rename = "context")]
871 | pub context: PluginRequestContext,
872 |
873 | #[serde(rename = "request")]
874 | pub request: ReadResourceRequestParam,
875 | }
876 |
877 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
878 | #[encoding(Json)]
879 | pub struct ReadResourceRequestParam {
880 | /// URI of the resource to read
881 | #[serde(rename = "uri")]
882 | pub uri: String,
883 | }
884 |
885 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
886 | #[encoding(Json)]
887 | pub struct ReadResourceResult {
888 | /// Array of TextResourceContents or BlobResourceContents
889 | #[serde(rename = "contents")]
890 | pub contents: Vec<ResourceContents>,
891 | }
892 |
893 | #[derive(Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
894 | #[encoding(Json)]
895 | #[serde(untagged)]
896 | pub enum Reference {
897 | Prompt(PromptReference),
898 | ResourceTemplate(ResourceTemplateReference),
899 | Empty(Empty),
900 | }
901 |
902 | impl Default for Reference {
903 | fn default() -> Self {
904 | Reference::Empty(Empty::default())
905 | }
906 | }
907 |
908 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
909 | #[encoding(Json)]
910 | pub struct Resource {
911 | /// Optional resource annotations
912 | #[serde(rename = "annotations")]
913 | #[serde(skip_serializing_if = "Option::is_none")]
914 | #[serde(default)]
915 | pub annotations: Option<Annotations>,
916 |
917 | /// Description of the resource
918 | #[serde(rename = "description")]
919 | #[serde(skip_serializing_if = "Option::is_none")]
920 | #[serde(default)]
921 | pub description: Option<String>,
922 |
923 | /// MIME type of the resource
924 | #[serde(rename = "mimeType")]
925 | #[serde(skip_serializing_if = "Option::is_none")]
926 | #[serde(default)]
927 | pub mime_type: Option<String>,
928 |
929 | /// Human-readable name
930 | #[serde(rename = "name")]
931 | pub name: String,
932 |
933 | /// Size in bytes
934 | #[serde(rename = "size")]
935 | #[serde(skip_serializing_if = "Option::is_none")]
936 | #[serde(default)]
937 | pub size: Option<i64>,
938 |
939 | /// Human-readable title
940 | #[serde(rename = "title")]
941 | #[serde(skip_serializing_if = "Option::is_none")]
942 | #[serde(default)]
943 | pub title: Option<String>,
944 |
945 | /// URI of the resource
946 | #[serde(rename = "uri")]
947 | pub uri: String,
948 | }
949 |
950 | #[derive(Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
951 | #[encoding(Json)]
952 | #[serde(untagged)]
953 | pub enum ResourceContents {
954 | Blob(BlobResourceContents),
955 | Text(TextResourceContents),
956 | Empty(Empty),
957 | }
958 |
959 | impl Default for ResourceContents {
960 | fn default() -> Self {
961 | ResourceContents::Empty(Empty::default())
962 | }
963 | }
964 |
965 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
966 | #[encoding(Json)]
967 | pub struct ResourceLink {
968 | /// Optional additional metadata about the resource link
969 | #[serde(rename = "_meta")]
970 | #[serde(skip_serializing_if = "Option::is_none")]
971 | #[serde(default)]
972 | pub meta: Option<Meta>,
973 |
974 | /// Optional resource annotations
975 | #[serde(rename = "annotations")]
976 | #[serde(skip_serializing_if = "Option::is_none")]
977 | #[serde(default)]
978 | pub annotations: Option<Annotations>,
979 |
980 | /// Optional description of the resource
981 | #[serde(rename = "description")]
982 | #[serde(skip_serializing_if = "Option::is_none")]
983 | #[serde(default)]
984 | pub description: Option<String>,
985 |
986 | /// Optional MIME type of the resource
987 | #[serde(rename = "mimeType")]
988 | #[serde(skip_serializing_if = "Option::is_none")]
989 | #[serde(default)]
990 | pub mime_type: Option<String>,
991 |
992 | /// Optional human-readable name
993 | #[serde(rename = "name")]
994 | pub name: String,
995 |
996 | /// Optional size in bytes
997 | #[serde(rename = "size")]
998 | #[serde(skip_serializing_if = "Option::is_none")]
999 | #[serde(default)]
1000 | pub size: Option<i64>,
1001 |
1002 | /// Optional human-readable title
1003 | #[serde(rename = "title")]
1004 | #[serde(skip_serializing_if = "Option::is_none")]
1005 | #[serde(default)]
1006 | pub title: Option<String>,
1007 |
1008 | #[serde(rename = "type")]
1009 | pub r#type: ResourceLinkType,
1010 |
1011 | /// URI of the resource
1012 | #[serde(rename = "uri")]
1013 | pub uri: String,
1014 | }
1015 |
1016 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1017 | #[encoding(Json)]
1018 | pub enum ResourceLinkType {
1019 | #[default]
1020 | #[serde(rename = "resource_link")]
1021 | ResourceLink,
1022 | }
1023 |
1024 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1025 | #[encoding(Json)]
1026 | pub enum ResourceReferenceType {
1027 | #[default]
1028 | #[serde(rename = "resource")]
1029 | Resource,
1030 | }
1031 |
1032 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1033 | #[encoding(Json)]
1034 | pub struct ResourceTemplate {
1035 | #[serde(rename = "annotations")]
1036 | #[serde(skip_serializing_if = "Option::is_none")]
1037 | #[serde(default)]
1038 | pub annotations: Option<Annotations>,
1039 |
1040 | /// Description of the template
1041 | #[serde(rename = "description")]
1042 | #[serde(skip_serializing_if = "Option::is_none")]
1043 | #[serde(default)]
1044 | pub description: Option<String>,
1045 |
1046 | /// MIME type for resources matching this template
1047 | #[serde(rename = "mimeType")]
1048 | #[serde(skip_serializing_if = "Option::is_none")]
1049 | #[serde(default)]
1050 | pub mime_type: Option<String>,
1051 |
1052 | /// Human-readable name
1053 | #[serde(rename = "name")]
1054 | pub name: String,
1055 |
1056 | /// Human-readable title
1057 | #[serde(rename = "title")]
1058 | #[serde(skip_serializing_if = "Option::is_none")]
1059 | #[serde(default)]
1060 | pub title: Option<String>,
1061 |
1062 | /// RFC 6570 URI template pattern
1063 | #[serde(rename = "uriTemplate")]
1064 | pub uri_template: String,
1065 | }
1066 |
1067 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1068 | #[encoding(Json)]
1069 | pub struct ResourceTemplateReference {
1070 | #[serde(rename = "type")]
1071 | pub r#type: ResourceReferenceType,
1072 |
1073 | /// URI or URI template pattern of the resource
1074 | #[serde(rename = "uri")]
1075 | pub uri: String,
1076 | }
1077 |
1078 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1079 | #[encoding(Json)]
1080 | pub enum ResourceType {
1081 | #[default]
1082 | #[serde(rename = "resource")]
1083 | Resource,
1084 | }
1085 |
1086 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1087 | #[encoding(Json)]
1088 | pub struct ResourceUpdatedNotificationParam {
1089 | /// URI of the updated resource
1090 | #[serde(rename = "uri")]
1091 | pub uri: String,
1092 | }
1093 |
1094 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1095 | #[encoding(Json)]
1096 | pub enum Role {
1097 | #[default]
1098 | #[serde(rename = "assistant")]
1099 | Assistant,
1100 | #[serde(rename = "user")]
1101 | User,
1102 | }
1103 |
1104 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1105 | #[encoding(Json)]
1106 | pub struct Root {
1107 | /// Optional human-readable name
1108 | #[serde(rename = "name")]
1109 | #[serde(skip_serializing_if = "Option::is_none")]
1110 | #[serde(default)]
1111 | pub name: Option<String>,
1112 |
1113 | /// URI of the root (typically file://)
1114 | #[serde(rename = "uri")]
1115 | pub uri: String,
1116 | }
1117 |
1118 | #[derive(Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1119 | #[encoding(Json)]
1120 | #[serde(untagged)]
1121 | pub enum SamplingMessage {
1122 | Audio(AudioContent),
1123 | Image(ImageContent),
1124 | Text(TextContent),
1125 | Empty(Empty),
1126 | }
1127 |
1128 | impl Default for SamplingMessage {
1129 | fn default() -> Self {
1130 | SamplingMessage::Empty(Empty::default())
1131 | }
1132 | }
1133 |
1134 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1135 | #[encoding(Json)]
1136 | pub struct Schema {
1137 | /// A map of StringSchema, NumberSchema, BooleanSchema or EnumSchema definitions (no nesting)
1138 | #[serde(rename = "properties")]
1139 | pub properties: HashMap<String, PrimitiveSchemaDefinition>,
1140 |
1141 | /// Required property names
1142 | #[serde(rename = "required")]
1143 | #[serde(skip_serializing_if = "Option::is_none")]
1144 | #[serde(default)]
1145 | pub required: Option<Vec<String>>,
1146 |
1147 | #[serde(rename = "type")]
1148 | pub r#type: ObjectType,
1149 | }
1150 |
1151 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1152 | #[encoding(Json)]
1153 | pub struct StringSchema {
1154 | /// Description of the string input
1155 | #[serde(rename = "description")]
1156 | #[serde(skip_serializing_if = "Option::is_none")]
1157 | #[serde(default)]
1158 | pub description: Option<String>,
1159 |
1160 | #[serde(rename = "format")]
1161 | #[serde(skip_serializing_if = "Option::is_none")]
1162 | #[serde(default)]
1163 | pub format: Option<StringSchemaFormat>,
1164 |
1165 | /// Maximum length of the string
1166 | #[serde(rename = "maxLength")]
1167 | #[serde(skip_serializing_if = "Option::is_none")]
1168 | #[serde(default)]
1169 | pub max_length: Option<i64>,
1170 |
1171 | /// Minimum length of the string
1172 | #[serde(rename = "minLength")]
1173 | #[serde(skip_serializing_if = "Option::is_none")]
1174 | #[serde(default)]
1175 | pub min_length: Option<i64>,
1176 |
1177 | /// Optional human-readable title
1178 | #[serde(rename = "title")]
1179 | #[serde(skip_serializing_if = "Option::is_none")]
1180 | #[serde(default)]
1181 | pub title: Option<String>,
1182 |
1183 | #[serde(rename = "type")]
1184 | pub r#type: StringType,
1185 | }
1186 |
1187 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1188 | #[encoding(Json)]
1189 | pub enum StringSchemaFormat {
1190 | #[default]
1191 | #[serde(rename = "email")]
1192 | Email,
1193 | #[serde(rename = "uri")]
1194 | Uri,
1195 | #[serde(rename = "date")]
1196 | Date,
1197 | #[serde(rename = "date_time")]
1198 | Datetime,
1199 | }
1200 |
1201 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1202 | #[encoding(Json)]
1203 | pub enum StringType {
1204 | #[default]
1205 | #[serde(rename = "string")]
1206 | String,
1207 | }
1208 |
1209 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1210 | #[encoding(Json)]
1211 | pub struct TextContent {
1212 | /// Optional additional metadata about the content block
1213 | #[serde(rename = "_meta")]
1214 | #[serde(skip_serializing_if = "Option::is_none")]
1215 | #[serde(default)]
1216 | pub meta: Option<Meta>,
1217 |
1218 | /// Optional content annotations
1219 | #[serde(rename = "annotations")]
1220 | #[serde(skip_serializing_if = "Option::is_none")]
1221 | #[serde(default)]
1222 | pub annotations: Option<Annotations>,
1223 |
1224 | /// The text content
1225 | #[serde(rename = "text")]
1226 | pub text: String,
1227 |
1228 | #[serde(rename = "type")]
1229 | pub r#type: TextType,
1230 | }
1231 |
1232 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1233 | #[encoding(Json)]
1234 | pub struct TextResourceContents {
1235 | /// Optional additional metadata about the text resource
1236 | #[serde(rename = "_meta")]
1237 | #[serde(skip_serializing_if = "Option::is_none")]
1238 | #[serde(default)]
1239 | pub meta: Option<Meta>,
1240 |
1241 | /// MIME type of the text content (e.g. 'text/plain')
1242 | #[serde(rename = "mimeType")]
1243 | #[serde(skip_serializing_if = "Option::is_none")]
1244 | #[serde(default)]
1245 | pub mime_type: Option<String>,
1246 |
1247 | /// Text content of the resource
1248 | #[serde(rename = "text")]
1249 | pub text: String,
1250 |
1251 | /// URI of the resource
1252 | #[serde(rename = "uri")]
1253 | pub uri: String,
1254 | }
1255 |
1256 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1257 | #[encoding(Json)]
1258 | pub enum TextType {
1259 | #[default]
1260 | #[serde(rename = "text")]
1261 | Text,
1262 | }
1263 |
1264 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1265 | #[encoding(Json)]
1266 | pub struct Tool {
1267 | /// Optional tool annotations
1268 | #[serde(rename = "annotations")]
1269 | #[serde(skip_serializing_if = "Option::is_none")]
1270 | #[serde(default)]
1271 | pub annotations: Option<Annotations>,
1272 |
1273 | /// Description of what the tool does
1274 | #[serde(rename = "description")]
1275 | #[serde(skip_serializing_if = "Option::is_none")]
1276 | #[serde(default)]
1277 | pub description: Option<String>,
1278 |
1279 | #[serde(rename = "inputSchema")]
1280 | pub input_schema: ToolSchema,
1281 |
1282 | /// Unique name of the tool
1283 | #[serde(rename = "name")]
1284 | pub name: String,
1285 |
1286 | #[serde(rename = "outputSchema")]
1287 | #[serde(skip_serializing_if = "Option::is_none")]
1288 | #[serde(default)]
1289 | pub output_schema: Option<ToolSchema>,
1290 |
1291 | /// Human-readable title
1292 | #[serde(rename = "title")]
1293 | #[serde(skip_serializing_if = "Option::is_none")]
1294 | #[serde(default)]
1295 | pub title: Option<String>,
1296 | }
1297 |
1298 | #[derive(Default, Debug, Clone, Serialize, Deserialize, FromBytes, ToBytes)]
1299 | #[encoding(Json)]
1300 | pub struct ToolSchema {
1301 | /// Schema properties
1302 | #[serde(rename = "properties")]
1303 | #[serde(skip_serializing_if = "Option::is_none")]
1304 | #[serde(default)]
1305 | pub properties: Option<Map<String, Value>>,
1306 |
1307 | /// Required properties
1308 | #[serde(rename = "required")]
1309 | #[serde(skip_serializing_if = "Option::is_none")]
1310 | #[serde(default)]
1311 | pub required: Option<Vec<String>>,
1312 |
1313 | #[serde(rename = "type")]
1314 | pub r#type: ObjectType,
1315 | }
1316 |
```