Building Your Own MCP Server for AI
Remote MCP Servers
Move past a local stdio process and expose MCP over the network so another machine can connect.
stdio is one laptop, one host process. A remote server listens on a port so a teammate, a CI job, or a hosted agent can connect. The tools stay the same. The transport changes.
Why remote exists
- The server must see a private network the laptop is not on.
- You want one long-lived process, not a spawn per IDE window.
- The host only supports HTTP MCP for that connector.
Transports, in practice
Remote MCP uses Streamable HTTP. Bind and port go on run(), not on the constructor. Keep a stdio entry point for local Cursor; switch transport only when you mean to listen on a port.
import os
# Same MCPServer as the stdio lessons.
if __name__ == "__main__":
if os.environ.get("MCP_TRANSPORT") == "http":
mcp.run(transport="streamable-http", host="127.0.0.1", port=8000)
else:
mcp.run() # stdio — default for local CursorBind to 127.0.0.1 while you experiment. Exposing 0.0.0.0 without auth is a public tool API.
What the host config looks like
Instead of command and args, the host stores a URL (and often headers). Exact JSON keys differ by product. You will put HTTPS in front in the next lesson — do not ship raw HTTP on the public internet.
Check it
- Run the server with the HTTP transport your SDK documents.
- Open the health or MCP endpoint from the same machine (curl or the inspector).
- Point a second client at that URL only after it works locally.