Remove redundant component paths from MCP tool descriptions
- Remove 'Moqui screen: component://...' prefix from descriptions - Use clean screen titles as descriptions instead - Fully decode screen paths from encoded tool names using established conventions - Tool names contain all necessary information: _ → /, . indicates XML boundary - Makes MCP tool list cleaner and more logical
Showing
1 changed file
with
9 additions
and
33 deletions
| ... | @@ -402,18 +402,6 @@ | ... | @@ -402,18 +402,6 @@ |
| 402 | def screenPath | 402 | def screenPath |
| 403 | def subscreenName = null | 403 | def subscreenName = null |
| 404 | 404 | ||
| 405 | // Find the actual screen path from the tool definition | ||
| 406 | def actualScreenPath = null | ||
| 407 | def toolDefinition = tools.find { it.name == name } | ||
| 408 | if (toolDefinition?.description) { | ||
| 409 | // Extract actual screen path from description: "Moqui screen: ${screenPath}" | ||
| 410 | def descMatch = toolDefinition.description =~ /Moqui screen: (.+)/ | ||
| 411 | if (descMatch.find()) { | ||
| 412 | actualScreenPath = descMatch.group(1) | ||
| 413 | ec.logger.info("Found actual screen path from tool description: ${actualScreenPath}") | ||
| 414 | } | ||
| 415 | } | ||
| 416 | |||
| 417 | // Check if this is a subscreen (contains dot after the initial prefix) | 405 | // Check if this is a subscreen (contains dot after the initial prefix) |
| 418 | if (toolNameSuffix.contains('.')) { | 406 | if (toolNameSuffix.contains('.')) { |
| 419 | // Split on dot to separate parent screen path from subscreen name | 407 | // Split on dot to separate parent screen path from subscreen name |
| ... | @@ -421,25 +409,13 @@ | ... | @@ -421,25 +409,13 @@ |
| 421 | def parentPath = toolNameSuffix.substring(0, lastDotIndex) | 409 | def parentPath = toolNameSuffix.substring(0, lastDotIndex) |
| 422 | subscreenName = toolNameSuffix.substring(lastDotIndex + 1) | 410 | subscreenName = toolNameSuffix.substring(lastDotIndex + 1) |
| 423 | 411 | ||
| 424 | // Use actual screen path if available, otherwise derive from tool name | 412 | // Restore parent path: _ -> /, prepend component://, append .xml |
| 425 | if (actualScreenPath) { | 413 | screenPath = "component://" + parentPath.replace('_', '/') + ".xml" |
| 426 | screenPath = actualScreenPath | 414 | ec.logger.info("Decoded subscreen path for tool ${name}: parent=${screenPath}, subscreen=${subscreenName}") |
| 427 | ec.logger.info("Using actual screen path for subscreen tool ${name}: ${screenPath}, subscreen=${subscreenName}") | ||
| 428 | } else { | ||
| 429 | // Restore parent path: _ -> /, prepend component://, append .xml | ||
| 430 | screenPath = "component://" + parentPath.replace('_', '/') + ".xml" | ||
| 431 | ec.logger.info("Decoded subscreen path for tool ${name}: parent=${screenPath}, subscreen=${subscreenName}") | ||
| 432 | } | ||
| 433 | } else { | 415 | } else { |
| 434 | // Use actual screen path if available, otherwise derive from tool name | 416 | // Regular screen path: _ -> /, prepend component://, append .xml |
| 435 | if (actualScreenPath) { | 417 | screenPath = "component://" + toolNameSuffix.replace('_', '/') + ".xml" |
| 436 | screenPath = actualScreenPath | 418 | ec.logger.info("Decoded screen path for tool ${name}: ${screenPath}") |
| 437 | ec.logger.info("Using actual screen path for tool ${name}: ${screenPath}") | ||
| 438 | } else { | ||
| 439 | // Regular screen path: _ -> /, prepend component://, append .xml | ||
| 440 | screenPath = "component://" + toolNameSuffix.replace('_', '/') + ".xml" | ||
| 441 | ec.logger.info("Decoded screen path for tool ${name}: ${screenPath}") | ||
| 442 | } | ||
| 443 | } | 419 | } |
| 444 | 420 | ||
| 445 | // Now call the screen tool with proper user context | 421 | // Now call the screen tool with proper user context |
| ... | @@ -1048,7 +1024,7 @@ try { | ... | @@ -1048,7 +1024,7 @@ try { |
| 1048 | return [ | 1024 | return [ |
| 1049 | name: toolName, | 1025 | name: toolName, |
| 1050 | title: title, | 1026 | title: title, |
| 1051 | description: "Moqui screen: ${screenPath}", // Store original path in description | 1027 | description: title, // Use title as description |
| 1052 | inputSchema: [ | 1028 | inputSchema: [ |
| 1053 | type: "object", | 1029 | type: "object", |
| 1054 | properties: parameters, | 1030 | properties: parameters, |
| ... | @@ -1147,7 +1123,7 @@ try { | ... | @@ -1147,7 +1123,7 @@ try { |
| 1147 | def tool = [ | 1123 | def tool = [ |
| 1148 | name: toolName, | 1124 | name: toolName, |
| 1149 | title: title, | 1125 | title: title, |
| 1150 | description: "Moqui screen: ${screenPath}", | 1126 | description: title, // Use title as description instead of redundant path |
| 1151 | inputSchema: [ | 1127 | inputSchema: [ |
| 1152 | type: "object", | 1128 | type: "object", |
| 1153 | properties: parameters, | 1129 | properties: parameters, |
| ... | @@ -1467,7 +1443,7 @@ try { | ... | @@ -1467,7 +1443,7 @@ try { |
| 1467 | tool = [ | 1443 | tool = [ |
| 1468 | name: "screen_${screenName}", | 1444 | name: "screen_${screenName}", |
| 1469 | title: title, | 1445 | title: title, |
| 1470 | description: "${description}. This tool renders the Moqui screen '${screenPath}' and returns the output.", | 1446 | description: title, // Use title as description |
| 1471 | inputSchema: [ | 1447 | inputSchema: [ |
| 1472 | type: "object", | 1448 | type: "object", |
| 1473 | properties: parameters, | 1449 | properties: parameters, | ... | ... |
-
Please register or sign in to post a comment