Skip to content

Commit 78b2083

Browse files
robertheadleycte
andauthored
feat: Add error console to MCP servers - Edited with Roo Code and Anthropic Claude 3.5 (#2722)
Co-authored-by: cte <[email protected]>
1 parent 82dd3d5 commit 78b2083

File tree

24 files changed

+199
-44
lines changed

24 files changed

+199
-44
lines changed

package-lock.json

Lines changed: 15 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@
370370
"@aws-sdk/client-bedrock-runtime": "^3.779.0",
371371
"@google/genai": "^0.12.0",
372372
"@mistralai/mistralai": "^1.3.6",
373-
"@modelcontextprotocol/sdk": "^1.7.0",
373+
"@modelcontextprotocol/sdk": "^1.9.0",
374374
"@types/clone-deep": "^4.0.4",
375375
"@types/pdf-parse": "^1.1.4",
376376
"@types/tmp": "^0.2.6",

src/services/mcp/McpHub.ts

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,7 @@ export class McpHub {
541541
disabled: config.disabled,
542542
source,
543543
projectPath: source === "project" ? vscode.workspace.workspaceFolders?.[0]?.uri.fsPath : undefined,
544+
errorHistory: [],
544545
},
545546
client,
546547
transport,
@@ -567,13 +568,31 @@ export class McpHub {
567568
}
568569
}
569570

570-
private appendErrorMessage(connection: McpConnection, error: string) {
571+
private appendErrorMessage(connection: McpConnection, error: string, level: "error" | "warn" | "info" = "error") {
571572
const MAX_ERROR_LENGTH = 1000
572-
const newError = connection.server.error ? `${connection.server.error}\n${error}` : error
573-
connection.server.error =
574-
newError.length > MAX_ERROR_LENGTH
575-
? `${newError.substring(0, MAX_ERROR_LENGTH)}...(error message truncated)`
576-
: newError
573+
const truncatedError =
574+
error.length > MAX_ERROR_LENGTH
575+
? `${error.substring(0, MAX_ERROR_LENGTH)}...(error message truncated)`
576+
: error
577+
578+
// Add to error history
579+
if (!connection.server.errorHistory) {
580+
connection.server.errorHistory = []
581+
}
582+
583+
connection.server.errorHistory.push({
584+
message: truncatedError,
585+
timestamp: Date.now(),
586+
level,
587+
})
588+
589+
// Keep only the last 100 errors
590+
if (connection.server.errorHistory.length > 100) {
591+
connection.server.errorHistory = connection.server.errorHistory.slice(-100)
592+
}
593+
594+
// Update current error display
595+
connection.server.error = truncatedError
577596
}
578597

579598
/**

src/shared/mcp.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1+
export type McpErrorEntry = {
2+
message: string
3+
timestamp: number
4+
level: "error" | "warn" | "info"
5+
}
6+
17
export type McpServer = {
28
name: string
39
config: string
410
status: "connected" | "connecting" | "disconnected"
511
error?: string
12+
errorHistory?: McpErrorEntry[]
613
tools?: McpTool[]
714
resources?: McpResource[]
815
resourceTemplates?: McpResourceTemplate[]
@@ -55,6 +62,11 @@ export type McpToolCallResponse = {
5562
data: string
5663
mimeType: string
5764
}
65+
| {
66+
type: "audio"
67+
data: string
68+
mimeType: string
69+
}
5870
| {
5971
type: "resource"
6072
resource: {

webview-ui/package-lock.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

webview-ui/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"class-variance-authority": "^0.7.1",
3737
"clsx": "^2.1.1",
3838
"cmdk": "^1.0.0",
39+
"date-fns": "^4.1.0",
3940
"debounce": "^2.1.1",
4041
"fast-deep-equal": "^3.1.3",
4142
"fzf": "^0.5.2",
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { useMemo } from "react"
2+
import { formatRelative } from "date-fns"
3+
4+
import type { McpErrorEntry } from "@roo/shared/mcp"
5+
6+
type McpErrorRowProps = {
7+
error: McpErrorEntry
8+
}
9+
10+
export const McpErrorRow = ({ error }: McpErrorRowProps) => {
11+
const color = useMemo(() => {
12+
switch (error.level) {
13+
case "error":
14+
return "var(--vscode-testing-iconFailed)"
15+
case "warn":
16+
return "var(--vscode-charts-yellow)"
17+
case "info":
18+
return "var(--vscode-testing-iconPassed)"
19+
}
20+
}, [error.level])
21+
22+
return (
23+
<div className="text-sm bg-vscode-textCodeBlock-background border-l-2 p-2" style={{ borderColor: color }}>
24+
<div className="mb-1" style={{ color }}>
25+
{error.message}
26+
</div>
27+
<div className="text-xs text-vscode-descriptionForeground">
28+
{formatRelative(error.timestamp, new Date())}
29+
</div>
30+
</div>
31+
)
32+
}

webview-ui/src/components/mcp/McpView.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import { Tab, TabContent, TabHeader } from "../common/Tab"
2929
import McpToolRow from "./McpToolRow"
3030
import McpResourceRow from "./McpResourceRow"
3131
import McpEnabledToggle from "./McpEnabledToggle"
32+
import { McpErrorRow } from "./McpErrorRow"
3233

3334
type McpViewProps = {
3435
onDone: () => void
@@ -42,6 +43,7 @@ const McpView = ({ onDone }: McpViewProps) => {
4243
enableMcpServerCreation,
4344
setEnableMcpServerCreation,
4445
} = useExtensionState()
46+
4547
const { t } = useAppTranslation()
4648

4749
return (
@@ -330,6 +332,9 @@ const ServerRow = ({ server, alwaysAllowMcp }: { server: McpServer; alwaysAllowM
330332
{t("mcp:tabs.resources")} (
331333
{[...(server.resourceTemplates || []), ...(server.resources || [])].length || 0})
332334
</VSCodePanelTab>
335+
<VSCodePanelTab id="errors">
336+
{t("mcp:tabs.errors")} ({server.errorHistory?.length || 0})
337+
</VSCodePanelTab>
333338

334339
<VSCodePanelView id="tools-view">
335340
{server.tools && server.tools.length > 0 ? (
@@ -372,6 +377,23 @@ const ServerRow = ({ server, alwaysAllowMcp }: { server: McpServer; alwaysAllowM
372377
</div>
373378
)}
374379
</VSCodePanelView>
380+
381+
<VSCodePanelView id="errors-view">
382+
{server.errorHistory && server.errorHistory.length > 0 ? (
383+
<div
384+
style={{ display: "flex", flexDirection: "column", gap: "8px", width: "100%" }}>
385+
{[...server.errorHistory]
386+
.sort((a, b) => b.timestamp - a.timestamp)
387+
.map((error, index) => (
388+
<McpErrorRow key={`${error.timestamp}-${index}`} error={error} />
389+
))}
390+
</div>
391+
) : (
392+
<div style={{ padding: "10px 0", color: "var(--vscode-descriptionForeground)" }}>
393+
{t("mcp:emptyState.noErrors")}
394+
</div>
395+
)}
396+
</VSCodePanelView>
375397
</VSCodePanels>
376398

377399
{/* Network Timeout */}

