CLI & Entry Points
Relevant source files
The following files were used as context for generating this wiki page:
The Stacklet MCP Server provides a Command Line Interface (CLI) to manage server execution and agent configurations. It serves as the primary interface for users to start the Model Context Protocol (MCP) server and generate the necessary .mcp.json files for integration with MCP clients like Claude Desktop. Sources: CLAUDE.md:14-15, README.md:1-5
Entry Point Architecture
The project defines two primary methods for execution. The stacklet-mcp command is registered as a script in the project metadata. Users can also run the server as a Python module. Sources: pyproject.toml:29, stacklet/mcp/utils/mcp_json.py:53-61
Python Entry Points
| Entry Type | Command / Reference | File Source |
|---|---|---|
| Console Script | stacklet-mcp | pyproject.toml:29 |
| Module Execution | python -m stacklet.mcp | stacklet/mcp/utils/mcp_json.py:56 |
| Main Function | stacklet.mcp.mcp:main | stacklet/mcp/mcp.py:17 |
The main() function in mcp.py uses pydantic_settings.CliApp to initialize the CLI based on the CLIArguments class. It catches ValidationError and SettingsError to provide clean exit messages. Sources: stacklet/mcp/mcp.py:17-23
Execution Flow
The following diagram illustrates the startup sequence from the command line to the server execution or configuration generation.
CLI Command Groups
The CLI is organized into two main subcommands: run and agent-config. Sources: stacklet/mcp/cmdline.py:16-24
Run Command
The run command starts the FastMCP server. It is the default action if no subcommand is provided. Sources: tests/test_cmdline.py:32-34
- Behavior: Initializes the server factory and calls
server.run(). - Options: It suppresses the default FastMCP banner by setting
show_banner=False.
Sources: stacklet/mcp/cmdline.py:26-30
Agent-Config Command
The agent-config command manages the .mcp.json configuration files used by external agents. Sources: stacklet/mcp/cmdline.py:32-52
Subcommands:
- list: Displays available security profiles (
defaultandunrestricted). - generate: Produces a JSON string to standard output containing the server configuration for a specific profile.
Sources: stacklet/mcp/cmdline.py:38-52
Configuration Profiles
The server uses profiles to define environment variables that control feature flags and permissions. Sources: stacklet/mcp/utils/mcp_json.py:16-30
| Profile | Description | Capabilities |
|---|---|---|
default | Restricted access | Read-only; AssetDB save/archive and Platform mutations disabled. |
unrestricted | Full access | Write enabled; AssetDB save/archive and Platform mutations allowed. |
| Sources: stacklet/mcp/utils/mcp_json.py:20-29, CLAUDE.md:144-149 |
JSON Generation Logic
The generation process automatically detects the execution environment to ensure the generated config is valid. On Windows, it injects the PYTHONUTF8=1 environment variable to prevent encoding errors. Sources: stacklet/mcp/utils/mcp_json.py:68-71, README.md:61-64
Sources: stacklet/mcp/utils/mcp_json.py:53-72
Development Entry Points
For development environments, the project uses a justfile to wrap CLI commands:
just run: Starts the server.just agent-config: Generates the.mcp.jsonconfiguration.
Sources: CLAUDE.md:73-82
The CLI architecture ensures that permissions are explicitly defined at the entry point through environment variables, preventing accidental destructive operations by the LLM unless the unrestricted profile is used. Sources: README.md:16-20, stacklet/mcp/utils/mcp_json.py:20-29