Skip to main content
Glama
markuskreitzer

PicoScope MCP Server

configure_channel

Set up oscilloscope channels by adjusting coupling, voltage range, offset, and enabling/disabling for precise signal measurement.

Instructions

Configure a channel on the oscilloscope.

Args: channel: Channel identifier (A, B, C, or D). enabled: Whether the channel is enabled. coupling: AC or DC coupling. voltage_range: Voltage range in volts (e.g., 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 20). analog_offset: DC offset voltage in volts.

Returns: Dictionary containing configuration status and applied settings.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
channelYes
enabledNo
couplingNoDC
voltage_rangeNo
analog_offsetNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The 'configure_channel' MCP tool handler, decorated with @mcp.tool(). It processes input arguments, constructs a ChannelConfig object, invokes the device_manager to apply the configuration, handles errors, and returns a status dictionary with applied settings.
    @mcp.tool()
    def configure_channel(
        channel: Literal["A", "B", "C", "D"],
        enabled: bool = True,
        coupling: Literal["AC", "DC"] = "DC",
        voltage_range: float = 5.0,
        analog_offset: float = 0.0,
    ) -> dict[str, Any]:
        """Configure a channel on the oscilloscope.
    
        Args:
            channel: Channel identifier (A, B, C, or D).
            enabled: Whether the channel is enabled.
            coupling: AC or DC coupling.
            voltage_range: Voltage range in volts (e.g., 0.02, 0.05, 0.1, 0.2, 0.5, 1, 2, 5, 10, 20).
            analog_offset: DC offset voltage in volts.
    
        Returns:
            Dictionary containing configuration status and applied settings.
        """
        try:
            if not device_manager.is_connected():
                return {
                    "status": "error",
                    "error": "No device connected",
                }
    
            # Create channel config
            config = ChannelConfig(
                channel=channel,
                enabled=enabled,
                coupling=ChannelCoupling.AC if coupling == "AC" else ChannelCoupling.DC,
                voltage_range=voltage_range,
                analog_offset=analog_offset,
            )
    
            # Configure the channel
            success = device_manager.configure_channel(config)
    
            if success:
                return {
                    "status": "success",
                    "channel": channel,
                    "enabled": enabled,
                    "coupling": coupling,
                    "voltage_range": voltage_range,
                    "analog_offset": analog_offset,
                }
            else:
                return {
                    "status": "error",
                    "error": "Failed to configure channel",
                    "channel": channel,
                }
    
        except Exception as e:
            return {
                "status": "error",
                "error": str(e),
                "channel": channel,
            }
  • Low-level 'configure_channel' method in PicoScopeManager class. Maps parameters to PicoSDK enums/constants, computes ADC values, calls ps5000aSetChannel API to configure the hardware channel, stores config, and returns success status.
    def configure_channel(self, config: ChannelConfig) -> bool:
        """Configure a channel.
    
        Args:
            config: Channel configuration.
    
        Returns:
            True if successful, False otherwise.
        """
        if not self.is_connected():
            return False
    
        try:
            # Map channel letter to PS5000A channel constant
            channel_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"],
            }
    
            if config.channel not in channel_map:
                return False
    
            # Map coupling type
            coupling = (
                ps.PS5000A_COUPLING["PS5000A_AC"]
                if config.coupling.value == "AC"
                else ps.PS5000A_COUPLING["PS5000A_DC"]
            )
    
            # Map voltage range to closest available range
            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",
            }
    
            # Find closest range
            closest_range = min(range_map.keys(), key=lambda x: abs(x - config.voltage_range))
            voltage_range = ps.PS5000A_RANGE[range_map[closest_range]]
    
            # Convert analog offset to ADC counts
            if self.device_info:
                analog_offset_adc = mV2adc(
                    config.analog_offset * 1000,  # V to mV
                    voltage_range,
                    self.device_info.max_adc_value
                )
            else:
                analog_offset_adc = 0
    
            # Set the channel
            self.status[f"setCh{config.channel}"] = ps.ps5000aSetChannel(
                self.chandle,
                channel_map[config.channel],
                1 if config.enabled else 0,
                coupling,
                voltage_range,
                analog_offset_adc
            )
    
            assert_pico_ok(self.status[f"setCh{config.channel}"])
    
            # Store configuration
            self.channel_configs[config.channel] = config
            return True
    
        except Exception as e:
            return False
  • ChannelConfig dataclass defining the structure for channel configuration data, used internally by the tool handler and device manager for type safety and validation.
    class ChannelConfig:
        """Channel configuration settings."""
    
        channel: str
        enabled: bool
        coupling: ChannelCoupling
        voltage_range: float
        analog_offset: float
  • Call to register_configuration_tools(mcp) in the main server setup, which registers the 'configure_channel' tool (and other configuration tools) with the FastMCP server instance.
    register_configuration_tools(mcp)
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 configures a channel, implying a write/mutation operation, but doesn't disclose critical traits like required permissions, whether changes are destructive or reversible, error conditions, or rate limits. The 'Returns' section hints at output but lacks behavioral context.

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

Conciseness4/5

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

The description is well-structured with a purpose statement, Args section, and Returns section. Every sentence earns its place by explaining parameters or output. It's appropriately sized for a 5-parameter tool, though the 'Returns' could be more concise given the output schema exists.

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's complexity (configuration/mutation), no annotations, and an output schema, the description is moderately complete. It explains parameters well but lacks behavioral context (e.g., side effects, errors). The output schema reduces the need to detail return values, but the description should address mutation implications more thoroughly.

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

Parameters4/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 compensate. It adds significant value by explaining all 5 parameters with clear semantics: channel identifiers, enabled state, coupling types, voltage range examples, and analog offset meaning. This goes beyond the bare schema, though it doesn't cover defaults or constraints like numeric ranges.

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 with a specific verb ('configure') and resource ('a channel on the oscilloscope'). It distinguishes itself from siblings like 'get_channel_config' (which reads) and 'configure_math_channel' (which configures a different resource). However, it doesn't explicitly contrast with all configuration siblings like 'configure_downsampling' or 'set_timebase'.

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 compare with siblings like 'get_channel_config' for reading settings or 'configure_math_channel' for math channels. Usage is implied only by the tool name and description.

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