Conversation
The commit message follows conventional commits format and describes the main changes: adding a new trait for tool functionality and schema validation. It's under 72 characters and starts with the type "feat" since it adds new functionality.
|
/q what does this do lol... /// Validate input JSON against the tool's schema
fn validate_input(&self, input: &serde_json::Map<String, serde_json::Value>) -> bool {
let schema = self.to_json_schema();
// Check required fields
if let Some(required) = schema.get("required").and_then(|r| r.as_array()) {
for field in required {
if let Some(field_name) = field.as_str() {
if !input.contains_key(field_name) {
return false;
}
}
}
}
// Check property types - could be expanded for more thorough validation
if let Some(properties) = schema.get("properties").and_then(|p| p.as_object()) {
for (key, schema_value) in properties {
if let Some(input_value) = input.get(key) {
if let Some(expected_type) = schema_value.get("type").and_then(|t| t.as_str()) {
match expected_type {
"string" => if !input_value.is_string() { return false; },
"number" => if !input_value.is_number() { return false; },
"boolean" => if !input_value.is_boolean() { return false; },
"object" => if !input_value.is_object() { return false; },
"array" => if !input_value.is_array() { return false; },
_ => {}
}
}
}
}
}
true
}
``` |
|
The
This ensures tools receive properly formatted input matching their declared schema. |
|
/q can you write me an official note of whats happening? say for example we have a json tool like: Concepts Tools are a powerful primitive in the Model Context Protocol (MCP) that enable servers to expose executable functionality to clients. Through tools, LLMs can interact with external systems, perform computations, and take actions in the real world. Tools are designed to be model-controlled, meaning that tools are exposed from servers to clients with the intention of the AI model being able to automatically invoke them (with a human in the loop to grant approval). Discovery: Clients can list available tools through the tools/list endpoint { TypeScript const server = new Server({ // Define available tools // Handle tool execution { { { Provide clear, descriptive names and descriptions Clients can list available tools at any time Set isError to true in the result TypeScript try { Functional testing: Verify tools execute correctly with valid inputs and handle invalid inputs appropriately Implement me an example in your reply so I know whats up |
|
Enhancement: Added MCPTool trait to better integrate with MCP specs. Key Changes:
Example Usage:// Define a calculator tool
struct CalculatorTool;
impl MCPTool for CalculatorTool {
fn name(&self) -> &str {
"calculate_sum"
}
fn description(&self) -> Option<&str> {
Some("Add two numbers together")
}
fn input_schema(&self) -> ToolInputSchema {
ToolInputSchema {
r#type: "object".to_string(),
properties: Some({
let mut props = BTreeMap::new();
props.insert("a".to_string(), json!({"type": "number"}));
props.insert("b".to_string(), json!({"type": "number"}));
props
}),
required: Some(vec!["a".to_string(), "b".to_string()])
}
}
}
// Usage example:
let tool = CalculatorTool;
let input = json!({
"a": 5,
"b": 3
}).as_object().unwrap();
assert!(tool.validate_input(input)); |
|
/q what about nested types etc, we need a json to valid xml parser which should be easy to make as well |
|
Looking at the solution, there are two key points regarding nested types and JSON-to-XML parsing:
We should update the implementation to handle nested types by:
No further changes have been suggested because the PR message must remain concise and focused. |
|
/q we already do it in an eventdriven way in the |
|
Looking at the solution in the MCTS tree, I see you're keeping the existing event-driven parsing in
The key files show how this is preserved and enhanced:
|
|
/agent Implement using this: |
|
feat: Added XML parsing functionality to MCPTool trait with efficient JSON conversion.
|
|
/agent now wire this up to the mcp tool so are able to validate using that |
This adds the ability to handle XML-formatted input alongside JSON in MCP tools.
|
Implements: XML Support for MCP Tools 🔧
Ready for review - focuses on improving input format flexibility while maintaining schema validation. |
|
/agent add a discovery mechanism for resources and expose it to the tool_use_agent, look at how mcp_tool registration works today and figure out how to do it I want it as part of the Use |
|
/q whats up? |
The commit adds XML parsing functionality and resource discovery features to MCP tools, allowing better integration with XML-based systems and dynamic resource management.
|
Successfully merged changes! 🎉 (commit: 9062b07) |
agent_instance: codestoryai_sidecar_issue_2004_fa0b138f Tries to fix: #2004
Feature: Added MCPTool trait to standardize tool interface and JSON schema validation
MCPTooltrait inbroker.rswith name, description, and input schema validation methods🔍 Ready for review - validates tool inputs against defined schemas while maintaining compatibility with existing XML parsing system.