Move whole rmcp crate to offcial rust sdk (#44)
* get rid of async-trait * move rmcp to official-rust-sdk * replace master with main * update readme, change license * fix typo * Update README.md Co-authored-by: Jefry Dewangga <jefrydco@gmail.com> * fix typos --------- Co-authored-by: = <=> Co-authored-by: Jefry Dewangga <jefrydco@gmail.com>
This commit is contained in:
parent
31493cfbcc
commit
0be6067326
1 changed files with 8676 additions and 4466 deletions
41
crates/rmcp/src/model/tool.rs
Normal file
41
crates/rmcp/src/model/tool.rs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
use std::{borrow::Cow, sync::Arc};
|
||||
|
||||
/// Tools represent a routine that a server can execute
|
||||
/// Tool calls represent requests from the client to execute one
|
||||
use serde::{Deserialize, Serialize};
|
||||
use serde_json::Value;
|
||||
|
||||
use super::JsonObject;
|
||||
|
||||
/// A tool that can be used by a model.
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct Tool {
|
||||
/// The name of the tool
|
||||
pub name: Cow<'static, str>,
|
||||
/// A description of what the tool does
|
||||
pub description: Cow<'static, str>,
|
||||
/// A JSON Schema object defining the expected parameters for the tool
|
||||
pub input_schema: Arc<JsonObject>,
|
||||
}
|
||||
|
||||
impl Tool {
|
||||
/// Create a new tool with the given name and description
|
||||
pub fn new<N, D, S>(name: N, description: D, input_schema: S) -> Self
|
||||
where
|
||||
N: Into<Cow<'static, str>>,
|
||||
D: Into<Cow<'static, str>>,
|
||||
S: Into<Arc<JsonObject>>,
|
||||
{
|
||||
Tool {
|
||||
name: name.into(),
|
||||
description: description.into(),
|
||||
input_schema: input_schema.into(),
|
||||
}
|
||||
}
|
||||
|
||||
/// Get the schema as json value
|
||||
pub fn schema_as_json_value(&self) -> Value {
|
||||
Value::Object(self.input_schema.as_ref().clone())
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue