Skip to content
Merged
23 changes: 16 additions & 7 deletions examples/minimal/tests/advanced-features.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,12 @@ describe("Advanced Features", () => {
const server = await startTestServer(app, { port: testPort });
await new Promise((resolve) => setTimeout(resolve, 100));

const client = await createTestClient(`http://localhost:${testPort}/v1/mcp`, {
trackHistory: true,
});
const client = await createTestClient(
{ transport: "http", url: `http://localhost:${testPort}/v1/mcp` },
{
trackHistory: true,
}
);

await client.callTool("greet", { name: "History1" });
await client.callTool("greet", { name: "History2" });
Expand All @@ -418,7 +421,10 @@ describe("Advanced Features", () => {
const testPort = 3014;
const server = await startTestServer(app, { port: testPort });
await new Promise((resolve) => setTimeout(resolve, 100));
const client = await createTestClient(`http://localhost:${testPort}/v1/mcp`);
const client = await createTestClient({
transport: "http",
url: `http://localhost:${testPort}/v1/mcp`,
});

const tools = await client.listTools();
expect(tools.some((t) => t.name === "greet")).toBe(true);
Expand All @@ -435,9 +441,12 @@ describe("Advanced Features", () => {
await new Promise((resolve) => setTimeout(resolve, 100));

// Client with short timeout
const client = await createTestClient(`http://localhost:${testPort}/v1/mcp`, {
timeout: 5000, // 5 second timeout
});
const client = await createTestClient(
{ transport: "http", url: `http://localhost:${testPort}/v1/mcp` },
{
timeout: 5000, // 5 second timeout
}
);

// Should complete within timeout
const result = await client.callTool("greet", { name: "Timeout" });
Expand Down
9 changes: 6 additions & 3 deletions examples/minimal/tests/greet-v1.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ describe("Greet Tool V1", () => {
const server = await startTestServer(app, { port: testPort });
await new Promise((resolve) => setTimeout(resolve, 100));

const client = await createTestClient(`http://localhost:${testPort}/v1/mcp`, {
trackHistory: true,
});
const client = await createTestClient(
{ transport: "http", url: `http://localhost:${testPort}/v1/mcp` },
{
trackHistory: true,
}
);

env = {
server,
Expand Down
9 changes: 6 additions & 3 deletions examples/minimal/tests/greet-v2.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,12 @@ describe("Greet Tool V2", () => {
const server = await startTestServer(app, { port: testPort });
await new Promise((resolve) => setTimeout(resolve, 100));

const client = await createTestClient(`http://localhost:${testPort}/v2/mcp`, {
trackHistory: true,
});
const client = await createTestClient(
{ transport: "http", url: `http://localhost:${testPort}/v2/mcp` },
{
trackHistory: true,
}
);

env = {
server,
Expand Down
11 changes: 7 additions & 4 deletions examples/minimal/tests/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ describe("Minimal Example Integration", () => {
const server = await startTestServer(app, { port: testPort });
await new Promise((resolve) => setTimeout(resolve, 100));

const client = await createTestClient(`http://localhost:${testPort}/v1/mcp`, {
trackHistory: true,
timeout: 10000,
});
const client = await createTestClient(
{ transport: "http", url: `http://localhost:${testPort}/v1/mcp` },
{
trackHistory: true,
timeout: 10000,
}
);

env = {
server,
Expand Down
20 changes: 13 additions & 7 deletions examples/minimal/tests/integration/versioning.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ describe("Versioning", () => {
mainServer = await startTestServer(app as unknown, { port: testPort });
await new Promise((resolve) => setTimeout(resolve, 100));

const v1Client = await createTestClient(`http://localhost:${testPort}/v1/mcp`, {
trackHistory: true,
});

const v2Client = await createTestClient(`http://localhost:${testPort}/v2/mcp`, {
trackHistory: true,
});
const v1Client = await createTestClient(
{ transport: "http", url: `http://localhost:${testPort}/v1/mcp` },
{
trackHistory: true,
}
);

const v2Client = await createTestClient(
{ transport: "http", url: `http://localhost:${testPort}/v2/mcp` },
{
trackHistory: true,
}
);

v1Env = {
server: mainServer,
Expand Down
11 changes: 7 additions & 4 deletions examples/weather-app/tests/integration/server.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ describe("Weather App MCP Server", () => {
const server = await startTestServer(app, { port: 0 });
await new Promise((r) => setTimeout(r, 100));

const client = await createTestClient(server.mcpUrl, {
trackHistory: true,
timeout: 15000,
});
const client = await createTestClient(
{ transport: "http", url: server.mcpUrl },
{
trackHistory: true,
timeout: 15000,
}
);

env = {
server,
Expand Down
4 changes: 2 additions & 2 deletions packages/create-app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,7 @@ describe("${name} MCP Server", () => {
const server = await startTestServer(app, { port: 0 });
await new Promise((r) => setTimeout(r, 100));

const client = await createTestClient(server.mcpUrl, {
const client = await createTestClient({ transport: "http", url: server.mcpUrl }, {
trackHistory: true,
timeout: 10000,
});
Expand Down Expand Up @@ -1106,7 +1106,7 @@ describe("${name} MCP Server", () => {
const server = await startTestServer(app, { port: 0 });
await new Promise((r) => setTimeout(r, 100));

const client = await createTestClient(server.mcpUrl, {
const client = await createTestClient({ transport: "http", url: server.mcpUrl }, {
trackHistory: true,
timeout: 10000,
});
Expand Down
7 changes: 4 additions & 3 deletions packages/inspector/src/connection-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import { randomUUID } from "node:crypto";
import { EventEmitter } from "node:events";
import type { ConnectionParams } from "@mcp-apps-kit/testing";
import { ConnectionManager } from "./connection";
import type { ConnectOptions, ConnectionStatusOutput, InspectorServerOptions } from "./types";

Expand Down Expand Up @@ -61,12 +62,12 @@ export class ConnectionRegistry extends EventEmitter {
/**
* Create a new connection and connect to the target server.
*
* @param url - MCP server URL to connect to.
* @param params - Connection parameters (transport type + config).
* @param options - Connection options passed to the ConnectionManager.
* @returns The new connection id and manager instance.
*/
async createConnection(
url: string,
params: ConnectionParams,
options?: ConnectOptions
): Promise<{ id: string; connectionManager: ConnectionManager }> {
if (this.connections.size >= this.maxConnections) {
Expand All @@ -80,7 +81,7 @@ export class ConnectionRegistry extends EventEmitter {
});

try {
await connectionManager.connect(url, options);
await connectionManager.connect(params, options);
} catch (error) {
try {
await connectionManager.disconnect();
Expand Down
Loading