-
Notifications
You must be signed in to change notification settings - Fork 399
Description
🐞 Bug Summary
I have an HTTPS MCP Server, created using self signed certificate.
I am trying to add that https mcp server with a self signed certificate to the MCP Server's in context forge. I am gettin 502 error when I click on ADD Gateway button.
I have used the default docker-compose to bring up the application.
The https mcpserver code is given below.
from typing import Any
import ssl
import uvicorn
from mcp.server.fastmcp import FastMCP
from mcp.server.fastmcp.prompts import base
Create the MCP server
mcp = FastMCP(
name="sample-mcp-server",
host="0.0.0.0",
port=8007,
)
Constants
NWS_API_BASE = "https://api.weather.gov"
USER_AGENT = "weather-app/1.0"
@mcp.resource("greeting://{name}")
def get_greeting(name: str) -> str:
"""Get a personalized greeting"""
return f"Hello, {name}!"
@mcp.resource("github://repos/{owner}/{repo}")
def github_repo(owner: str, repo: str) -> str:
"""GitHub repository resource."""
return f"Repository: {owner}/{repo}"
@mcp.prompt(title="Code Review")
def review_code(code: str) -> str:
"""Review code"""
return f"Please review this code:\n\n{code}"
@mcp.prompt(title="Debug Assistant")
def debug_error(error: str) -> list[base.Message]:
"""Assist with debugging"""
return [
base.UserMessage("I'm seeing this error:"),
base.UserMessage(error),
base.AssistantMessage("I'll help debug that. What have you tried so far?"),
]
@mcp.tool()
def sum(a: int, b: int) -> int:
"""Add two numbers together"""
return a + b
@mcp.tool()
def get_weather(city: str, unit: str = "celsius") -> str:
"""Get weather for a city"""
return f"Weather in {city}: 22degrees{unit[0].upper()}"
if name == "main":
# Create an SSL context
ssl_context = ssl.SSLContext(ssl.PROTOCOL_TLS_SERVER)
ssl_context.load_cert_chain(certfile="cert.pem", keyfile="key.pem")
# Access the internal FastAPI app (works across versions)
try:
asgi_app = mcp.fastapi_app # most recent versions
except AttributeError:
asgi_app = getattr(mcp, "app", mcp) # fallback to older style
# Serve the app securely
uvicorn.run(
asgi_app,
host="0.0.0.0",
port=8007,
ssl_keyfile="key.pem",
ssl_certfile="cert.pem",
)
🧩 Affected Component
Select the area of the project impacted:
-
mcpgateway- API -
mcpgateway- UI (admin panel) -
mcpgateway.wrapper- stdio wrapper - Federation or Transports
- CLI, Makefiles, or shell scripts
- Container setup (Docker/Podman/Compose)
- Other (explain below)
🔁 Steps to Reproduce
- ...
- ...
- ...
🤔 Expected Behavior
What should have happened instead?
📓 Logs / Error Output
Paste any relevant stack traces or logs here.
🧠 Environment Info
You can retrieve most of this from the /version endpoint.
| Key | Value |
|---|---|
| Version or commit | e.g. v0.9.0 or main@a1b2c3d |
| Runtime | e.g. Python 3.11, Gunicorn |
| Platform / OS | e.g. Ubuntu 22.04, macOS |
| Container | e.g. Docker, Podman, none |
🧩 Additional Context (optional)
Add any configuration details, flags, or related issues.