Skip to content

Commit 23706cb

Browse files
authored
feat: enhance schema-utils conversion implementations for elicitation types (#97)
* feat: improve schema-utils with new conversion implementations for elicitation types * chore: update readme
1 parent 0be3cfd commit 23706cb

File tree

8 files changed

+145
-11
lines changed

8 files changed

+145
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# Model Context Protocol (MCP) Schema for Rust
66

77
[<img alt="crates.io" src="https://img.shields.io/crates/v/rust-mcp-schema?style=for-the-badge&logo=rust&color=FE965D" height="22">](https://crates.io/crates/rust-mcp-schema)
8-
[<img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-rust_mcp_schema-0ECDAB?style=for-the-badge&logo=docs.rs" height="22">](https://docs.rs/rust-mcp-schema/0.1.0)
8+
[<img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-rust_mcp_schema-0ECDAB?style=for-the-badge&logo=docs.rs" height="22">](https://docs.rs/rust-mcp-schema/latest/rust_mcp_schema)
99
[<img alt="build status" src="https://img.shields.io/github/actions/workflow/status/rust-mcp-stack/rust-mcp-schema/ci.yml?style=for-the-badge" height="22">
1010
](https://github.com/rust-mcp-stack/rust-mcp-schema/actions/workflows/ci.yml)
1111

src/generated_schema/2024_11_05/mcp_schema.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/// Copyright (c) 2025 Ali Hashemi (rust-mcp-stack)
22
/// Licensed under the MIT License. See LICENSE in the project root.
33
/// ----------------------------------------------------------------------------
4-
/// This file is auto-generated by mcp-schema-gen v0.5.0.
4+
/// This file is auto-generated by mcp-schema-gen v0.5.1.
55
/// WARNING:
66
/// It is not recommended to modify this file directly. You are free to
77
/// modify or extend the implementations as needed, but please do so at your own risk.
88
///
99
/// Generated from : <https://github.com/modelcontextprotocol/specification.git>
1010
/// Hash : 77572f31dae0644acd1c537133bc49846c0abdb8
11-
/// Generated at : 2025-12-13 16:34:16
11+
/// Generated at : 2025-12-14 16:37:05
1212
/// ----------------------------------------------------------------------------
1313
///
1414
use super::validators as validate;

src/generated_schema/2025_03_26/mcp_schema.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/// Copyright (c) 2025 Ali Hashemi (rust-mcp-stack)
22
/// Licensed under the MIT License. See LICENSE in the project root.
33
/// ----------------------------------------------------------------------------
4-
/// This file is auto-generated by mcp-schema-gen v0.5.0.
4+
/// This file is auto-generated by mcp-schema-gen v0.5.1.
55
/// WARNING:
66
/// It is not recommended to modify this file directly. You are free to
77
/// modify or extend the implementations as needed, but please do so at your own risk.
88
///
99
/// Generated from : <https://github.com/modelcontextprotocol/specification.git>
1010
/// Hash : 77572f31dae0644acd1c537133bc49846c0abdb8
11-
/// Generated at : 2025-12-13 16:34:17
11+
/// Generated at : 2025-12-14 16:37:07
1212
/// ----------------------------------------------------------------------------
1313
///
1414
use super::validators as validate;

src/generated_schema/2025_06_18/mcp_schema.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/// Copyright (c) 2025 Ali Hashemi (rust-mcp-stack)
22
/// Licensed under the MIT License. See LICENSE in the project root.
33
/// ----------------------------------------------------------------------------
4-
/// This file is auto-generated by mcp-schema-gen v0.5.0.
4+
/// This file is auto-generated by mcp-schema-gen v0.5.1.
55
/// WARNING:
66
/// It is not recommended to modify this file directly. You are free to
77
/// modify or extend the implementations as needed, but please do so at your own risk.
88
///
99
/// Generated from : <https://github.com/modelcontextprotocol/specification.git>
1010
/// Hash : 77572f31dae0644acd1c537133bc49846c0abdb8
11-
/// Generated at : 2025-12-13 16:34:18
11+
/// Generated at : 2025-12-14 16:37:07
1212
/// ----------------------------------------------------------------------------
1313
///
1414
use super::validators as validate;

src/generated_schema/2025_11_25/mcp_schema.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/// Copyright (c) 2025 Ali Hashemi (rust-mcp-stack)
22
/// Licensed under the MIT License. See LICENSE in the project root.
33
/// ----------------------------------------------------------------------------
4-
/// This file is auto-generated by mcp-schema-gen v0.5.0.
4+
/// This file is auto-generated by mcp-schema-gen v0.5.1.
55
/// WARNING:
66
/// It is not recommended to modify this file directly. You are free to
77
/// modify or extend the implementations as needed, but please do so at your own risk.
88
///
99
/// Generated from : <https://github.com/modelcontextprotocol/specification.git>
1010
/// Hash : 77572f31dae0644acd1c537133bc49846c0abdb8
11-
/// Generated at : 2025-12-13 16:34:19
11+
/// Generated at : 2025-12-14 16:37:08
1212
/// ----------------------------------------------------------------------------
1313
///
1414
use super::validators as validate;

src/generated_schema/2025_11_25/schema_utils.rs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3089,6 +3089,73 @@ impl ClientRequest {
30893089
}
30903090
}
30913091
}
3092+
impl From<&str> for IconTheme {
3093+
fn from(s: &str) -> Self {
3094+
match s {
3095+
"dark" => Self::Dark,
3096+
"light" => Self::Light,
3097+
_ => Self::Light,
3098+
}
3099+
}
3100+
}
3101+
impl From<&str> for ElicitResultContent {
3102+
fn from(value: &str) -> Self {
3103+
Self::Primitive(ElicitResultContentPrimitive::String(value.to_string()))
3104+
}
3105+
}
3106+
impl From<&str> for ElicitResultContentPrimitive {
3107+
fn from(value: &str) -> Self {
3108+
ElicitResultContentPrimitive::String(value.to_string())
3109+
}
3110+
}
3111+
impl From<String> for ElicitResultContentPrimitive {
3112+
fn from(value: String) -> Self {
3113+
ElicitResultContentPrimitive::String(value)
3114+
}
3115+
}
3116+
impl From<String> for ElicitResultContent {
3117+
fn from(value: String) -> Self {
3118+
Self::Primitive(ElicitResultContentPrimitive::String(value))
3119+
}
3120+
}
3121+
impl From<Vec<&str>> for ElicitResultContent {
3122+
fn from(value: Vec<&str>) -> Self {
3123+
Self::StringArray(value.iter().map(|v| v.to_string()).collect())
3124+
}
3125+
}
3126+
impl From<i64> for ElicitResultContent {
3127+
fn from(value: i64) -> Self {
3128+
Self::Primitive(value.into())
3129+
}
3130+
}
3131+
impl CallToolRequestParams {
3132+
pub fn new<T>(tool_name: T) -> Self
3133+
where
3134+
T: ToString,
3135+
{
3136+
Self {
3137+
name: tool_name.to_string(),
3138+
arguments: None,
3139+
meta: None,
3140+
task: None,
3141+
}
3142+
}
3143+
/// Sets the arguments for the tool call.
3144+
pub fn with_arguments(mut self, arguments: serde_json::Map<String, Value>) -> Self {
3145+
self.arguments = Some(arguments);
3146+
self
3147+
}
3148+
/// Assigns metadata to the CallToolRequestParams, enabling the inclusion of extra context or details.
3149+
pub fn with_meta(mut self, meta: CallToolMeta) -> Self {
3150+
self.meta = Some(meta);
3151+
self
3152+
}
3153+
/// Set task metadata , requesting task-augmented execution for this request
3154+
pub fn with_task(mut self, task: TaskMetadata) -> Self {
3155+
self.task = Some(task);
3156+
self
3157+
}
3158+
}
30923159
/// END AUTO GENERATED
30933160
#[cfg(test)]
30943161
mod tests {

src/generated_schema/draft/mcp_schema.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
/// Copyright (c) 2025 Ali Hashemi (rust-mcp-stack)
22
/// Licensed under the MIT License. See LICENSE in the project root.
33
/// ----------------------------------------------------------------------------
4-
/// This file is auto-generated by mcp-schema-gen v0.5.0.
4+
/// This file is auto-generated by mcp-schema-gen v0.5.1.
55
/// WARNING:
66
/// It is not recommended to modify this file directly. You are free to
77
/// modify or extend the implementations as needed, but please do so at your own risk.
88
///
99
/// Generated from : <https://github.com/modelcontextprotocol/specification.git>
1010
/// Hash : 77572f31dae0644acd1c537133bc49846c0abdb8
11-
/// Generated at : 2025-12-13 16:34:20
11+
/// Generated at : 2025-12-14 16:37:09
1212
/// ----------------------------------------------------------------------------
1313
///
1414
use super::validators as validate;

src/generated_schema/draft/schema_utils.rs

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3089,6 +3089,73 @@ impl ClientRequest {
30893089
}
30903090
}
30913091
}
3092+
impl From<&str> for IconTheme {
3093+
fn from(s: &str) -> Self {
3094+
match s {
3095+
"dark" => Self::Dark,
3096+
"light" => Self::Light,
3097+
_ => Self::Light,
3098+
}
3099+
}
3100+
}
3101+
impl From<&str> for ElicitResultContent {
3102+
fn from(value: &str) -> Self {
3103+
Self::Primitive(ElicitResultContentPrimitive::String(value.to_string()))
3104+
}
3105+
}
3106+
impl From<&str> for ElicitResultContentPrimitive {
3107+
fn from(value: &str) -> Self {
3108+
ElicitResultContentPrimitive::String(value.to_string())
3109+
}
3110+
}
3111+
impl From<String> for ElicitResultContentPrimitive {
3112+
fn from(value: String) -> Self {
3113+
ElicitResultContentPrimitive::String(value)
3114+
}
3115+
}
3116+
impl From<String> for ElicitResultContent {
3117+
fn from(value: String) -> Self {
3118+
Self::Primitive(ElicitResultContentPrimitive::String(value))
3119+
}
3120+
}
3121+
impl From<Vec<&str>> for ElicitResultContent {
3122+
fn from(value: Vec<&str>) -> Self {
3123+
Self::StringArray(value.iter().map(|v| v.to_string()).collect())
3124+
}
3125+
}
3126+
impl From<i64> for ElicitResultContent {
3127+
fn from(value: i64) -> Self {
3128+
Self::Primitive(value.into())
3129+
}
3130+
}
3131+
impl CallToolRequestParams {
3132+
pub fn new<T>(tool_name: T) -> Self
3133+
where
3134+
T: ToString,
3135+
{
3136+
Self {
3137+
name: tool_name.to_string(),
3138+
arguments: None,
3139+
meta: None,
3140+
task: None,
3141+
}
3142+
}
3143+
/// Sets the arguments for the tool call.
3144+
pub fn with_arguments(mut self, arguments: serde_json::Map<String, Value>) -> Self {
3145+
self.arguments = Some(arguments);
3146+
self
3147+
}
3148+
/// Assigns metadata to the CallToolRequestParams, enabling the inclusion of extra context or details.
3149+
pub fn with_meta(mut self, meta: CallToolMeta) -> Self {
3150+
self.meta = Some(meta);
3151+
self
3152+
}
3153+
/// Set task metadata , requesting task-augmented execution for this request
3154+
pub fn with_task(mut self, task: TaskMetadata) -> Self {
3155+
self.task = Some(task);
3156+
self
3157+
}
3158+
}
30923159
/// END AUTO GENERATED
30933160
#[cfg(test)]
30943161
mod tests {

0 commit comments

Comments
 (0)