@loop_ouroboros/mcp-hub-lite 1.2.2 → 1.2.4
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/CHANGELOG.md +552 -380
- package/dist/client/assets/{HomeView-V1fKvWQ8.js → HomeView-BnO4yIT9.js} +1 -1
- package/dist/client/assets/{ResourceDetailView-DHGHssrh.js → ResourceDetailView-BGBtmsyc.js} +1 -1
- package/dist/client/assets/{ResourcesView-B1bvkmQD.js → ResourcesView-B5Xg0ynh.js} +1 -1
- package/dist/client/assets/{ServerDashboard-CZCByd7y.js → ServerDashboard-DYAVrrUk.js} +1 -1
- package/dist/client/assets/{ServerDetail-CI5UD8gj.js → ServerDetail-q94ZFfjL.js} +1 -1
- package/dist/client/assets/ServerListView-C7kcd4GC.js +36 -0
- package/dist/client/assets/{ServerListView-B-bPljsO.css → ServerListView-DshgDGSc.css} +1 -1
- package/dist/client/assets/{SettingsView-C-ae0-zz.js → SettingsView-BM6P5yrT.js} +1 -1
- package/dist/client/assets/{ToolCallDialog-BudOyGvS.js → ToolCallDialog-BoAGxlB5.js} +1 -1
- package/dist/client/assets/{ToolsView-CbQkgTAu.js → ToolsView-lqFhr7Bk.js} +1 -1
- package/dist/client/assets/{_baseClone-e9R6V78L.js → _baseClone-kbJbcBJT.js} +1 -1
- package/dist/client/assets/{el-form-item-Dyx5MiWB.js → el-form-item-iQ0G8e97.js} +1 -1
- package/dist/client/assets/{el-input-CL9HPfdW.js → el-input-DkJq57wP.js} +1 -1
- package/dist/client/assets/{el-loading-2TW6JdfY.js → el-loading-C3v6a9xV.js} +1 -1
- package/dist/client/assets/{el-overlay-B5ZGCmXY.js → el-overlay-Cy5xg31y.js} +1 -1
- package/dist/client/assets/{el-radio-group-Cr2ScjjJ.js → el-radio-group-C9QUL5mm.js} +1 -1
- package/dist/client/assets/{el-skeleton-item-CdAfEgVR.js → el-skeleton-item-Bbmpc0Xz.js} +1 -1
- package/dist/client/assets/{el-switch-DnN1s0Wb.js → el-switch-KpjV93lm.js} +1 -1
- package/dist/client/assets/{el-tab-pane-BebZh0XF.js → el-tab-pane-YsYuBcem.js} +1 -1
- package/dist/client/assets/{el-table-column-CV2zp3yI.js → el-table-column-fofd_2n-.js} +1 -1
- package/dist/client/assets/{index-Ci5n5dA9.js → index-5tzIwwtS.js} +1 -1
- package/dist/client/assets/{index-DTZ9o3XO.js → index-MqHvQjDP.js} +2 -2
- package/dist/client/assets/{omit-DlmW8Yd6.js → omit-CB4hTeTH.js} +1 -1
- package/dist/client/assets/{raf-CeCd08aN.js → raf-MWAHt9ca.js} +1 -1
- package/dist/client/index.html +1 -1
- package/dist/server/src/cli/commands/install.d.ts +25 -0
- package/dist/server/src/cli/commands/install.d.ts.map +1 -0
- package/dist/server/src/cli/commands/install.js +274 -0
- package/dist/server/src/cli/commands/use-guide.d.ts +11 -0
- package/dist/server/src/cli/commands/use-guide.d.ts.map +1 -0
- package/dist/server/src/cli/commands/use-guide.js +175 -0
- package/dist/server/src/cli/index.d.ts.map +1 -1
- package/dist/server/src/cli/index.js +4 -0
- package/dist/server/src/cli/server.d.ts +71 -0
- package/dist/server/src/cli/server.d.ts.map +1 -1
- package/dist/server/src/cli/server.js +138 -0
- package/dist/server/src/cli/use-guide.md +156 -0
- package/dist/server/src/services/gateway/request-handlers/initialize-handler.d.ts.map +1 -1
- package/dist/server/src/services/gateway/request-handlers/initialize-handler.js +12 -5
- package/dist/server/src/services/hub-tools.service.d.ts.map +1 -1
- package/dist/server/src/services/hub-tools.service.js +4 -0
- package/package.json +1 -5
- package/dist/client/assets/ServerListView-D8qv-xYg.js +0 -36
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aa as c,bw as f,bs as s,bx as a,bq as l,by as g,ah as b}from"./index-
|
|
1
|
+
import{aa as c,bw as f,bs as s,bx as a,bq as l,by as g,ah as b}from"./index-MqHvQjDP.js";import{g as v,c as O,f as _,e as p}from"./_baseClone-kbJbcBJT.js";var y="[object Object]",P=Function.prototype,L=Object.prototype,u=P.toString,w=L.hasOwnProperty,h=u.call(Object);function j(e){if(!c(e)||f(e)!=y)return!1;var r=v(e);if(r===null)return!0;var t=w.call(r,"constructor")&&r.constructor;return typeof t=="function"&&t instanceof t&&u.call(t)==h}function m(e,r,t){var o=-1,n=e.length;r<0&&(r=-r>n?0:n+r),t=t>n?n:t,t<0&&(t+=n),n=r>t?0:t-r>>>0,r>>>=0;for(var i=Array(n);++o<n;)i[o]=e[o+r];return i}function C(e){var r=e==null?0:e.length;return r?e[r-1]:void 0}function A(e,r){return r.length<2?e:s(e,m(r,0,-1))}var S=Object.prototype,E=S.hasOwnProperty;function F(e,r){r=a(r,e);var t=-1,o=r.length;if(!o)return!0;for(;++t<o;){var n=l(r[t]);if(n==="__proto__"&&!E.call(e,"__proto__")||(n==="constructor"||n==="prototype")&&t<o-1)return!1}var i=A(e,r);return i==null||delete i[l(C(r))]}function G(e){return j(e)?void 0:e}var x=1,T=2,N=4,M=g(function(e,r){var t={};if(e==null)return t;var o=!1;r=b(r,function(i){return i=a(i,e),o||(o=i.length>1),i}),O(e,_(e),t),o&&(t=p(t,x|T|N,G));for(var n=r.length;n--;)F(t,r[n]);return t});export{j as i,M as o};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as o}from"./index-
|
|
1
|
+
import{D as o}from"./index-MqHvQjDP.js";const e=i=>o?window.requestAnimationFrame(i):setTimeout(i,16),r=i=>o?window.cancelAnimationFrame(i):clearTimeout(i);export{r as c,e as r};
|
package/dist/client/index.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" href="/favicon.ico" />
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>MCP Server Manager</title>
|
|
8
|
-
<script type="module" crossorigin src="/assets/index-
|
|
8
|
+
<script type="module" crossorigin src="/assets/index-MqHvQjDP.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/assets/vue-vendor-CbgVSHIh.js">
|
|
10
10
|
<link rel="stylesheet" crossorigin href="/assets/index-DpH6ZSbs.css">
|
|
11
11
|
</head>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* CLI command for installing a new MCP server to MCP Hub Lite.
|
|
4
|
+
*
|
|
5
|
+
* This command provides two modes of operation:
|
|
6
|
+
*
|
|
7
|
+
* 1. **Parametric mode** (default): Specify server properties via individual options
|
|
8
|
+
* 2. **JSON mode** (--json): Pass a complete server configuration as JSON
|
|
9
|
+
*
|
|
10
|
+
* ## Parametric Mode
|
|
11
|
+
*
|
|
12
|
+
* ```
|
|
13
|
+
* mcp-hub-lite install <name> <commandOrUrl> [args...]
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* ## JSON Mode
|
|
17
|
+
*
|
|
18
|
+
* ```
|
|
19
|
+
* mcp-hub-lite install --json '{"name":"github-mcp","type":"stdio","command":"npx github-mcp"}'
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @returns {Command} The configured install command instance for registration with Commander.js
|
|
23
|
+
*/
|
|
24
|
+
export declare const installCommand: Command;
|
|
25
|
+
//# sourceMappingURL=install.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"install.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/install.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAqBpC;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,cAAc,SA6EvB,CAAC"}
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { getServerStatus, installServer } from '../server.js';
|
|
3
|
+
import { parseEnvVars, parseHeaders } from '../server.js';
|
|
4
|
+
/**
|
|
5
|
+
* CLI command for installing a new MCP server to MCP Hub Lite.
|
|
6
|
+
*
|
|
7
|
+
* This command provides two modes of operation:
|
|
8
|
+
*
|
|
9
|
+
* 1. **Parametric mode** (default): Specify server properties via individual options
|
|
10
|
+
* 2. **JSON mode** (--json): Pass a complete server configuration as JSON
|
|
11
|
+
*
|
|
12
|
+
* ## Parametric Mode
|
|
13
|
+
*
|
|
14
|
+
* ```
|
|
15
|
+
* mcp-hub-lite install <name> <commandOrUrl> [args...]
|
|
16
|
+
* ```
|
|
17
|
+
*
|
|
18
|
+
* ## JSON Mode
|
|
19
|
+
*
|
|
20
|
+
* ```
|
|
21
|
+
* mcp-hub-lite install --json '{"name":"github-mcp","type":"stdio","command":"npx github-mcp"}'
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @returns {Command} The configured install command instance for registration with Commander.js
|
|
25
|
+
*/
|
|
26
|
+
export const installCommand = new Command('install')
|
|
27
|
+
.description('Add a new MCP server to MCP Hub Lite')
|
|
28
|
+
.argument('[name]', 'Server name (required in parametric mode)')
|
|
29
|
+
.argument('[commandOrUrl]', 'Command (stdio) or URL (sse/streamable-http)')
|
|
30
|
+
.argument('[args...]', 'Command arguments (stdio only)')
|
|
31
|
+
.option('-j, --json <config>', 'Server configuration as JSON')
|
|
32
|
+
.option('-t, --transport <type>', 'Transport type (stdio, sse, streamable-http)', 'stdio')
|
|
33
|
+
.option('-e, --env <env...>', 'Environment variables (KEY=VALUE)')
|
|
34
|
+
.option('-H, --header <header...>', 'HTTP headers (Header-Key: Value)')
|
|
35
|
+
.option('--timeout <seconds>', 'Timeout in seconds', parseInt, 60)
|
|
36
|
+
.option('--strategy <strategy>', 'Instance selection strategy (random, round-robin, tag-match-unique)', 'random')
|
|
37
|
+
.option('-a, --auto-start', 'Auto-start the server', true)
|
|
38
|
+
.option('--no-auto-start', 'Disable auto-start')
|
|
39
|
+
.option('-d, --description <description>', 'Server description')
|
|
40
|
+
.addHelpText('after', `
|
|
41
|
+
|
|
42
|
+
Modes:
|
|
43
|
+
This command supports two modes - parametric (default) and JSON.
|
|
44
|
+
|
|
45
|
+
# Parametric mode (individual options):
|
|
46
|
+
mcp-hub-lite install github-mcp "npx github-mcp" --env API_KEY=xxx
|
|
47
|
+
|
|
48
|
+
# JSON mode (complete config):
|
|
49
|
+
mcp-hub-lite install --json '{"name":"github-mcp","type":"stdio","command":"npx github-mcp","env":{"API_KEY":"xxx"}}'
|
|
50
|
+
|
|
51
|
+
JSON config fields:
|
|
52
|
+
name (required) - Server name
|
|
53
|
+
type - Transport type: stdio, sse, streamable-http (default: stdio)
|
|
54
|
+
command - Command for stdio transport
|
|
55
|
+
url - URL for sse/streamable-http transport
|
|
56
|
+
args - Command arguments (stdio)
|
|
57
|
+
env - Environment variables object
|
|
58
|
+
headers - HTTP headers object
|
|
59
|
+
timeout - Timeout in seconds (default: 60)
|
|
60
|
+
enabled - Auto-start enabled (default: true)
|
|
61
|
+
description - Server description
|
|
62
|
+
instanceSelectionStrategy - random, round-robin, tag-match-unique (default: random)
|
|
63
|
+
|
|
64
|
+
Examples:
|
|
65
|
+
# Parametric mode
|
|
66
|
+
mcp-hub-lite install github-mcp "npx github-mcp" --env API_KEY=xxx
|
|
67
|
+
mcp-hub-lite install api-server https://api.example.com/mcp -t streamable-http -H "Authorization: Bearer xxx"
|
|
68
|
+
|
|
69
|
+
# JSON mode
|
|
70
|
+
mcp-hub-lite install --json '{"name":"github-mcp","type":"stdio","command":"npx github-mcp","env":{"API_KEY":"xxx"}}'
|
|
71
|
+
mcp-hub-lite install --json '{"name":"api-server","type":"streamable-http","url":"https://api.example.com/mcp","headers":{"Authorization":"Bearer xxx"}}'
|
|
72
|
+
`)
|
|
73
|
+
.action(async (name, commandOrUrl, args, options) => {
|
|
74
|
+
try {
|
|
75
|
+
// Check if server is running and get connection info
|
|
76
|
+
const status = await getServerStatus();
|
|
77
|
+
if (!status.running) {
|
|
78
|
+
console.error('Error: MCP Hub Lite server is not running.');
|
|
79
|
+
console.error('Start the server with: mcp-hub-lite start');
|
|
80
|
+
process.exit(1);
|
|
81
|
+
}
|
|
82
|
+
// JSON mode
|
|
83
|
+
if (options.json) {
|
|
84
|
+
await handleJsonMode(options.json, status.host, status.port);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
// Parametric mode
|
|
88
|
+
await handleParametricMode(name, commandOrUrl, args, options, status.host, status.port);
|
|
89
|
+
}
|
|
90
|
+
catch (error) {
|
|
91
|
+
console.error(`Error: ${error instanceof Error ? error.message : String(error)}`);
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
/**
|
|
96
|
+
* Handles JSON mode - installs server from complete JSON config
|
|
97
|
+
*/
|
|
98
|
+
async function handleJsonMode(jsonConfig, host, port) {
|
|
99
|
+
let config;
|
|
100
|
+
// Parse JSON
|
|
101
|
+
try {
|
|
102
|
+
config = JSON.parse(jsonConfig);
|
|
103
|
+
}
|
|
104
|
+
catch {
|
|
105
|
+
console.error('Error: Invalid JSON format in --json option');
|
|
106
|
+
process.exit(1);
|
|
107
|
+
}
|
|
108
|
+
// Validate required fields
|
|
109
|
+
if (!config.name) {
|
|
110
|
+
console.error('Error: "name" field is required in JSON config');
|
|
111
|
+
process.exit(1);
|
|
112
|
+
}
|
|
113
|
+
// Validate transport type
|
|
114
|
+
const transport = config.type || 'stdio';
|
|
115
|
+
if (!['stdio', 'sse', 'streamable-http'].includes(transport)) {
|
|
116
|
+
console.error(`Error: Invalid transport type "${config.type}"`);
|
|
117
|
+
console.error('Valid types: stdio, sse, streamable-http');
|
|
118
|
+
process.exit(1);
|
|
119
|
+
}
|
|
120
|
+
// Validate command/url based on transport
|
|
121
|
+
const isHttpTransport = transport !== 'stdio';
|
|
122
|
+
if (isHttpTransport && !config.url) {
|
|
123
|
+
console.error(`Error: "url" field is required for transport type "${transport}"`);
|
|
124
|
+
process.exit(1);
|
|
125
|
+
}
|
|
126
|
+
if (!isHttpTransport && !config.command) {
|
|
127
|
+
console.error(`Error: "command" field is required for transport type "${transport}"`);
|
|
128
|
+
process.exit(1);
|
|
129
|
+
}
|
|
130
|
+
// Validate URL format for HTTP transports
|
|
131
|
+
if (isHttpTransport && config.url) {
|
|
132
|
+
try {
|
|
133
|
+
new URL(config.url);
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
console.error(`Error: Invalid URL "${config.url}"`);
|
|
137
|
+
process.exit(1);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
// Build install options
|
|
141
|
+
const installOptions = {
|
|
142
|
+
name: config.name,
|
|
143
|
+
...(isHttpTransport
|
|
144
|
+
? { url: config.url }
|
|
145
|
+
: { command: config.command, args: config.args || [] }),
|
|
146
|
+
transport: transport,
|
|
147
|
+
env: config.env || {},
|
|
148
|
+
headers: config.headers || {},
|
|
149
|
+
timeout: config.timeout || 60,
|
|
150
|
+
autoStart: config.enabled !== false,
|
|
151
|
+
instanceSelectionStrategy: config.instanceSelectionStrategy || 'random',
|
|
152
|
+
description: config.description
|
|
153
|
+
};
|
|
154
|
+
// Install the server
|
|
155
|
+
await installServer(installOptions, host, port);
|
|
156
|
+
console.log(`Successfully installed server: ${config.name}`);
|
|
157
|
+
console.log(` Type: ${transport}`);
|
|
158
|
+
if (isHttpTransport) {
|
|
159
|
+
console.log(` URL: ${config.url}`);
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
console.log(` Command: ${config.command}`);
|
|
163
|
+
}
|
|
164
|
+
if (Object.keys(installOptions.env).length > 0) {
|
|
165
|
+
console.log(` Env: ${JSON.stringify(installOptions.env)}`);
|
|
166
|
+
}
|
|
167
|
+
if (Object.keys(installOptions.headers).length > 0) {
|
|
168
|
+
console.log(` Headers: ${JSON.stringify(installOptions.headers)}`);
|
|
169
|
+
}
|
|
170
|
+
if (installOptions.instanceSelectionStrategy !== 'random') {
|
|
171
|
+
console.log(` Strategy: ${installOptions.instanceSelectionStrategy}`);
|
|
172
|
+
}
|
|
173
|
+
if (config.description) {
|
|
174
|
+
console.log(` Description: ${config.description}`);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Handles parametric mode - installs server from individual options
|
|
179
|
+
*/
|
|
180
|
+
async function handleParametricMode(name, commandOrUrl, args, options, host, port) {
|
|
181
|
+
// Validate required positional arguments
|
|
182
|
+
if (!name) {
|
|
183
|
+
console.error('Error: Server name is required in parametric mode');
|
|
184
|
+
console.error('Or use --json mode for complete config: mcp-hub-lite install --json \'{"name":"..."}\'');
|
|
185
|
+
process.exit(1);
|
|
186
|
+
}
|
|
187
|
+
if (!commandOrUrl) {
|
|
188
|
+
console.error('Error: Command or URL is required in parametric mode');
|
|
189
|
+
console.error('Or use --json mode for complete config: mcp-hub-lite install --json \'{"name":"..."}\'');
|
|
190
|
+
process.exit(1);
|
|
191
|
+
}
|
|
192
|
+
// Determine transport type
|
|
193
|
+
const transportLower = options.transport.toLowerCase();
|
|
194
|
+
if (!['stdio', 'sse', 'streamable-http'].includes(transportLower)) {
|
|
195
|
+
console.error(`Error: Invalid transport type "${options.transport}"`);
|
|
196
|
+
console.error('Valid types: stdio, sse, streamable-http');
|
|
197
|
+
process.exit(1);
|
|
198
|
+
}
|
|
199
|
+
// Parse environment variables
|
|
200
|
+
let env = {};
|
|
201
|
+
if (options.env && options.env.length > 0) {
|
|
202
|
+
try {
|
|
203
|
+
env = parseEnvVars(options.env);
|
|
204
|
+
}
|
|
205
|
+
catch (error) {
|
|
206
|
+
console.error(`Error: Invalid env format - ${error instanceof Error ? error.message : String(error)}`);
|
|
207
|
+
process.exit(1);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
// Parse HTTP headers
|
|
211
|
+
let headers = {};
|
|
212
|
+
if (options.header && options.header.length > 0) {
|
|
213
|
+
try {
|
|
214
|
+
headers = parseHeaders(options.header);
|
|
215
|
+
}
|
|
216
|
+
catch (error) {
|
|
217
|
+
console.error(`Error: Invalid header format - ${error instanceof Error ? error.message : String(error)}`);
|
|
218
|
+
process.exit(1);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
// Determine if this is a URL (sse/streamable-http) or command (stdio)
|
|
222
|
+
const isHttpTransport = transportLower !== 'stdio';
|
|
223
|
+
// Validate that URL is provided for HTTP transports
|
|
224
|
+
if (isHttpTransport) {
|
|
225
|
+
try {
|
|
226
|
+
new URL(commandOrUrl);
|
|
227
|
+
}
|
|
228
|
+
catch {
|
|
229
|
+
console.error(`Error: Invalid URL "${commandOrUrl}" for transport type "${transportLower}"`);
|
|
230
|
+
process.exit(1);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
// Parse strategy
|
|
234
|
+
const strategyLower = options.strategy.toLowerCase();
|
|
235
|
+
if (!['random', 'round-robin', 'tag-match-unique'].includes(strategyLower)) {
|
|
236
|
+
console.error(`Error: Invalid strategy "${options.strategy}"`);
|
|
237
|
+
console.error('Valid strategies: random, round-robin, tag-match-unique');
|
|
238
|
+
process.exit(1);
|
|
239
|
+
}
|
|
240
|
+
// Build install options
|
|
241
|
+
const installOptions = {
|
|
242
|
+
name,
|
|
243
|
+
...(isHttpTransport ? { url: commandOrUrl } : { command: commandOrUrl, args }),
|
|
244
|
+
transport: transportLower,
|
|
245
|
+
env,
|
|
246
|
+
headers,
|
|
247
|
+
timeout: options.timeout,
|
|
248
|
+
autoStart: options.autoStart,
|
|
249
|
+
instanceSelectionStrategy: strategyLower,
|
|
250
|
+
description: options.description
|
|
251
|
+
};
|
|
252
|
+
// Install the server
|
|
253
|
+
await installServer(installOptions, host, port);
|
|
254
|
+
console.log(`Successfully installed server: ${name}`);
|
|
255
|
+
console.log(` Type: ${transportLower}`);
|
|
256
|
+
if (isHttpTransport) {
|
|
257
|
+
console.log(` URL: ${commandOrUrl}`);
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
console.log(` Command: ${commandOrUrl}`);
|
|
261
|
+
}
|
|
262
|
+
if (Object.keys(env).length > 0) {
|
|
263
|
+
console.log(` Env: ${JSON.stringify(env)}`);
|
|
264
|
+
}
|
|
265
|
+
if (Object.keys(headers).length > 0) {
|
|
266
|
+
console.log(` Headers: ${JSON.stringify(headers)}`);
|
|
267
|
+
}
|
|
268
|
+
if (strategyLower !== 'random') {
|
|
269
|
+
console.log(` Strategy: ${strategyLower}`);
|
|
270
|
+
}
|
|
271
|
+
if (options.description) {
|
|
272
|
+
console.log(` Description: ${options.description}`);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* CLI command for displaying the use guide in Markdown format.
|
|
4
|
+
*
|
|
5
|
+
* This command outputs the CLI usage guide, similar to how MCP Hub Lite
|
|
6
|
+
* provides a use-guide resource for MCP protocol usage.
|
|
7
|
+
*
|
|
8
|
+
* @returns {Command} The configured use-guide command instance for registration with Commander.js
|
|
9
|
+
*/
|
|
10
|
+
export declare const useGuideCommand: Command;
|
|
11
|
+
//# sourceMappingURL=use-guide.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-guide.d.ts","sourceRoot":"","sources":["../../../../../src/cli/commands/use-guide.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAmKpC;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,SAKxB,CAAC"}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* CLI use guide content
|
|
4
|
+
*/
|
|
5
|
+
const USE_GUIDE_CONTENT = `# MCP Hub Lite CLI Use Guide
|
|
6
|
+
|
|
7
|
+
## Overview
|
|
8
|
+
|
|
9
|
+
MCP Hub Lite CLI provides command-line interface for managing MCP servers. This guide covers CLI-specific usage only.
|
|
10
|
+
|
|
11
|
+
## Commands
|
|
12
|
+
|
|
13
|
+
### start
|
|
14
|
+
|
|
15
|
+
Start the MCP Hub Lite server.
|
|
16
|
+
|
|
17
|
+
\`\`\`bash
|
|
18
|
+
# Start in daemon mode (default)
|
|
19
|
+
mcp-hub-lite start
|
|
20
|
+
|
|
21
|
+
# Start in foreground mode
|
|
22
|
+
mcp-hub-lite start --foreground
|
|
23
|
+
|
|
24
|
+
# Start with custom port
|
|
25
|
+
mcp-hub-lite start --port 8080
|
|
26
|
+
\`\`\`
|
|
27
|
+
|
|
28
|
+
### stop
|
|
29
|
+
|
|
30
|
+
Stop the running MCP Hub Lite server.
|
|
31
|
+
|
|
32
|
+
\`\`\`bash
|
|
33
|
+
mcp-hub-lite stop
|
|
34
|
+
\`\`\`
|
|
35
|
+
|
|
36
|
+
### status
|
|
37
|
+
|
|
38
|
+
Display server status and connected MCP servers.
|
|
39
|
+
|
|
40
|
+
\`\`\`bash
|
|
41
|
+
mcp-hub-lite status
|
|
42
|
+
\`\`\`
|
|
43
|
+
|
|
44
|
+
### ui
|
|
45
|
+
|
|
46
|
+
Open the web UI in default browser.
|
|
47
|
+
|
|
48
|
+
\`\`\`bash
|
|
49
|
+
mcp-hub-lite ui
|
|
50
|
+
\`\`\`
|
|
51
|
+
|
|
52
|
+
### list
|
|
53
|
+
|
|
54
|
+
List all configured MCP servers.
|
|
55
|
+
|
|
56
|
+
\`\`\`bash
|
|
57
|
+
mcp-hub-lite list
|
|
58
|
+
\`\`\`
|
|
59
|
+
|
|
60
|
+
### restart
|
|
61
|
+
|
|
62
|
+
Restart the MCP Hub Lite server.
|
|
63
|
+
|
|
64
|
+
\`\`\`bash
|
|
65
|
+
mcp-hub-lite restart
|
|
66
|
+
\`\`\`
|
|
67
|
+
|
|
68
|
+
### install
|
|
69
|
+
|
|
70
|
+
Add a new MCP server to MCP Hub Lite.
|
|
71
|
+
|
|
72
|
+
**Parametric Mode:**
|
|
73
|
+
|
|
74
|
+
\`\`\`bash
|
|
75
|
+
# stdio server
|
|
76
|
+
mcp-hub-lite install github-mcp "npx github-mcp" --env API_KEY=xxx
|
|
77
|
+
|
|
78
|
+
# HTTP server
|
|
79
|
+
mcp-hub-lite install api-server https://api.example.com/mcp -t streamable-http -H "Authorization: Bearer xxx"
|
|
80
|
+
\`\`\`
|
|
81
|
+
|
|
82
|
+
**JSON Mode:**
|
|
83
|
+
|
|
84
|
+
\`\`\`bash
|
|
85
|
+
# stdio server
|
|
86
|
+
mcp-hub-lite install --json '{"name":"github-mcp","type":"stdio","command":"npx github-mcp","env":{"API_KEY":"xxx"}}'
|
|
87
|
+
|
|
88
|
+
# HTTP server
|
|
89
|
+
mcp-hub-lite install --json '{"name":"api-server","type":"streamable-http","url":"https://api.example.com/mcp","headers":{"Authorization":"Bearer xxx"}}'
|
|
90
|
+
\`\`\`
|
|
91
|
+
|
|
92
|
+
**Options:**
|
|
93
|
+
|
|
94
|
+
| Option | Description |
|
|
95
|
+
| -------------------------- | ------------------------------------------------------------ |
|
|
96
|
+
| \`-t, --transport <type>\` | Transport type: stdio, sse, streamable-http (default: stdio) |
|
|
97
|
+
| \`-e, --env <env...>\` | Environment variables (KEY=VALUE) |
|
|
98
|
+
| \`-H, --header <header...>\` | HTTP headers (Header-Key: Value) |
|
|
99
|
+
| \`--timeout <seconds>\` | Timeout in seconds (default: 60) |
|
|
100
|
+
| \`--strategy <strategy>\` | Instance selection: random, round-robin, tag-match-unique |
|
|
101
|
+
| \`-a, --auto-start\` | Auto-start server (default: true) |
|
|
102
|
+
| \`--no-auto-start\` | Disable auto-start |
|
|
103
|
+
| \`-d, --description <desc>\` | Server description |
|
|
104
|
+
|
|
105
|
+
**JSON Config Fields:**
|
|
106
|
+
|
|
107
|
+
| Field | Required | Description |
|
|
108
|
+
| --------------------------- | ----------- | ------------------------------- |
|
|
109
|
+
| \`name\` | Yes | Server name |
|
|
110
|
+
| \`type\` | No | Transport type (default: stdio) |
|
|
111
|
+
| \`command\` | Yes (stdio) | Command to execute |
|
|
112
|
+
| \`url\` | Yes (HTTP) | Server URL |
|
|
113
|
+
| \`args\` | No | Command arguments |
|
|
114
|
+
| \`env\` | No | Environment variables object |
|
|
115
|
+
| \`headers\` | No | HTTP headers object |
|
|
116
|
+
| \`timeout\` | No | Timeout in seconds |
|
|
117
|
+
| \`enabled\` | No | Auto-start enabled |
|
|
118
|
+
| \`description\` | No | Server description |
|
|
119
|
+
| \`instanceSelectionStrategy\` | No | Instance selection strategy |
|
|
120
|
+
|
|
121
|
+
### tool-use
|
|
122
|
+
|
|
123
|
+
Manage MCP server tools via API.
|
|
124
|
+
|
|
125
|
+
\`\`\`bash
|
|
126
|
+
# List all connected servers
|
|
127
|
+
mcp-hub-lite tool-use list-servers
|
|
128
|
+
|
|
129
|
+
# List system tools
|
|
130
|
+
mcp-hub-lite tool-use list-tools
|
|
131
|
+
|
|
132
|
+
# List tools from specific server
|
|
133
|
+
mcp-hub-lite tool-use list-tools --server baidu-search
|
|
134
|
+
|
|
135
|
+
# Get tool schema
|
|
136
|
+
mcp-hub-lite tool-use get-tool --tool list_tools
|
|
137
|
+
|
|
138
|
+
# Call a tool
|
|
139
|
+
mcp-hub-lite tool-use call-tool --tool search --server baidu-search --args '{"query":"天气"}'
|
|
140
|
+
\`\`\`
|
|
141
|
+
|
|
142
|
+
**Options:**
|
|
143
|
+
|
|
144
|
+
| Option | Description |
|
|
145
|
+
| ----------------- | ------------------------------------------- |
|
|
146
|
+
| \`--server <name>\` | Server name (default: mcp-hub-lite) |
|
|
147
|
+
| \`--tool <name>\` | Tool name (required for get-tool/call-tool) |
|
|
148
|
+
| \`--args <json>\` | Tool arguments JSON |
|
|
149
|
+
| \`--tags <json>\` | Instance selection tags |
|
|
150
|
+
|
|
151
|
+
**JSON Merge Form:**
|
|
152
|
+
|
|
153
|
+
\`\`\`bash
|
|
154
|
+
# All parameters in one JSON
|
|
155
|
+
mcp-hub-lite tool-use call-tool --args '{"server":"baidu-search","tool":"search","query":"天气"}'
|
|
156
|
+
\`\`\`
|
|
157
|
+
|
|
158
|
+
---
|
|
159
|
+
|
|
160
|
+
_Last updated: 2026-04-20_
|
|
161
|
+
`;
|
|
162
|
+
/**
|
|
163
|
+
* CLI command for displaying the use guide in Markdown format.
|
|
164
|
+
*
|
|
165
|
+
* This command outputs the CLI usage guide, similar to how MCP Hub Lite
|
|
166
|
+
* provides a use-guide resource for MCP protocol usage.
|
|
167
|
+
*
|
|
168
|
+
* @returns {Command} The configured use-guide command instance for registration with Commander.js
|
|
169
|
+
*/
|
|
170
|
+
export const useGuideCommand = new Command('use-guide')
|
|
171
|
+
.description('Output CLI usage guide in Markdown format')
|
|
172
|
+
.action(() => {
|
|
173
|
+
process.stdout.write(USE_GUIDE_CONTENT);
|
|
174
|
+
process.exit(0);
|
|
175
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cli/index.ts"],"names":[],"mappings":";AAEA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/cli/index.ts"],"names":[],"mappings":";AAEA;;;GAGG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAgDpC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAoBnC"}
|
|
@@ -14,6 +14,8 @@ import { uiCommand } from './commands/ui.js';
|
|
|
14
14
|
import { listCommand } from './commands/list.js';
|
|
15
15
|
import { restartCommand } from './commands/restart.js';
|
|
16
16
|
import { toolUseCommand } from './commands/tool-use.js';
|
|
17
|
+
import { installCommand } from './commands/install.js';
|
|
18
|
+
import { useGuideCommand } from './commands/use-guide.js';
|
|
17
19
|
/**
|
|
18
20
|
* Check if the CLI is being executed directly (vs imported as module)
|
|
19
21
|
* Handles Windows/npm symlink path resolution issues by comparing package paths
|
|
@@ -112,6 +114,8 @@ export function createCli() {
|
|
|
112
114
|
program.addCommand(listCommand);
|
|
113
115
|
program.addCommand(restartCommand);
|
|
114
116
|
program.addCommand(toolUseCommand);
|
|
117
|
+
program.addCommand(installCommand);
|
|
118
|
+
program.addCommand(useGuideCommand);
|
|
115
119
|
return program;
|
|
116
120
|
}
|
|
117
121
|
// Execute the CLI if this file is run directly
|
|
@@ -176,5 +176,76 @@ export declare function listServers(): Promise<{
|
|
|
176
176
|
name: string;
|
|
177
177
|
config: import("../config/config-manager.js").ServerConfig;
|
|
178
178
|
}[]>;
|
|
179
|
+
/**
|
|
180
|
+
* Options for installing a new MCP server.
|
|
181
|
+
*/
|
|
182
|
+
export interface InstallServerOptions {
|
|
183
|
+
name: string;
|
|
184
|
+
command?: string;
|
|
185
|
+
url?: string;
|
|
186
|
+
transport: 'stdio' | 'sse' | 'streamable-http';
|
|
187
|
+
args?: string[];
|
|
188
|
+
env?: Record<string, string>;
|
|
189
|
+
headers?: Record<string, string>;
|
|
190
|
+
timeout: number;
|
|
191
|
+
autoStart: boolean;
|
|
192
|
+
instanceSelectionStrategy: 'random' | 'round-robin' | 'tag-match-unique';
|
|
193
|
+
description?: string;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Installs a new MCP server via the web API.
|
|
197
|
+
*
|
|
198
|
+
* This function sends a POST request to the /web/servers endpoint to add a new
|
|
199
|
+
* server configuration. If the instance selection strategy is not 'random', it
|
|
200
|
+
* sends an additional PUT request to update the strategy.
|
|
201
|
+
*
|
|
202
|
+
* @param options - Server installation options
|
|
203
|
+
* @param host - Server host address
|
|
204
|
+
* @param port - Server port number
|
|
205
|
+
* @returns Promise that resolves when installation completes
|
|
206
|
+
* @throws Error if the server already exists or the API request fails
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```typescript
|
|
210
|
+
* await installServer({
|
|
211
|
+
* name: 'github-mcp',
|
|
212
|
+
* command: 'npx github-mcp',
|
|
213
|
+
* transport: 'stdio',
|
|
214
|
+
* env: { API_KEY: 'xxx' },
|
|
215
|
+
* timeout: 60,
|
|
216
|
+
* autoStart: true,
|
|
217
|
+
* instanceSelectionStrategy: 'random'
|
|
218
|
+
* }, 'localhost', 7788);
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
export declare function installServer(options: InstallServerOptions, host: string, port: number): Promise<void>;
|
|
222
|
+
/**
|
|
223
|
+
* Parses environment variable flags into a key-value object.
|
|
224
|
+
*
|
|
225
|
+
* @param envFlags - Array of environment variables in KEY=VALUE format
|
|
226
|
+
* @returns Record of environment variable key-value pairs
|
|
227
|
+
* @throws Error if the format is invalid
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```typescript
|
|
231
|
+
* parseEnvVars(['API_KEY=xxx', 'DEBUG=true'])
|
|
232
|
+
* // Returns: { API_KEY: 'xxx', DEBUG: 'true' }
|
|
233
|
+
* ```
|
|
234
|
+
*/
|
|
235
|
+
export declare function parseEnvVars(envFlags: string[]): Record<string, string>;
|
|
236
|
+
/**
|
|
237
|
+
* Parses HTTP header flags into a key-value object.
|
|
238
|
+
*
|
|
239
|
+
* @param headerFlags - Array of headers in "Key: Value" format
|
|
240
|
+
* @returns Record of header key-value pairs
|
|
241
|
+
* @throws Error if the format is invalid
|
|
242
|
+
*
|
|
243
|
+
* @example
|
|
244
|
+
* ```typescript
|
|
245
|
+
* parseHeaders(['Authorization: Bearer xxx', 'Content-Type: application/json'])
|
|
246
|
+
* // Returns: { Authorization: 'Bearer xxx', 'Content-Type': 'application/json' }
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
export declare function parseHeaders(headerFlags: string[]): Record<string, string>;
|
|
179
250
|
export {};
|
|
180
251
|
//# sourceMappingURL=server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../../src/cli/server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAOH,UAAU,aAAa;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CA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