@rudderjs/mcp 0.0.1 → 0.0.2
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 +68 -0
- package/dist/Mcp.d.ts +21 -5
- package/dist/Mcp.d.ts.map +1 -1
- package/dist/Mcp.js +13 -1
- package/dist/Mcp.js.map +1 -1
- package/dist/McpPrompt.d.ts +8 -5
- package/dist/McpPrompt.d.ts.map +1 -1
- package/dist/McpPrompt.js.map +1 -1
- package/dist/McpResource.d.ts +9 -3
- package/dist/McpResource.d.ts.map +1 -1
- package/dist/McpResource.js +4 -0
- package/dist/McpResource.js.map +1 -1
- package/dist/McpTool.d.ts +17 -5
- package/dist/McpTool.d.ts.map +1 -1
- package/dist/McpTool.js.map +1 -1
- package/dist/auth/oauth2.d.ts +25 -0
- package/dist/auth/oauth2.d.ts.map +1 -0
- package/dist/auth/oauth2.js +128 -0
- package/dist/auth/oauth2.js.map +1 -0
- package/dist/commands/inspector-ui.d.ts +2 -0
- package/dist/commands/inspector-ui.d.ts.map +1 -0
- package/dist/commands/inspector-ui.js +300 -0
- package/dist/commands/inspector-ui.js.map +1 -0
- package/dist/commands/inspector.d.ts +5 -0
- package/dist/commands/inspector.d.ts.map +1 -0
- package/dist/commands/inspector.js +226 -0
- package/dist/commands/inspector.js.map +1 -0
- package/dist/commands/make-mcp-prompt.d.ts +3 -0
- package/dist/commands/make-mcp-prompt.d.ts.map +1 -0
- package/dist/commands/make-mcp-prompt.js +27 -0
- package/dist/commands/make-mcp-prompt.js.map +1 -0
- package/dist/commands/make-mcp-resource.d.ts +3 -0
- package/dist/commands/make-mcp-resource.d.ts.map +1 -0
- package/dist/commands/make-mcp-resource.js +26 -0
- package/dist/commands/make-mcp-resource.js.map +1 -0
- package/dist/commands/make-mcp-server.d.ts +3 -0
- package/dist/commands/make-mcp-server.d.ts.map +1 -0
- package/dist/commands/make-mcp-server.js +28 -0
- package/dist/commands/make-mcp-server.js.map +1 -0
- package/dist/commands/make-mcp-tool.d.ts +3 -0
- package/dist/commands/make-mcp-tool.d.ts.map +1 -0
- package/dist/commands/make-mcp-tool.js +25 -0
- package/dist/commands/make-mcp-tool.js.map +1 -0
- package/dist/decorators.d.ts +17 -0
- package/dist/decorators.d.ts.map +1 -1
- package/dist/decorators.js +22 -0
- package/dist/decorators.js.map +1 -1
- package/dist/index.d.ts +9 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -3
- package/dist/index.js.map +1 -1
- package/dist/observers.d.ts +32 -0
- package/dist/observers.d.ts.map +1 -0
- package/dist/observers.js +31 -0
- package/dist/observers.js.map +1 -0
- package/dist/provider.d.ts +4 -2
- package/dist/provider.d.ts.map +1 -1
- package/dist/provider.js +78 -40
- package/dist/provider.js.map +1 -1
- package/dist/runtime.d.ts +30 -0
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +267 -24
- package/dist/runtime.js.map +1 -1
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +3 -1
- package/dist/testing.js.map +1 -1
- package/dist/types.d.ts +11 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/zod-to-json-schema.d.ts +4 -3
- package/dist/zod-to-json-schema.d.ts.map +1 -1
- package/dist/zod-to-json-schema.js +54 -24
- package/dist/zod-to-json-schema.js.map +1 -1
- package/package.json +41 -3
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
export const INSPECTOR_HTML = /* html */ `<!doctype html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="utf-8" />
|
|
5
|
+
<title>MCP Inspector</title>
|
|
6
|
+
<style>
|
|
7
|
+
:root {
|
|
8
|
+
--bg: #0f1115;
|
|
9
|
+
--surface: #1a1d24;
|
|
10
|
+
--border: #2a2f3a;
|
|
11
|
+
--text: #e4e6eb;
|
|
12
|
+
--muted: #8a919e;
|
|
13
|
+
--accent: #5c9cf5;
|
|
14
|
+
--error: #ff7b7b;
|
|
15
|
+
--success: #8be78b;
|
|
16
|
+
}
|
|
17
|
+
* { box-sizing: border-box; }
|
|
18
|
+
body {
|
|
19
|
+
margin: 0; font: 14px/1.5 system-ui, sans-serif;
|
|
20
|
+
background: var(--bg); color: var(--text);
|
|
21
|
+
display: grid; grid-template-columns: 280px 1fr; height: 100vh;
|
|
22
|
+
}
|
|
23
|
+
aside {
|
|
24
|
+
background: var(--surface); border-right: 1px solid var(--border);
|
|
25
|
+
padding: 16px; overflow-y: auto;
|
|
26
|
+
}
|
|
27
|
+
aside h2 { font-size: 11px; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; letter-spacing: .05em; }
|
|
28
|
+
aside ul { list-style: none; padding: 0; margin: 0 0 20px; }
|
|
29
|
+
aside li button {
|
|
30
|
+
display: block; width: 100%; text-align: left;
|
|
31
|
+
padding: 8px 12px; margin-bottom: 2px; border: 0; border-radius: 6px;
|
|
32
|
+
background: transparent; color: var(--text); font: inherit; cursor: pointer;
|
|
33
|
+
}
|
|
34
|
+
aside li button:hover { background: rgba(255,255,255,.04); }
|
|
35
|
+
aside li button.active { background: var(--accent); color: #fff; }
|
|
36
|
+
main { padding: 24px 32px; overflow-y: auto; }
|
|
37
|
+
h1 { margin: 0 0 4px; font-size: 20px; }
|
|
38
|
+
.meta { color: var(--muted); margin-bottom: 24px; }
|
|
39
|
+
section { margin-bottom: 32px; }
|
|
40
|
+
section h3 { font-size: 12px; text-transform: uppercase; color: var(--muted); margin: 0 0 12px; letter-spacing: .05em; }
|
|
41
|
+
.card {
|
|
42
|
+
background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
|
|
43
|
+
padding: 14px 16px; margin-bottom: 8px;
|
|
44
|
+
}
|
|
45
|
+
.card-head { display: flex; justify-content: space-between; align-items: center; cursor: pointer; }
|
|
46
|
+
.card-head strong { color: var(--text); }
|
|
47
|
+
.card-head span { color: var(--muted); font-size: 13px; }
|
|
48
|
+
.card-body { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
|
|
49
|
+
.card-body[hidden] { display: none; }
|
|
50
|
+
textarea, input {
|
|
51
|
+
width: 100%; font: 12px ui-monospace, monospace; padding: 8px; border-radius: 6px;
|
|
52
|
+
background: var(--bg); color: var(--text); border: 1px solid var(--border); resize: vertical;
|
|
53
|
+
}
|
|
54
|
+
button.run {
|
|
55
|
+
margin-top: 10px; padding: 6px 14px; background: var(--accent); color: #fff; border: 0;
|
|
56
|
+
border-radius: 6px; cursor: pointer; font: 13px system-ui;
|
|
57
|
+
}
|
|
58
|
+
button.run:hover { filter: brightness(1.1); }
|
|
59
|
+
pre {
|
|
60
|
+
background: var(--bg); padding: 12px; border-radius: 6px; overflow-x: auto;
|
|
61
|
+
font: 12px ui-monospace, monospace; margin: 10px 0 0; max-height: 320px; overflow-y: auto;
|
|
62
|
+
}
|
|
63
|
+
.response.error { color: var(--error); }
|
|
64
|
+
.response.ok { color: var(--success); }
|
|
65
|
+
.empty { color: var(--muted); font-style: italic; }
|
|
66
|
+
.pill {
|
|
67
|
+
display: inline-block; padding: 1px 6px; border-radius: 3px; background: var(--border);
|
|
68
|
+
color: var(--muted); font-size: 11px; margin-left: 6px;
|
|
69
|
+
}
|
|
70
|
+
</style>
|
|
71
|
+
</head>
|
|
72
|
+
<body>
|
|
73
|
+
|
|
74
|
+
<aside>
|
|
75
|
+
<h1 style="font-size:15px;margin:0 0 20px;">⚡ MCP Inspector</h1>
|
|
76
|
+
<h2>Web servers</h2>
|
|
77
|
+
<ul id="web-list"></ul>
|
|
78
|
+
<h2>Local servers</h2>
|
|
79
|
+
<ul id="local-list"></ul>
|
|
80
|
+
</aside>
|
|
81
|
+
|
|
82
|
+
<main id="main">
|
|
83
|
+
<p class="empty">Select a server from the sidebar.</p>
|
|
84
|
+
</main>
|
|
85
|
+
|
|
86
|
+
<script>
|
|
87
|
+
async function api(path, options) {
|
|
88
|
+
const r = await fetch(path, options)
|
|
89
|
+
if (!r.ok) throw new Error((await r.json().catch(() => ({}))).error || r.statusText)
|
|
90
|
+
return r.json()
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function el(tag, attrs, ...children) {
|
|
94
|
+
const n = document.createElement(tag)
|
|
95
|
+
if (attrs) for (const [k, v] of Object.entries(attrs)) {
|
|
96
|
+
if (k === 'class') n.className = v
|
|
97
|
+
else if (k.startsWith('on')) n[k] = v
|
|
98
|
+
else if (v !== undefined && v !== null) n.setAttribute(k, v)
|
|
99
|
+
}
|
|
100
|
+
for (const c of children) {
|
|
101
|
+
if (c == null) continue
|
|
102
|
+
n.appendChild(typeof c === 'string' ? document.createTextNode(c) : c)
|
|
103
|
+
}
|
|
104
|
+
return n
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
let activeKey = null
|
|
108
|
+
|
|
109
|
+
async function refreshList() {
|
|
110
|
+
const { web, local } = await api('/api/servers')
|
|
111
|
+
const render = (items, ul) => {
|
|
112
|
+
ul.innerHTML = ''
|
|
113
|
+
if (items.length === 0) {
|
|
114
|
+
ul.appendChild(el('li', { class: 'empty' }, '(none)'))
|
|
115
|
+
return
|
|
116
|
+
}
|
|
117
|
+
for (const s of items) {
|
|
118
|
+
ul.appendChild(el('li', null, el('button', {
|
|
119
|
+
class: s.key === activeKey ? 'active' : '',
|
|
120
|
+
onclick: () => openServer(s.key),
|
|
121
|
+
}, s.label)))
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
render(web, document.getElementById('web-list'))
|
|
125
|
+
render(local, document.getElementById('local-list'))
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
async function openServer(key) {
|
|
129
|
+
activeKey = key
|
|
130
|
+
await refreshList()
|
|
131
|
+
const main = document.getElementById('main')
|
|
132
|
+
main.innerHTML = 'Loading…'
|
|
133
|
+
try {
|
|
134
|
+
const detail = await api('/api/servers/' + encodeURIComponent(key))
|
|
135
|
+
main.innerHTML = ''
|
|
136
|
+
main.appendChild(el('h1', null, detail.metadata.name || detail.label))
|
|
137
|
+
main.appendChild(el('div', { class: 'meta' },
|
|
138
|
+
'v' + detail.metadata.version + ' · ' + detail.kind + ' · ' + detail.key,
|
|
139
|
+
))
|
|
140
|
+
if (detail.metadata.instructions) main.appendChild(el('p', { class: 'meta' }, detail.metadata.instructions))
|
|
141
|
+
renderTools(main, key, detail.tools)
|
|
142
|
+
renderResources(main, key, detail.resources)
|
|
143
|
+
renderPrompts(main, key, detail.prompts)
|
|
144
|
+
} catch (err) {
|
|
145
|
+
main.innerHTML = ''
|
|
146
|
+
main.appendChild(el('p', { class: 'response error' }, err.message))
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function renderTools(container, key, tools) {
|
|
151
|
+
container.appendChild(el('section', null,
|
|
152
|
+
el('h3', null, 'Tools (' + tools.length + ')'),
|
|
153
|
+
...(tools.length === 0 ? [el('p', { class: 'empty' }, 'No tools.')] : tools.map((t) => toolCard(key, t))),
|
|
154
|
+
))
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function toolCard(key, t) {
|
|
158
|
+
const inputEl = el('textarea', { rows: 4, 'aria-label': 'input' })
|
|
159
|
+
inputEl.value = JSON.stringify(defaultFromSchema(t.inputSchema), null, 2)
|
|
160
|
+
const outEl = el('pre', { class: 'response' })
|
|
161
|
+
outEl.hidden = true
|
|
162
|
+
const body = el('div', { class: 'card-body', hidden: true },
|
|
163
|
+
el('div', { class: 'meta' }, t.description || '(no description)'),
|
|
164
|
+
el('label', null, 'Input JSON'), inputEl,
|
|
165
|
+
el('button', {
|
|
166
|
+
class: 'run',
|
|
167
|
+
onclick: async () => {
|
|
168
|
+
outEl.hidden = false
|
|
169
|
+
outEl.className = 'response'
|
|
170
|
+
outEl.textContent = 'Running…'
|
|
171
|
+
try {
|
|
172
|
+
const input = JSON.parse(inputEl.value)
|
|
173
|
+
const r = await api('/api/servers/' + encodeURIComponent(key) + '/tools/' + encodeURIComponent(t.name), {
|
|
174
|
+
method: 'POST',
|
|
175
|
+
headers: { 'Content-Type': 'application/json' },
|
|
176
|
+
body: JSON.stringify(input),
|
|
177
|
+
})
|
|
178
|
+
outEl.className = 'response ' + (r.isError ? 'error' : 'ok')
|
|
179
|
+
outEl.textContent = JSON.stringify(r, null, 2)
|
|
180
|
+
} catch (e) {
|
|
181
|
+
outEl.className = 'response error'
|
|
182
|
+
outEl.textContent = e.message
|
|
183
|
+
}
|
|
184
|
+
},
|
|
185
|
+
}, 'Call tool'),
|
|
186
|
+
outEl,
|
|
187
|
+
)
|
|
188
|
+
const head = el('div', { class: 'card-head', onclick: () => { body.hidden = !body.hidden } },
|
|
189
|
+
el('strong', null, t.name),
|
|
190
|
+
el('span', null, (t.description || '').slice(0, 60)),
|
|
191
|
+
)
|
|
192
|
+
return el('div', { class: 'card' }, head, body)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function renderResources(container, key, resources) {
|
|
196
|
+
container.appendChild(el('section', null,
|
|
197
|
+
el('h3', null, 'Resources (' + resources.length + ')'),
|
|
198
|
+
...(resources.length === 0 ? [el('p', { class: 'empty' }, 'No resources.')] : resources.map((r) => resourceCard(key, r))),
|
|
199
|
+
))
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function resourceCard(key, r) {
|
|
203
|
+
const uriEl = el('input', { value: r.uri, 'aria-label': 'uri' })
|
|
204
|
+
const outEl = el('pre', { class: 'response' })
|
|
205
|
+
outEl.hidden = true
|
|
206
|
+
const body = el('div', { class: 'card-body', hidden: true },
|
|
207
|
+
el('label', null, 'URI' + (r.template ? ' (template — fill in {placeholders})' : '')),
|
|
208
|
+
uriEl,
|
|
209
|
+
el('button', {
|
|
210
|
+
class: 'run',
|
|
211
|
+
onclick: async () => {
|
|
212
|
+
outEl.hidden = false
|
|
213
|
+
outEl.className = 'response'
|
|
214
|
+
outEl.textContent = 'Loading…'
|
|
215
|
+
try {
|
|
216
|
+
const r2 = await api('/api/servers/' + encodeURIComponent(key) + '/resource?uri=' + encodeURIComponent(uriEl.value))
|
|
217
|
+
outEl.className = 'response ok'
|
|
218
|
+
outEl.textContent = JSON.stringify(r2, null, 2)
|
|
219
|
+
} catch (e) {
|
|
220
|
+
outEl.className = 'response error'
|
|
221
|
+
outEl.textContent = e.message
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
}, 'Read resource'),
|
|
225
|
+
outEl,
|
|
226
|
+
)
|
|
227
|
+
return el('div', { class: 'card' },
|
|
228
|
+
el('div', { class: 'card-head', onclick: () => { body.hidden = !body.hidden } },
|
|
229
|
+
el('strong', null, r.uri),
|
|
230
|
+
el('span', null, (r.description || '') + (r.template ? ' · template' : '')),
|
|
231
|
+
),
|
|
232
|
+
body,
|
|
233
|
+
)
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function renderPrompts(container, key, prompts) {
|
|
237
|
+
container.appendChild(el('section', null,
|
|
238
|
+
el('h3', null, 'Prompts (' + prompts.length + ')'),
|
|
239
|
+
...(prompts.length === 0 ? [el('p', { class: 'empty' }, 'No prompts.')] : prompts.map((p) => promptCard(key, p))),
|
|
240
|
+
))
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function promptCard(key, p) {
|
|
244
|
+
const argsEl = el('textarea', { rows: 3, 'aria-label': 'arguments' })
|
|
245
|
+
argsEl.value = JSON.stringify(p.argumentSchema ? defaultFromSchema(p.argumentSchema) : {}, null, 2)
|
|
246
|
+
const outEl = el('pre', { class: 'response' })
|
|
247
|
+
outEl.hidden = true
|
|
248
|
+
const body = el('div', { class: 'card-body', hidden: true },
|
|
249
|
+
el('div', { class: 'meta' }, p.description || '(no description)'),
|
|
250
|
+
el('label', null, 'Arguments JSON'), argsEl,
|
|
251
|
+
el('button', {
|
|
252
|
+
class: 'run',
|
|
253
|
+
onclick: async () => {
|
|
254
|
+
outEl.hidden = false
|
|
255
|
+
outEl.className = 'response'
|
|
256
|
+
outEl.textContent = 'Running…'
|
|
257
|
+
try {
|
|
258
|
+
const args = JSON.parse(argsEl.value)
|
|
259
|
+
const r = await api('/api/servers/' + encodeURIComponent(key) + '/prompts/' + encodeURIComponent(p.name), {
|
|
260
|
+
method: 'POST',
|
|
261
|
+
headers: { 'Content-Type': 'application/json' },
|
|
262
|
+
body: JSON.stringify(args),
|
|
263
|
+
})
|
|
264
|
+
outEl.className = 'response ok'
|
|
265
|
+
outEl.textContent = JSON.stringify(r, null, 2)
|
|
266
|
+
} catch (e) {
|
|
267
|
+
outEl.className = 'response error'
|
|
268
|
+
outEl.textContent = e.message
|
|
269
|
+
}
|
|
270
|
+
},
|
|
271
|
+
}, 'Get prompt'),
|
|
272
|
+
outEl,
|
|
273
|
+
)
|
|
274
|
+
return el('div', { class: 'card' },
|
|
275
|
+
el('div', { class: 'card-head', onclick: () => { body.hidden = !body.hidden } },
|
|
276
|
+
el('strong', null, p.name),
|
|
277
|
+
el('span', null, (p.description || '').slice(0, 60)),
|
|
278
|
+
),
|
|
279
|
+
body,
|
|
280
|
+
)
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function defaultFromSchema(schema) {
|
|
284
|
+
if (!schema || schema.type !== 'object' || !schema.properties) return {}
|
|
285
|
+
const out = {}
|
|
286
|
+
for (const [k, v] of Object.entries(schema.properties)) {
|
|
287
|
+
if (v.type === 'string') out[k] = ''
|
|
288
|
+
else if (v.type === 'number' || v.type === 'integer') out[k] = 0
|
|
289
|
+
else if (v.type === 'boolean') out[k] = false
|
|
290
|
+
else if (v.type === 'array') out[k] = []
|
|
291
|
+
else out[k] = null
|
|
292
|
+
}
|
|
293
|
+
return out
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
refreshList()
|
|
297
|
+
</script>
|
|
298
|
+
</body>
|
|
299
|
+
</html>`;
|
|
300
|
+
//# sourceMappingURL=inspector-ui.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspector-ui.js","sourceRoot":"","sources":["../../src/commands/inspector-ui.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA0SjC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspector.d.ts","sourceRoot":"","sources":["../../src/commands/inspector.ts"],"names":[],"mappings":"AAUA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED,wBAAsB,cAAc,CAAC,OAAO,GAAE,gBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CAmBlF"}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { Mcp } from '../Mcp.js';
|
|
2
|
+
import { zodToJsonSchema } from '../zod-to-json-schema.js';
|
|
3
|
+
import { resolveHandleDeps } from '../runtime.js';
|
|
4
|
+
import { INSPECTOR_HTML } from './inspector-ui.js';
|
|
5
|
+
export async function startInspector(options = {}) {
|
|
6
|
+
const port = options.port ?? 9100;
|
|
7
|
+
const { createServer } = await import('node:http');
|
|
8
|
+
const server = createServer(async (req, res) => {
|
|
9
|
+
try {
|
|
10
|
+
await handle(req, res);
|
|
11
|
+
}
|
|
12
|
+
catch (err) {
|
|
13
|
+
sendJson(res, 500, { error: err instanceof Error ? err.message : String(err) });
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
await new Promise((resolve) => {
|
|
17
|
+
server.listen(port, () => {
|
|
18
|
+
console.log(` MCP Inspector — http://localhost:${port}`);
|
|
19
|
+
console.log(' Ctrl-C to exit.');
|
|
20
|
+
resolve();
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
// ─── request dispatch ────────────────────────────────────
|
|
25
|
+
async function handle(req, res) {
|
|
26
|
+
const url = new URL(req.url ?? '/', `http://${req.headers.host ?? 'localhost'}`);
|
|
27
|
+
const method = req.method ?? 'GET';
|
|
28
|
+
const path = url.pathname;
|
|
29
|
+
if (method === 'GET' && path === '/') {
|
|
30
|
+
res.statusCode = 200;
|
|
31
|
+
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
|
32
|
+
res.end(INSPECTOR_HTML);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
if (method === 'GET' && path === '/api/servers') {
|
|
36
|
+
sendJson(res, 200, listServers());
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const toolMatch = /^\/api\/servers\/([^/]+)\/tools\/([^/]+)$/.exec(path);
|
|
40
|
+
if (method === 'POST' && toolMatch) {
|
|
41
|
+
const [, key, toolName] = toolMatch;
|
|
42
|
+
const input = await readJson(req);
|
|
43
|
+
const entry = resolveServer(decodeURIComponent(key));
|
|
44
|
+
if (!entry)
|
|
45
|
+
return sendJson(res, 404, { error: `Unknown server "${key}"` });
|
|
46
|
+
const result = await callTool(entry, decodeURIComponent(toolName), input);
|
|
47
|
+
sendJson(res, 200, result);
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const readMatch = /^\/api\/servers\/([^/]+)\/resource$/.exec(path);
|
|
51
|
+
if (method === 'GET' && readMatch) {
|
|
52
|
+
const [, key] = readMatch;
|
|
53
|
+
const uri = url.searchParams.get('uri');
|
|
54
|
+
if (!uri)
|
|
55
|
+
return sendJson(res, 400, { error: 'uri query param required' });
|
|
56
|
+
const entry = resolveServer(decodeURIComponent(key));
|
|
57
|
+
if (!entry)
|
|
58
|
+
return sendJson(res, 404, { error: `Unknown server "${key}"` });
|
|
59
|
+
const result = await readResource(entry, uri);
|
|
60
|
+
sendJson(res, 200, result);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const promptMatch = /^\/api\/servers\/([^/]+)\/prompts\/([^/]+)$/.exec(path);
|
|
64
|
+
if (method === 'POST' && promptMatch) {
|
|
65
|
+
const [, key, promptName] = promptMatch;
|
|
66
|
+
const args = await readJson(req);
|
|
67
|
+
const entry = resolveServer(decodeURIComponent(key));
|
|
68
|
+
if (!entry)
|
|
69
|
+
return sendJson(res, 404, { error: `Unknown server "${key}"` });
|
|
70
|
+
const result = await getPrompt(entry, decodeURIComponent(promptName), args);
|
|
71
|
+
sendJson(res, 200, result);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
const detailMatch = /^\/api\/servers\/([^/]+)$/.exec(path);
|
|
75
|
+
if (method === 'GET' && detailMatch) {
|
|
76
|
+
const [, key] = detailMatch;
|
|
77
|
+
const entry = resolveServer(decodeURIComponent(key));
|
|
78
|
+
if (!entry)
|
|
79
|
+
return sendJson(res, 404, { error: `Unknown server "${key}"` });
|
|
80
|
+
sendJson(res, 200, describeServer(entry));
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
sendJson(res, 404, { error: 'Not found' });
|
|
84
|
+
}
|
|
85
|
+
function listServers() {
|
|
86
|
+
const web = [];
|
|
87
|
+
for (const [path, { server }] of Mcp.getWebServers()) {
|
|
88
|
+
web.push({ key: `web:${path}`, kind: 'web', label: `${server.name} (${path})`, Server: server });
|
|
89
|
+
}
|
|
90
|
+
const local = [];
|
|
91
|
+
for (const [name, server] of Mcp.getLocalServers()) {
|
|
92
|
+
local.push({ key: `local:${name}`, kind: 'local', label: `${server.name} (${name})`, Server: server });
|
|
93
|
+
}
|
|
94
|
+
return {
|
|
95
|
+
web: web.map((e) => ({ ...e, Server: undefined })),
|
|
96
|
+
local: local.map((e) => ({ ...e, Server: undefined })),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function resolveServer(key) {
|
|
100
|
+
if (key.startsWith('web:')) {
|
|
101
|
+
const path = key.slice(4);
|
|
102
|
+
const entry = Mcp.getWebServers().get(path);
|
|
103
|
+
if (!entry)
|
|
104
|
+
return undefined;
|
|
105
|
+
return { key, kind: 'web', label: `${entry.server.name} (${path})`, Server: entry.server };
|
|
106
|
+
}
|
|
107
|
+
if (key.startsWith('local:')) {
|
|
108
|
+
const name = key.slice(6);
|
|
109
|
+
const Server = Mcp.getLocalServers().get(name);
|
|
110
|
+
if (!Server)
|
|
111
|
+
return undefined;
|
|
112
|
+
return { key, kind: 'local', label: `${Server.name} (${name})`, Server };
|
|
113
|
+
}
|
|
114
|
+
return undefined;
|
|
115
|
+
}
|
|
116
|
+
function getProtected(server, key, fallback) {
|
|
117
|
+
return (server[key]) ?? fallback;
|
|
118
|
+
}
|
|
119
|
+
function instantiateServer(entry) {
|
|
120
|
+
const server = new entry.Server();
|
|
121
|
+
const tools = getProtected(server, 'tools', []).map((T) => new T());
|
|
122
|
+
const resources = getProtected(server, 'resources', []).map((R) => new R());
|
|
123
|
+
const prompts = getProtected(server, 'prompts', []).map((P) => new P());
|
|
124
|
+
return { server, tools, resources, prompts };
|
|
125
|
+
}
|
|
126
|
+
function describeServer(entry) {
|
|
127
|
+
const { server, tools, resources, prompts } = instantiateServer(entry);
|
|
128
|
+
const meta = server.metadata();
|
|
129
|
+
return {
|
|
130
|
+
key: entry.key,
|
|
131
|
+
kind: entry.kind,
|
|
132
|
+
label: entry.label,
|
|
133
|
+
metadata: meta,
|
|
134
|
+
tools: tools.map((t) => ({
|
|
135
|
+
name: t.name(),
|
|
136
|
+
description: t.description(),
|
|
137
|
+
inputSchema: zodToJsonSchema(t.schema()),
|
|
138
|
+
...(t.outputSchema ? { outputSchema: zodToJsonSchema(t.outputSchema()) } : {}),
|
|
139
|
+
})),
|
|
140
|
+
resources: resources.map((r) => ({
|
|
141
|
+
uri: r.uri(),
|
|
142
|
+
description: r.description(),
|
|
143
|
+
mimeType: r.mimeType(),
|
|
144
|
+
template: r.isTemplate(),
|
|
145
|
+
})),
|
|
146
|
+
prompts: prompts.map((p) => ({
|
|
147
|
+
name: p.name(),
|
|
148
|
+
description: p.description(),
|
|
149
|
+
...(p.arguments
|
|
150
|
+
? { argumentSchema: zodToJsonSchema(p.arguments()) }
|
|
151
|
+
: {}),
|
|
152
|
+
})),
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
async function callTool(entry, name, input) {
|
|
156
|
+
const { tools } = instantiateServer(entry);
|
|
157
|
+
const tool = tools.find((t) => t.name() === name);
|
|
158
|
+
if (!tool)
|
|
159
|
+
throw new Error(`Tool "${name}" not found on ${entry.label}`);
|
|
160
|
+
const extras = resolveHandleDeps(tool, 'handle');
|
|
161
|
+
return tool.handle(input, ...extras);
|
|
162
|
+
}
|
|
163
|
+
async function readResource(entry, uri) {
|
|
164
|
+
const { resources } = instantiateServer(entry);
|
|
165
|
+
const exact = resources.find((r) => !r.isTemplate() && r.uri() === uri);
|
|
166
|
+
if (exact) {
|
|
167
|
+
const extras = resolveHandleDeps(exact, 'handle');
|
|
168
|
+
return { uri, content: await exact.handle(undefined, ...extras), mimeType: exact.mimeType() };
|
|
169
|
+
}
|
|
170
|
+
// Try template resources
|
|
171
|
+
for (const tmpl of resources.filter((r) => r.isTemplate())) {
|
|
172
|
+
const params = matchTemplate(tmpl.uri(), uri);
|
|
173
|
+
if (params) {
|
|
174
|
+
const extras = resolveHandleDeps(tmpl, 'handle');
|
|
175
|
+
return { uri, content: await tmpl.handle(params, ...extras), mimeType: tmpl.mimeType() };
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
throw new Error(`Resource "${uri}" not found`);
|
|
179
|
+
}
|
|
180
|
+
function matchTemplate(template, uri) {
|
|
181
|
+
const names = [];
|
|
182
|
+
const regex = template.replace(/\{(\w+)\}/g, (_, name) => {
|
|
183
|
+
names.push(name);
|
|
184
|
+
return '([^/]+)';
|
|
185
|
+
});
|
|
186
|
+
const match = uri.match(new RegExp(`^${regex}$`));
|
|
187
|
+
if (!match)
|
|
188
|
+
return null;
|
|
189
|
+
const out = {};
|
|
190
|
+
for (let i = 0; i < names.length; i++)
|
|
191
|
+
out[names[i]] = decodeURIComponent(match[i + 1]);
|
|
192
|
+
return out;
|
|
193
|
+
}
|
|
194
|
+
async function getPrompt(entry, name, args) {
|
|
195
|
+
const { prompts } = instantiateServer(entry);
|
|
196
|
+
const prompt = prompts.find((p) => p.name() === name);
|
|
197
|
+
if (!prompt)
|
|
198
|
+
throw new Error(`Prompt "${name}" not found on ${entry.label}`);
|
|
199
|
+
const extras = resolveHandleDeps(prompt, 'handle');
|
|
200
|
+
return { messages: await prompt.handle(args, ...extras) };
|
|
201
|
+
}
|
|
202
|
+
// ─── http helpers ────────────────────────────────────────
|
|
203
|
+
function sendJson(res, status, body) {
|
|
204
|
+
res.statusCode = status;
|
|
205
|
+
res.setHeader('Content-Type', 'application/json');
|
|
206
|
+
res.end(JSON.stringify(body, null, 2));
|
|
207
|
+
}
|
|
208
|
+
async function readJson(req) {
|
|
209
|
+
return new Promise((resolve, reject) => {
|
|
210
|
+
const chunks = [];
|
|
211
|
+
req.on('data', (chunk) => chunks.push(chunk));
|
|
212
|
+
req.on('end', () => {
|
|
213
|
+
const raw = Buffer.concat(chunks).toString('utf8');
|
|
214
|
+
if (!raw)
|
|
215
|
+
return resolve({});
|
|
216
|
+
try {
|
|
217
|
+
resolve(JSON.parse(raw));
|
|
218
|
+
}
|
|
219
|
+
catch (e) {
|
|
220
|
+
reject(e);
|
|
221
|
+
}
|
|
222
|
+
});
|
|
223
|
+
req.on('error', reject);
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
//# sourceMappingURL=inspector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspector.js","sourceRoot":"","sources":["../../src/commands/inspector.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAA;AAK/B,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,e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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make-mcp-prompt.d.ts","sourceRoot":"","sources":["../../src/commands/make-mcp-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAEhD,eAAO,MAAM,iBAAiB,EAAE,QAyB/B,CAAA"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export const makeMcpPromptSpec = {
|
|
2
|
+
command: 'make:mcp-prompt',
|
|
3
|
+
description: 'Create a new MCP prompt class',
|
|
4
|
+
label: 'MCP prompt created',
|
|
5
|
+
suffix: 'Prompt',
|
|
6
|
+
directory: 'app/Mcp/Prompts',
|
|
7
|
+
stub: (className) => `import { McpPrompt, Description } from '@rudderjs/mcp'
|
|
8
|
+
import type { McpPromptMessage } from '@rudderjs/mcp'
|
|
9
|
+
import { z } from 'zod'
|
|
10
|
+
|
|
11
|
+
@Description('Describe what this prompt does.')
|
|
12
|
+
export class ${className} extends McpPrompt {
|
|
13
|
+
arguments() {
|
|
14
|
+
return z.object({
|
|
15
|
+
// Define your prompt arguments here
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async handle(args: Record<string, unknown>): Promise<McpPromptMessage[]> {
|
|
20
|
+
return [
|
|
21
|
+
{ role: 'user', content: 'Summarize the following data...' },
|
|
22
|
+
]
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
`,
|
|
26
|
+
};
|
|
27
|
+
//# sourceMappingURL=make-mcp-prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make-mcp-prompt.js","sourceRoot":"","sources":["../../src/commands/make-mcp-prompt.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,iBAAiB,GAAa;IACzC,OAAO,EAAM,iBAAiB;IAC9B,WAAW,EAAE,+BAA+B;IAC5C,KAAK,EAAQ,oBAAoB;IACjC,MAAM,EAAO,QAAQ;IACrB,SAAS,EAAI,iBAAiB;IAC9B,IAAI,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC;;;;;eAKR,SAAS;;;;;;;;;;;;;CAavB;CACA,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make-mcp-resource.d.ts","sourceRoot":"","sources":["../../src/commands/make-mcp-resource.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAEhD,eAAO,MAAM,mBAAmB,EAAE,QAwBjC,CAAA"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export const makeMcpResourceSpec = {
|
|
2
|
+
command: 'make:mcp-resource',
|
|
3
|
+
description: 'Create a new MCP resource class',
|
|
4
|
+
label: 'MCP resource created',
|
|
5
|
+
suffix: 'Resource',
|
|
6
|
+
directory: 'app/Mcp/Resources',
|
|
7
|
+
stub: (className) => `import { McpResource, Description } from '@rudderjs/mcp'
|
|
8
|
+
|
|
9
|
+
@Description('Describe what this resource provides.')
|
|
10
|
+
export class ${className} extends McpResource {
|
|
11
|
+
uri(): string {
|
|
12
|
+
return 'app://${className.replace(/Resource$/, '').toLowerCase()}'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
mimeType(): string {
|
|
16
|
+
return 'text/plain'
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
async handle(): Promise<string> {
|
|
20
|
+
// Return resource content here
|
|
21
|
+
return 'Resource content'
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
`,
|
|
25
|
+
};
|
|
26
|
+
//# sourceMappingURL=make-mcp-resource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make-mcp-resource.js","sourceRoot":"","sources":["../../src/commands/make-mcp-resource.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,mBAAmB,GAAa;IAC3C,OAAO,EAAM,mBAAmB;IAChC,WAAW,EAAE,iCAAiC;IAC9C,KAAK,EAAQ,sBAAsB;IACnC,MAAM,EAAO,UAAU;IACvB,SAAS,EAAI,mBAAmB;IAChC,IAAI,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC;;;eAGR,SAAS;;oBAEJ,SAAS,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE;;;;;;;;;;;;CAYnE;CACA,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"make-mcp-server.d.ts","sourceRoot":"","sources":["../../src/commands/make-mcp-server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAEhD,eAAO,MAAM,iBAAiB,EAAE,QA0B/B,CAAA"}
|