feat: optimize MCP tools response format with automatic schema generation

- Remove all manual ReturnSchema() methods from tools
- Implement automatic schema generation using reflection
- Unify response format to flat structure with action/success/message fields
- Simplify tool implementation by removing MCPResponse embedding
- Update documentation to reflect new architecture
- Achieve ~70% code reduction while maintaining type safety
This commit is contained in:
lilong.129
2025-06-05 23:17:06 +08:00
parent 56831845ca
commit 6e1bd5bbe2
15 changed files with 990 additions and 797 deletions

View File

@@ -161,7 +161,7 @@ func (host *MCPHost) convertSingleToolToRecord(serverName string, tool mcp.Tool,
return MCPToolRecord{
ToolID: id,
VisibleRange: 1,
ToolType: "edge",
ToolType: "Hrp",
ServerName: serverName,
ToolName: tool.Name,
Description: info.Description,
@@ -227,7 +227,7 @@ func (host *MCPHost) extractReturns(serverName, toolName string, info DocStringI
// Priority 1: Get from ActionTool interface if available
if actionToolProvider := host.getActionToolProvider(serverName); actionToolProvider != nil {
if actionTool := actionToolProvider.GetToolByAction(option.ActionName(toolName)); actionTool != nil {
returnSchema := actionTool.ReturnSchema()
returnSchema := uixt.GenerateReturnSchema(actionTool)
if len(returnSchema) > 0 {
return host.marshalToJSON(returnSchema, "return schema")
}