Skip to content

Commit 14b8f9c

Browse files
committed
Disabling SSL verification for testing
1 parent c2ca8e0 commit 14b8f9c

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/mcp/client/__main__.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,12 +47,12 @@ async def run_session(
4747
logger.info("Initialized")
4848

4949

50-
async def main(command_or_url: str, args: list[str], env: list[tuple[str, str]]):
50+
async def main(command_or_url: str, args: list[str], env: list[tuple[str, str]], disable_ssl_verification: bool):
5151
env_dict = dict(env)
5252

5353
if urlparse(command_or_url).scheme in ("http", "https"):
5454
# Use SSE client for HTTP(S) URLs
55-
async with sse_client(command_or_url) as streams:
55+
async with sse_client(command_or_url, verify_ssl=not disable_ssl_verification) as streams:
5656
await run_session(*streams)
5757
else:
5858
# Use stdio client for commands
@@ -76,9 +76,15 @@ def cli():
7676
help="Environment variables to set. Can be used multiple times.",
7777
default=[],
7878
)
79+
parser.add_argument(
80+
"--disable-ssl-verification",
81+
nargs="+",
82+
default=[],
83+
help="Disable SSL verification when using HTTPS. SSL verification is enabled by default.",
84+
)
7985

8086
args = parser.parse_args()
81-
anyio.run(partial(main, args.command_or_url, args.args, args.env), backend="trio")
87+
anyio.run(partial(main, args.command_or_url, args.args, args.env, args.disable_ssl_verification if len(args.disable_ssl_verification) > 0 else False), backend="trio")
8288

8389

8490
if __name__ == "__main__":

src/mcp/client/sse.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ async def sse_client(
2424
headers: dict[str, Any] | None = None,
2525
timeout: float = 5,
2626
sse_read_timeout: float = 60 * 5,
27+
verify_ssl: bool = True,
2728
):
2829
"""
2930
Client transport for SSE.
@@ -43,7 +44,7 @@ async def sse_client(
4344
async with anyio.create_task_group() as tg:
4445
try:
4546
logger.info(f"Connecting to SSE endpoint: {remove_request_params(url)}")
46-
async with httpx.AsyncClient(headers=headers) as client:
47+
async with httpx.AsyncClient(headers=headers, verify=verify_ssl) as client:
4748
async with aconnect_sse(
4849
client,
4950
"GET",

0 commit comments

Comments
 (0)