Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions extensions/cli/src/configEnhancer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@

// MCPs from --mcp flag should be prepended (at the start)
expect(config.mcpServers).toHaveLength(2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like these tests failed, you need to make sure they pass

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please fix the failing tests

expect(config.mcpServers?.[0]).toEqual({

Check failure on line 216 in extensions/cli/src/configEnhancer.test.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 20)

src/configEnhancer.test.ts > ConfigEnhancer > should prepend MCPs from --mcp flag

AssertionError: expected { name: 'test', provider: 'test' } to deeply equal { name: 'New-MCP', command: 'new-mcp' } - Expected + Received { - "command": "new-mcp", - "name": "New-MCP", + "name": "test", + "provider": "test", } ❯ src/configEnhancer.test.ts:216:36

Check failure on line 216 in extensions/cli/src/configEnhancer.test.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 24)

src/configEnhancer.test.ts > ConfigEnhancer > should prepend MCPs from --mcp flag

AssertionError: expected { name: 'test', provider: 'test' } to deeply equal { name: 'New-MCP', command: 'new-mcp' } - Expected + Received { - "command": "new-mcp", - "name": "New-MCP", + "name": "test", + "provider": "test", } ❯ src/configEnhancer.test.ts:216:36

Check failure on line 216 in extensions/cli/src/configEnhancer.test.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 22)

src/configEnhancer.test.ts > ConfigEnhancer > should prepend MCPs from --mcp flag

AssertionError: expected { name: 'test', provider: 'test' } to deeply equal { name: 'New-MCP', command: 'new-mcp' } - Expected + Received { - "command": "new-mcp", - "name": "New-MCP", + "name": "test", + "provider": "test", } ❯ src/configEnhancer.test.ts:216:36

Check failure on line 216 in extensions/cli/src/configEnhancer.test.ts

View workflow job for this annotation

GitHub Actions / test (ubuntu-latest, 18)

src/configEnhancer.test.ts > ConfigEnhancer > should prepend MCPs from --mcp flag

AssertionError: expected { name: 'test', provider: 'test' } to deeply equal { name: 'New-MCP', command: 'new-mcp' } - Expected + Received { - "command": "new-mcp", - "name": "New-MCP", + "name": "test", + "provider": "test", } ❯ src/configEnhancer.test.ts:216:36

Check failure on line 216 in extensions/cli/src/configEnhancer.test.ts

View workflow job for this annotation

GitHub Actions / test (macos-latest, 24)

src/configEnhancer.test.ts > ConfigEnhancer > should prepend MCPs from --mcp flag

AssertionError: expected { name: 'test', provider: 'test' } to deeply equal { name: 'New-MCP', command: 'new-mcp' } - Expected + Received { - "command": "new-mcp", - "name": "New-MCP", + "name": "test", + "provider": "test", } ❯ src/configEnhancer.test.ts:216:36

Check failure on line 216 in extensions/cli/src/configEnhancer.test.ts

View workflow job for this annotation

GitHub Actions / test (macos-latest, 20)

src/configEnhancer.test.ts > ConfigEnhancer > should prepend MCPs from --mcp flag

AssertionError: expected { name: 'test', provider: 'test' } to deeply equal { name: 'New-MCP', command: 'new-mcp' } - Expected + Received { - "command": "new-mcp", - "name": "New-MCP", + "name": "test", + "provider": "test", } ❯ src/configEnhancer.test.ts:216:36

Check failure on line 216 in extensions/cli/src/configEnhancer.test.ts

View workflow job for this annotation

GitHub Actions / test (macos-latest, 22)

src/configEnhancer.test.ts > ConfigEnhancer > should prepend MCPs from --mcp flag

AssertionError: expected { name: 'test', provider: 'test' } to deeply equal { name: 'New-MCP', command: 'new-mcp' } - Expected + Received { - "command": "new-mcp", - "name": "New-MCP", + "name": "test", + "provider": "test", } ❯ src/configEnhancer.test.ts:216:36

Check failure on line 216 in extensions/cli/src/configEnhancer.test.ts

View workflow job for this annotation

GitHub Actions / test (macos-latest, 18)

src/configEnhancer.test.ts > ConfigEnhancer > should prepend MCPs from --mcp flag

AssertionError: expected { name: 'test', provider: 'test' } to deeply equal { name: 'New-MCP', command: 'new-mcp' } - Expected + Received { - "command": "new-mcp", - "name": "New-MCP", + "name": "test", + "provider": "test", } ❯ src/configEnhancer.test.ts:216:36

Check failure on line 216 in extensions/cli/src/configEnhancer.test.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 18)

src/configEnhancer.test.ts > ConfigEnhancer > should prepend MCPs from --mcp flag

AssertionError: expected { name: 'test', provider: 'test' } to deeply equal { name: 'New-MCP', command: 'new-mcp' } - Expected + Received { - "command": "new-mcp", - "name": "New-MCP", + "name": "test", + "provider": "test", } ❯ src/configEnhancer.test.ts:216:36

