Problem:
I created a MCP server with SSE transport and hosted it using fastAPI in my virtual network (adding below the implementation). I was able to access this server through a browser in my network, but when I tried setting it up in cursor, it is failing with the below error:
2025-04-17 19:05:08.389 [error] -DPA: Client error for command SSE error: TypeError: fetch failed: unable to verify the first certificate
Did anyone see this error? If so, how did you fix it?
Implementation details:
- mcp_server with a simple tool:
from mcp.server.fastmcp import FastMCP
mcp = FastMCP(“name”)
@mcp.tool()
def some_tool(question: str) → str:
return “Hello, world!”if name == “main”:
mcp.run(transport=“stdio”)
- Hosted it using fastAPI:
…
sse = SseServerTransport(“/messages/”)
app.router.routes.append(Mount(“/messages”, app=sse.handle_post_message))@app.get("/sse", tags=["MCP"]) async def handle_sse(request: Request): """Handle SSE connections for MCP server.""" try: # Log request details logger.info(f"New SSE connection from {request.client.host}") logger.info(f"Request headers: {dict(request.headers)}") async with sse.connect_sse(request.scope, request.receive, request._send) as ( read_stream, write_stream, ): init_options = mcp._mcp_server.create_initialization_options() await mcp._mcp_server.run( read_stream, write_stream, init_options ) except Exception as e: logger.error(f"Error in MCP SSE handler: {str(e)}") logger.error(f"Traceback: {traceback.format_exc()}") return JSONResponse( status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, content={"error": "Internal server error"}, )
…
- When I tried accessing the endpoint through a terminal or a web browser, it is responding correctly (accessing SSE endpoint is returning the /messages endpoint)
For e.g., something like:
event: endpoint
data: /messages/?session_id=749358774849032423
- But when I tried to set this up in cursor using the below config, it is continuously failing with the above error:
{
“mcpServers”: {
“name”: {
“url”: “https://url/sse”
}
}
}