@mcp-weave/webui 0.1.1 → 0.2.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 +7 -7
- package/dist/index.d.mts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +25 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +27 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -68,19 +68,19 @@ mcp-weave webui --port 3000 --title "My Dashboard"
|
|
|
68
68
|
|
|
69
69
|
```typescript
|
|
70
70
|
interface McpWebUIOptions {
|
|
71
|
-
port?: number;
|
|
72
|
-
host?: string;
|
|
73
|
-
title?: string;
|
|
74
|
-
theme?: 'light' | 'dark';
|
|
75
|
-
enableLogs?: boolean;
|
|
71
|
+
port?: number; // Default: 3000
|
|
72
|
+
host?: string; // Default: 'localhost'
|
|
73
|
+
title?: string; // Dashboard title
|
|
74
|
+
theme?: 'light' | 'dark'; // UI theme
|
|
75
|
+
enableLogs?: boolean; // Show server logs
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
class McpWebUI {
|
|
79
79
|
constructor(serverClass: any, options?: McpWebUIOptions);
|
|
80
|
-
|
|
80
|
+
|
|
81
81
|
start(): Promise<void>;
|
|
82
82
|
stop(): Promise<void>;
|
|
83
|
-
|
|
83
|
+
|
|
84
84
|
getUrl(): string;
|
|
85
85
|
}
|
|
86
86
|
```
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
|
+
import { McpAuthOptions } from '@mcp-weave/nestjs';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Web UI configuration options
|
|
@@ -14,6 +15,8 @@ interface McpWebUIOptions {
|
|
|
14
15
|
theme?: 'light' | 'dark';
|
|
15
16
|
/** Enable server logs panel */
|
|
16
17
|
enableLogs?: boolean;
|
|
18
|
+
/** Authentication options */
|
|
19
|
+
auth?: McpAuthOptions;
|
|
17
20
|
}
|
|
18
21
|
/**
|
|
19
22
|
* Server information for the dashboard
|
|
@@ -70,6 +73,7 @@ interface CallHistoryEntry {
|
|
|
70
73
|
error?: string;
|
|
71
74
|
timestamp: Date;
|
|
72
75
|
duration: number;
|
|
76
|
+
clientId?: string;
|
|
73
77
|
}
|
|
74
78
|
/**
|
|
75
79
|
* McpWebUI - Web dashboard for testing MCP servers
|
|
@@ -82,6 +86,7 @@ declare class McpWebUI extends EventEmitter {
|
|
|
82
86
|
private serverInfo;
|
|
83
87
|
private callHistory;
|
|
84
88
|
private logs;
|
|
89
|
+
private authMiddleware;
|
|
85
90
|
constructor(serverClass: new (...args: unknown[]) => unknown, options?: McpWebUIOptions);
|
|
86
91
|
/**
|
|
87
92
|
* Initialize server instance and extract metadata
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
|
+
import { McpAuthOptions } from '@mcp-weave/nestjs';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Web UI configuration options
|
|
@@ -14,6 +15,8 @@ interface McpWebUIOptions {
|
|
|
14
15
|
theme?: 'light' | 'dark';
|
|
15
16
|
/** Enable server logs panel */
|
|
16
17
|
enableLogs?: boolean;
|
|
18
|
+
/** Authentication options */
|
|
19
|
+
auth?: McpAuthOptions;
|
|
17
20
|
}
|
|
18
21
|
/**
|
|
19
22
|
* Server information for the dashboard
|
|
@@ -70,6 +73,7 @@ interface CallHistoryEntry {
|
|
|
70
73
|
error?: string;
|
|
71
74
|
timestamp: Date;
|
|
72
75
|
duration: number;
|
|
76
|
+
clientId?: string;
|
|
73
77
|
}
|
|
74
78
|
/**
|
|
75
79
|
* McpWebUI - Web dashboard for testing MCP servers
|
|
@@ -82,6 +86,7 @@ declare class McpWebUI extends EventEmitter {
|
|
|
82
86
|
private serverInfo;
|
|
83
87
|
private callHistory;
|
|
84
88
|
private logs;
|
|
89
|
+
private authMiddleware;
|
|
85
90
|
constructor(serverClass: new (...args: unknown[]) => unknown, options?: McpWebUIOptions);
|
|
86
91
|
/**
|
|
87
92
|
* Initialize server instance and extract metadata
|
package/dist/index.js
CHANGED
|
@@ -1139,6 +1139,7 @@ var McpWebUI = class extends import_events.EventEmitter {
|
|
|
1139
1139
|
serverInfo = null;
|
|
1140
1140
|
callHistory = [];
|
|
1141
1141
|
logs = [];
|
|
1142
|
+
authMiddleware;
|
|
1142
1143
|
constructor(serverClass, options = {}) {
|
|
1143
1144
|
super();
|
|
1144
1145
|
if (!(0, import_nestjs.isMcpServer)(serverClass)) {
|
|
@@ -1150,8 +1151,10 @@ var McpWebUI = class extends import_events.EventEmitter {
|
|
|
1150
1151
|
host: options.host ?? "localhost",
|
|
1151
1152
|
title: options.title ?? "MCP Server Dashboard",
|
|
1152
1153
|
theme: options.theme ?? "dark",
|
|
1153
|
-
enableLogs: options.enableLogs ?? true
|
|
1154
|
+
enableLogs: options.enableLogs ?? true,
|
|
1155
|
+
auth: options.auth
|
|
1154
1156
|
};
|
|
1157
|
+
this.authMiddleware = (0, import_nestjs.createAuthMiddleware)(options.auth);
|
|
1155
1158
|
}
|
|
1156
1159
|
/**
|
|
1157
1160
|
* Initialize server instance and extract metadata
|
|
@@ -1256,12 +1259,12 @@ var McpWebUI = class extends import_events.EventEmitter {
|
|
|
1256
1259
|
/**
|
|
1257
1260
|
* Handle HTTP requests
|
|
1258
1261
|
*/
|
|
1259
|
-
handleRequest(req, res) {
|
|
1262
|
+
async handleRequest(req, res) {
|
|
1260
1263
|
const parsedUrl = url.parse(req.url ?? "/", true);
|
|
1261
1264
|
const pathname = parsedUrl.pathname ?? "/";
|
|
1262
1265
|
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
1263
1266
|
res.setHeader("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
|
|
1264
|
-
res.setHeader("Access-Control-Allow-Headers", "Content-Type");
|
|
1267
|
+
res.setHeader("Access-Control-Allow-Headers", "Content-Type, Authorization, X-Api-Key");
|
|
1265
1268
|
if (req.method === "OPTIONS") {
|
|
1266
1269
|
res.writeHead(200);
|
|
1267
1270
|
res.end();
|
|
@@ -1269,7 +1272,19 @@ var McpWebUI = class extends import_events.EventEmitter {
|
|
|
1269
1272
|
}
|
|
1270
1273
|
if (pathname === "/" && req.method === "GET") {
|
|
1271
1274
|
this.serveDashboard(res);
|
|
1272
|
-
|
|
1275
|
+
return;
|
|
1276
|
+
}
|
|
1277
|
+
if (pathname.startsWith("/api/")) {
|
|
1278
|
+
const authResult = await this.authMiddleware(req, res);
|
|
1279
|
+
if (!authResult) return;
|
|
1280
|
+
if (this.options.auth?.enabled) {
|
|
1281
|
+
this.log(
|
|
1282
|
+
`[${authResult.requestId}] ${authResult.auth.clientName ?? authResult.auth.clientId} - ${req.method} ${pathname}`
|
|
1283
|
+
);
|
|
1284
|
+
}
|
|
1285
|
+
res.setHeader("X-Request-Id", authResult.requestId);
|
|
1286
|
+
}
|
|
1287
|
+
if (pathname === "/api/info" && req.method === "GET") {
|
|
1273
1288
|
this.serveServerInfo(res);
|
|
1274
1289
|
} else if (pathname === "/api/tools" && req.method === "GET") {
|
|
1275
1290
|
this.serveTools(res);
|
|
@@ -1305,7 +1320,12 @@ var McpWebUI = class extends import_events.EventEmitter {
|
|
|
1305
1320
|
*/
|
|
1306
1321
|
serveServerInfo(res) {
|
|
1307
1322
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
1308
|
-
res.end(
|
|
1323
|
+
res.end(
|
|
1324
|
+
JSON.stringify({
|
|
1325
|
+
...this.serverInfo,
|
|
1326
|
+
authEnabled: this.options.auth?.enabled ?? false
|
|
1327
|
+
})
|
|
1328
|
+
);
|
|
1309
1329
|
}
|
|
1310
1330
|
/**
|
|
1311
1331
|
* Serve tools list
|