model-context-protocol

How to enable multi-porting in FastMCP


I am trying to have multiple port setup for my different MCP servers using FastMCP. However, I am unable to set the port correctly. Here's my code

from mcp.server.fastmcp import FastMCP

mcp = FastMCP("Linux")

@mcp.tool()
def function(argument: str) -> str:
    return ""

mcp.run(transport="sse", port = 8082)

Solution

  • Found the problem, all i had to do was pass port parameter in the initialization of my server

    from mcp.server.fastmcp import FastMCP
    
    mcp = FastMCP("Linux", port = 8082)
    

    This would start the port on the desired address

    INFO:     Started server process [29007]
    INFO:     Waiting for application startup.
    INFO:     Application startup complete.
    INFO:     Uvicorn running on http://0.0.0.0:8083 (Press CTRL+C to quit)