from stinger_python_utils.mcp import (
    MethodDefinition,
    PropertyDefinition,
    SignalDefinition,
    StingerMCPPlugin,
)

from {{stinger.python.package_name}}.client import {{stinger.python.client_class_name}}, {{stinger.python.client_class_name}}Discoverer
from {{stinger.python.package_name}}.interface_types import *

class {{stinger.name|UpperCamelCase}}MCPPlugin(StingerMCPPlugin):
    """MCP plugin for the {{stinger.name}} interface."""

    def get_plugin_name(self) -> str:
        return "{{stinger.name|loweronly}}"
    
    def get_discovery_class(self) -> type:
        return {{stinger.python.client_class_name}}Discoverer

    def get_client_class(self) -> type:
        return {{stinger.python.client_class_name}}
    
    def get_signals(self) -> list[SignalDefinition]:
        return [
            {%for sig_name, sig in stinger.signals.items()%}
            SignalDefinition(
                name="{{sig_name|snake_case}}",
                description="{{sig.documentation | replace('\n', ' ') if sig.documentation else ''}}",
            ),
            {%endfor%}
        ]

    def get_methods(self) -> list[MethodDefinition]:
        return [
            {%for method_name, method in stinger.methods.items()%}
            MethodDefinition(
                name="{{method_name|snake_case}}",
                description="{{method.documentation | replace('\n', ' ') if method.documentation else ''}}",
                arguments_model={{method_name|UpperCamelCase}}MethodRequest,
            ),
            {%endfor%}
        ]

    def get_properties(self) -> list[PropertyDefinition]:
        return [
            {%for prop_name, prop in stinger.properties.items()%}
            PropertyDefinition(
                name="{{prop_name|snake_case}}",
                description="{{prop.documentation | replace('\n', ' ') if prop.documentation else ''}}",
                readonly={{prop.read_only and "True" or "False"}},
                schema={{prop.python.model_class_name}}.model_json_schema(),
            ),
            {%endfor%}
        ]
