Skip to content
This repository was archived by the owner on May 21, 2026. It is now read-only.

Commit 48951d8

Browse files
committed
feat(inspector): integrate MCP UI client and enhance ToolsTab functionality
- Add @mcp-ui/client dependency to inspector package - Implement PromptsTab and ResourcesTab components for improved layout - Enhance ToolsTab to display MCP UI resources and JSON content conditionally - Update Layout component to support new tab functionality and server connection states - Refactor code for better readability and maintainability
1 parent 6a1e392 commit 48951d8

7 files changed

Lines changed: 1046 additions & 20 deletions

File tree

packages/inspector/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
},
5050
"dependencies": {
5151
"@hono/node-server": "^1.19.5",
52+
"@mcp-ui/client": "^5.12.1",
5253
"@modelcontextprotocol/sdk": "1.12.1",
5354
"@radix-ui/react-alert-dialog": "^1.1.15",
5455
"@radix-ui/react-dialog": "^1.1.15",

packages/inspector/src/client/components/Layout.tsx

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ import {
2525
DropdownMenuTrigger,
2626
} from '../../components/ui/dropdown-menu'
2727
import { useMcpContext } from '../context/McpContext'
28+
import { PromptsTab } from './PromptsTab'
29+
import { ResourcesTab } from './ResourcesTab'
2830
import { ServerIcon } from './ServerIcon'
2931
import { ToolsTab } from './ToolsTab'
3032

@@ -311,9 +313,25 @@ export function Layout({ children }: LayoutProps) {
311313
isConnected={selectedServer.state === 'ready'}
312314
/>
313315
)
314-
: (
315-
children
316-
)}
316+
: selectedServer && activeTab === 'prompts'
317+
? (
318+
<PromptsTab
319+
prompts={selectedServer.prompts}
320+
callPrompt={selectedServer.callTool} // Using callTool for now, should be callPrompt when available
321+
isConnected={selectedServer.state === 'ready'}
322+
/>
323+
)
324+
: selectedServer && activeTab === 'resources'
325+
? (
326+
<ResourcesTab
327+
resources={selectedServer.resources}
328+
readResource={(uri: string) => selectedServer.callTool('read_resource', { uri })} // Using callTool for now, should be readResource when available
329+
isConnected={selectedServer.state === 'ready'}
330+
/>
331+
)
332+
: (
333+
children
334+
)}
317335
</main>
318336
</div>
319337
</TooltipProvider>
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { UIResourceRenderer } from '@mcp-ui/client'
2+
import type { Resource } from '@modelcontextprotocol/sdk/types.js'
3+
4+
interface McpUIRendererProps {
5+
resource: Resource
6+
onUIAction?: (action: any) => void
7+
className?: string
8+
}
9+
10+
/**
11+
* Helper function to check if a resource is an MCP UI resource
12+
*/
13+
export function isMcpUIResource(resource: any): boolean {
14+
if (!resource?.mimeType) return false
15+
16+
const mimeType = resource.mimeType.toLowerCase()
17+
return (
18+
mimeType === 'text/html' ||
19+
mimeType === 'text/uri-list' ||
20+
mimeType.startsWith('application/vnd.mcp-ui.remote-dom')
21+
)
22+
}
23+
24+
/**
25+
* Helper function to convert MCP SDK Resource to MCP UI Resource format
26+
*/
27+
function convertToMcpUIResource(resource: Resource): any {
28+
return {
29+
uri: resource.uri,
30+
mimeType: resource.mimeType,
31+
text: resource.text,
32+
blob: resource.blob,
33+
}
34+
}
35+
36+
/**
37+
* Component to render MCP UI resources
38+
*/
39+
export function McpUIRenderer({ resource, onUIAction, className }: McpUIRendererProps) {
40+
const handleUIAction = (action: any) => {
41+
console.log('MCP UI Action:', action)
42+
onUIAction?.(action)
43+
}
44+
45+
const uiResource = convertToMcpUIResource(resource)
46+
47+
return (
48+
<div className={className}>
49+
<UIResourceRenderer
50+
resource={uiResource}
51+
onUIAction={handleUIAction}
52+
htmlProps={{
53+
autoResizeIframe: { width: true, height: true },
54+
style: {
55+
width: '100%',
56+
minHeight: '200px',
57+
},
58+
}}
59+
/>
60+
</div>
61+
)
62+
}
63+

0 commit comments

Comments
 (0)