Skip to main content
Glama
markuskreitzer

PicoScope MCP Server

set_simple_trigger

Configure basic edge triggering on PicoScope oscilloscopes by setting source channel, voltage threshold, edge direction, and auto-trigger timeout for signal capture.

Instructions

Set up a simple edge trigger.

Args: source: Trigger source channel or external. threshold_mv: Trigger threshold in millivolts. direction: Trigger on rising, falling, or either edge. auto_trigger_ms: Auto-trigger timeout in milliseconds (0 = disabled).

Returns: Dictionary containing trigger configuration status.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceYes
threshold_mvYes
directionNoRising
auto_trigger_msNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function for set_simple_trigger tool: validates inputs, maps to TriggerConfig, calls device_manager.set_trigger, returns status.
    @mcp.tool()
    def set_simple_trigger(
        source: Literal["A", "B", "C", "D", "External"],
        threshold_mv: float,
        direction: Literal["Rising", "Falling", "Rising_Or_Falling"] = "Rising",
        auto_trigger_ms: int = 1000,
    ) -> dict[str, Any]:
        """Set up a simple edge trigger.
    
        Args:
            source: Trigger source channel or external.
            threshold_mv: Trigger threshold in millivolts.
            direction: Trigger on rising, falling, or either edge.
            auto_trigger_ms: Auto-trigger timeout in milliseconds (0 = disabled).
    
        Returns:
            Dictionary containing trigger configuration status.
        """
        try:
            if not device_manager.is_connected():
                return {
                    "status": "error",
                    "error": "No device connected",
                }
    
            # Map direction string to enum
            direction_map = {
                "Rising": TriggerDirection.RISING,
                "Falling": TriggerDirection.FALLING,
                "Rising_Or_Falling": TriggerDirection.RISING_OR_FALLING,
            }
    
            # Create trigger config
            config = TriggerConfig(
                source=source,
                threshold_mv=threshold_mv,
                direction=direction_map[direction],
                auto_trigger_ms=auto_trigger_ms,
            )
    
            # Set trigger
            success = device_manager.set_trigger(config)
    
            if success:
                return {
                    "status": "success",
                    "source": source,
                    "threshold_mv": threshold_mv,
                    "direction": direction,
                    "auto_trigger_ms": auto_trigger_ms,
                }
            else:
                return {
                    "status": "error",
                    "error": "Failed to set trigger",
                }
    
        except Exception as e:
            return {
                "status": "error",
                "error": str(e),
            }
  • Registration block calling register_acquisition_tools(mcp), which defines and registers the set_simple_trigger tool via @mcp.tool() decorator.
    register_discovery_tools(mcp)
    register_configuration_tools(mcp)
    register_acquisition_tools(mcp)
    register_analysis_tools(mcp)
    register_advanced_tools(mcp)
  • Supporting method in device_manager that implements the actual trigger setup using PicoSDK's ps5000aSetSimpleTrigger, called by the tool handler.
    def set_trigger(self, config: TriggerConfig) -> bool:
        """Set up trigger.
    
        Args:
            config: Trigger configuration.
    
        Returns:
            True if successful, False otherwise.
        """
        if not self.is_connected():
            return False
    
        try:
            # Map source to channel
            source_map = {
                "A": ps.PS5000A_CHANNEL["PS5000A_CHANNEL_A"],
                "B": ps.PS5000A_CHANNEL["PS5000A_CHANNEL_B"],
                "C": ps.PS5000A_CHANNEL["PS5000A_CHANNEL_C"],
                "D": ps.PS5000A_CHANNEL["PS5000A_CHANNEL_D"],
                "External": ps.PS5000A_CHANNEL["PS5000A_EXTERNAL"],
            }
    
            if config.source not in source_map:
                return False
    
            # Map trigger direction
            direction_map = {
                "Rising": ps.PS5000A_THRESHOLD_DIRECTION["PS5000A_RISING"],
                "Falling": ps.PS5000A_THRESHOLD_DIRECTION["PS5000A_FALLING"],
                "Rising_Or_Falling": ps.PS5000A_THRESHOLD_DIRECTION[
                    "PS5000A_RISING_OR_FALLING"
                ],
            }
    
            direction = direction_map[config.direction.value]
    
            # Convert threshold from mV to ADC counts
            # Use the configured range for the source channel if available
            if config.source in self.channel_configs:
                ch_config = self.channel_configs[config.source]
                range_map = {
                    0.02: "PS5000A_20MV",
                    0.05: "PS5000A_50MV",
                    0.1: "PS5000A_100MV",
                    0.2: "PS5000A_200MV",
                    0.5: "PS5000A_500MV",
                    1.0: "PS5000A_1V",
                    2.0: "PS5000A_2V",
                    5.0: "PS5000A_5V",
                    10.0: "PS5000A_10V",
                    20.0: "PS5000A_20V",
                }
                closest_range = min(
                    range_map.keys(), key=lambda x: abs(x - ch_config.voltage_range)
                )
                voltage_range = ps.PS5000A_RANGE[range_map[closest_range]]
            else:
                voltage_range = ps.PS5000A_RANGE["PS5000A_2V"]  # Default
    
            threshold_adc = mV2adc(
                config.threshold_mv,
                voltage_range,
                self.device_info.max_adc_value if self.device_info else 32767,
            )
    
            # Set simple trigger
            self.status["trigger"] = ps.ps5000aSetSimpleTrigger(
                self.chandle,
                1,  # Enable trigger
                source_map[config.source],
                threshold_adc,
                direction,
                0,  # Delay (samples)
                config.auto_trigger_ms,  # Auto-trigger timeout
            )
    
            assert_pico_ok(self.status["trigger"])
            return True
    
        except Exception as e:
            return False
  • Dataclass defining the TriggerConfig structure used by the tool for input validation and passing to device_manager.set_trigger.
    @dataclass
    class TriggerConfig:
        """Trigger configuration settings."""
    
        source: str
        threshold_mv: float
        direction: TriggerDirection
        auto_trigger_ms: int
  • Enum defining TriggerDirection options matching the tool's direction parameter Literals.
    class TriggerDirection(str, Enum):
        """Trigger direction options."""
    
        RISING = "Rising"
        FALLING = "Falling"
        RISING_OR_FALLING = "Rising_Or_Falling"
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. It mentions the tool sets up a trigger and returns a status dictionary, but lacks critical behavioral details: whether this is a read/write operation, if it requires specific device states, potential side effects (e.g., interrupting streaming), or error conditions. The description is minimal and doesn't compensate for the absence of annotations.

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 well-structured and concise. It starts with a purpose statement, followed by a bulleted 'Args' section with clear explanations, and ends with return information. Every sentence earns its place, with no redundant or vague language, making it easy to parse quickly.

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

Completeness4/5

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

Given the complexity (a configuration tool with 4 parameters), no annotations, and an output schema (implied by 'Returns'), the description is reasonably complete. It explains all parameters thoroughly and notes the return format. However, it lacks context on integration with sibling tools (e.g., how triggering relates to 'capture_block'), slightly reducing completeness for an agent operating in this domain.

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

Parameters5/5

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

Schema description coverage is 0%, so the description must fully explain parameters. It does so effectively: each parameter is listed with clear semantics (e.g., 'threshold_mv: Trigger threshold in millivolts'), including units and practical meaning. This adds significant value beyond the bare schema, which only provides enums and types without context.

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 tool's purpose: 'Set up a simple edge trigger.' It specifies the action (set up) and resource (edge trigger), distinguishing it from siblings like 'configure_channel' or 'set_signal_generator' which handle different configurations. However, it doesn't explicitly differentiate from potential similar tools (none listed), keeping it at 4 rather than 5.

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. It doesn't mention prerequisites (e.g., device connection), exclusions, or context for edge triggering relative to other operations like 'capture_block' or 'start_streaming'. This lack of usage context leaves the agent without clear decision-making criteria.

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/markuskreitzer/picoscope_mcp'

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