Skip to main content
Glama

set_pwm

Adjust PWM frequency from 0 to 100 to control IoT device behavior through MQTT communication.

Instructions

设置PWM频率,范围0-100

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
frequencyYesPWM频率值(0-100)

Implementation Reference

  • Executes the set_pwm tool: validates frequency argument (0-100), constructs MQTT payload 'PWM {frequency}'.
    if name == "set_pwm":
        frequency = arguments.get("frequency", 0)
        if not (0 <= frequency <= 100):
            return [types.TextContent(
                type="text",
                text="Error: Frequency must be between 0 and 100"
            )]
        message = f"PWM {frequency}"
  • Dynamically lists and registers MCP tools loaded from config.yaml, including set_pwm if configured, with schema derived from config parameters.
    @server.list_tools()
    async def handle_list_tools() -> List[types.Tool]:
        """List available tools."""
        tools = []
        for tool_name, tool_config in config.tools.items():
            tools.append(
                types.Tool(
                    name=tool_config.name,
                    description=tool_config.description,
                    inputSchema={
                        "type": "object",
                        "properties": {
                            param["name"]: {
                                "type": param["type"],
                                "description": param["description"],
                                **({"enum": param["enum"]} if "enum" in param else {})
                            }
                            for param in tool_config.parameters
                        },
                        "required": [
                            param["name"]
                            for param in tool_config.parameters
                            if param.get("required", False)
                        ]
                    }
                )
            )
        return tools
  • Constructs JSON schema for tool inputs from configuration parameters (used for set_pwm schema).
    inputSchema={
        "type": "object",
        "properties": {
            param["name"]: {
                "type": param["type"],
                "description": param["description"],
                **({"enum": param["enum"]} if "enum" in param else {})
            }
            for param in tool_config.parameters
        },
        "required": [
            param["name"]
            for param in tool_config.parameters
            if param.get("required", False)
        ]
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the action is to set PWM frequency, implying a write/mutation operation, but doesn't describe effects (e.g., whether this changes hardware output, requires specific permissions, or has side effects). It lacks details on rate limits, error handling, or what happens if the tool fails. For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

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 extremely concise ('设置PWM频率,范围0-100' - set PWM frequency, range 0-100), consisting of a single, front-loaded sentence that directly states the purpose and key constraint. There is no wasted text, and every part earns its place by conveying essential information efficiently.

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

Completeness2/5

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

Given the tool's complexity (a mutation operation to set PWM frequency), lack of annotations, and no output schema, the description is incomplete. It doesn't explain what the tool returns, potential errors, or behavioral traits like whether the setting is persistent. For a tool that likely interacts with hardware or low-level systems, more context on effects and limitations is needed to be fully helpful.

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?

The input schema has 100% description coverage, with the 'frequency' parameter fully documented in the schema (type: integer, description: 'PWM频率值(0-100)'). The description adds the same range information ('范围0-100'), providing no additional meaning beyond what the schema already states. According to the rules, when schema_description_coverage is high (>80%), the baseline is 3 even with no extra param info in the description.

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

Purpose4/5

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

The description clearly states the action ('设置PWM频率' - set PWM frequency) and specifies the resource (PWM), making the purpose understandable. It distinguishes from sibling tools like 'get_pico_info' (which likely reads info) and 'led_control' (which might control LEDs differently), though it doesn't explicitly contrast with them. The description is specific but lacks explicit sibling differentiation.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives like 'led_control' or other potential tools. It mentions the frequency range (0-100), which hints at valid usage contexts, but doesn't specify scenarios, prerequisites, or exclusions. Without explicit when/when-not instructions or named alternatives, it offers minimal usage direction.

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/mcp2everything/mcp2mqtt'

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