refactor: update driver caching mechanism to use generic CacheManager and improve metadata handling

This commit is contained in:
lilong.129
2025-06-22 21:42:50 +08:00
parent e48bbb2271
commit 6cc3c3acb5
5 changed files with 251 additions and 155 deletions

View File

@@ -327,7 +327,7 @@ func NewMCPSuccessResponse(message string, actionTool ActionTool) *mcp.CallToolR
"message": message,
}
// Add all tool-specific fields at the same level
// Add tool-specific fields if provided
toolData := convertToolToData(actionTool)
for key, value := range toolData {
response[key] = value
@@ -336,7 +336,7 @@ func NewMCPSuccessResponse(message string, actionTool ActionTool) *mcp.CallToolR
return marshalToMCPResult(response)
}
// convertToolToData converts tool struct to map[string]any for Data field
// convertToolToData converts tool struct to map for response
func convertToolToData(tool interface{}) map[string]any {
data := make(map[string]any)
@@ -381,7 +381,7 @@ func convertToolToData(tool interface{}) map[string]any {
return data
}
// NewMCPErrorResponse creates an error response
// NewMCPErrorResponse creates an error MCP response
func NewMCPErrorResponse(message string) *mcp.CallToolResult {
response := map[string]any{
"success": false,
@@ -419,7 +419,7 @@ func GenerateReturnSchema(toolStruct interface{}) map[string]string {
for i := 0; i < structType.NumField(); i++ {
field := structType.Field(i)
// Skip embedded MCPResponse fields (though they shouldn't exist now)
// Skip embedded MCPResponse fields
if field.Type.Name() == "MCPResponse" {
continue
}