Skip to content

Commit 227ed28

Browse files
allozaurevalstate
andauthored
webui: MCP Diagnostics improvements (ggml-org#21803)
* Add MCP Connection diagnostics and CORS hint to web-ui * tidy up test * webui: Refactor and improve MCP diagnostic logging --------- Co-authored-by: evalstate <1936278+evalstate@users.noreply.github.com>
1 parent bafae27 commit 227ed28

14 files changed

Lines changed: 1329 additions & 308 deletions

File tree

tools/server/public/bundle.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tools/server/public/bundle.js

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

tools/server/webui/src/lib/components/app/mcp/McpConnectionLogs.svelte

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@
1515
let { logs, connectionTimeMs, defaultExpanded = false, class: className }: Props = $props();
1616
1717
let isExpanded = $derived(defaultExpanded);
18+
19+
function formatLogDetails(details: unknown): string {
20+
if (details == null) {
21+
return '';
22+
}
23+
24+
try {
25+
return JSON.stringify(details, null, 2);
26+
} catch {
27+
return String(details);
28+
}
29+
}
1830
</script>
1931

2032
{#if logs.length > 0}
@@ -53,6 +65,16 @@
5365

5466
<span class="break-all">{log.message}</span>
5567
</div>
68+
69+
{#if log.details !== undefined}
70+
<details class="ml-11">
71+
<summary class="cursor-pointer text-[10px] text-muted-foreground"> details </summary>
72+
73+
<pre
74+
class="mt-1 overflow-x-auto rounded bg-background/70 p-2 text-[10px] break-all whitespace-pre-wrap text-foreground/80">
75+
{formatLogDetails(log.details)}</pre>
76+
</details>
77+
{/if}
5678
{/each}
5779
</div>
5880
</Collapsible.Content>

tools/server/webui/src/lib/constants/mcp.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,26 @@ export const EXPECTED_THEMED_ICON_PAIR_COUNT = 2;
4848
/** CORS proxy URL query parameter name */
4949
export const CORS_PROXY_URL_PARAM = 'url';
5050

51+
/** Number of trailing characters to keep visible when partially redacting mcp-session-id */
52+
export const MCP_SESSION_ID_VISIBLE_CHARS = 5;
53+
54+
/** Partial-redaction rules for MCP headers: header name -> visible trailing chars */
55+
export const MCP_PARTIAL_REDACT_HEADERS = new Map<string, number>([
56+
['mcp-session-id', MCP_SESSION_ID_VISIBLE_CHARS]
57+
]);
58+
59+
/** Header names whose values should be redacted in diagnostic logs */
60+
export const REDACTED_HEADERS = new Set([
61+
'authorization',
62+
'api-key',
63+
'cookie',
64+
'mcp-session-id',
65+
'proxy-authorization',
66+
'set-cookie',
67+
'x-auth-token',
68+
'x-api-key'
69+
]);
70+
5171
/** Human-readable labels for MCP transport types */
5272
export const MCP_TRANSPORT_LABELS: Record<MCPTransportType, string> = {
5373
[MCPTransportType.WEBSOCKET]: 'WebSocket',

0 commit comments

Comments
 (0)