This commit is contained in:
Felix Weinberger 2025-08-05 14:08:26 +01:00
commit 1e399b7055
No known key found for this signature in database
5 changed files with 27 additions and 19 deletions

View file

@ -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:
**STDIO (default):**
```json
{
"mcpServers": {
@ -252,6 +253,7 @@ The inspector automatically detects the transport type from your config file. Yo
```
**SSE (Server-Sent Events):**
```json
{
"mcpServers": {
@ -264,6 +266,7 @@ The inspector automatically detects the transport type from your config file. Yo
```
**Streamable HTTP:**
```json
{
"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:
1. **A single server** - automatically selected:
```bash
# Automatically uses "my-server" if it's the only one
npx @modelcontextprotocol/inspector --config config.json
```
2. **A server named "default-server"** - automatically selected:
```json
{
"mcpServers": {

View file

@ -785,7 +785,10 @@ async function runTests() {
);
// 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(
singleServerConfigPath,
JSON.stringify(
@ -803,7 +806,10 @@ async function runTests() {
);
// 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(
defaultServerConfigPath,
JSON.stringify(
@ -831,11 +837,11 @@ async function runTests() {
JSON.stringify(
{
mcpServers: {
"server1": {
server1: {
command: "npx",
args: ["@modelcontextprotocol/server-everything"],
},
"server2": {
server2: {
command: "node",
args: ["other.js"],
},

View file

@ -222,9 +222,7 @@ function parseArgs(): Args {
// Validate config and server options
if (!options.config && options.server) {
throw new Error(
"--server requires --config to be specified",
);
throw new Error("--server requires --config to be specified");
}
// If config is provided without server, try to auto-select
@ -233,11 +231,11 @@ function parseArgs(): Args {
path.isAbsolute(options.config)
? options.config
: path.resolve(process.cwd(), options.config),
"utf8"
"utf8",
);
const parsedConfig = JSON.parse(configContent);
const servers = Object.keys(parsedConfig.mcpServers || {});
if (servers.includes("default-server")) {
// Use default-server if it exists
options.server = "default-server";
@ -249,7 +247,7 @@ function parseArgs(): Args {
} else {
// Multiple servers, no default-server
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(", ")}`,
);
}
}

View file

@ -13,12 +13,7 @@ function delay(ms) {
return new Promise((resolve) => setTimeout(resolve, ms, true));
}
function getClientUrl(
port,
authDisabled,
sessionToken,
serverPort,
) {
function getClientUrl(port, authDisabled, sessionToken, serverPort) {
const host = process.env.HOST || "localhost";
const baseUrl = `http://${host}:${port}`;

View file

@ -7,7 +7,9 @@ test.describe("CLI Arguments @cli", () => {
page,
}) => {
// 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
const selectTrigger = page.getByLabel("Transport Type");
@ -26,7 +28,9 @@ test.describe("CLI Arguments @cli", () => {
page,
}) => {
// 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
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("#arguments-input")).toBeVisible();
});
});
});