Skip to content

feat: Verify SSL for MCP #7229

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
32 changes: 23 additions & 9 deletions core/context/mcp/MCPConnection.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { Client } from "@modelcontextprotocol/sdk/client/index.js";
import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";

import {
SSEClientTransport,
SseError,
} from "@modelcontextprotocol/sdk/client/sse.js";
import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
import { WebSocketClientTransport } from "@modelcontextprotocol/sdk/client/websocket.js";

import { Transport } from "@modelcontextprotocol/sdk/shared/transport.js";
import { Agent as HttpsAgent } from "https";
import {
IDE,
MCPConnectionStatus,
Expand Down Expand Up @@ -393,6 +392,11 @@
case "websocket":
return new WebSocketClientTransport(new URL(options.transport.url));
case "sse":
const sseAgent =
options.transport.requestOptions?.verifySsl === false
? new HttpsAgent({ rejectUnauthorized: false })
: undefined;

return new SSEClientTransport(new URL(options.transport.url), {
eventSourceInit: {
fetch: (input, init) =>
Expand All @@ -404,17 +408,27 @@
| Record<string, string>
| undefined),
},
...(sseAgent && { agent: sseAgent }),
}),
},
requestInit: { headers: options.transport.requestOptions?.headers },
requestInit: {
headers: options.transport.requestOptions?.headers,
...(sseAgent && { agent: sseAgent }),
},
});
case "streamable-http":
return new StreamableHTTPClientTransport(
new URL(options.transport.url),
{
requestInit: { headers: options.transport.requestOptions?.headers },
const { url, requestOptions } = options.transport;
const streamableAgent =
requestOptions?.verifySsl === false
? new HttpsAgent({ rejectUnauthorized: false })
: undefined;

return new StreamableHTTPClientTransport(new URL(url), {
requestInit: {
headers: requestOptions?.headers,
...(streamableAgent && { agent: streamableAgent }),
},
);
});
default:
throw new Error(
`Unsupported transport type: ${(options.transport as any).type}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ public static int[] sortingAlgorithm2(int[] x) {
// the model to make decisions and save you the work of manually finding context and performing actions.

// 1. Switch from "Chat" to "Agent" mode using the dropdown in the bottom left of the input box
// 2. Try asking Continue "Write unit tests for this code in a new file and run the test"
// 2. Use the "/init" slash command to generate a CONTINUE.md file

// —————————————————— Learn more at https://docs.continue.dev/getting-started/overview ——————————————————— //
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ def sorting_algorithm2(x):
# the model to make decisions and save you the work of manually finding context and performing actions.

# 1. Switch from "Chat" to "Agent" mode using the dropdown in the bottom left of the input box
# 2. Try asking Continue "Write unit tests for this code in a new file and run the test"
# 2. Use the "/init" slash command to generate a CONTINUE.md file

# —————————————————— Learn more at https://docs.continue.dev/getting-started/overview ——————————————————— #
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ function sortingAlgorithm2(x: number[]): number[] {
// the model to make decisions and save you the work of manually finding context and performing actions.

// 1. Switch from "Chat" to "Agent" mode using the dropdown in the bottom left of the input box
// 2. Try asking Continue "Write unit tests for this code in a new file"
// 2. Use the "/init" slash command to generate a CONTINUE.md file

// —————————————————— Learn more at https://docs.continue.dev/getting-started/overview ——————————————————— //
3 changes: 1 addition & 2 deletions extensions/vscode/continue_tutorial.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def sorting_algorithm2(x):
# the model to make decisions and save you the work of manually finding context and performing actions.

# 1. Switch from "Chat" to "Agent" mode using the dropdown in the bottom left of the input box
# 2. Try asking Continue "Write unit tests for this code in a new file",
# or if you have Python installed, "Write unit tests for this code in a new file and run the test"
# 2. Use the "/init" slash command to generate a CONTINUE.md file

# —————————————————— Learn more at https://docs.continue.dev/getting-started/overview ——————————————————— #
Loading