Implementation of SEP-986: Specify Format for Tool Names (#551)
* feat: implement SEP-986 tool name validation and error reporting Adds validation for MCP tool naming conventions as specified in SEP-986. Ensures Rust SDK enforces standardized tool name formats, provides clear errors for invalid names, and improves consistency across implementations. Signed-off-by: tanish111 <tanishdesai37@gmail.com> * fix(doctests): correct import paths in tool_name_validation Update doctest examples to use the correct module path rmcp::handler::server::tool_name_validation instead of rmcp::model::tool_name_validation. Signed-off-by: tanish111 <tanishdesai37@gmail.com> * fix: only warn when warnings exist Prevent empty warnings array from triggering warning output. Signed-off-by: tanish111 <tanishdesai37@gmail.com> * fix: remove internal check Signed-off-by: tanish111 <tanishdesai37@gmail.com> * refactor: remove doc comments from validation functions Signed-off-by: tanish111 <tanishdesai37@gmail.com> * refactor: remove doc comments from add_route functions Signed-off-by: tanish111 <tanishdesai37@gmail.com> * refactor: make tool name validation helpers private Made ToolNameValidationResult and its functions and fields private. Made validate_tool_name and issue_tool_name_warning private. Signed-off-by: tanish111 <tanishdesai37@gmail.com> --------- Signed-off-by: tanish111 <tanishdesai37@gmail.com>
This commit is contained in:
parent
cf45070ce7
commit
97ef6c97e4
1 changed files with 268 additions and 3 deletions
|
|
@ -4,8 +4,9 @@ use futures::{FutureExt, future::BoxFuture};
|
|||
use schemars::JsonSchema;
|
||||
|
||||
use crate::{
|
||||
handler::server::tool::{
|
||||
CallToolHandler, DynCallToolHandler, ToolCallContext, schema_for_type,
|
||||
handler::server::{
|
||||
tool::{CallToolHandler, DynCallToolHandler, ToolCallContext, schema_for_type},
|
||||
tool_name_validation::validate_and_warn_tool_name,
|
||||
},
|
||||
model::{CallToolResult, Tool, ToolAnnotations},
|
||||
};
|
||||
|
|
@ -219,7 +220,9 @@ where
|
|||
}
|
||||
|
||||
pub fn add_route(&mut self, item: ToolRoute<S>) {
|
||||
self.map.insert(item.attr.name.clone(), item);
|
||||
let new_name = &item.attr.name;
|
||||
validate_and_warn_tool_name(new_name);
|
||||
self.map.insert(new_name.clone(), item);
|
||||
}
|
||||
|
||||
pub fn merge(&mut self, other: ToolRouter<S>) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue