Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,13 @@ shellmcp validate my-server.yml --verbose
### `shellmcp generate`
Generate a FastMCP server from YAML configuration.

**Default behavior**: Creates a subdirectory with the server name to prevent overwriting existing files.

```bash
# Generate with default output directory (creates ./my-server/ subdirectory)
shellmcp generate my-server.yml --verbose

# Generate with custom output directory
shellmcp generate my-server.yml --output-dir ./output --verbose
```

Expand Down
48 changes: 47 additions & 1 deletion docs/agentdocs/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,53 @@ shellmcp validate config.yml
shellmcp validate config.yml --verbose
```

**Output:**
### `generate`

Generate a FastMCP server from YAML configuration.

```bash
shellmcp generate <config_file> [--output-dir <dir>] [--verbose]
```

**Arguments:**
- `config_file`: Path to the YAML configuration file

**Flags:**
- `--output-dir`: Optional output directory (defaults to creating a subdirectory with the server name)
- `--verbose` / `-v`: Show detailed generation information

**Default Behavior:**
When no `--output-dir` is specified, the generator automatically creates a subdirectory named after the server (with spaces and hyphens converted to underscores). This prevents accidentally overwriting existing files like README.md in your current directory.

**Examples:**

```bash
# Generate with default output directory (creates ./my-server/ subdirectory)
shellmcp generate my-server.yml --verbose

# Generate with custom output directory
shellmcp generate my-server.yml --output-dir ./output --verbose
```

**Generate Output:**

The `generate` command creates a complete FastMCP server with the following files:

```
✅ FastMCP server generated successfully!
📁 Output directory: /path/to/my_mcp_server
🐍 Server file: /path/to/my_mcp_server/my_mcp_server_server.py
📦 Requirements: /path/to/my_mcp_server/requirements.txt
📖 Documentation: /path/to/my_mcp_server/README.md

🚀 To run the server:
cd /path/to/my_mcp_server
python3 -m venv venv && source venv/bin/activate
pip install -r requirements.txt
python my_mcp_server_server.py
```

**Validation Output:**

The `validate` command performs comprehensive validation including:

Expand Down
11 changes: 10 additions & 1 deletion docs/agentdocs/generator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,22 @@ The generator takes a YAML configuration file and produces:
### Command Line Interface

```bash
# Generate server from YAML configuration
# Generate server from YAML configuration (creates ./server-name/ subdirectory by default)
python -m shellmcp.cli generate config.yml --verbose

# Generate with custom output directory
python -m shellmcp.cli generate config.yml --output-dir ./output --verbose
```

**Default Output Directory Behavior**

When no `--output-dir` is specified, the generator automatically creates a subdirectory named after the server (with spaces and hyphens converted to underscores). This prevents accidentally overwriting existing files like README.md in your current directory.

For example, if your server is named "my-mcp-server", the generator will create a `my_mcp_server/` directory containing:
- `my_mcp_server_server.py` - The generated server
- `requirements.txt` - Python dependencies
- `README.md` - Documentation

### Programmatic Usage

```python
Expand Down
4 changes: 3 additions & 1 deletion shellmcp/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def generate(config_file: str, output_dir: str = None, verbose: bool = False) ->

Args:
config_file: Path to the YAML configuration file
output_dir: Optional output directory (defaults to same directory as config file)
output_dir: Optional output directory (defaults to creating a subdirectory with the server name)
verbose: Show detailed generation information

Returns:
Expand All @@ -116,6 +116,8 @@ def generate(config_file: str, output_dir: str = None, verbose: bool = False) ->

# Determine output directory
if output_dir is None:
# Default behavior: create a subdirectory with the server name
# This prevents accidentally overwriting existing files like README.md
config_dir = Path(config_file).parent
server_name = config.server.name.replace('-', '_').replace(' ', '_').lower()
output_dir = config_dir / server_name
Expand Down