/python
/sdk
/best practices
Best Practices
- Controllers vs providers — tools/resources/prompts on
controllers; business logic on providers.
- Explicit DI —
@injectable(deps=[...]) matching __init__. Never construct services inside a tool.
- Pydantic descriptions —
Field(description=...) so clients and Inspector show useful schemas.
- Empty-string optionals — coerce Inspector
"" with field_validator(..., mode="before").
- Do not copy TypeScript — no Zod, no
@McpApp, no UseGuards(), no React widget SDK.
- Skills — rely on
nitrostack-py init / upgrade rather than pasting TS skills.
- Secrets —
.env is never packed; ship .env.example.
- OAuth — set
OAUTH_REQUIRED in production; default allow-without-token is for Studio mocks.
- Transports —
stdio for desktop clients; http + MCP_STATELESS=true for Inspector; dual in production.
- Validate before pack —
nitrostack-py validate.