Check failure on line 216 in extensions/cli/src/configEnhancer.test.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 22)

src/configEnhancer.test.ts > ConfigEnhancer > should prepend MCPs from --mcp flag

AssertionError: expected { name: 'test', provider: 'test' } to deeply equal { name: 'New-MCP', command: 'new-mcp' } - Expected + Received { - "command": "new-mcp", - "name": "New-MCP", + "name": "test", + "provider": "test", } ❯ src/configEnhancer.test.ts:216:36

Check failure on line 216 in extensions/cli/src/configEnhancer.test.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 24)

src/configEnhancer.test.ts > ConfigEnhancer > should prepend MCPs from --mcp flag

AssertionError: expected { name: 'test', provider: 'test' } to deeply equal { name: 'New-MCP', command: 'new-mcp' } - Expected + Received { - "command": "new-mcp", - "name": "New-MCP", + "name": "test", + "provider": "test", } ❯ src/configEnhancer.test.ts:216:36

Check failure on line 216 in extensions/cli/src/configEnhancer.test.ts

View workflow job for this annotation

GitHub Actions / test (windows-latest, 20)

src/configEnhancer.test.ts > ConfigEnhancer > should prepend MCPs from --mcp flag

AssertionError: expected { name: 'test', provider: 'test' } to deeply equal { name: 'New-MCP', command: 'new-mcp' } - Expected + Received { - "command": "new-mcp", - "name": "New-MCP", + "name": "test", + "provider": "test", } ❯ src/configEnhancer.test.ts:216:36
name: "New-MCP",
command: "new-mcp",
});
Expand All @@ -223,6 +223,70 @@
});
});

it("should handle URLs in --mcp flag as streamable-http servers", async () => {
// Set up existing MCPs in config
mockConfig.mcpServers = [{ name: "Existing-MCP", command: "existing-mcp" }];

const options: BaseCommandOptions = {
mcp: ["https://docs.continue.dev/mcp"],
};

const config = await enhancer.enhanceConfig(mockConfig, options);

// URL should be converted to streamable-http MCP configuration
expect(config.mcpServers).toHaveLength(2);
expect(config.mcpServers?.[0]).toEqual({
name: "docs.continue.dev",
type: "streamable-http",
url: "https://docs.continue.dev/mcp",
});
expect(config.mcpServers?.[1]).toEqual({
name: "Existing-MCP",
command: "existing-mcp",
});
});

it("should handle mix of URLs and hub slugs in --mcp flag", async () => {
// Mock loadPackageFromHub to return test MCP for hub slug
const { loadPackageFromHub } = await import("./hubLoader.js");
(loadPackageFromHub as any).mockResolvedValueOnce({
name: "Hub-MCP",
command: "hub-mcp",
});

const options: BaseCommandOptions = {
mcp: ["https://example.com/mcp", "test/hub-mcp"],
};

const config = await enhancer.enhanceConfig(mockConfig, options);

expect(config.mcpServers).toHaveLength(2);
expect(config.mcpServers?.[0]).toEqual({
name: "example.com",
type: "streamable-http",
url: "https://example.com/mcp",
});
expect(config.mcpServers?.[1]).toEqual({
name: "Hub-MCP",
command: "hub-mcp",
});
});

it("should handle http:// URLs in --mcp flag", async () => {
const options: BaseCommandOptions = {
mcp: ["http://localhost:8080/mcp"],
};

const config = await enhancer.enhanceConfig(mockConfig, options);

expect(config.mcpServers).toHaveLength(1);
expect(config.mcpServers?.[0]).toEqual({
name: "localhost",
type: "streamable-http",
url: "http://localhost:8080/mcp",
});
});

it("should handle workflow integration gracefully when no workflow", async () => {
// The mocked service container returns null workflow state
const options: BaseCommandOptions = {
Expand Down
23 changes: 22 additions & 1 deletion extensions/cli/src/configEnhancer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,28 @@ export class ConfigEnhancer {
config: AssistantUnrolled,
mcps: string[],
): Promise<AssistantUnrolled> {
const processedMcps = await loadPackagesFromHub(mcps, mcpProcessor);
const processedMcps: any[] = [];

// Process each MCP spec - check if it's a URL or hub slug
for (const mcpSpec of mcps) {
try {
// Check if it's a URL (starts with http:// or https://)
if (mcpSpec.startsWith("http://") || mcpSpec.startsWith("https://")) {
// Create a streamable-http MCP configuration
processedMcps.push({
name: new URL(mcpSpec).hostname,
type: "streamable-http",
url: mcpSpec,
});
} else {
// Otherwise, treat it as a hub slug
const hubMcp = await loadPackageFromHub(mcpSpec, mcpProcessor);
processedMcps.push(hubMcp);
}
} catch (error: any) {
logger.warn(`Failed to load MCP "${mcpSpec}": ${error.message}`);
}
}

// Clone the config to avoid mutating the original
const modifiedConfig = { ...config };
Expand Down
Loading