Exposing an AI Agent as an MCP server > Overview > Step 2. Run the MCP server
  

Step 2. Run the MCP server

Add code to the MCP server configuration that deploys the server either locally or remotely.
    1In server.py, call the run() method on the FastMCP instance.
    For example, add the following code:
    if __name__ == "__main__":
    mcp.run
    2If necessary, add arguments to the run() call.
    The following example shows a run() call with additional arguments:
    if __name__ == "__main__":
    mcp.run(
    transport="http",
    host="127.0.0.1",
    port=4200,
    path="/my-custom-path",
    log_level="debug",
    )
    3To deploy the server locally, run the server configuration file from the command line.
    You can run the file using the following Python command:
    python server.py
    Alternatively, if you have FastMCP installed, you can run the file with the following command:
    fastmcp run server.py
    4To deploy the server remotely, refer to the documentation for your cloud provider.
For more information about running a FastMCP server, see "Running Your Server" in the FastMCP documentation.