Skip to content

Commit e09b8cd

Browse files
Merge pull request #84 from sveltejs/mcp-ui-playground
2 parents 60aa303 + 7f52a2b commit e09b8cd

File tree

4 files changed

+105
-79
lines changed

4 files changed

+105
-79
lines changed

.changeset/icy-cameras-punch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@sveltejs/mcp': patch
3+
---
4+
5+
feat: return `mcp-ui` resource from `playground-link`

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: 12 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();
@@ -100,12 +101,23 @@ export function playground_link(server: SvelteMcp) {
100101
url: playground_base.toString(),
101102
};
102103

104+
// use the embed path to have a cleaner UI for mcp-ui
105+
playground_base.pathname = '/playground/embed';
106+
103107
return {
104108
content: [
105109
{
106110
type: 'text',
107111
text: JSON.stringify(content),
108112
},
113+
createUIResource({
114+
uri: 'ui://svelte/playground-link',
115+
content: {
116+
type: 'externalUrl',
117+
iframeUrl: playground_base.toString(),
118+
},
119+
encoding: 'text',
120+
}),
109121
],
110122
structuredContent: content,
111123
};

0 commit comments

Comments
 (0)