Skip to main content
Glama
fkesheh

Skill Management MCP Server

by fkesheh

run_skill_script

Execute scripts within skill directories with automatic dependency management, environment variable injection, and secure execution boundaries.

Instructions

Execute a script within a skill directory. Skills are modular libraries with reusable code - scripts can import from their own modules or use external dependencies.

IMPORTANT: ALWAYS use this tool to execute scripts. DO NOT use external bash/shell tools to execute scripts directly. This tool provides:

  • Automatic dependency management (Python PEP 723, npm packages)

  • Proper environment variable injection from .env files

  • Secure execution within skill directory boundaries

  • Proper error handling and output capture

SKILLS AS LIBRARIES: Scripts within a skill can import from local modules naturally:

weather-skill/
├── main.py          # Script that imports from modules below
├── api_client.py    # Reusable API client module
├── parsers.py       # Data parsing utilities
└── formatters.py    # Output formatting

In main.py:

from api_client import WeatherAPI
from formatters import format_temperature

api = WeatherAPI()
data = api.get_weather("London")
print(format_temperature(data))

Execute with:

{
  "skill_name": "weather-skill",
  "script_path": "main.py",
  "args": ["--city", "London"]
}

SUPPORTED LANGUAGES:

  • Python: Automatically detects and installs PEP 723 inline dependencies via 'uv run'

  • JavaScript/Node.js: Automatically runs 'npm install' if package.json exists

  • Bash: Executes shell scripts (.sh files)

  • Other: Any executable file with proper shebang line

FEATURES:

  • Module imports: Scripts can import from other files within the skill directory

  • Automatic PEP 723 dependency detection: Python scripts with inline metadata are automatically run with 'uv run'

  • Automatic npm dependency installation: Node.js scripts install dependencies from package.json

  • Environment variables: Loads skill-specific .env file and injects variables into script environment

  • Working directory: Can specify a subdirectory to run the script from

  • Arguments: Pass command-line arguments to the script

  • Output capture: Returns stdout, stderr, and exit code

PEP 723 AUTOMATIC DEPENDENCY DETECTION: Python scripts with inline dependencies are automatically detected and executed with 'uv run':

Example Python script with PEP 723 (e.g., weather-skill/fetch_weather.py):

#!/usr/bin/env python3
# /// script
# dependencies = [
#   "requests>=2.31.0",
#   "beautifulsoup4>=4.12.0",
# ]
# ///

import requests
from bs4 import BeautifulSoup

response = requests.get("https://api.weather.com/data")
print(response.json())

Execute with automatic dependency handling:

{
  "skill_name": "weather-skill",
  "script_path": "fetch_weather.py",
  "args": ["--city", "London"]
}

No manual dependency installation needed - the server automatically:

  1. Detects the PEP 723 metadata in your script

  2. Uses 'uv run' to create an isolated environment

  3. Installs the declared dependencies

  4. Executes your script with access to those dependencies

PARAMETERS:

  • skill_name: The name of the skill directory (e.g., 'weather-skill')

  • script_path: Relative path to the script within skill directory (e.g., 'main.py', 'scripts/fetch_weather.py', 'bin/process.sh')

  • args: Optional list of command-line arguments (e.g., ['--verbose', 'input.txt'])

  • working_dir: Optional working directory relative to skill root (e.g., 'scripts')

  • timeout: Optional timeout in seconds (defaults to 30 seconds if not specified)

IMPORTANT PATH NOTES:

  • All paths are RELATIVE to the skill directory, never absolute paths

  • Script path example: 'main.py' NOT '/Users/username/.skill-mcp/skills/my-skill/main.py'

  • Working dir example: 'scripts' NOT '/full/path/to/scripts'

RETURNS: Script execution result with:

  • Exit code (0 = success, non-zero = failure)

  • STDOUT (standard output)

  • STDERR (error output)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
skill_nameYesName of the skill
script_pathYesRelative path to the script within the skill directory
argsNoOptional command-line arguments to pass to the script
working_dirNoOptional working directory for script execution
timeoutNoOptional timeout in seconds (defaults to 30 seconds if not specified)

