Skip to content

Commit e9a601c

Browse files
fix: add missing type field to MCPServerConfig (#15465)
1 parent 308aa70 commit e9a601c

File tree

3 files changed

+68
-2
lines changed

3 files changed

+68
-2
lines changed

packages/cli/src/config/settings-validation.test.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,60 @@ describe('settings-validation', () => {
219219
}
220220
});
221221

222+
it('should validate mcpServers with type field for all transport types', () => {
223+
const validSettings = {
224+
mcpServers: {
225+
'sse-server': {
226+
url: 'https://example.com/sse',
227+
type: 'sse',
228+
headers: { 'X-API-Key': 'key' },
229+
},
230+
'http-server': {
231+
url: 'https://example.com/mcp',
232+
type: 'http',
233+
},
234+
'stdio-server': {
235+
command: '/usr/bin/mcp-server',
236+
type: 'stdio',
237+
},
238+
},
239+
};
240+
241+
const result = validateSettings(validSettings);
242+
expect(result.success).toBe(true);
243+
});
244+
245+
it('should reject invalid type values in mcpServers', () => {
246+
const invalidSettings = {
247+
mcpServers: {
248+
'bad-server': {
249+
url: 'https://example.com/mcp',
250+
type: 'invalid-type',
251+
},
252+
},
253+
};
254+
255+
const result = validateSettings(invalidSettings);
256+
expect(result.success).toBe(false);
257+
});
258+
259+
it('should validate mcpServers without type field', () => {
260+
const validSettings = {
261+
mcpServers: {
262+
'stdio-server': {
263+
command: '/usr/bin/mcp-server',
264+
args: ['--port', '8080'],
265+
},
266+
'url-server': {
267+
url: 'https://example.com/mcp',
268+
},
269+
},
270+
};
271+
272+
const result = validateSettings(validSettings);
273+
expect(result.success).toBe(true);
274+
});
275+
222276
it('should validate complex nested customThemes configuration', () => {
223277
const invalidSettings = {
224278
ui: {

packages/cli/src/config/settingsSchema.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1704,7 +1704,8 @@ export const SETTINGS_SCHEMA_DEFINITIONS: Record<
17041704
},
17051705
url: {
17061706
type: 'string',
1707-
description: 'SSE transport URL.',
1707+
description:
1708+
'URL for SSE or HTTP transport. Use with "type" field to specify transport type.',
17081709
},
17091710
httpUrl: {
17101711
type: 'string',
@@ -1719,6 +1720,12 @@ export const SETTINGS_SCHEMA_DEFINITIONS: Record<
17191720
type: 'string',
17201721
description: 'TCP address for websocket transport.',
17211722
},
1723+
type: {
1724+
type: 'string',
1725+
description:
1726+
'Transport type. Use "stdio" for local command, "sse" for Server-Sent Events, or "http" for Streamable HTTP.',
1727+
enum: ['stdio', 'sse', 'http'],
1728+
},
17221729
timeout: {
17231730
type: 'number',
17241731
description: 'Timeout in milliseconds for MCP requests.',

schemas/settings.schema.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1599,7 +1599,7 @@
15991599
},
16001600
"url": {
16011601
"type": "string",
1602-
"description": "SSE transport URL."
1602+
"description": "URL for SSE or HTTP transport. Use with \"type\" field to specify transport type."
16031603
},
16041604
"httpUrl": {
16051605
"type": "string",
@@ -1616,6 +1616,11 @@
16161616
"type": "string",
16171617
"description": "TCP address for websocket transport."
16181618
},
1619+
"type": {
1620+
"type": "string",
1621+
"description": "Transport type. Use \"stdio\" for local command, \"sse\" for Server-Sent Events, or \"http\" for Streamable HTTP.",
1622+
"enum": ["stdio", "sse", "http"]
1623+
},
16191624
"timeout": {
16201625
"type": "number",
16211626
"description": "Timeout in milliseconds for MCP requests."

0 commit comments

Comments
 (0)