Skip to content
Open
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ dependencies = [
]

[project.optional-dependencies]
lsp = [
"pygls>=1.0.0",
]
dev = [
"pytest>=7.0.0",
"pytest-cov>=4.0.0",
Expand Down
10 changes: 9 additions & 1 deletion shellmcp/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
"""ShellMCP - Expose Shell Commands as MCP tools."""

__version__ = "0.1.0"
__version__ = "0.1.0"

# Import LSP components for easy access (optional)
try:
from .lsp.server import create_server
__all__ = ["create_server"]
except ImportError:
# LSP dependencies not available - install with: pip install shellmcp[lsp]
__all__ = []
39 changes: 38 additions & 1 deletion shellmcp/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,46 @@ def generate(config_file: str, output_dir: str = None, verbose: bool = False) ->
return 1


def lsp(log_level: str = "INFO") -> int:
"""
Start the LSP server for shellmcp YAML files.

Args:
log_level: Logging level (DEBUG, INFO, WARNING, ERROR)

Returns:
Exit code (0 for success, 1 for failure)
"""
try:
from .lsp.server import create_server
import logging

# Configure logging
logging.basicConfig(level=getattr(logging, log_level.upper()))

# Create and start server
server = create_server()
server.start_io()

return 0

except ImportError as e:
print("❌ LSP dependencies not installed.", file=sys.stderr)
print("", file=sys.stderr)
print("To install LSP support, run:", file=sys.stderr)
print(" pip install shellmcp[lsp]", file=sys.stderr)
print("", file=sys.stderr)
print("This will install the required pygls dependency for LSP functionality.", file=sys.stderr)
return 1
except Exception as e:
print(f"❌ Error starting LSP server: {e}", file=sys.stderr)
return 1


def main():
"""Main CLI entry point using Fire."""
fire.Fire({
'validate': validate,
'generate': generate
'generate': generate,
'lsp': lsp
})
83 changes: 83 additions & 0 deletions shellmcp/lsp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# ShellMCP LSP Server

LSP server providing autocomplete for shellmcp YAML configuration files.

## Features

- **Autocomplete**: Simple autocomplete for shellmcp YAML keys and values
- **Type Completions**: Built-in type suggestions (string, number, boolean, array)
- **YAML Keywords**: Basic YAML keyword completions (true, false, null)

## Installation

### Basic Installation
```bash
pip install shellmcp
```

### With LSP Support
```bash
pip install shellmcp[lsp]
```

## Usage

### Run LSP Server

```bash
shellmcp lsp
```

**Note**: If you get an import error, make sure you installed with LSP support:
```bash
pip install shellmcp[lsp]
```

### VS Code Configuration

The LSP server provides autocomplete without requiring schema configuration, but you can still add YAML schema support if desired.

## Autocomplete Features

### YAML Keys
- `server` - Server configuration
- `tools` - Tool definitions
- `resources` - Resource definitions
- `prompts` - Prompt definitions
- `args` - Reusable argument definitions

### Properties
- `name`, `desc`, `version`, `env` - Server properties
- `cmd`, `help-cmd`, `args` - Tool properties
- `uri`, `mime_type`, `file`, `text` - Resource properties
- `template` - Prompt properties
- `help`, `type`, `default`, `choices`, `pattern`, `ref` - Argument properties

### Types
- `string` - Text value
- `number` - Numeric value
- `boolean` - True/false value
- `array` - List of values

### YAML Keywords
- `true` - YAML true value
- `false` - YAML false value
- `null` - YAML null value

## Example

```yaml
server:
name: my-server
desc: My MCP server

tools:
Hello:
cmd: echo "Hello World"
desc: Say hello
args:
- name: name
help: Name to greet
type: string
default: "World"
```
3 changes: 3 additions & 0 deletions shellmcp/lsp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""LSP server for shellmcp YAML schema validation and completion."""

__version__ = "0.1.0"
Loading