Dynamic Application Loading with app_from_slug
One of the powerful features of Universal MCP is its ability to dynamically load application packages. If an application follows the standard naming convention (universal-mcp-<app-name>), it can often be loaded using the app_from_slug function.
The app_from_slug function (found in applications.__init__.py) handles several tasks:
- Derives Names: It determines the expected package name (e.g.,
universal_mcp_my_app), module path (e.g.,universal_mcp_my_app.app), and class name (e.g.,MyAppApp) from the provided slug (e.g.,"my-app"). - Installs/Upgrades Package: It attempts to install or upgrade the application package from the universal-mcp GitHub repository using
uv. The packages are installed into a dedicated directory (usually~/.universal-mcp/packages/). - Imports Module: It imports the application module.
- Retrieves Class: It gets the application class from the imported module.
reddit application.
examples/reddit_summary.py or examples/like_tweet.py) to quickly set up applications.
Manual Application Instantiation
If your application is part of your local project or you prefer more direct control, you can import and instantiate it directly:Configuring Applications in ServerConfig
When running a LocalServer, you typically define which applications to load in your server configuration file (e.g., local_config.json):
LocalServer will then iterate through this apps list, use app_from_slug to load each application class, instantiate it (potentially with the specified integration), and then register its tools.
Once an application is instantiated, its primary use is to provide tools to a ToolManager, which then makes them available to AI agents.