webview-ui/src/i18n/locales/ca/mcp.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@
1919
},
2020
"tabs": {
2121
"tools": "Eines",
22-
"resources": "Recursos"
22+
"resources": "Recursos",
23+
"errors": "Errors"
2324
},
2425
"emptyState": {
2526
"noTools": "No s'han trobat eines",
26-
"noResources": "No s'han trobat recursos"
27+
"noResources": "No s'han trobat recursos",
28+
"noLogs": "No s'han trobat registres",
29+
"noErrors": "No s'han trobat errors"
2730
},
2831
"networkTimeout": {
2932
"label": "Temps d'espera de xarxa",

webview-ui/src/i18n/locales/de/mcp.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,14 @@
1919
},
2020
"tabs": {
2121
"tools": "Tools",
22-
"resources": "Ressourcen"
22+
"resources": "Ressourcen",
23+
"errors": "Fehler"
2324
},
2425
"emptyState": {
2526
"noTools": "Keine Tools gefunden",
26-
"noResources": "Keine Ressourcen gefunden"
27+
"noResources": "Keine Ressourcen gefunden",
28+
"noLogs": "Keine Logs gefunden",
29+
"noErrors": "Keine Fehler gefunden"
2730
},
2831
"networkTimeout": {
2932
"label": "Netzwerk-Timeout",

0 commit comments

Comments
 (0)