mcponce 0.1.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 +1013 -0
- package/dist/cli/analytics.d.ts +5 -0
- package/dist/cli/analytics.d.ts.map +1 -0
- package/dist/cli/analytics.js +93 -0
- package/dist/cli/analytics.js.map +1 -0
- package/dist/cli/bin.d.ts +20 -0
- package/dist/cli/bin.d.ts.map +1 -0
- package/dist/cli/bin.js +510 -0
- package/dist/cli/bin.js.map +1 -0
- package/dist/cli/index.d.ts +9 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +196 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/info.d.ts +3 -0
- package/dist/cli/info.d.ts.map +1 -0
- package/dist/cli/info.js +42 -0
- package/dist/cli/info.js.map +1 -0
- package/dist/cli/installer.d.ts +64 -0
- package/dist/cli/installer.d.ts.map +1 -0
- package/dist/cli/installer.js +183 -0
- package/dist/cli/installer.js.map +1 -0
- package/dist/cli/logs.d.ts +3 -0
- package/dist/cli/logs.d.ts.map +1 -0
- package/dist/cli/logs.js +19 -0
- package/dist/cli/logs.js.map +1 -0
- package/dist/cli/tool-caller.d.ts +70 -0
- package/dist/cli/tool-caller.d.ts.map +1 -0
- package/dist/cli/tool-caller.js +404 -0
- package/dist/cli/tool-caller.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +27 -0
- package/dist/index.js.map +1 -0
- package/dist/logging/file-logger.d.ts +21 -0
- package/dist/logging/file-logger.d.ts.map +1 -0
- package/dist/logging/file-logger.js +96 -0
- package/dist/logging/file-logger.js.map +1 -0
- package/dist/logging/logger.d.ts +22 -0
- package/dist/logging/logger.d.ts.map +1 -0
- package/dist/logging/logger.js +57 -0
- package/dist/logging/logger.js.map +1 -0
- package/dist/logging/rotation.d.ts +6 -0
- package/dist/logging/rotation.d.ts.map +1 -0
- package/dist/logging/rotation.js +32 -0
- package/dist/logging/rotation.js.map +1 -0
- package/dist/registry/central.d.ts +54 -0
- package/dist/registry/central.d.ts.map +1 -0
- package/dist/registry/central.js +205 -0
- package/dist/registry/central.js.map +1 -0
- package/dist/registry/prompts.d.ts +9 -0
- package/dist/registry/prompts.d.ts.map +1 -0
- package/dist/registry/prompts.js +18 -0
- package/dist/registry/prompts.js.map +1 -0
- package/dist/registry/resources.d.ts +52 -0
- package/dist/registry/resources.d.ts.map +1 -0
- package/dist/registry/resources.js +102 -0
- package/dist/registry/resources.js.map +1 -0
- package/dist/registry/subscriptions.d.ts +44 -0
- package/dist/registry/subscriptions.d.ts.map +1 -0
- package/dist/registry/subscriptions.js +96 -0
- package/dist/registry/subscriptions.js.map +1 -0
- package/dist/registry/tools.d.ts +24 -0
- package/dist/registry/tools.d.ts.map +1 -0
- package/dist/registry/tools.js +120 -0
- package/dist/registry/tools.js.map +1 -0
- package/dist/runtime/config.d.ts +30 -0
- package/dist/runtime/config.d.ts.map +1 -0
- package/dist/runtime/config.js +79 -0
- package/dist/runtime/config.js.map +1 -0
- package/dist/runtime/health.d.ts +15 -0
- package/dist/runtime/health.d.ts.map +1 -0
- package/dist/runtime/health.js +63 -0
- package/dist/runtime/health.js.map +1 -0
- package/dist/runtime/instance.d.ts +33 -0
- package/dist/runtime/instance.d.ts.map +1 -0
- package/dist/runtime/instance.js +148 -0
- package/dist/runtime/instance.js.map +1 -0
- package/dist/runtime/lock.d.ts +33 -0
- package/dist/runtime/lock.d.ts.map +1 -0
- package/dist/runtime/lock.js +105 -0
- package/dist/runtime/lock.js.map +1 -0
- package/dist/runtime/paths.d.ts +16 -0
- package/dist/runtime/paths.d.ts.map +1 -0
- package/dist/runtime/paths.js +54 -0
- package/dist/runtime/paths.js.map +1 -0
- package/dist/runtime/state.d.ts +24 -0
- package/dist/runtime/state.d.ts.map +1 -0
- package/dist/runtime/state.js +71 -0
- package/dist/runtime/state.js.map +1 -0
- package/dist/runtime/unitup.d.ts +44 -0
- package/dist/runtime/unitup.d.ts.map +1 -0
- package/dist/runtime/unitup.js +134 -0
- package/dist/runtime/unitup.js.map +1 -0
- package/dist/server/analytics.d.ts +47 -0
- package/dist/server/analytics.d.ts.map +1 -0
- package/dist/server/analytics.js +327 -0
- package/dist/server/analytics.js.map +1 -0
- package/dist/server/app.d.ts +249 -0
- package/dist/server/app.d.ts.map +1 -0
- package/dist/server/app.js +1332 -0
- package/dist/server/app.js.map +1 -0
- package/dist/server/context.d.ts +12 -0
- package/dist/server/context.d.ts.map +1 -0
- package/dist/server/context.js +52 -0
- package/dist/server/context.js.map +1 -0
- package/dist/server/hono.d.ts +54 -0
- package/dist/server/hono.d.ts.map +1 -0
- package/dist/server/hono.js +423 -0
- package/dist/server/hono.js.map +1 -0
- package/dist/server/inspector.d.ts +21 -0
- package/dist/server/inspector.d.ts.map +1 -0
- package/dist/server/inspector.js +834 -0
- package/dist/server/inspector.js.map +1 -0
- package/dist/server/mcp.d.ts +41 -0
- package/dist/server/mcp.d.ts.map +1 -0
- package/dist/server/mcp.js +425 -0
- package/dist/server/mcp.js.map +1 -0
- package/dist/transport/http.d.ts +14 -0
- package/dist/transport/http.d.ts.map +1 -0
- package/dist/transport/http.js +48 -0
- package/dist/transport/http.js.map +1 -0
- package/dist/transport/proxy.d.ts +12 -0
- package/dist/transport/proxy.d.ts.map +1 -0
- package/dist/transport/proxy.js +115 -0
- package/dist/transport/proxy.js.map +1 -0
- package/dist/types.d.ts +602 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/browser.d.ts +6 -0
- package/dist/utils/browser.d.ts.map +1 -0
- package/dist/utils/browser.js +39 -0
- package/dist/utils/browser.js.map +1 -0
- package/dist/utils/cache.d.ts +43 -0
- package/dist/utils/cache.d.ts.map +1 -0
- package/dist/utils/cache.js +126 -0
- package/dist/utils/cache.js.map +1 -0
- package/dist/utils/coercion.d.ts +38 -0
- package/dist/utils/coercion.d.ts.map +1 -0
- package/dist/utils/coercion.js +175 -0
- package/dist/utils/coercion.js.map +1 -0
- package/dist/utils/completion.d.ts +30 -0
- package/dist/utils/completion.d.ts.map +1 -0
- package/dist/utils/completion.js +79 -0
- package/dist/utils/completion.js.map +1 -0
- package/dist/utils/media.d.ts +65 -0
- package/dist/utils/media.d.ts.map +1 -0
- package/dist/utils/media.js +305 -0
- package/dist/utils/media.js.map +1 -0
- package/dist/utils/middleware.d.ts +48 -0
- package/dist/utils/middleware.d.ts.map +1 -0
- package/dist/utils/middleware.js +133 -0
- package/dist/utils/middleware.js.map +1 -0
- package/dist/utils/openapi.d.ts +102 -0
- package/dist/utils/openapi.d.ts.map +1 -0
- package/dist/utils/openapi.js +368 -0
- package/dist/utils/openapi.js.map +1 -0
- package/dist/utils/progress.d.ts +26 -0
- package/dist/utils/progress.d.ts.map +1 -0
- package/dist/utils/progress.js +91 -0
- package/dist/utils/progress.js.map +1 -0
- package/dist/utils/queue.d.ts +51 -0
- package/dist/utils/queue.d.ts.map +1 -0
- package/dist/utils/queue.js +136 -0
- package/dist/utils/queue.js.map +1 -0
- package/dist/utils/retry.d.ts +26 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +125 -0
- package/dist/utils/retry.js.map +1 -0
- package/dist/utils/roots.d.ts +21 -0
- package/dist/utils/roots.d.ts.map +1 -0
- package/dist/utils/roots.js +74 -0
- package/dist/utils/roots.js.map +1 -0
- package/dist/utils/sampling.d.ts +129 -0
- package/dist/utils/sampling.d.ts.map +1 -0
- package/dist/utils/sampling.js +177 -0
- package/dist/utils/sampling.js.map +1 -0
- package/dist/utils/security.d.ts +35 -0
- package/dist/utils/security.d.ts.map +1 -0
- package/dist/utils/security.js +113 -0
- package/dist/utils/security.js.map +1 -0
- package/dist/utils/validation.d.ts +52 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +176 -0
- package/dist/utils/validation.js.map +1 -0
- package/package.json +61 -0
|
@@ -0,0 +1,834 @@
|
|
|
1
|
+
import { resolveCompletion } from '../utils/completion.js';
|
|
2
|
+
import { normalizeResourceResult } from '../utils/media.js';
|
|
3
|
+
export function createInspectorHtml(serverName, version) {
|
|
4
|
+
return `<!DOCTYPE html>
|
|
5
|
+
<html lang="en">
|
|
6
|
+
<head>
|
|
7
|
+
<meta charset="UTF-8">
|
|
8
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
9
|
+
<title>${serverName} — mcponce Inspector</title>
|
|
10
|
+
<style>
|
|
11
|
+
:root {
|
|
12
|
+
--bg: #0b0f19;
|
|
13
|
+
--surface: #111827;
|
|
14
|
+
--surface-hover: #1f2937;
|
|
15
|
+
--surface-active: #283548;
|
|
16
|
+
--border: #1f293d;
|
|
17
|
+
--border-focus: #4f46e5;
|
|
18
|
+
--text: #f9fafb;
|
|
19
|
+
--text-muted: #9ca3af;
|
|
20
|
+
--text-dim: #6b7280;
|
|
21
|
+
--primary: #6366f1;
|
|
22
|
+
--primary-hover: #4f46e5;
|
|
23
|
+
--primary-glow: rgba(99, 102, 241, 0.25);
|
|
24
|
+
--success: #10b981;
|
|
25
|
+
--success-bg: rgba(16, 185, 129, 0.12);
|
|
26
|
+
--warning: #f59e0b;
|
|
27
|
+
--warning-bg: rgba(245, 158, 11, 0.12);
|
|
28
|
+
--error: #ef4444;
|
|
29
|
+
--error-bg: rgba(239, 68, 68, 0.12);
|
|
30
|
+
--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
31
|
+
--font-sans: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
|
|
32
|
+
}
|
|
33
|
+
* { box-sizing: border-box; margin: 0; padding: 0; }
|
|
34
|
+
body {
|
|
35
|
+
font-family: var(--font-sans);
|
|
36
|
+
background: var(--bg);
|
|
37
|
+
color: var(--text);
|
|
38
|
+
line-height: 1.5;
|
|
39
|
+
height: 100vh;
|
|
40
|
+
overflow: hidden;
|
|
41
|
+
display: flex;
|
|
42
|
+
flex-direction: column;
|
|
43
|
+
}
|
|
44
|
+
header {
|
|
45
|
+
background: var(--surface);
|
|
46
|
+
border-bottom: 1px solid var(--border);
|
|
47
|
+
padding: 0.75rem 1.25rem;
|
|
48
|
+
display: flex;
|
|
49
|
+
align-items: center;
|
|
50
|
+
justify-content: space-between;
|
|
51
|
+
flex-shrink: 0;
|
|
52
|
+
}
|
|
53
|
+
.brand {
|
|
54
|
+
display: flex;
|
|
55
|
+
align-items: center;
|
|
56
|
+
gap: 0.75rem;
|
|
57
|
+
}
|
|
58
|
+
.logo {
|
|
59
|
+
background: linear-gradient(135deg, #6366f1, #a855f7);
|
|
60
|
+
color: white;
|
|
61
|
+
font-weight: 800;
|
|
62
|
+
font-size: 0.85rem;
|
|
63
|
+
padding: 0.25rem 0.6rem;
|
|
64
|
+
border-radius: 6px;
|
|
65
|
+
letter-spacing: -0.02em;
|
|
66
|
+
}
|
|
67
|
+
.server-name {
|
|
68
|
+
font-weight: 700;
|
|
69
|
+
font-size: 1.05rem;
|
|
70
|
+
letter-spacing: -0.01em;
|
|
71
|
+
}
|
|
72
|
+
.badge {
|
|
73
|
+
font-size: 0.72rem;
|
|
74
|
+
padding: 0.15rem 0.5rem;
|
|
75
|
+
border-radius: 9999px;
|
|
76
|
+
font-weight: 600;
|
|
77
|
+
text-transform: uppercase;
|
|
78
|
+
letter-spacing: 0.04em;
|
|
79
|
+
}
|
|
80
|
+
.badge-status {
|
|
81
|
+
background: var(--success-bg);
|
|
82
|
+
color: var(--success);
|
|
83
|
+
display: inline-flex;
|
|
84
|
+
align-items: center;
|
|
85
|
+
gap: 0.35rem;
|
|
86
|
+
}
|
|
87
|
+
.badge-status::before {
|
|
88
|
+
content: '';
|
|
89
|
+
width: 6px;
|
|
90
|
+
height: 6px;
|
|
91
|
+
border-radius: 50%;
|
|
92
|
+
background: var(--success);
|
|
93
|
+
box-shadow: 0 0 6px var(--success);
|
|
94
|
+
}
|
|
95
|
+
.badge-version {
|
|
96
|
+
background: var(--surface-hover);
|
|
97
|
+
color: var(--text-muted);
|
|
98
|
+
}
|
|
99
|
+
.nav-links {
|
|
100
|
+
display: flex;
|
|
101
|
+
align-items: center;
|
|
102
|
+
gap: 0.75rem;
|
|
103
|
+
}
|
|
104
|
+
.nav-link {
|
|
105
|
+
color: var(--text-muted);
|
|
106
|
+
text-decoration: none;
|
|
107
|
+
font-size: 0.82rem;
|
|
108
|
+
font-weight: 500;
|
|
109
|
+
padding: 0.35rem 0.65rem;
|
|
110
|
+
border-radius: 6px;
|
|
111
|
+
border: 1px solid var(--border);
|
|
112
|
+
transition: all 0.15s;
|
|
113
|
+
}
|
|
114
|
+
.nav-link:hover {
|
|
115
|
+
background: var(--surface-hover);
|
|
116
|
+
color: var(--text);
|
|
117
|
+
border-color: var(--text-dim);
|
|
118
|
+
}
|
|
119
|
+
.container {
|
|
120
|
+
display: flex;
|
|
121
|
+
flex: 1;
|
|
122
|
+
overflow: hidden;
|
|
123
|
+
}
|
|
124
|
+
.sidebar {
|
|
125
|
+
width: 320px;
|
|
126
|
+
background: var(--surface);
|
|
127
|
+
border-right: 1px solid var(--border);
|
|
128
|
+
display: flex;
|
|
129
|
+
flex-direction: column;
|
|
130
|
+
flex-shrink: 0;
|
|
131
|
+
}
|
|
132
|
+
.search-box {
|
|
133
|
+
padding: 0.85rem;
|
|
134
|
+
border-bottom: 1px solid var(--border);
|
|
135
|
+
}
|
|
136
|
+
.search-input {
|
|
137
|
+
width: 100%;
|
|
138
|
+
background: var(--bg);
|
|
139
|
+
border: 1px solid var(--border);
|
|
140
|
+
border-radius: 6px;
|
|
141
|
+
padding: 0.5rem 0.75rem;
|
|
142
|
+
color: var(--text);
|
|
143
|
+
font-size: 0.85rem;
|
|
144
|
+
outline: none;
|
|
145
|
+
transition: border-color 0.15s;
|
|
146
|
+
}
|
|
147
|
+
.search-input:focus {
|
|
148
|
+
border-color: var(--border-focus);
|
|
149
|
+
}
|
|
150
|
+
.section-tabs {
|
|
151
|
+
display: flex;
|
|
152
|
+
border-bottom: 1px solid var(--border);
|
|
153
|
+
background: rgba(0, 0, 0, 0.15);
|
|
154
|
+
}
|
|
155
|
+
.tab-btn {
|
|
156
|
+
flex: 1;
|
|
157
|
+
padding: 0.65rem 0.25rem;
|
|
158
|
+
background: none;
|
|
159
|
+
border: none;
|
|
160
|
+
color: var(--text-muted);
|
|
161
|
+
font-size: 0.78rem;
|
|
162
|
+
font-weight: 600;
|
|
163
|
+
cursor: pointer;
|
|
164
|
+
border-bottom: 2px solid transparent;
|
|
165
|
+
transition: all 0.15s;
|
|
166
|
+
}
|
|
167
|
+
.tab-btn:hover {
|
|
168
|
+
color: var(--text);
|
|
169
|
+
}
|
|
170
|
+
.tab-btn.active {
|
|
171
|
+
color: var(--primary);
|
|
172
|
+
border-bottom-color: var(--primary);
|
|
173
|
+
background: var(--surface);
|
|
174
|
+
}
|
|
175
|
+
.item-list {
|
|
176
|
+
flex: 1;
|
|
177
|
+
overflow-y: auto;
|
|
178
|
+
padding: 0.5rem;
|
|
179
|
+
}
|
|
180
|
+
.list-item {
|
|
181
|
+
padding: 0.65rem 0.75rem;
|
|
182
|
+
border-radius: 6px;
|
|
183
|
+
cursor: pointer;
|
|
184
|
+
margin-bottom: 0.25rem;
|
|
185
|
+
border: 1px solid transparent;
|
|
186
|
+
transition: all 0.15s;
|
|
187
|
+
}
|
|
188
|
+
.list-item:hover {
|
|
189
|
+
background: var(--surface-hover);
|
|
190
|
+
}
|
|
191
|
+
.list-item.active {
|
|
192
|
+
background: var(--surface-active);
|
|
193
|
+
border-color: var(--primary);
|
|
194
|
+
}
|
|
195
|
+
.item-name {
|
|
196
|
+
font-weight: 600;
|
|
197
|
+
font-size: 0.85rem;
|
|
198
|
+
font-family: var(--font-mono);
|
|
199
|
+
display: flex;
|
|
200
|
+
align-items: center;
|
|
201
|
+
justify-content: space-between;
|
|
202
|
+
}
|
|
203
|
+
.item-desc {
|
|
204
|
+
font-size: 0.75rem;
|
|
205
|
+
color: var(--text-muted);
|
|
206
|
+
margin-top: 0.2rem;
|
|
207
|
+
white-space: nowrap;
|
|
208
|
+
overflow: hidden;
|
|
209
|
+
text-overflow: ellipsis;
|
|
210
|
+
}
|
|
211
|
+
.main {
|
|
212
|
+
flex: 1;
|
|
213
|
+
overflow-y: auto;
|
|
214
|
+
padding: 1.5rem;
|
|
215
|
+
display: flex;
|
|
216
|
+
flex-direction: column;
|
|
217
|
+
gap: 1.25rem;
|
|
218
|
+
}
|
|
219
|
+
.card {
|
|
220
|
+
background: var(--surface);
|
|
221
|
+
border: 1px solid var(--border);
|
|
222
|
+
border-radius: 8px;
|
|
223
|
+
padding: 1.25rem;
|
|
224
|
+
}
|
|
225
|
+
.card-header {
|
|
226
|
+
display: flex;
|
|
227
|
+
align-items: center;
|
|
228
|
+
justify-content: space-between;
|
|
229
|
+
margin-bottom: 0.85rem;
|
|
230
|
+
padding-bottom: 0.75rem;
|
|
231
|
+
border-bottom: 1px solid var(--border);
|
|
232
|
+
}
|
|
233
|
+
.card-title {
|
|
234
|
+
font-size: 1.15rem;
|
|
235
|
+
font-weight: 700;
|
|
236
|
+
font-family: var(--font-mono);
|
|
237
|
+
}
|
|
238
|
+
.form-group {
|
|
239
|
+
margin-bottom: 1rem;
|
|
240
|
+
}
|
|
241
|
+
.form-label {
|
|
242
|
+
display: flex;
|
|
243
|
+
align-items: center;
|
|
244
|
+
justify-content: space-between;
|
|
245
|
+
font-size: 0.8rem;
|
|
246
|
+
font-weight: 600;
|
|
247
|
+
color: var(--text);
|
|
248
|
+
margin-bottom: 0.35rem;
|
|
249
|
+
font-family: var(--font-mono);
|
|
250
|
+
}
|
|
251
|
+
.form-type {
|
|
252
|
+
font-size: 0.72rem;
|
|
253
|
+
color: var(--text-muted);
|
|
254
|
+
font-weight: normal;
|
|
255
|
+
}
|
|
256
|
+
.form-input, .form-textarea {
|
|
257
|
+
width: 100%;
|
|
258
|
+
background: var(--bg);
|
|
259
|
+
border: 1px solid var(--border);
|
|
260
|
+
border-radius: 6px;
|
|
261
|
+
padding: 0.55rem 0.75rem;
|
|
262
|
+
color: var(--text);
|
|
263
|
+
font-size: 0.85rem;
|
|
264
|
+
font-family: var(--font-mono);
|
|
265
|
+
outline: none;
|
|
266
|
+
transition: border-color 0.15s;
|
|
267
|
+
}
|
|
268
|
+
.form-input:focus, .form-textarea:focus {
|
|
269
|
+
border-color: var(--border-focus);
|
|
270
|
+
}
|
|
271
|
+
.form-textarea {
|
|
272
|
+
min-height: 80px;
|
|
273
|
+
resize: vertical;
|
|
274
|
+
}
|
|
275
|
+
.form-checkbox {
|
|
276
|
+
margin-right: 0.5rem;
|
|
277
|
+
accent-color: var(--primary);
|
|
278
|
+
}
|
|
279
|
+
.actions {
|
|
280
|
+
display: flex;
|
|
281
|
+
gap: 0.75rem;
|
|
282
|
+
margin-top: 1rem;
|
|
283
|
+
}
|
|
284
|
+
.btn {
|
|
285
|
+
padding: 0.55rem 1.1rem;
|
|
286
|
+
border-radius: 6px;
|
|
287
|
+
font-weight: 600;
|
|
288
|
+
font-size: 0.85rem;
|
|
289
|
+
cursor: pointer;
|
|
290
|
+
border: none;
|
|
291
|
+
transition: all 0.15s;
|
|
292
|
+
display: inline-flex;
|
|
293
|
+
align-items: center;
|
|
294
|
+
gap: 0.4rem;
|
|
295
|
+
}
|
|
296
|
+
.btn-primary {
|
|
297
|
+
background: var(--primary);
|
|
298
|
+
color: white;
|
|
299
|
+
box-shadow: 0 2px 8px var(--primary-glow);
|
|
300
|
+
}
|
|
301
|
+
.btn-primary:hover {
|
|
302
|
+
background: var(--primary-hover);
|
|
303
|
+
}
|
|
304
|
+
.btn-secondary {
|
|
305
|
+
background: var(--surface-hover);
|
|
306
|
+
color: var(--text);
|
|
307
|
+
border: 1px solid var(--border);
|
|
308
|
+
}
|
|
309
|
+
.btn-secondary:hover {
|
|
310
|
+
background: var(--surface-active);
|
|
311
|
+
}
|
|
312
|
+
.output-section {
|
|
313
|
+
background: var(--bg);
|
|
314
|
+
border: 1px solid var(--border);
|
|
315
|
+
border-radius: 6px;
|
|
316
|
+
padding: 1rem;
|
|
317
|
+
margin-top: 1rem;
|
|
318
|
+
}
|
|
319
|
+
.output-header {
|
|
320
|
+
display: flex;
|
|
321
|
+
align-items: center;
|
|
322
|
+
justify-content: space-between;
|
|
323
|
+
margin-bottom: 0.75rem;
|
|
324
|
+
font-size: 0.78rem;
|
|
325
|
+
color: var(--text-muted);
|
|
326
|
+
}
|
|
327
|
+
.output-pre {
|
|
328
|
+
font-family: var(--font-mono);
|
|
329
|
+
font-size: 0.82rem;
|
|
330
|
+
white-space: pre-wrap;
|
|
331
|
+
word-break: break-word;
|
|
332
|
+
color: #e2e8f0;
|
|
333
|
+
max-height: 400px;
|
|
334
|
+
overflow-y: auto;
|
|
335
|
+
}
|
|
336
|
+
.grid-stats {
|
|
337
|
+
display: grid;
|
|
338
|
+
grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
|
|
339
|
+
gap: 1rem;
|
|
340
|
+
}
|
|
341
|
+
.stat-card {
|
|
342
|
+
background: var(--bg);
|
|
343
|
+
border: 1px solid var(--border);
|
|
344
|
+
border-radius: 6px;
|
|
345
|
+
padding: 1rem;
|
|
346
|
+
}
|
|
347
|
+
.stat-value {
|
|
348
|
+
font-size: 1.5rem;
|
|
349
|
+
font-weight: 700;
|
|
350
|
+
font-family: var(--font-mono);
|
|
351
|
+
color: var(--primary);
|
|
352
|
+
margin-top: 0.25rem;
|
|
353
|
+
}
|
|
354
|
+
.stat-label {
|
|
355
|
+
font-size: 0.75rem;
|
|
356
|
+
color: var(--text-muted);
|
|
357
|
+
text-transform: uppercase;
|
|
358
|
+
letter-spacing: 0.05em;
|
|
359
|
+
}
|
|
360
|
+
.toast {
|
|
361
|
+
position: fixed;
|
|
362
|
+
bottom: 1.5rem;
|
|
363
|
+
right: 1.5rem;
|
|
364
|
+
background: var(--surface);
|
|
365
|
+
border: 1px solid var(--border);
|
|
366
|
+
padding: 0.65rem 1.25rem;
|
|
367
|
+
border-radius: 6px;
|
|
368
|
+
box-shadow: 0 4px 12px rgba(0,0,0,0.5);
|
|
369
|
+
font-size: 0.85rem;
|
|
370
|
+
color: var(--text);
|
|
371
|
+
opacity: 0;
|
|
372
|
+
transform: translateY(10px);
|
|
373
|
+
transition: all 0.2s;
|
|
374
|
+
pointer-events: none;
|
|
375
|
+
}
|
|
376
|
+
.toast.show {
|
|
377
|
+
opacity: 1;
|
|
378
|
+
transform: translateY(0);
|
|
379
|
+
}
|
|
380
|
+
</style>
|
|
381
|
+
</head>
|
|
382
|
+
<body>
|
|
383
|
+
<header>
|
|
384
|
+
<div class="brand">
|
|
385
|
+
<span class="logo">mcponce</span>
|
|
386
|
+
<span class="server-name">${serverName}</span>
|
|
387
|
+
<span class="badge badge-version">v${version}</span>
|
|
388
|
+
<span class="badge badge-status">Active</span>
|
|
389
|
+
</div>
|
|
390
|
+
<div class="nav-links">
|
|
391
|
+
<a href="/metrics" target="_blank" class="nav-link">Prometheus (/metrics)</a>
|
|
392
|
+
<a href="/analytics" target="_blank" class="nav-link">Telemetry (/analytics)</a>
|
|
393
|
+
<a href="/health" target="_blank" class="nav-link">Health (/health)</a>
|
|
394
|
+
</div>
|
|
395
|
+
</header>
|
|
396
|
+
|
|
397
|
+
<div class="container">
|
|
398
|
+
<aside class="sidebar">
|
|
399
|
+
<div class="search-box">
|
|
400
|
+
<input type="text" id="search" class="search-input" placeholder="Search tools, resources, prompts...">
|
|
401
|
+
</div>
|
|
402
|
+
<div class="section-tabs">
|
|
403
|
+
<button class="tab-btn active" onclick="switchSection('tools')">Tools (<span id="count-tools">0</span>)</button>
|
|
404
|
+
<button class="tab-btn" onclick="switchSection('resources')">Resources (<span id="count-resources">0</span>)</button>
|
|
405
|
+
<button class="tab-btn" onclick="switchSection('prompts')">Prompts (<span id="count-prompts">0</span>)</button>
|
|
406
|
+
<button class="tab-btn" onclick="switchSection('metrics')">Metrics</button>
|
|
407
|
+
</div>
|
|
408
|
+
<div id="items-list" class="item-list"></div>
|
|
409
|
+
</aside>
|
|
410
|
+
|
|
411
|
+
<main class="main" id="workspace">
|
|
412
|
+
<div class="card">
|
|
413
|
+
<div class="card-title">Select an item from the sidebar to inspect and run</div>
|
|
414
|
+
</div>
|
|
415
|
+
</main>
|
|
416
|
+
</div>
|
|
417
|
+
|
|
418
|
+
<div id="toast" class="toast">Copied to clipboard!</div>
|
|
419
|
+
|
|
420
|
+
<script>
|
|
421
|
+
let state = { tools: [], resources: [], resourceTemplates: [], prompts: [], analytics: {}, server: {} };
|
|
422
|
+
let activeSection = 'tools';
|
|
423
|
+
let activeItem = null;
|
|
424
|
+
|
|
425
|
+
async function loadState() {
|
|
426
|
+
try {
|
|
427
|
+
const res = await fetch('/inspect/api/state');
|
|
428
|
+
state = await res.json();
|
|
429
|
+
document.getElementById('count-tools').textContent = state.tools.length;
|
|
430
|
+
document.getElementById('count-resources').textContent = state.resources.length + (state.resourceTemplates || []).length;
|
|
431
|
+
document.getElementById('count-prompts').textContent = state.prompts.length;
|
|
432
|
+
renderSidebar();
|
|
433
|
+
if (state.tools.length > 0 && !activeItem) {
|
|
434
|
+
selectItem('tools', state.tools[0].name);
|
|
435
|
+
}
|
|
436
|
+
} catch (err) {
|
|
437
|
+
console.error('Failed to load inspector state:', err);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
function switchSection(section) {
|
|
442
|
+
activeSection = section;
|
|
443
|
+
document.querySelectorAll('.tab-btn').forEach((btn, idx) => {
|
|
444
|
+
btn.classList.toggle('active', ['tools', 'resources', 'prompts', 'metrics'][idx] === section);
|
|
445
|
+
});
|
|
446
|
+
renderSidebar();
|
|
447
|
+
if (section === 'metrics') {
|
|
448
|
+
renderMetricsWorkspace();
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
function renderSidebar() {
|
|
453
|
+
const list = document.getElementById('items-list');
|
|
454
|
+
list.innerHTML = '';
|
|
455
|
+
const query = document.getElementById('search').value.toLowerCase();
|
|
456
|
+
|
|
457
|
+
if (activeSection === 'tools') {
|
|
458
|
+
state.tools.filter(t => t.name.toLowerCase().includes(query) || (t.description || '').toLowerCase().includes(query)).forEach(t => {
|
|
459
|
+
const item = document.createElement('div');
|
|
460
|
+
item.className = 'list-item' + (activeItem === t.name ? ' active' : '');
|
|
461
|
+
item.onclick = () => selectItem('tools', t.name);
|
|
462
|
+
item.innerHTML = '<div class="item-name">' + t.name + '</div><div class="item-desc">' + (t.description || 'No description') + '</div>';
|
|
463
|
+
list.appendChild(item);
|
|
464
|
+
});
|
|
465
|
+
} else if (activeSection === 'resources') {
|
|
466
|
+
const allRes = [...(state.resources || []), ...(state.resourceTemplates || [])];
|
|
467
|
+
allRes.filter(r => (r.uri || r.uriTemplate || '').toLowerCase().includes(query)).forEach(r => {
|
|
468
|
+
const name = r.uri || r.uriTemplate;
|
|
469
|
+
const item = document.createElement('div');
|
|
470
|
+
item.className = 'list-item' + (activeItem === name ? ' active' : '');
|
|
471
|
+
item.onclick = () => selectItem('resources', name);
|
|
472
|
+
item.innerHTML = '<div class="item-name">' + name + '</div><div class="item-desc">' + (r.description || 'Resource') + '</div>';
|
|
473
|
+
list.appendChild(item);
|
|
474
|
+
});
|
|
475
|
+
} else if (activeSection === 'prompts') {
|
|
476
|
+
state.prompts.filter(p => p.name.toLowerCase().includes(query)).forEach(p => {
|
|
477
|
+
const item = document.createElement('div');
|
|
478
|
+
item.className = 'list-item' + (activeItem === p.name ? ' active' : '');
|
|
479
|
+
item.onclick = () => selectItem('prompts', p.name);
|
|
480
|
+
item.innerHTML = '<div class="item-name">' + p.name + '</div><div class="item-desc">' + (p.description || 'Prompt') + '</div>';
|
|
481
|
+
list.appendChild(item);
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
document.getElementById('search').addEventListener('input', renderSidebar);
|
|
487
|
+
|
|
488
|
+
function selectItem(section, name) {
|
|
489
|
+
activeItem = name;
|
|
490
|
+
renderSidebar();
|
|
491
|
+
if (section === 'tools') {
|
|
492
|
+
renderToolWorkspace(name);
|
|
493
|
+
} else if (section === 'resources') {
|
|
494
|
+
renderResourceWorkspace(name);
|
|
495
|
+
} else if (section === 'prompts') {
|
|
496
|
+
renderPromptWorkspace(name);
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
function renderToolWorkspace(name) {
|
|
501
|
+
const tool = state.tools.find(t => t.name === name);
|
|
502
|
+
if (!tool) return;
|
|
503
|
+
|
|
504
|
+
const ws = document.getElementById('workspace');
|
|
505
|
+
let propertiesHtml = '';
|
|
506
|
+
const schema = tool.inputSchema || {};
|
|
507
|
+
const props = schema.properties || {};
|
|
508
|
+
|
|
509
|
+
Object.entries(props).forEach(([propName, propDef]) => {
|
|
510
|
+
const type = propDef.type || 'string';
|
|
511
|
+
const isRequired = Array.isArray(schema.required) && schema.required.includes(propName);
|
|
512
|
+
propertiesHtml += '<div class="form-group"><label class="form-label"><span>' + propName + (isRequired ? ' *' : '') + '</span><span class="form-type">' + type + (propDef.description ? ' — ' + propDef.description : '') + '</span></label>';
|
|
513
|
+
if (type === 'boolean') {
|
|
514
|
+
propertiesHtml += '<input type="checkbox" id="field-' + propName + '" class="form-checkbox" ' + (propDef.default ? 'checked' : '') + '>';
|
|
515
|
+
} else if (type === 'number' || type === 'integer') {
|
|
516
|
+
propertiesHtml += '<input type="number" id="field-' + propName + '" class="form-input" value="' + (propDef.default !== undefined ? propDef.default : '') + '">';
|
|
517
|
+
} else if (type === 'object' || type === 'array') {
|
|
518
|
+
propertiesHtml += '<textarea id="field-' + propName + '" class="form-textarea">' + (propDef.default ? JSON.stringify(propDef.default, null, 2) : '') + '</textarea>';
|
|
519
|
+
} else {
|
|
520
|
+
propertiesHtml += '<input type="text" id="field-' + propName + '" class="form-input" value="' + (propDef.default !== undefined ? propDef.default : '') + '">';
|
|
521
|
+
}
|
|
522
|
+
propertiesHtml += '</div>';
|
|
523
|
+
});
|
|
524
|
+
|
|
525
|
+
if (!propertiesHtml) {
|
|
526
|
+
propertiesHtml = '<div style="color: var(--text-muted); font-size: 0.85rem;">This tool takes no arguments.</div>';
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
ws.innerHTML = '<div class="card"><div class="card-header"><div class="card-title">' + tool.name + '</div><div>' +
|
|
530
|
+
(tool.cache ? '<span class="badge" style="background: rgba(99,102,241,0.15); color: #818cf8;">LRU Cached</span> ' : '') +
|
|
531
|
+
(tool.sequential ? '<span class="badge" style="background: rgba(245,158,11,0.15); color: #f59e0b;">Sequential</span>' : '') +
|
|
532
|
+
'</div></div><p style="color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.25rem;">' + (tool.description || 'No description provided.') + '</p>' +
|
|
533
|
+
'<form id="tool-form" onsubmit="executeTool(event, \'' + tool.name + '\')">' + propertiesHtml +
|
|
534
|
+
'<div class="actions"><button type="submit" class="btn btn-primary">▶ Run Tool</button><button type="button" class="btn btn-secondary" onclick="renderToolWorkspace(\'' + tool.name + '\')">Reset</button></div></form>' +
|
|
535
|
+
'<div id="output-box" style="display: none;" class="output-section"><div class="output-header"><span id="output-status"></span><span id="output-meta"></span></div><pre id="output-text" class="output-pre"></pre></div></div>';
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
async function executeTool(e, name) {
|
|
539
|
+
e.preventDefault();
|
|
540
|
+
const tool = state.tools.find(t => t.name === name);
|
|
541
|
+
const props = (tool.inputSchema || {}).properties || {};
|
|
542
|
+
const args = {};
|
|
543
|
+
|
|
544
|
+
Object.entries(props).forEach(([propName, propDef]) => {
|
|
545
|
+
const el = document.getElementById('field-' + propName);
|
|
546
|
+
if (!el) return;
|
|
547
|
+
if (propDef.type === 'boolean') {
|
|
548
|
+
args[propName] = el.checked;
|
|
549
|
+
} else if (propDef.type === 'number' || propDef.type === 'integer') {
|
|
550
|
+
if (el.value !== '') args[propName] = Number(el.value);
|
|
551
|
+
} else if (propDef.type === 'object' || propDef.type === 'array') {
|
|
552
|
+
if (el.value.trim() !== '') {
|
|
553
|
+
try { args[propName] = JSON.parse(el.value); } catch { args[propName] = el.value; }
|
|
554
|
+
}
|
|
555
|
+
} else {
|
|
556
|
+
if (el.value !== '') args[propName] = el.value;
|
|
557
|
+
}
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
const outBox = document.getElementById('output-box');
|
|
561
|
+
const outStatus = document.getElementById('output-status');
|
|
562
|
+
const outMeta = document.getElementById('output-meta');
|
|
563
|
+
const outText = document.getElementById('output-text');
|
|
564
|
+
|
|
565
|
+
outBox.style.display = 'block';
|
|
566
|
+
outStatus.innerHTML = '<span style="color: var(--warning);">Running...</span>';
|
|
567
|
+
outText.textContent = 'Executing tool...';
|
|
568
|
+
|
|
569
|
+
const start = performance.now();
|
|
570
|
+
try {
|
|
571
|
+
const res = await fetch('/inspect/api/tools/' + encodeURIComponent(name), {
|
|
572
|
+
method: 'POST',
|
|
573
|
+
headers: { 'Content-Type': 'application/json' },
|
|
574
|
+
body: JSON.stringify({ args })
|
|
575
|
+
});
|
|
576
|
+
const duration = Math.round(performance.now() - start);
|
|
577
|
+
const data = await res.json();
|
|
578
|
+
|
|
579
|
+
if (data.success) {
|
|
580
|
+
outStatus.innerHTML = '<span style="color: var(--success); font-weight: bold;">✔ OK (200)</span>';
|
|
581
|
+
outMeta.textContent = duration + ' ms' + (data.cached ? ' • Cache HIT' : ' • Cache MISS');
|
|
582
|
+
outText.textContent = JSON.stringify(data.result, null, 2);
|
|
583
|
+
} else {
|
|
584
|
+
outStatus.innerHTML = '<span style="color: var(--error); font-weight: bold;">✖ Error</span>';
|
|
585
|
+
outMeta.textContent = duration + ' ms';
|
|
586
|
+
outText.textContent = data.error || 'Unknown error occurred';
|
|
587
|
+
}
|
|
588
|
+
} catch (err) {
|
|
589
|
+
outStatus.innerHTML = '<span style="color: var(--error); font-weight: bold;">✖ Network Error</span>';
|
|
590
|
+
outText.textContent = String(err);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
function renderResourceWorkspace(name) {
|
|
595
|
+
const allRes = [...(state.resources || []), ...(state.resourceTemplates || [])];
|
|
596
|
+
const res = allRes.find(r => (r.uri || r.uriTemplate) === name);
|
|
597
|
+
if (!res) return;
|
|
598
|
+
|
|
599
|
+
const ws = document.getElementById('workspace');
|
|
600
|
+
const isTemplate = !!res.uriTemplate;
|
|
601
|
+
const uriStr = res.uri || res.uriTemplate;
|
|
602
|
+
|
|
603
|
+
ws.innerHTML = '<div class="card"><div class="card-header"><div class="card-title">' + uriStr + '</div>' +
|
|
604
|
+
'<span class="badge" style="background: rgba(16,185,129,0.15); color: #10b981;">' + (isTemplate ? 'Template (RFC 6570)' : 'Static Resource') + '</span></div>' +
|
|
605
|
+
'<p style="color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.25rem;">' + (res.description || 'No description.') + '</p>' +
|
|
606
|
+
'<div class="actions"><button class="btn btn-primary" onclick="readResource(\'' + encodeURIComponent(uriStr) + '\')">Read Resource</button></div>' +
|
|
607
|
+
'<div id="res-output" style="display: none;" class="output-section"><pre id="res-text" class="output-pre"></pre></div></div>';
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
async function readResource(encodedUri) {
|
|
611
|
+
const uri = decodeURIComponent(encodedUri);
|
|
612
|
+
const outBox = document.getElementById('res-output');
|
|
613
|
+
const outText = document.getElementById('res-text');
|
|
614
|
+
outBox.style.display = 'block';
|
|
615
|
+
outText.textContent = 'Reading resource...';
|
|
616
|
+
|
|
617
|
+
try {
|
|
618
|
+
const res = await fetch('/inspect/api/resources/read', {
|
|
619
|
+
method: 'POST',
|
|
620
|
+
headers: { 'Content-Type': 'application/json' },
|
|
621
|
+
body: JSON.stringify({ uri })
|
|
622
|
+
});
|
|
623
|
+
const data = await res.json();
|
|
624
|
+
outText.textContent = JSON.stringify(data, null, 2);
|
|
625
|
+
} catch (err) {
|
|
626
|
+
outText.textContent = String(err);
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
function renderPromptWorkspace(name) {
|
|
631
|
+
const prompt = state.prompts.find(p => p.name === name);
|
|
632
|
+
if (!prompt) return;
|
|
633
|
+
const ws = document.getElementById('workspace');
|
|
634
|
+
ws.innerHTML = '<div class="card"><div class="card-header"><div class="card-title">' + prompt.name + '</div><span class="badge badge-version">Prompt</span></div>' +
|
|
635
|
+
'<p style="color: var(--text-muted); font-size: 0.9rem; margin-bottom: 1.25rem;">' + (prompt.description || 'No description.') + '</p>' +
|
|
636
|
+
'<div class="actions"><button class="btn btn-primary" onclick="getPrompt(\'' + prompt.name + '\')">Render Prompt</button></div>' +
|
|
637
|
+
'<div id="prompt-output" style="display: none;" class="output-section"><pre id="prompt-text" class="output-pre"></pre></div></div>';
|
|
638
|
+
}
|
|
639
|
+
|
|
640
|
+
async function getPrompt(name) {
|
|
641
|
+
const outBox = document.getElementById('prompt-output');
|
|
642
|
+
const outText = document.getElementById('prompt-text');
|
|
643
|
+
outBox.style.display = 'block';
|
|
644
|
+
outText.textContent = 'Fetching prompt...';
|
|
645
|
+
try {
|
|
646
|
+
const res = await fetch('/inspect/api/prompts/get', {
|
|
647
|
+
method: 'POST',
|
|
648
|
+
headers: { 'Content-Type': 'application/json' },
|
|
649
|
+
body: JSON.stringify({ name })
|
|
650
|
+
});
|
|
651
|
+
const data = await res.json();
|
|
652
|
+
outText.textContent = JSON.stringify(data, null, 2);
|
|
653
|
+
} catch (err) {
|
|
654
|
+
outText.textContent = String(err);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
function renderMetricsWorkspace() {
|
|
659
|
+
const ws = document.getElementById('workspace');
|
|
660
|
+
const a = state.analytics || {};
|
|
661
|
+
const m = state.metrics || {};
|
|
662
|
+
|
|
663
|
+
ws.innerHTML = '<div class="card"><div class="card-header"><div class="card-title">Live Server Telemetry & Metrics</div></div>' +
|
|
664
|
+
'<div class="grid-stats">' +
|
|
665
|
+
'<div class="stat-card"><div class="stat-label">Total Calls</div><div class="stat-value">' + (a.totalInvocations || 0) + '</div></div>' +
|
|
666
|
+
'<div class="stat-card"><div class="stat-label">Total Errors</div><div class="stat-value" style="color: var(--error);">' + (a.totalErrors || 0) + '</div></div>' +
|
|
667
|
+
'<div class="stat-card"><div class="stat-label">Active Sessions</div><div class="stat-value" style="color: var(--success);">' + (m.activeSessions || 0) + '</div></div>' +
|
|
668
|
+
'<div class="stat-card"><div class="stat-label">Avg Duration</div><div class="stat-value">' + (a.avgDurationMs ? Math.round(a.avgDurationMs) + 'ms' : '0ms') + '</div></div>' +
|
|
669
|
+
'</div>' +
|
|
670
|
+
'<div style="margin-top: 1.5rem;"><a href="/metrics" target="_blank" class="btn btn-secondary">Open Raw Prometheus (/metrics)</a> <a href="/analytics" target="_blank" class="btn btn-secondary">Open JSON Analytics (/analytics)</a></div></div>';
|
|
671
|
+
}
|
|
672
|
+
|
|
673
|
+
loadState();
|
|
674
|
+
</script>
|
|
675
|
+
</body>
|
|
676
|
+
</html>`;
|
|
677
|
+
}
|
|
678
|
+
export function setupInspectorRoutes(app, options) {
|
|
679
|
+
const { serverName, version, toolRegistry, resourceRegistry, promptRegistry, analytics, metrics, callTool, context } = options;
|
|
680
|
+
// 1. Web Inspector HTML UI
|
|
681
|
+
app.get('/inspect', (c) => {
|
|
682
|
+
return c.html(createInspectorHtml(serverName, version));
|
|
683
|
+
});
|
|
684
|
+
// 2. Full State for Inspector UI
|
|
685
|
+
app.get('/inspect/api/state', (c) => {
|
|
686
|
+
const tools = toolRegistry.getAll().map((t) => ({
|
|
687
|
+
name: t.name,
|
|
688
|
+
description: t.description,
|
|
689
|
+
inputSchema: t.inputSchema,
|
|
690
|
+
cache: !!t.cache,
|
|
691
|
+
sequential: t.sequential,
|
|
692
|
+
timeoutMs: t.timeoutMs
|
|
693
|
+
}));
|
|
694
|
+
const resources = resourceRegistry.getAll().map((r) => ({
|
|
695
|
+
uri: r.uri,
|
|
696
|
+
name: r.name,
|
|
697
|
+
description: r.description,
|
|
698
|
+
mimeType: r.mimeType
|
|
699
|
+
}));
|
|
700
|
+
const resourceTemplates = resourceRegistry.getAllTemplates
|
|
701
|
+
? resourceRegistry.getAllTemplates().map((t) => ({
|
|
702
|
+
uriTemplate: t.uriTemplate,
|
|
703
|
+
name: t.name,
|
|
704
|
+
description: t.description,
|
|
705
|
+
mimeType: t.mimeType
|
|
706
|
+
}))
|
|
707
|
+
: [];
|
|
708
|
+
const prompts = promptRegistry.getAll().map((p) => ({
|
|
709
|
+
name: p.name,
|
|
710
|
+
description: p.description,
|
|
711
|
+
argsSchema: p.argsSchema
|
|
712
|
+
}));
|
|
713
|
+
return c.json({
|
|
714
|
+
server: {
|
|
715
|
+
name: serverName,
|
|
716
|
+
version,
|
|
717
|
+
pid: process.pid,
|
|
718
|
+
uptime: Math.round(process.uptime())
|
|
719
|
+
},
|
|
720
|
+
tools,
|
|
721
|
+
resources,
|
|
722
|
+
resourceTemplates,
|
|
723
|
+
prompts,
|
|
724
|
+
metrics,
|
|
725
|
+
analytics: analytics.getSnapshot()
|
|
726
|
+
});
|
|
727
|
+
});
|
|
728
|
+
// 3. Execute Tool via Inspector
|
|
729
|
+
app.post('/inspect/api/tools/:name', async (c) => {
|
|
730
|
+
const name = c.req.param('name');
|
|
731
|
+
let body = {};
|
|
732
|
+
try {
|
|
733
|
+
body = await c.req.json();
|
|
734
|
+
}
|
|
735
|
+
catch { }
|
|
736
|
+
const args = body.args || {};
|
|
737
|
+
const start = performance.now();
|
|
738
|
+
try {
|
|
739
|
+
if (!callTool) {
|
|
740
|
+
return c.json({ success: false, error: 'Tool execution is not enabled on this server' }, 500);
|
|
741
|
+
}
|
|
742
|
+
const result = await callTool(name, args);
|
|
743
|
+
const durationMs = Math.round(performance.now() - start);
|
|
744
|
+
return c.json({
|
|
745
|
+
success: true,
|
|
746
|
+
durationMs,
|
|
747
|
+
result
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
catch (err) {
|
|
751
|
+
const durationMs = Math.round(performance.now() - start);
|
|
752
|
+
return c.json({
|
|
753
|
+
success: false,
|
|
754
|
+
durationMs,
|
|
755
|
+
error: err.message || String(err)
|
|
756
|
+
}, 500);
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
// 4. Read Resource via Inspector
|
|
760
|
+
app.post('/inspect/api/resources/read', async (c) => {
|
|
761
|
+
let body = {};
|
|
762
|
+
try {
|
|
763
|
+
body = await c.req.json();
|
|
764
|
+
}
|
|
765
|
+
catch { }
|
|
766
|
+
const uriStr = body.uri;
|
|
767
|
+
if (!uriStr) {
|
|
768
|
+
return c.json({ success: false, error: 'Missing uri parameter' }, 400);
|
|
769
|
+
}
|
|
770
|
+
try {
|
|
771
|
+
const url = new URL(uriStr.includes('://') ? uriStr : `custom://${uriStr}`);
|
|
772
|
+
const resource = resourceRegistry.get(uriStr);
|
|
773
|
+
if (resource) {
|
|
774
|
+
const raw = await resource.handler(url, context);
|
|
775
|
+
const result = normalizeResourceResult(raw, url, resource.mimeType);
|
|
776
|
+
return c.json({ success: true, result });
|
|
777
|
+
}
|
|
778
|
+
if (resourceRegistry.findMatchingTemplate) {
|
|
779
|
+
const match = resourceRegistry.findMatchingTemplate(uriStr);
|
|
780
|
+
if (match) {
|
|
781
|
+
const raw = await match.template.handler(url, match.params, context);
|
|
782
|
+
const result = normalizeResourceResult(raw, url, match.template.mimeType);
|
|
783
|
+
return c.json({ success: true, result });
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
return c.json({ success: false, error: `Resource not found for URI: ${uriStr}` }, 404);
|
|
787
|
+
}
|
|
788
|
+
catch (err) {
|
|
789
|
+
return c.json({ success: false, error: err.message || String(err) }, 500);
|
|
790
|
+
}
|
|
791
|
+
});
|
|
792
|
+
// 5. Get Prompt via Inspector
|
|
793
|
+
app.post('/inspect/api/prompts/get', async (c) => {
|
|
794
|
+
let body = {};
|
|
795
|
+
try {
|
|
796
|
+
body = await c.req.json();
|
|
797
|
+
}
|
|
798
|
+
catch { }
|
|
799
|
+
const name = body.name;
|
|
800
|
+
if (!name) {
|
|
801
|
+
return c.json({ success: false, error: 'Missing prompt name' }, 400);
|
|
802
|
+
}
|
|
803
|
+
const prompt = promptRegistry.get(name);
|
|
804
|
+
if (!prompt) {
|
|
805
|
+
return c.json({ success: false, error: `Prompt not found: ${name}` }, 404);
|
|
806
|
+
}
|
|
807
|
+
try {
|
|
808
|
+
const result = await prompt.handler(body.args || {}, context);
|
|
809
|
+
return c.json({ success: true, result });
|
|
810
|
+
}
|
|
811
|
+
catch (err) {
|
|
812
|
+
return c.json({ success: false, error: err.message || String(err) }, 500);
|
|
813
|
+
}
|
|
814
|
+
});
|
|
815
|
+
// 6. Autocomplete via Inspector
|
|
816
|
+
app.post('/inspect/api/complete', async (c) => {
|
|
817
|
+
let body = {};
|
|
818
|
+
try {
|
|
819
|
+
body = await c.req.json();
|
|
820
|
+
}
|
|
821
|
+
catch { }
|
|
822
|
+
const { ref, argument } = body;
|
|
823
|
+
const result = await resolveCompletion({
|
|
824
|
+
promptRegistry,
|
|
825
|
+
resourceRegistry,
|
|
826
|
+
toolRegistry,
|
|
827
|
+
ref,
|
|
828
|
+
argument,
|
|
829
|
+
context
|
|
830
|
+
});
|
|
831
|
+
return c.json(result);
|
|
832
|
+
});
|
|
833
|
+
}
|
|
834
|
+
//# sourceMappingURL=inspector.js.map
|