Model Context Protocol (MCP) 1 · Python server
Log without breaking stdio
A stdio server must not write to stdout, which carries protocol messages. Log to stderr.
import logging, sys
logging.basicConfig(stream=sys.stderr, level=logging.INFO)
Official Model Context Protocol (MCP) 1 documentation
More python server commands
- Install the Python SDK
- Create a Python server with a tool
- Expose a resource
- Expose a prompt template
- Serve over HTTP
- Test with the dev server
All python server commands · Model Context Protocol (MCP) 1 cheatsheet