Skip to main content
Glama
sourcefuse

Robot Framework MCP Server

by sourcefuse

create_login_test_case

Generate Robot Framework test case code for login functionality. Returns complete .robot file content for automated login testing without execution.

Instructions

Generate Robot Framework test case code for login functionality. Returns the complete .robot file content as text - does not execute the test.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYes
usernameYes
passwordYes
template_typeNoappLocator

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The main handler function for the 'create_login_test_case' tool. It validates inputs, selects appropriate UI selectors based on template_type, substitutes variables into a Robot Framework template, and returns the generated test case code.
    @mcp.tool()
    def create_login_test_case(url: str, username: str, password: str, template_type: str = "appLocator") -> str:
        """Generate Robot Framework test case code for login functionality. Returns the complete .robot file content as text - does not execute the test."""
        try:
            # Validate inputs
            validated_url = InputValidator.validate_url(url)
            validated_username, validated_password = InputValidator.validate_credentials(username, password)
            
            # Get selector configuration
            selectors = SELECTOR_CONFIGS.get(template_type.lower(), SELECTOR_CONFIGS["generic"])
            
            # Use Template for safe variable substitution and correct Robot Framework syntax
            template = Template("""*** Settings ***
    Library    SeleniumLibrary
    
    *** Variables ***
    $${URL}           $url
    $${USERNAME}      $username
    $${PASSWORD}      $password
    $${BROWSER}       Chrome
    
    # Selector Variables
    $${USERNAME_FIELD}        $username_field
    $${PASSWORD_FIELD}        $password_field
    $${LOGIN_BUTTON}          $login_button
    $${SUCCESS_INDICATOR}     $success_indicator
    
    *** Test Cases ***
    Login Test
        [Documentation]    Test login functionality for $template_type
        [Tags]    smoke    login    $template_type
        Open Browser    $${URL}    $${BROWSER}
        Maximize Browser Window
        Input Text    $${USERNAME_FIELD}    $${USERNAME}
        Input Text    $${PASSWORD_FIELD}    $${PASSWORD}
        Click Button    $${LOGIN_BUTTON}
        Wait Until Page Contains Element    $${SUCCESS_INDICATOR}    10s
        Element Text Should Be    $${SUCCESS_INDICATOR}    Products
        [Teardown]    Close Browser
    """)
            
            return template.substitute(
                url=validated_url,
                username=validated_username,
                password=validated_password,
                template_type=template_type,
                username_field=selectors["username_field"],
                password_field=selectors["password_field"],
                login_button=selectors["login_button"],
                success_indicator=selectors["success_indicator"]
            )
            
        except ValidationError as e:
            return f"# VALIDATION ERROR: {str(e)}\n# Please correct the input and try again."
        except Exception as e:
            return f"# UNEXPECTED ERROR: {str(e)}\n# Please contact support."
  • mcp_server.py:113-113 (registration)
    The @mcp.tool() decorator registers the create_login_test_case function as an MCP tool.
    @mcp.tool()
  • Predefined SELECTOR_CONFIGS dictionary providing UI element selectors for different application template types (appLocator, generic, bootstrap), used by the tool to generate accurate test locators.
    SELECTOR_CONFIGS = {
        "appLocator": {
            "username_field": "id=user-name",
            "password_field": "id=password",
            "login_button": "id=login-button",
            "success_indicator": "xpath=//span[@class='title']",
            "error_message": "xpath=//h3[@data-test='error']",
            "logout_button": "id=logout_sidebar_link"
        },
        "generic": {
            "username_field": "id=username",
            "password_field": "id=password",
            "login_button": "css=button[type='submit']",
            "success_indicator": "css=.dashboard",
            "error_message": "css=.error",
            "logout_button": "css=.logout"
        },
        "bootstrap": {
            "username_field": "css=input[name='username']",
            "password_field": "css=input[name='password']",
            "login_button": "css=.btn-primary",
            "success_indicator": "css=.navbar-brand",
            "error_message": "css=.alert-danger",
            "logout_button": "css=.btn-outline-secondary"
        }
    }
  • InputValidator class providing static methods for validating URL, username, and password inputs used in the tool's try block.
    class InputValidator:
        """Centralized input validation for MCP tools"""
        
        @staticmethod
        def validate_url(url: str) -> str:
            """Validate and return sanitized URL"""
            if not url or not url.strip():
                raise ValidationError("URL cannot be empty")
            
            url = url.strip()
            try:
                result = urlparse(url)
                if not all([result.scheme, result.netloc]):
                    raise ValidationError(f"Invalid URL format: {url}")
                
                if result.scheme not in ['http', 'https']:
                    raise ValidationError(f"URL must use http or https protocol: {url}")
                    
                return url
            except Exception as e:
                raise ValidationError(f"URL validation failed: {str(e)}")
    
        @staticmethod
        def validate_credentials(username: str, password: str) -> tuple:
            """Validate and return sanitized credentials"""
            if not username or not username.strip():
                raise ValidationError("Username cannot be empty")
            
            if not password or not password.strip():
                raise ValidationError("Password cannot be empty")
            
            username = username.strip()
            password = password.strip()
            
            if len(username) > 100:
                raise ValidationError("Username too long (max 100 characters)")
            
            if len(password) > 100:
                raise ValidationError("Password too long (max 100 characters)")
            
            # Check for dangerous characters
            dangerous_chars = ['<', '>', '"', "'", '&', '\n', '\r', '\t']
            for char in dangerous_chars:
                if char in username or char in password:
                    raise ValidationError(f"Credentials contain invalid character: {char}")
            
            return username, password
        
        @staticmethod
        def validate_selector(selector: str) -> str:
            """Validate and return sanitized selector"""
            if not selector or not selector.strip():
                raise ValidationError("Selector cannot be empty")
            
            selector = selector.strip()
            
            # Basic validation patterns
            valid_patterns = [
                r'^id=.+',           # id=element-id
                r'^name=.+',         # name=element-name
                r'^class=.+',        # class=element-class
                r'^css=.+',          # css=.class-name
                r'^xpath=.+',        # xpath=//div[@id='test']
                r'^tag=.+',          # tag=input
                r'^\w+',             # plain CSS selector
            ]
            
            if not any(re.match(pattern, selector) for pattern in valid_patterns):
                raise ValidationError(f"Invalid selector format: {selector}")
            
            return selector
