feat(meta): add _meta field to prompts, resources and paginated result (#558)
This commit is contained in:
parent
eb5a7f7408
commit
81411fc12d
9 changed files with 195 additions and 8 deletions
|
|
@ -102,7 +102,7 @@ where
|
|||
let tools = self.tool_router.list_all();
|
||||
Ok(ServerResult::ListToolsResult(ListToolsResult {
|
||||
tools,
|
||||
next_cursor: None,
|
||||
..Default::default()
|
||||
}))
|
||||
}
|
||||
ClientRequest::GetPromptRequest(request) => {
|
||||
|
|
@ -125,7 +125,7 @@ where
|
|||
let prompts = self.prompt_router.list_all();
|
||||
Ok(ServerResult::ListPromptsResult(ListPromptsResult {
|
||||
prompts,
|
||||
next_cursor: None,
|
||||
..Default::default()
|
||||
}))
|
||||
}
|
||||
rest => self.service.handle_request(rest, context).await,
|
||||
|
|
|
|||
|
|
@ -828,6 +828,8 @@ macro_rules! paginated_result {
|
|||
#[serde(rename_all = "camelCase")]
|
||||
#[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))]
|
||||
pub struct $t {
|
||||
#[serde(rename = "_meta", skip_serializing_if = "Option::is_none")]
|
||||
pub meta: Option<Meta>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub next_cursor: Option<Cursor>,
|
||||
pub $i_item: $t_item,
|
||||
|
|
@ -838,6 +840,7 @@ macro_rules! paginated_result {
|
|||
items: $t_item,
|
||||
) -> Self {
|
||||
Self {
|
||||
meta: None,
|
||||
next_cursor: None,
|
||||
$i_item: items,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -258,6 +258,7 @@ mod tests {
|
|||
mime_type: Some("text/plain".to_string()),
|
||||
size: Some(100),
|
||||
icons: None,
|
||||
meta: None,
|
||||
});
|
||||
|
||||
let json = serde_json::to_string(&resource_link).unwrap();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ use base64::engine::{Engine, general_purpose::STANDARD as BASE64_STANDARD};
|
|||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use super::{
|
||||
AnnotateAble, Annotations, Icon, RawEmbeddedResource, RawImageContent,
|
||||
AnnotateAble, Annotations, Icon, Meta, RawEmbeddedResource, RawImageContent,
|
||||
content::{EmbeddedResource, ImageContent},
|
||||
resource::ResourceContents,
|
||||
};
|
||||
|
|
@ -25,6 +25,9 @@ pub struct Prompt {
|
|||
/// Optional list of icons for the prompt
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub icons: Option<Vec<Icon>>,
|
||||
/// Optional additional metadata for this prompt
|
||||
#[serde(rename = "_meta", skip_serializing_if = "Option::is_none")]
|
||||
pub meta: Option<Meta>,
|
||||
}
|
||||
|
||||
impl Prompt {
|
||||
|
|
@ -44,6 +47,7 @@ impl Prompt {
|
|||
description: description.map(Into::into),
|
||||
arguments,
|
||||
icons: None,
|
||||
meta: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,9 @@ pub struct RawResource {
|
|||
/// Optional list of icons for the resource
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub icons: Option<Vec<Icon>>,
|
||||
/// Optional additional metadata for this resource
|
||||
#[serde(rename = "_meta", skip_serializing_if = "Option::is_none")]
|
||||
pub meta: Option<Meta>,
|
||||
}
|
||||
|
||||
pub type Resource = Annotated<RawResource>;
|
||||
|
|
@ -95,6 +98,7 @@ impl RawResource {
|
|||
mime_type: None,
|
||||
size: None,
|
||||
icons: None,
|
||||
meta: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -115,6 +119,7 @@ mod tests {
|
|||
mime_type: Some("text/plain".to_string()),
|
||||
size: Some(100),
|
||||
icons: None,
|
||||
meta: None,
|
||||
};
|
||||
|
||||
let json = serde_json::to_string(&resource).unwrap();
|
||||
|
|
|
|||
|
|
@ -992,6 +992,14 @@
|
|||
"description": "Represents a resource in the extension with metadata",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"_meta": {
|
||||
"description": "Optional additional metadata for this resource",
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"description": {
|
||||
"description": "Optional description of the resource",
|
||||
"type": [
|
||||
|
|
|
|||
|
|
@ -992,6 +992,14 @@
|
|||
"description": "Represents a resource in the extension with metadata",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"_meta": {
|
||||
"description": "Optional additional metadata for this resource",
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"description": {
|
||||
"description": "Optional description of the resource",
|
||||
"type": [
|
||||
|
|
|
|||
|
|
@ -172,6 +172,14 @@
|
|||
"description": "Represents a resource in the extension with metadata",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"_meta": {
|
||||
"description": "Optional additional metadata for this resource",
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"annotations": {
|
||||
"anyOf": [
|
||||
{
|
||||
|
|
@ -1031,6 +1039,13 @@
|
|||
"ListPromptsResult": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"_meta": {
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"nextCursor": {
|
||||
"type": [
|
||||
"string",
|
||||
|
|
@ -1051,6 +1066,13 @@
|
|||
"ListResourceTemplatesResult": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"_meta": {
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"nextCursor": {
|
||||
"type": [
|
||||
"string",
|
||||
|
|
@ -1071,6 +1093,13 @@
|
|||
"ListResourcesResult": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"_meta": {
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"nextCursor": {
|
||||
"type": [
|
||||
"string",
|
||||
|
|
@ -1096,6 +1125,13 @@
|
|||
"ListToolsResult": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"_meta": {
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"nextCursor": {
|
||||
"type": [
|
||||
"string",
|
||||
|
|
@ -1472,6 +1508,14 @@
|
|||
"description": "A prompt that can be used to generate text from a model",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"_meta": {
|
||||
"description": "Optional additional metadata for this prompt",
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"arguments": {
|
||||
"description": "Optional arguments that can be passed to customize the prompt",
|
||||
"type": [
|
||||
|
|
@ -1660,6 +1704,14 @@
|
|||
"description": "A link to a resource that can be fetched separately",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"_meta": {
|
||||
"description": "Optional additional metadata for this resource",
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"annotations": {
|
||||
"anyOf": [
|
||||
{
|
||||
|
|
@ -1816,6 +1868,14 @@
|
|||
"description": "Represents a resource in the extension with metadata",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"_meta": {
|
||||
"description": "Optional additional metadata for this resource",
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"description": {
|
||||
"description": "Optional description of the resource",
|
||||
"type": [
|
||||
|
|
|
|||
|
|
@ -172,6 +172,14 @@
|
|||
"description": "Represents a resource in the extension with metadata",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"_meta": {
|
||||
"description": "Optional additional metadata for this resource",
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"annotations": {
|
||||
"anyOf": [
|
||||
{
|
||||
|
|
@ -1031,6 +1039,13 @@
|
|||
"ListPromptsResult": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"_meta": {
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"nextCursor": {
|
||||
"type": [
|
||||
"string",
|
||||
|
|
@ -1051,6 +1066,13 @@
|
|||
"ListResourceTemplatesResult": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"_meta": {
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"nextCursor": {
|
||||
"type": [
|
||||
"string",
|
||||
|
|
@ -1071,6 +1093,13 @@
|
|||
"ListResourcesResult": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"_meta": {
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"nextCursor": {
|
||||
"type": [
|
||||
"string",
|
||||
|
|
@ -1096,6 +1125,13 @@
|
|||
"ListToolsResult": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"_meta": {
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"nextCursor": {
|
||||
"type": [
|
||||
"string",
|
||||
|
|
@ -1472,6 +1508,14 @@
|
|||
"description": "A prompt that can be used to generate text from a model",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"_meta": {
|
||||
"description": "Optional additional metadata for this prompt",
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"arguments": {
|
||||
"description": "Optional arguments that can be passed to customize the prompt",
|
||||
"type": [
|
||||
|
|
@ -1660,6 +1704,14 @@
|
|||
"description": "A link to a resource that can be fetched separately",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"_meta": {
|
||||
"description": "Optional additional metadata for this resource",
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"annotations": {
|
||||
"anyOf": [
|
||||
{
|
||||
|
|
@ -1816,6 +1868,14 @@
|
|||
"description": "Represents a resource in the extension with metadata",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"_meta": {
|
||||
"description": "Optional additional metadata for this resource",
|
||||
"type": [
|
||||
"object",
|
||||
"null"
|
||||
],
|
||||
"additionalProperties": true
|
||||
},
|
||||
"description": {
|
||||
"description": "Optional description of the resource",
|
||||
"type": [
|
||||
|
|
|
|||
Loading…
Reference in a new issue