Skip to content

cannot use custom cert when connecting to server with MCPServerSse #1182

@Arif-Karim

Description

@Arif-Karim

Hello team,

Trying to connect to the server like this:


async with MCPServerSse(
                name="Sample Server",
                params={
                    "url": self.server_url,
                    "timeout": 60,
                }
            ) as mcp_server:
                logger.info(json.dumps({
                    "content": "MCP server connection established successfully",
                    "metadata": {
                        "server_name": "Sample Server",
                        "success": True
                    }
                }))
                mcp_agent = Agent(
                    name="MCP Agent",
                    instructions="You use the tools provided to answer the question",
                    model=self.model,
                    model_settings=ModelSettings(extra_headers= AzureOpenAIConnector.populate_extra_headers()),
                    mcp_servers=[mcp_server],
                )

However when i try and connect to the server I get self signed certificate error because the request is using our company's certs. I was able to get around the solution by setting

os.environ["REQUESTS_CA_BUNDLE"] = "/etc/ssl/certs/ca-certificates.crt"
os.environ["SSL_CERT_FILE"] = "/etc/ssl/certs/ca-certificates.crt"

before the execution and then reverting the cert back after the code execution. But my manager does not like the fact that I am setting the cert globally even if its just for the execution.

I have looked at the docs and cant seem to find a parameter to pass in a SSL context when using MCPServerSse.

Could you please suggest a way around this and if possible include a for us to pass in a SSL context in the future.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions