-
Notifications
You must be signed in to change notification settings - Fork 292
Description
π Bug Summary
I have the below MCP server code with transport "streamable_http".
By default from client side to call this, the endpoint will be http://{ip_address}/mcp or for protocol SSE it will be http://{ip_address}/sse
We can override this default path as below.
mcp = FastMCP(
name="another-mcp-server",
host="0.0.0.0",
port=8007,
base_path="/api" # Add this parameter
)
But with custom path, when I try to add, Gateways/MCP Servers, it is throwing below error.

Full Test Code:
`from typing import Any
import httpx
from mcp.server.fastmcp import FastMCP
from mcp.server.fastmcp.prompts import base
Create an MCP server
mcp = FastMCP(
name="another-mcp-server",
host="0.0.0.0",
port=8007,
base_path="/api" # Add this parameter
)
Constants
MATH_API_BASE = "https://api.math.com"
USER_AGENT = "math-app/1.0"
Add a dynamic calculator resource
@mcp.resource("calculator://{operation}/{num1}/{num2}")
def get_calculator_result(operation: str, num1: float, num2: float) -> float:
"""Get a calculator result"""
if operation == "add":
return num1 + num2
elif operation == "subtract":
return num1 - num2
elif operation == "multiply":
return num1 * num2
elif operation == "divide":
if num2 != 0:
return num1 / num2
else:
return float("inf")
else:
return float("nan")
@mcp.prompt(title="Math Problem")
def solve_math_problem(problem: str) -> str:
return f"Please solve this math problem:\n\n{problem}"
@mcp.prompt(title="Unit Converter")
def convert_units(value: float, from_unit: str, to_unit: str) -> list[base.Message]:
return [
base.UserMessage("I'm converting this value:"),
base.UserMessage(f"{value} {from_unit}"),
base.AssistantMessage(f"Converting to {to_unit}..."),
]
@mcp.tool()
def power(base: float, exponent: float) -> float:
"""Get the power of a number."""
return base ** exponent
@mcp.tool()
def get_random_string(length: int) -> str:
"""Get a random string of a given length."""
import random
import string
return ''.join(random.choice(string.ascii_lowercase) for _ in range(length))
Run the server
if name == "main":
mcp.run(transport="streamable-http")
`
Thanks,
Sunish
π§© 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.