Implementation Reference

  • The primary handler function for the 'run_skill_script' tool. It calls ScriptService.run_script to execute the script and formats the output including exit code, stdout, and stderr.
    async def run_skill_script(input_data: RunSkillScriptInput) -> list[types.TextContent]:
        """Execute a skill script."""
        try:
            result = await ScriptService.run_script(
                input_data.skill_name,
                input_data.script_path,
                input_data.args,
                input_data.working_dir,
                input_data.timeout,
            )
    
            output = f"Script: {input_data.skill_name}/{input_data.script_path}\n"
            output += f"Exit code: {result.exit_code}\n\n"
    
            if result.stdout:
                output += f"STDOUT:\n{result.stdout}\n"
    
            if result.stderr:
                output += f"STDERR:\n{result.stderr}\n"
    
            if not result.stdout and not result.stderr:
                output += "(No output)\n"
    
            return [types.TextContent(type="text", text=output)]
        except SkillMCPException as e:
            return [types.TextContent(type="text", text=f"Error: {str(e)}")]
        except Exception as e:
            return [types.TextContent(type="text", text=f"Error running script: {str(e)}")]
  • Pydantic model defining the input schema (parameters and types) for the 'run_skill_script' tool.
    class RunSkillScriptInput(BaseModel):
        """Input for running a skill script."""
    
        skill_name: str = Field(description="Name of the skill")
        script_path: str = Field(description="Relative path to the script within the skill directory")
        args: Optional[List[str]] = Field(
            default=None, description="Optional command-line arguments to pass to the script"
        )
        working_dir: Optional[str] = Field(
            default=None, description="Optional working directory for script execution"
        )
        timeout: Optional[int] = Field(
            default=None,
            description="Optional timeout in seconds (defaults to 30 seconds if not specified)",
        )
  • The Tool object definition for 'run_skill_script', including name, detailed description, and input schema reference. This is returned by ScriptTools.get_script_tools().
                types.Tool(
                    name="run_skill_script",
                    description="""Execute a script within a skill directory. Skills are modular libraries with reusable code - scripts can import from their own modules or use external dependencies.
    
    IMPORTANT: ALWAYS use this tool to execute scripts. DO NOT use external bash/shell tools to execute scripts directly. This tool provides:
    - Automatic dependency management (Python PEP 723, npm packages)
    - Proper environment variable injection from .env files
    - Secure execution within skill directory boundaries
    - Proper error handling and output capture
    
    SKILLS AS LIBRARIES:
    Scripts within a skill can import from local modules naturally:
    ```
    weather-skill/
    ├── main.py          # Script that imports from modules below
    ├── api_client.py    # Reusable API client module
    ├── parsers.py       # Data parsing utilities
    └── formatters.py    # Output formatting
    ```
    
    In main.py:
    ```python
    from api_client import WeatherAPI
    from formatters import format_temperature
    
    api = WeatherAPI()
    data = api.get_weather("London")
    print(format_temperature(data))
    ```
    
    Execute with:
    ```json
    {
      "skill_name": "weather-skill",
      "script_path": "main.py",
      "args": ["--city", "London"]
    }
    ```
    
    SUPPORTED LANGUAGES:
    - Python: Automatically detects and installs PEP 723 inline dependencies via 'uv run'
    - JavaScript/Node.js: Automatically runs 'npm install' if package.json exists
    - Bash: Executes shell scripts (.sh files)
    - Other: Any executable file with proper shebang line
    
    FEATURES:
    - Module imports: Scripts can import from other files within the skill directory
    - **Automatic PEP 723 dependency detection**: Python scripts with inline metadata are automatically run with 'uv run'
    - Automatic npm dependency installation: Node.js scripts install dependencies from package.json
    - Environment variables: Loads skill-specific .env file and injects variables into script environment
    - Working directory: Can specify a subdirectory to run the script from
    - Arguments: Pass command-line arguments to the script
    - Output capture: Returns stdout, stderr, and exit code
    
    PEP 723 AUTOMATIC DEPENDENCY DETECTION:
    Python scripts with inline dependencies are automatically detected and executed with 'uv run':
    
    Example Python script with PEP 723 (e.g., weather-skill/fetch_weather.py):
    ```python
    #!/usr/bin/env python3
    # /// script
    # dependencies = [
    #   "requests>=2.31.0",
    #   "beautifulsoup4>=4.12.0",
    # ]
    # ///
    
    import requests
    from bs4 import BeautifulSoup
    
    response = requests.get("https://api.weather.com/data")
    print(response.json())
    ```
    
    Execute with automatic dependency handling:
    ```json
    {
      "skill_name": "weather-skill",
      "script_path": "fetch_weather.py",
      "args": ["--city", "London"]
    }
    ```
    
    No manual dependency installation needed - the server automatically:
    1. Detects the PEP 723 metadata in your script
    2. Uses 'uv run' to create an isolated environment
    3. Installs the declared dependencies
    4. Executes your script with access to those dependencies
    
    PARAMETERS:
    - skill_name: The name of the skill directory (e.g., 'weather-skill')
    - script_path: Relative path to the script within skill directory (e.g., 'main.py', 'scripts/fetch_weather.py', 'bin/process.sh')
    - args: Optional list of command-line arguments (e.g., ['--verbose', 'input.txt'])
    - working_dir: Optional working directory relative to skill root (e.g., 'scripts')
    - timeout: Optional timeout in seconds (defaults to 30 seconds if not specified)
    
    IMPORTANT PATH NOTES:
    - All paths are RELATIVE to the skill directory, never absolute paths
    - Script path example: 'main.py' NOT '/Users/username/.skill-mcp/skills/my-skill/main.py'
    - Working dir example: 'scripts' NOT '/full/path/to/scripts'
    
    RETURNS: Script execution result with:
    - Exit code (0 = success, non-zero = failure)
    - STDOUT (standard output)
    - STDERR (error output)""",
                    inputSchema=RunSkillScriptInput.model_json_schema(),
                ),
  • MCP server registration via list_tools() decorator, which includes ScriptTools.get_script_tools() to add the 'run_skill_script' tool to the server's tool list.
    @app.list_tools()  # type: ignore[misc]
    async def list_tools() -> list[types.Tool]:
        """List available tools."""
        tools = []
        tools.extend(SkillCrud.get_tool_definition())
        tools.extend(SkillFilesCrud.get_tool_definition())
        tools.extend(SkillEnvCrud.get_tool_definition())
        tools.extend(ScriptTools.get_script_tools())
        return tools
  • Dispatch handler in the MCP server's call_tool function that validates input with RunSkillScriptInput and delegates to ScriptTools.run_skill_script.
    elif name == "run_skill_script":
        script_input = RunSkillScriptInput(**arguments)
        return await ScriptTools.run_skill_script(script_input)
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure and does so comprehensively. It details automatic dependency management, environment variable injection, secure execution boundaries, error handling, output capture, timeout defaults, and supported languages. The only minor gap is that it doesn't explicitly mention authentication requirements or rate limits, though these might not apply to this type of tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness3/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is comprehensive but overly long with redundant sections. While well-structured with clear headings, it repeats information about PEP 723 and includes excessive implementation details that could be condensed. The core information could be presented more efficiently without sacrificing clarity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of the tool (script execution with dependency management, multiple languages, security boundaries) and the absence of both annotations and output schema, the description provides complete context. It thoroughly explains what the tool does, how to use it, behavioral characteristics, parameter semantics, and even documents the return structure despite no output schema being provided.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 100% schema description coverage, the baseline is 3. The description adds significant value by providing concrete examples of parameter usage (e.g., skill_name: 'weather-skill', script_path: 'main.py'), explaining path relativity rules in detail, and clarifying the timeout default. It also provides context about what each parameter enables (working_dir for subdirectory execution, args for command-line arguments).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('Execute a script within a skill directory') and distinguishes it from sibling tools by emphasizing that this is the ONLY tool to use for script execution, not external bash/shell tools or other siblings like execute_python_code. It provides concrete examples of what skills are and how they differ from general code execution.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides explicit guidance on when to use this tool ('ALWAYS use this tool to execute scripts') and when not to ('DO NOT use external bash/shell tools to execute scripts directly'). It distinguishes this from sibling tools by positioning it as the dedicated script execution mechanism within the skill system, unlike execute_python_code which appears to be for general Python code execution.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/fkesheh/skill-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server