prettier
This commit is contained in:
parent
3a4f3bc510
commit
1e399b7055
5 changed files with 27 additions and 19 deletions
|
|
@ -239,6 +239,7 @@ Example server configuration file:
|
||||||
The inspector automatically detects the transport type from your config file. You can specify different transport types:
|
The inspector automatically detects the transport type from your config file. You can specify different transport types:
|
||||||
|
|
||||||
**STDIO (default):**
|
**STDIO (default):**
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"mcpServers": {
|
"mcpServers": {
|
||||||
|
|
@ -252,6 +253,7 @@ The inspector automatically detects the transport type from your config file. Yo
|
||||||
```
|
```
|
||||||
|
|
||||||
**SSE (Server-Sent Events):**
|
**SSE (Server-Sent Events):**
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"mcpServers": {
|
"mcpServers": {
|
||||||
|
|
@ -264,6 +266,7 @@ The inspector automatically detects the transport type from your config file. Yo
|
||||||
```
|
```
|
||||||
|
|
||||||
**Streamable HTTP:**
|
**Streamable HTTP:**
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"mcpServers": {
|
"mcpServers": {
|
||||||
|
|
@ -280,12 +283,14 @@ The inspector automatically detects the transport type from your config file. Yo
|
||||||
You can launch the inspector without specifying a server name if your config has:
|
You can launch the inspector without specifying a server name if your config has:
|
||||||
|
|
||||||
1. **A single server** - automatically selected:
|
1. **A single server** - automatically selected:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# Automatically uses "my-server" if it's the only one
|
# Automatically uses "my-server" if it's the only one
|
||||||
npx @modelcontextprotocol/inspector --config config.json
|
npx @modelcontextprotocol/inspector --config config.json
|
||||||
```
|
```
|
||||||
|
|
||||||
2. **A server named "default-server"** - automatically selected:
|
2. **A server named "default-server"** - automatically selected:
|
||||||
|
|
||||||
```json
|
```json
|
||||||
{
|
{
|
||||||
"mcpServers": {
|
"mcpServers": {
|
||||||
|
|
|
||||||
|
|
@ -785,7 +785,10 @@ async function runTests() {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create config with single server for auto-selection
|
// Create config with single server for auto-selection
|
||||||
const singleServerConfigPath = path.join(TEMP_DIR, "single-server-config.json");
|
const singleServerConfigPath = path.join(
|
||||||
|
TEMP_DIR,
|
||||||
|
"single-server-config.json",
|
||||||
|
);
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
singleServerConfigPath,
|
singleServerConfigPath,
|
||||||
JSON.stringify(
|
JSON.stringify(
|
||||||
|
|
@ -803,7 +806,10 @@ async function runTests() {
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create config with default-server
|
// Create config with default-server
|
||||||
const defaultServerConfigPath = path.join(TEMP_DIR, "default-server-config.json");
|
const defaultServerConfigPath = path.join(
|
||||||
|
TEMP_DIR,
|
||||||
|
"default-server-config.json",
|
||||||
|
);
|
||||||
fs.writeFileSync(
|
fs.writeFileSync(
|
||||||
defaultServerConfigPath,
|
defaultServerConfigPath,
|
||||||
JSON.stringify(
|
JSON.stringify(
|
||||||
|
|
@ -831,11 +837,11 @@ async function runTests() {
|
||||||
JSON.stringify(
|
JSON.stringify(
|
||||||
{
|
{
|
||||||
mcpServers: {
|
mcpServers: {
|
||||||
"server1": {
|
server1: {
|
||||||
command: "npx",
|
command: "npx",
|
||||||
args: ["@modelcontextprotocol/server-everything"],
|
args: ["@modelcontextprotocol/server-everything"],
|
||||||
},
|
},
|
||||||
"server2": {
|
server2: {
|
||||||
command: "node",
|
command: "node",
|
||||||
args: ["other.js"],
|
args: ["other.js"],
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -222,9 +222,7 @@ function parseArgs(): Args {
|
||||||
|
|
||||||
// Validate config and server options
|
// Validate config and server options
|
||||||
if (!options.config && options.server) {
|
if (!options.config && options.server) {
|
||||||
throw new Error(
|
throw new Error("--server requires --config to be specified");
|
||||||
"--server requires --config to be specified",
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If config is provided without server, try to auto-select
|
// If config is provided without server, try to auto-select
|
||||||
|
|
@ -233,11 +231,11 @@ function parseArgs(): Args {
|
||||||
path.isAbsolute(options.config)
|
path.isAbsolute(options.config)
|
||||||
? options.config
|
? options.config
|
||||||
: path.resolve(process.cwd(), options.config),
|
: path.resolve(process.cwd(), options.config),
|
||||||
"utf8"
|
"utf8",
|
||||||
);
|
);
|
||||||
const parsedConfig = JSON.parse(configContent);
|
const parsedConfig = JSON.parse(configContent);
|
||||||
const servers = Object.keys(parsedConfig.mcpServers || {});
|
const servers = Object.keys(parsedConfig.mcpServers || {});
|
||||||
|
|
||||||
if (servers.includes("default-server")) {
|
if (servers.includes("default-server")) {
|
||||||
// Use default-server if it exists
|
// Use default-server if it exists
|
||||||
options.server = "default-server";
|
options.server = "default-server";
|
||||||
|
|
@ -249,7 +247,7 @@ function parseArgs(): Args {
|
||||||
} else {
|
} else {
|
||||||
// Multiple servers, no default-server
|
// Multiple servers, no default-server
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Multiple servers found in config file. Please specify one with --server.\nAvailable servers: ${servers.join(", ")}`
|
`Multiple servers found in config file. Please specify one with --server.\nAvailable servers: ${servers.join(", ")}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,7 @@ function delay(ms) {
|
||||||
return new Promise((resolve) => setTimeout(resolve, ms, true));
|
return new Promise((resolve) => setTimeout(resolve, ms, true));
|
||||||
}
|
}
|
||||||
|
|
||||||
function getClientUrl(
|
function getClientUrl(port, authDisabled, sessionToken, serverPort) {
|
||||||
port,
|
|
||||||
authDisabled,
|
|
||||||
sessionToken,
|
|
||||||
serverPort,
|
|
||||||
) {
|
|
||||||
const host = process.env.HOST || "localhost";
|
const host = process.env.HOST || "localhost";
|
||||||
const baseUrl = `http://${host}:${port}`;
|
const baseUrl = `http://${host}:${port}`;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,9 @@ test.describe("CLI Arguments @cli", () => {
|
||||||
page,
|
page,
|
||||||
}) => {
|
}) => {
|
||||||
// Simulate: npx . --transport sse --server-url http://localhost:3000/sse
|
// Simulate: npx . --transport sse --server-url http://localhost:3000/sse
|
||||||
await page.goto("http://localhost:6274/?transport=sse&serverUrl=http://localhost:3000/sse");
|
await page.goto(
|
||||||
|
"http://localhost:6274/?transport=sse&serverUrl=http://localhost:3000/sse",
|
||||||
|
);
|
||||||
|
|
||||||
// Wait for the Transport Type dropdown to be visible
|
// Wait for the Transport Type dropdown to be visible
|
||||||
const selectTrigger = page.getByLabel("Transport Type");
|
const selectTrigger = page.getByLabel("Transport Type");
|
||||||
|
|
@ -26,7 +28,9 @@ test.describe("CLI Arguments @cli", () => {
|
||||||
page,
|
page,
|
||||||
}) => {
|
}) => {
|
||||||
// Simulate config with streamable-http transport
|
// Simulate config with streamable-http transport
|
||||||
await page.goto("http://localhost:6274/?transport=streamable-http&serverUrl=http://localhost:3000/mcp");
|
await page.goto(
|
||||||
|
"http://localhost:6274/?transport=streamable-http&serverUrl=http://localhost:3000/mcp",
|
||||||
|
);
|
||||||
|
|
||||||
// Wait for the Transport Type dropdown to be visible
|
// Wait for the Transport Type dropdown to be visible
|
||||||
const selectTrigger = page.getByLabel("Transport Type");
|
const selectTrigger = page.getByLabel("Transport Type");
|
||||||
|
|
@ -58,4 +62,4 @@ test.describe("CLI Arguments @cli", () => {
|
||||||
await expect(page.locator("#command-input")).toBeVisible();
|
await expect(page.locator("#command-input")).toBeVisible();
|
||||||
await expect(page.locator("#arguments-input")).toBeVisible();
|
await expect(page.locator("#arguments-input")).toBeVisible();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue