*** Settings ***
Documentation    Smoke tests for MCP Tool Adapter
Resource         ${CURDIR}/common.resource
Suite Setup      Setup Test Environment
Suite Teardown   Cleanup Test Environment

*** Variables ***
${HELPER}    ${CURDIR}/helper_mcp_adapter.py

*** Test Cases ***
Create MCP Adapter From Config
    [Documentation]    Create an adapter from a server config and verify properties
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    create-adapter    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Log    ${result.stderr}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    server-name: github
    Should Contain    ${result.stdout}    transport: stdio
    Should Contain    ${result.stdout}    connected: False

Discover MCP Tools
    [Documentation]    Connect and discover tools from a mock MCP server
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    discover-tools    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    discovered: 3
    Should Contain    ${result.stdout}    tool-0: create_issue

Invoke MCP Tool
    [Documentation]    Invoke a discovered tool and verify result
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    invoke-tool    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    success: True
    Should Contain    ${result.stdout}    has-data: True

Register MCP Tools In Registry
    [Documentation]    Register discovered tools into a ToolRegistry
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    register-tools    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    registered: 2
    Should Contain    ${result.stdout}    prefix: mcp-test/

Reject Stdio Config Without Command
    [Documentation]    Validate that stdio transport requires command
    ${result}=    Run Process    ${PYTHON}    ${HELPER}    reject-no-command    cwd=${WORKSPACE}
    Log    ${result.stdout}
    Should Be Equal As Integers    ${result.rc}    0
    Should Contain    ${result.stdout}    validation-error: command
