Skip to main content
Glama
juanqui

joulescope-mcp

by juanqui

Read GPI

read_gpi
Read-only

Read the general-purpose input pin state from a JS220 device, returning both raw 32-bit value and decoded pin states.

Instructions

Read JS220 general-purpose input pin state as a 32-bit value and decoded pins.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
device_pathNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • MCP tool registration for 'read_gpi' with title, description, readOnly annotations, and structured_output=True.
    @mcp.tool(
        title="Read GPI",
        description="Read JS220 general-purpose input pin state as a 32-bit value and decoded pins.",
        annotations=read_only,
        structured_output=True,
    )
    def read_gpi(device_path: str | None = None) -> dict[str, Any]:
        try:
            return service.read_gpi(device_path=device_path)
        except JoulescopeMcpError as exc:
            raise _tool_error(exc) from exc
  • Core handler that opens a driver session, selects the device, publishes a request on 's/gpi/+/!req', waits for 's/gpi/+/!value' response, and returns the 32-bit GPI value plus decoded individual pin booleans.
    def read_gpi(self, device_path: str | None = None) -> dict[str, Any]:
        with self._driver_session() as driver:
            device = self._select_device(driver, device_path=device_path)
            driver.open(device, mode="restore")
            try:
                value = driver.publish_and_wait(
                    f"{device}/s/gpi/+/!req",
                    0,
                    f"{device}/s/gpi/+/!value",
                    timeout=1.0,
                )
            finally:
                driver.close(device)
        return {
            "device_path": device,
            "gpi_value": int(value),
            "gpi_hex": f"0x{int(value):08x}",
            "pins": {str(i): bool(int(value) & (1 << i)) for i in range(32)},
        }
  • Fake driver's publish_and_wait used for testing read_gpi; returns 0b101 (binary) as the mock GPI value.
    def publish_and_wait(self, *_args: Any, **_kwargs: Any) -> int:
        return 0b101
  • Unit test verifying read_gpi correctly decodes the pin mask from the fake driver's return value of 0b101.
    def test_read_gpi_decodes_pin_mask() -> None:
        result = service_with(FakeDriver()).read_gpi()
        assert result["gpi_hex"] == "0x00000005"
        assert result["pins"]["0"] is True
        assert result["pins"]["1"] is False
        assert result["pins"]["2"] is True
Behavior3/5

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

Annotations already indicate readOnlyHint=true and destructiveHint=false, so the description's claim of reading is consistent. No additional behavioral context (e.g., permissions, rate limits, side effects) is provided beyond what annotations convey. The idempotentHint=false is not explained.

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 a single sentence with no wasted words. However, it could be more structured to front-load the most critical information, but given its brevity, it is efficient.

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?

While an output schema exists (so return values need not be detailed), the description lacks parameter explanations and usage context. For a tool with one undocumented optional parameter, this is incomplete.

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

Parameters1/5

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

The only parameter, device_path, has no description in the schema (0% coverage). The description does not clarify its purpose, format, or effect, leaving the agent without guidance on how to use it.

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

Purpose5/5

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

Description clearly states the action (Read), the resource (JS220 general-purpose input pin state), and the output (32-bit value and decoded pins). It distinguishes from sibling tools which cover statistics, configuration, measurements, etc.

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?

No guidance on when to use this tool vs alternatives like measure_energy or device_info. No exclusions or prerequisites mentioned.

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/juanqui/joulescope-mcp'

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