Skip to content

Commit 9015753

Browse files
committed
feat: return mcp ui resource for playground
1 parent 60aa303 commit 9015753

File tree

3 files changed

+97
-79
lines changed

3 files changed

+97
-79
lines changed

packages/mcp-server/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"drizzle-orm": "^0.44.0"
2121
},
2222
"dependencies": {
23+
"@mcp-ui/server": "^5.12.0",
2324
"@sveltejs/mcp-schema": "workspace:^",
2425
"@tmcp/adapter-valibot": "^0.1.4",
2526
"@typescript-eslint/parser": "^8.44.0",

packages/mcp-server/src/mcp/handlers/tools/playground-link.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { SvelteMcp } from '../../index.js';
22
import * as v from 'valibot';
33
import { icons } from '../../icons/index.js';
4+
import { createUIResource } from '@mcp-ui/server';
45

56
async function compress_and_encode_text(input: string) {
67
const reader = new Blob([input]).stream().pipeThrough(new CompressionStream('gzip')).getReader();
@@ -106,6 +107,14 @@ export function playground_link(server: SvelteMcp) {
106107
type: 'text',
107108
text: JSON.stringify(content),
108109
},
110+
createUIResource({
111+
uri: 'ui://svelte/playground-link',
112+
content: {
113+
type: 'externalUrl',
114+
iframeUrl: content.url,
115+
},
116+
encoding: 'text',
117+
}),
109118
],
110119
structuredContent: content,
111120
};

0 commit comments

Comments
 (0)