demobun-mcp-server 0.0.0-stage → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +26 -2
- package/index.mjs +177 -0
- package/package.json +30 -4
package/README.md
CHANGED
|
@@ -1,3 +1,27 @@
|
|
|
1
|
-
#
|
|
1
|
+
# demobun-mcp-server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Official Model Context Protocol (MCP) server for **DemoBun**. Lets AI coding agents (Claude Desktop, Cursor, Windsurf, VS Code, Antigravity) publish Playwright screenshots and hotspot coordinates directly to a hosted interactive demo URL.
|
|
4
|
+
|
|
5
|
+
## Setup
|
|
6
|
+
|
|
7
|
+
1. Generate a Workspace API key (`dbun_...`) in DemoBun under **Workspace Settings -> Workspace API Keys**.
|
|
8
|
+
2. Add the server to your MCP client config:
|
|
9
|
+
|
|
10
|
+
```json
|
|
11
|
+
{
|
|
12
|
+
"mcpServers": {
|
|
13
|
+
"demobun": {
|
|
14
|
+
"command": "npx",
|
|
15
|
+
"args": ["-y", "demobun-mcp-server"],
|
|
16
|
+
"env": {
|
|
17
|
+
"DEMOBUN_API_KEY": "dbun_your_key_here",
|
|
18
|
+
"DEMOBUN_API_BASE": "https://demobun.com"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Tool: `publish_interactive_demo`
|
|
26
|
+
|
|
27
|
+
Publishes an array of screenshot steps and hotspot coordinates and returns the hosted demo `id` and `url`.
|
package/index.mjs
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import readline from 'node:readline';
|
|
3
|
+
|
|
4
|
+
const RAW_API_BASE = (process.env.DEMOBUN_API_BASE || 'https://demobun.com').replace(/\/+$/, '');
|
|
5
|
+
const API_KEY = (process.env.DEMOBUN_API_KEY || '').trim();
|
|
6
|
+
|
|
7
|
+
function validateApiBase(raw) {
|
|
8
|
+
let parsed;
|
|
9
|
+
try {
|
|
10
|
+
parsed = new URL(raw);
|
|
11
|
+
} catch {
|
|
12
|
+
throw new Error('DEMOBUN_API_BASE must be a valid URL.');
|
|
13
|
+
}
|
|
14
|
+
const isLocal = parsed.hostname === 'localhost' || parsed.hostname === '127.0.0.1';
|
|
15
|
+
if (parsed.protocol !== 'https:' && !(isLocal && parsed.protocol === 'http:')) {
|
|
16
|
+
throw new Error('DEMOBUN_API_BASE must use HTTPS (HTTP is only allowed for localhost).');
|
|
17
|
+
}
|
|
18
|
+
return parsed.origin;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function send(msg) {
|
|
22
|
+
process.stdout.write(`${JSON.stringify(msg)}\n`);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
async function publishDemo(args) {
|
|
26
|
+
if (!API_KEY) {
|
|
27
|
+
return { error: 'DEMOBUN_API_KEY environment variable is required (dbun_...).' };
|
|
28
|
+
}
|
|
29
|
+
if (!API_KEY.startsWith('dbun_')) {
|
|
30
|
+
return { error: 'DEMOBUN_API_KEY must be a valid DemoBun workspace key starting with dbun_.' };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
let apiBase;
|
|
34
|
+
try {
|
|
35
|
+
apiBase = validateApiBase(RAW_API_BASE);
|
|
36
|
+
} catch (err) {
|
|
37
|
+
return { error: err instanceof Error ? err.message : 'Invalid DEMOBUN_API_BASE.' };
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const steps = Array.isArray(args?.steps) ? args.steps : [];
|
|
41
|
+
if (steps.length === 0) {
|
|
42
|
+
return { error: 'steps must be a non-empty array.' };
|
|
43
|
+
}
|
|
44
|
+
if (steps.length > 50) {
|
|
45
|
+
return { error: 'steps cannot exceed 50 slides per publish call.' };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
try {
|
|
49
|
+
const res = await fetch(`${apiBase}/api/agent/publish`, {
|
|
50
|
+
method: 'POST',
|
|
51
|
+
headers: {
|
|
52
|
+
'Content-Type': 'application/json',
|
|
53
|
+
Authorization: `Bearer ${API_KEY}`,
|
|
54
|
+
},
|
|
55
|
+
body: JSON.stringify({
|
|
56
|
+
title: typeof args.title === 'string' && args.title.trim() ? args.title.trim() : 'AI Agent Demo',
|
|
57
|
+
subtitle:
|
|
58
|
+
typeof args.subtitle === 'string' && args.subtitle.trim()
|
|
59
|
+
? args.subtitle.trim()
|
|
60
|
+
: 'Published via demobun-mcp-server',
|
|
61
|
+
steps,
|
|
62
|
+
}),
|
|
63
|
+
signal: AbortSignal.timeout(30_000),
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
const text = await res.text();
|
|
67
|
+
let data = {};
|
|
68
|
+
try {
|
|
69
|
+
data = text ? JSON.parse(text) : {};
|
|
70
|
+
} catch {
|
|
71
|
+
return { error: `Unexpected non-JSON response from server (HTTP ${res.status}).` };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (!res.ok) {
|
|
75
|
+
return { error: data.error || `HTTP ${res.status}` };
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
id: data.id,
|
|
79
|
+
url: `${apiBase}${data.url || `/demo/${data.id}`}`,
|
|
80
|
+
};
|
|
81
|
+
} catch (err) {
|
|
82
|
+
return { error: `Request failed: ${err instanceof Error ? err.message : 'Network error'}` };
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const rl = readline.createInterface({ input: process.stdin, crlfDelay: Infinity });
|
|
87
|
+
|
|
88
|
+
rl.on('line', async (line) => {
|
|
89
|
+
if (!line.trim()) return;
|
|
90
|
+
let req;
|
|
91
|
+
try {
|
|
92
|
+
req = JSON.parse(line);
|
|
93
|
+
} catch {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
const { id, method, params } = req;
|
|
98
|
+
|
|
99
|
+
if (method === 'notifications/initialized') {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (method === 'ping') {
|
|
104
|
+
if (id !== undefined) send({ jsonrpc: '2.0', id, result: {} });
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if (method === 'initialize') {
|
|
109
|
+
send({
|
|
110
|
+
jsonrpc: '2.0',
|
|
111
|
+
id,
|
|
112
|
+
result: {
|
|
113
|
+
protocolVersion: '2024-11-05',
|
|
114
|
+
capabilities: { tools: {} },
|
|
115
|
+
serverInfo: { name: 'demobun-mcp', version: '1.0.0' },
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if (method === 'tools/list') {
|
|
122
|
+
send({
|
|
123
|
+
jsonrpc: '2.0',
|
|
124
|
+
id,
|
|
125
|
+
result: {
|
|
126
|
+
tools: [
|
|
127
|
+
{
|
|
128
|
+
name: 'publish_interactive_demo',
|
|
129
|
+
description:
|
|
130
|
+
'Publish screenshots and hotspot coordinates to DemoBun and get a hosted interactive demo URL.',
|
|
131
|
+
inputSchema: {
|
|
132
|
+
type: 'object',
|
|
133
|
+
properties: {
|
|
134
|
+
title: { type: 'string' },
|
|
135
|
+
subtitle: { type: 'string' },
|
|
136
|
+
steps: {
|
|
137
|
+
type: 'array',
|
|
138
|
+
items: {
|
|
139
|
+
type: 'object',
|
|
140
|
+
properties: {
|
|
141
|
+
title: { type: 'string' },
|
|
142
|
+
imageUrl: { type: 'string' },
|
|
143
|
+
hotspots: { type: 'array' },
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
required: ['title', 'steps'],
|
|
149
|
+
},
|
|
150
|
+
},
|
|
151
|
+
],
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (method === 'tools/call' && params?.name === 'publish_interactive_demo') {
|
|
158
|
+
const out = await publishDemo(params.arguments || {});
|
|
159
|
+
send({
|
|
160
|
+
jsonrpc: '2.0',
|
|
161
|
+
id,
|
|
162
|
+
result: {
|
|
163
|
+
content: [{ type: 'text', text: JSON.stringify(out, null, 2) }],
|
|
164
|
+
isError: Boolean(out.error),
|
|
165
|
+
},
|
|
166
|
+
});
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
if (id !== undefined) {
|
|
171
|
+
send({
|
|
172
|
+
jsonrpc: '2.0',
|
|
173
|
+
id,
|
|
174
|
+
error: { code: -32601, message: `Method not found: ${method}` },
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "demobun-mcp-server",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Model Context Protocol (MCP) server for publishing interactive product demos to DemoBun.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"demobun-mcp": "./index.mjs"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"index.mjs",
|
|
12
|
+
"README.md"
|
|
13
|
+
],
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public"
|
|
16
|
+
},
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "https://github.com/CoderSufiyan/demobun.site.git",
|
|
20
|
+
"directory": "packages/mcp-server"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"mcp",
|
|
24
|
+
"model-context-protocol",
|
|
25
|
+
"demobun",
|
|
26
|
+
"interactive-demo",
|
|
27
|
+
"product-demo"
|
|
28
|
+
],
|
|
29
|
+
"engines": {
|
|
30
|
+
"node": ">=18"
|
|
31
|
+
}
|
|
32
|
+
}
|