View the source code for this module on GitHub: https://github.com/mcp-use/mcp-use/blob/main/mcp_use/utils.py
singleton
function
singleton
A decorator that implements the singleton pattern for a class.This decorator ensures that only one instance of a class is ever created.
Subsequent attempts to create a new instance will return the existing one.Usage:
@singleton
class MySingletonClass:
def init(self):… initialization …
passSignatureThe class to be decorated.