Skip to content

Commit 628715f

Browse files
authored
Merge pull request #3452 from Kilo-Org/fix/improve-mcp-tool-request-and-response-rendering-in-cli
Improve MCP tool request and response rendering in CLI
2 parents 1264304 + 0fc6fa8 commit 628715f

File tree

8 files changed

+928
-55
lines changed

8 files changed

+928
-55
lines changed

.changeset/good-pigs-beam.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
"@kilocode/cli": minor
3+
---
4+
5+
This PR improves the display of MCP tool requests and responses in the CLI, addressing issues with truncated payloads, poor formatting, and lack of metadata.
6+
7+
- MCP request arguments were difficult to read (no formatting, no preview mode)
8+
- MCP response payloads were displayed as raw text dumps, overwhelming the terminal
9+
- No JSON detection or pretty-printing
10+
- No metadata about content size or type
11+
- Missing error handling for malformed data
12+
- No indication when content is truncated/previewed
13+
14+
Created new `SayMcpServerResponseMessage` component for MCP responses and refactored `AskUseMcpServerMessage` to share formatting logic. Both will make use of newly added utility functions for JSON detection, formatting, and metadata display.
15+
`formatContentWithMetadata()` - Detects JSON, formats it, handles preview logic (>20 lines → show 5)
16+
`formatJson()` - Pretty-prints JSON with configurable indentation
17+
`approximateByteSize()` - Estimates byte size using `str.length * 3`
18+
`formatByteSize()`, `buildMetadataString()` - Display helpers
19+
20+
| before | after |
21+
| ------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------- |
22+
| <img width="1511" height="890" alt="before" src="https://github.com/user-attachments/assets/9b57d85c-1846-42d5-ba7b-2511a96e77b2" /> | <img width="1510" height="884" alt="after" src="https://github.com/user-attachments/assets/1a7599ce-4112-40d0-ac47-678d626cb51c" /> |
23+
24+
Run the KiloCode CLI and let it automatically use any configured MCP server.

cli/src/ui/messages/extension/SayMessageRouter.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
SayUserEditTodosMessage,
2424
SayImageMessage,
2525
SayMcpServerRequestStartedMessage,
26+
SayMcpServerResponseMessage,
2627
SayApiReqFinishedMessage,
2728
SayApiReqRetryDelayedMessage,
2829
SayCommandOutputMessage,
@@ -108,6 +109,9 @@ export const SayMessageRouter: React.FC<MessageComponentProps> = ({ message }) =
108109
case "mcp_server_request_started":
109110
return <SayMcpServerRequestStartedMessage message={message} />
110111

112+
case "mcp_server_response":
113+
return <SayMcpServerResponseMessage message={message} />
114+
111115
case "api_req_finished":
112116
return <SayApiReqFinishedMessage message={message} />
113117

0 commit comments

Comments
 (0)