Behavior2/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. It states the tool generates code and returns file content without execution, which covers basic output behavior. However, it lacks details on permissions needed, error handling, rate limits, or whether the generation is deterministic or customizable beyond the parameters, leaving gaps for a mutation-like tool.

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

Conciseness5/5

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

The description is front-loaded with the core purpose in the first sentence and adds a critical behavioral note in the second. Every sentence earns its place by clarifying functionality and output without redundancy, making it efficient and well-structured.

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

Completeness3/5

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

Given the tool has an output schema (which should cover return values), the description need not explain outputs. However, with no annotations and 0% schema description coverage for parameters, the description is incomplete for a code-generation tool with 4 parameters, as it lacks details on parameter meanings, usage constraints, or behavioral nuances beyond basic output.

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

Parameters3/5

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

Schema description coverage is 0%, so the schema provides no parameter details. The description does not explain the parameters at all, failing to compensate for the coverage gap. However, with 4 parameters and no schema descriptions, the baseline is low, and the description adds no value beyond the schema, resulting in a minimal score.

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 ('Generate Robot Framework test case code') and resource ('for login functionality'), distinguishing it from siblings like create_api_integration_test or create_performance_monitoring_test by focusing on login-specific test generation. It also specifies the output format ('complete .robot file content as text'), which further clarifies its purpose.

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

Usage Guidelines3/5

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

The description implies usage for generating login test code, but does not explicitly state when to use this tool versus alternatives like create_page_object_login or validate_robot_framework_syntax. It mentions 'does not execute the test,' which provides some context on limitations, but lacks guidance on prerequisites or specific scenarios for selection.

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/sourcefuse/robotframework-mcp'

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