A Python MCP server that works in Inspector can still fail in production because of an unpinned environment, an unbounded result, a blocking call, or a missing authentication check. Use this checklist to turn a working script into an operable service.
Environment and packaging
-
pyproject.tomland a lockfile are committed for applications; libraries use compatible version ranges. - Python version is declared and matches the deployment runtime.
-
uv sync --frozenor the equivalent creates a reproducible environment. - The client command points at an absolute interpreter or
uvpath. - No secrets, local absolute paths, or developer tokens are baked into the package.
Contract and validation
- Tool signatures use
Annotated, PydanticField,Literal, and bounded collections. - Every tool has a docstring that says what it does, what it does not do, and its main side effects.
- Destructive tools have explicit names and require an approval path.
- Credentials never appear as tool arguments.
- Errors distinguish validation, authorization, upstream failure, and timeout.
- Tool results are bounded and do not dump raw upstream payloads.
Async and resource control
- Network calls use an async client with connect and read timeouts.
- Blocking libraries are isolated with
asyncio.to_threador a worker. - Concurrency is capped per tool or tenant.
- Retries are bounded and limited to idempotent operations.
- Cancellation stops work and releases resources.
- Shared clients and pools close on shutdown.
Security
- Authentication is enforced before tool discovery and calls.
- Authorization checks the tenant and resource inside each tool.
- Remote endpoints use TLS; Origin validation is configured.
- Logs redact tokens, cookies, and sensitive payloads.
- Filesystem tools use allow-lists and path containment checks.
- HTTP-fetching tools consider SSRF, including localhost and metadata endpoints.
- Dependencies are audited and updated; the MCP SDK version is pinned.
Observability and operations
- Logging goes to stderr for stdio, or to the platform’s log collector for HTTP.
- Logs include request id, tool, duration, outcome; not arguments or secrets.
- A health endpoint exists for remote deployments.
- Metrics or at least counters exist for errors, timeouts, and tool calls.
- Alerts have an owner and a runbook.
- The container runs as a non-root user with resource limits.
- Backups, retention, and data deletion are defined for any persistent state.
Testing and release
- Unit tests cover the happy path, invalid input, permission denial, and upstream failure.
- An integration test uses the real MCP transport.
- The configuration in each supported client is tested from a fresh install.
- The README documents transports, environment variables, scopes, and limitations.
- A rollback procedure exists for both server and client config.
- The version and protocol revision are recorded in the release notes.
What not to claim
Do not claim “production ready” because the process starts. Do not claim a server is secure because it uses HTTPS. Do not claim compatibility with every client because one client connected. Record the exact clients, versions, and tests you performed, and mark everything else as unverified.
The same discipline applies to writes: a tool that sends email, moves money, closes issues, or deletes records needs an explicit human approval path and an audit trail. MCP does not provide those semantics; your server and workflow do.
For the TypeScript equivalent, see the TypeScript production checklist. For deployment mechanics, read deploy an MCP server, and for the security model, read securing MCP servers.
Sources
Sources were checked on Oct 23, 2026. Versions and client behavior can change; confirm the current documentation before relying on a configuration.