@mcpspec/server 1.0.0 → 1.0.1
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 +82 -0
- package/package.json +3 -3
package/README.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# @mcpspec/server
|
|
2
|
+
|
|
3
|
+
HTTP server and web UI backend for [MCPSpec](https://www.npmjs.com/package/mcpspec). Provides a REST API, WebSocket real-time events, and serves the MCPSpec web dashboard.
|
|
4
|
+
|
|
5
|
+
> **For CLI usage, install [`mcpspec`](https://www.npmjs.com/package/mcpspec) instead.** This package is for embedding the MCPSpec server in your own applications.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install @mcpspec/server
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { startServer } from '@mcpspec/server';
|
|
17
|
+
|
|
18
|
+
const server = await startServer({
|
|
19
|
+
port: 6274, // default
|
|
20
|
+
host: '127.0.0.1', // localhost-only by default
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
// server.port, server.host, server.app, server.db, server.wsHandler
|
|
24
|
+
// server.close() to shut down
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Exports
|
|
28
|
+
|
|
29
|
+
- `startServer(options?)` — Start the HTTP server with WebSocket support
|
|
30
|
+
- `createApp(options)` — Create the Hono app without starting a server (for testing/embedding)
|
|
31
|
+
- `Database` — sql.js (WASM SQLite) database for storing servers, collections, runs, and audit results
|
|
32
|
+
- `WebSocketHandler` — Real-time event broadcasting over WebSocket
|
|
33
|
+
- `UI_DIST_PATH` — Path to the bundled web UI static files
|
|
34
|
+
|
|
35
|
+
### Types
|
|
36
|
+
|
|
37
|
+
- `StartServerOptions` — `{ port?, host?, uiDistPath?, dbPath? }`
|
|
38
|
+
- `ServerInstance` — `{ port, host, app, db, wsHandler, close() }`
|
|
39
|
+
- `AppOptions` — Options for `createApp`
|
|
40
|
+
|
|
41
|
+
## REST API
|
|
42
|
+
|
|
43
|
+
| Method | Endpoint | Description |
|
|
44
|
+
|--------|----------|-------------|
|
|
45
|
+
| GET | `/api/servers` | List saved servers |
|
|
46
|
+
| POST | `/api/servers` | Save a server connection |
|
|
47
|
+
| GET | `/api/servers/:id` | Get server details |
|
|
48
|
+
| PUT | `/api/servers/:id` | Update server |
|
|
49
|
+
| DELETE | `/api/servers/:id` | Delete server |
|
|
50
|
+
| GET | `/api/collections` | List collections |
|
|
51
|
+
| POST | `/api/collections` | Save a collection |
|
|
52
|
+
| GET | `/api/collections/:id` | Get collection |
|
|
53
|
+
| PUT | `/api/collections/:id` | Update collection |
|
|
54
|
+
| DELETE | `/api/collections/:id` | Delete collection |
|
|
55
|
+
| GET | `/api/runs` | List test runs |
|
|
56
|
+
| POST | `/api/runs` | Trigger a test run |
|
|
57
|
+
| GET | `/api/runs/:id` | Get run details |
|
|
58
|
+
| POST | `/api/inspect/connect` | Start inspect session |
|
|
59
|
+
| POST | `/api/inspect/call` | Call a tool in session |
|
|
60
|
+
| POST | `/api/inspect/disconnect` | End inspect session |
|
|
61
|
+
| POST | `/api/audit` | Start security audit |
|
|
62
|
+
| POST | `/api/benchmark` | Start benchmark |
|
|
63
|
+
| POST | `/api/docs/generate` | Generate documentation |
|
|
64
|
+
| POST | `/api/score/calculate` | Calculate MCP Score |
|
|
65
|
+
|
|
66
|
+
## WebSocket
|
|
67
|
+
|
|
68
|
+
Connect to `ws://localhost:6274/ws` for real-time events.
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
// Subscribe to events
|
|
72
|
+
ws.send(JSON.stringify({ type: 'subscribe', channel: 'run:<id>' }));
|
|
73
|
+
|
|
74
|
+
// Receive events
|
|
75
|
+
// { type: 'event', channel: 'run:<id>', event: 'test-completed', data: {...} }
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Channels: `server:<id>`, `run:<id>`, `scan:<id>`, `benchmark:<id>`
|
|
79
|
+
|
|
80
|
+
## License
|
|
81
|
+
|
|
82
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mcpspec/server",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"@hono/node-server": "^1.13.0",
|
|
29
29
|
"sql.js": "^1.11.0",
|
|
30
30
|
"ws": "^8.18.0",
|
|
31
|
-
"@mcpspec/core": "1.0.
|
|
32
|
-
"@mcpspec/shared": "1.0.
|
|
31
|
+
"@mcpspec/core": "1.0.1",
|
|
32
|
+
"@mcpspec/shared": "1.0.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"@types/node": "^22.0.0",
|