Skip to main content
Glama
juanqui

joulescope-mcp

by juanqui

Get device info

device_info
Read-only

Retrieve retained device topics and optional metadata for a JouleScope energy analyzer. Use to get device information and status.

Instructions

Return retained device topics and optional metadata for one JouleScope.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
device_pathNo
include_metadataNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The MCP tool registration for 'device_info' using @mcp.tool decorator. Defines the tool's title, description, annotations (read_only), structured output, and parameters (device_path, include_metadata). Delegates to service.device_info().
    @mcp.tool(
        title="Get device info",
        description="Return retained device topics and optional metadata for one JouleScope.",
        annotations=read_only,
        structured_output=True,
    )
    def device_info(device_path: str | None = None, include_metadata: bool = False) -> dict[str, Any]:
        try:
            return service.device_info(device_path=device_path, include_metadata=include_metadata)
        except JoulescopeMcpError as exc:
            raise _tool_error(exc) from exc
  • The actual handler logic for device_info in Js220Service. Opens a driver session, selects a device, subscribes to retained publications (pub_retain) and optionally metadata (metadata_rsp_retain), strips the device prefix from topic keys, and returns device_path, values dict, and optional metadata dict.
    def device_info(self, device_path: str | None = None, include_metadata: bool = False) -> dict[str, Any]:
        values: dict[str, Any] = {}
        metadata: dict[str, Any] = {}
    
        def on_pub(topic: str, value: Any) -> None:
            values[topic] = _jsonable(value)
    
        def on_metadata(topic: str, value: Any) -> None:
            metadata[topic[:-1] if topic.endswith("$") else topic] = _jsonable(value)
    
        with self._driver_session() as driver:
            device = self._select_device(driver, device_path=device_path, require_js220=False)
            driver.open(device, mode="restore")
            try:
                driver.subscribe(device, "pub_retain", on_pub)
                driver.unsubscribe(device, on_pub)
                if include_metadata:
                    driver.subscribe(device, "metadata_rsp_retain", on_metadata)
                    driver.unsubscribe(device, on_metadata)
            finally:
                driver.close(device)
    
        def strip_prefix(items: dict[str, Any]) -> dict[str, Any]:
            prefix = device + "/"
            return {k[len(prefix) :] if k.startswith(prefix) else k: v for k, v in sorted(items.items())}
    
        return {
            "device_path": device,
            "values": strip_prefix(values),
            "metadata": strip_prefix(metadata) if include_metadata else None,
        }
  • Function signature showing input parameters: device_path (str | None, default None) and include_metadata (bool, default False). Return type is dict[str, Any] with keys 'device_path', 'values', and 'metadata'.
    def device_info(self, device_path: str | None = None, include_metadata: bool = False) -> dict[str, Any]:
        values: dict[str, Any] = {}
  • Helper function strip_prefix used within device_info to remove the device path prefix from topic keys for cleaner output.
    def strip_prefix(items: dict[str, Any]) -> dict[str, Any]:
        prefix = device + "/"
        return {k[len(prefix) :] if k.startswith(prefix) else k: v for k, v in sorted(items.items())}
Behavior3/5

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

Annotations already declare readOnlyHint=true and destructiveHint=false. Description consistently says 'Return', confirming read-only operation. However, no additional behavioral details (e.g., behavior on missing device, response size) are added beyond annotations.

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?

Single sentence, concise and front-loaded. Every word is meaningful. Could add slight context without excessive length, but current length is efficient.

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?

Output schema exists, so return values are covered. However, tool complexity is low, but gaps remain: behavior when device_path is null (uses default?), what metadata entails, and relation to sibling tools. Adequate but not fully complete for a seamless agent usage.

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

Parameters2/5

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

Schema coverage is 0% for both parameters. Description only mentions 'retained device topics' (linked to device_path) and 'optional metadata' (linked to include_metadata). It does not explain format of device_path, default behavior when null, or what metadata includes. Insufficient compensation for missing schema descriptions.

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 it returns retained device topics and optional metadata for a single device (JouleScope). Verb 'Return' is specific, and 'for one JouleScope' distinguishes from sibling tools like list_devices (plural) or list_topics (general).

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

Usage Guidelines3/5

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

Description implies usage when needing a specific device's topics, but does not explicitly state when not to use it or mention alternative tools like list_devices or list_topics. Lacks usage exclusions or selection 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/juanqui/joulescope-mcp'

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