Skip to content

Commit 677c4e0

Browse files
committed
Minor simplifications
1 parent 84c2c3d commit 677c4e0

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

src/core/tools/useMcpToolTool.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -84,26 +84,23 @@ async function validateParams(
8484
}
8585

8686
/**
87-
* Reverses property renaming applied in schema generation.
87+
* Reverses property renaming applied in schema generation (native tool calling).
8888
* Properties named `renamed_*` are converted back to their original names.
8989
*/
90-
function reversePropertyRenaming(args: Record<string, unknown> | undefined): Record<string, unknown> | undefined {
90+
function reversePropertyRenaming_kilocode(
91+
args: Record<string, unknown> | undefined,
92+
): Record<string, unknown> | undefined {
9193
if (!args) {
9294
return args
9395
}
94-
9596
const reversed: Record<string, unknown> = {}
96-
9797
for (const [key, value] of Object.entries(args)) {
9898
if (key.startsWith("renamed_")) {
99-
// Extract original property name (e.g., "renamed_type" -> "type")
100-
const originalKey = key.substring("renamed_".length)
101-
reversed[originalKey] = value
99+
reversed[key.substring("renamed_".length)] = value
102100
} else {
103101
reversed[key] = value
104102
}
105103
}
106-
107104
return reversed
108105
}
109106

@@ -275,10 +272,10 @@ async function executeToolAndProcessResult(
275272
toolName,
276273
})
277274

278-
// Reverse any property renaming before calling the tool
279-
const actualArguments = reversePropertyRenaming(parsedArguments)
280-
281-
const toolResult = await cline.providerRef.deref()?.getMcpHub()?.callTool(serverName, toolName, actualArguments)
275+
const toolResult = await cline.providerRef
276+
.deref()
277+
?.getMcpHub()
278+
?.callTool(serverName, toolName, reversePropertyRenaming_kilocode(parsedArguments))
282279

283280
let toolResultPretty = "(No response)"
284281

webview-ui/src/components/chat/McpExecution.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,11 @@ export const McpExecution = ({
5454
// kilocode_change: Main collapse state for the entire MCP execution content
5555
const [isResponseExpanded, setIsResponseExpanded] = useState(initiallyExpanded)
5656

57-
// Remove "renamed_" prefix from property names in JSON
58-
const removeRenamedPrefix = useCallback((text: string): string => {
59-
if (!text) return text
60-
return text.replace(/"renamed_([^"]+)":/g, '"$1":')
57+
// kilocode_change: Remove "renamed_" prefix from property names in JSON (native tool calling)
58+
const removeRenamedPrefix_kilocode = useCallback((text: string): string => {
59+
const prefix = "renamed_"
60+
if (!text || !text.startsWith(prefix)) return text
61+
return text.substring(prefix.length)
6162
}, [])
6263

6364
// Try to parse JSON and return both the result and formatted text
@@ -281,7 +282,7 @@ export const McpExecution = ({
281282
"mt-1 pt-1":
282283
!isArguments && (useMcpServer?.type === "use_mcp_tool" || (toolName && serverName)),
283284
})}>
284-
<CodeBlock source={removeRenamedPrefix(formattedArgumentsText)} language="json" />
285+
<CodeBlock source={removeRenamedPrefix_kilocode(formattedArgumentsText)} language="json" />
285286
</div>
286287
)}
287288

0 commit comments

Comments
 (0)