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.
- To deploy the server remotely in a cloud environment, add the argument transport="http" to use Streamable HTTP transport.
When you deploy the server locally, you don’t need to specify a transport type. The default transport type, standard input/output (STDIO), works for local deployment. However, if you want to make your intent clear, you can add the argument transport="stdio".
- You can set a host, port, and path to bind when using HTTP transport.
- You can set the log level to debug, info, warning, error, or critical.
The following example shows a run() call with additional arguments: