Skip to main content
Glama
juanqui

joulescope-mcp

by juanqui

List topics

list_topics
Read-only

List retained JouleScope driver topics, showing current values and optional metadata, to explore available data points.

Instructions

List retained JouleScope driver topics with current values and optional metadata.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
device_pathNo
include_metadataNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The core implementation of list_topics. Calls self.device_info() to get all retained topics and their values, then optionally enriches each with metadata. Returns a dict with device_path and a list of topic items.
    def list_topics(self, device_path: str | None = None, include_metadata: bool = True) -> dict[str, Any]:
        info = self.device_info(device_path=device_path, include_metadata=include_metadata)
        topics = []
        values = info["values"]
        metadata = info.get("metadata") or {}
        for topic, value in values.items():
            item = {"topic": topic, "value": value}
            if include_metadata and topic in metadata:
                item["metadata"] = metadata[topic]
            topics.append(item)
        return {"device_path": info["device_path"], "topics": topics}
  • The @mcp.tool decorator registering list_topics as an MCP tool with title, description, read_only annotation, and structured_output=True. Defines the parameters device_path (optional str) and include_metadata (bool, default True).
    @mcp.tool(
        title="List topics",
        description="List retained JouleScope driver topics with current values and optional metadata.",
        annotations=read_only,
        structured_output=True,
    )
  • The MCP tool handler in the server layer. Delegates to service.list_topics() and wraps JoulescopeMcpError into ToolError.
    def list_topics(device_path: str | None = None, include_metadata: bool = True) -> dict[str, Any]:
        try:
            return service.list_topics(device_path=device_path, include_metadata=include_metadata)
        except JoulescopeMcpError as exc:
            raise _tool_error(exc) from exc
  • The device_info helper method called by list_topics. Subscribes to pub_retain and metadata_rsp_retain topics, collects values, and returns them with device_path.
    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,
        }
Behavior3/5

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

Annotations already indicate readOnlyHint=true and destructiveHint=false, so behavior is safe. Description adds that it lists 'retained' topics with current values and optional metadata, but does not disclose any further behavioral traits (e.g., pagination, error conditions, or effect of parameters). Adequate but not rich.

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?

Single sentence of 10 words, front-loaded with verb and noun, no filler. Every word adds value. Perfectly concise.

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 to explain return values, so description need not cover that. However, with 2 optional parameters and no explanation of their roles, the description is not fully complete. For a simple list tool it's adequate but misses opportunity to clarify device_path filtering.

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 description coverage is 0%, so description must compensate. It only hints at include_metadata via 'optional metadata', but device_path is completely unexplained. With two optional parameters, this leaves significant ambiguity about how to filter or scope the list.

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?

The description clearly states the verb 'List' and the resource 'retained JouleScope driver topics with current values and optional metadata', specifying scope and content. It distinguishes from sibling tools like query_topic (likely single topic) and publish_topic (write operation).

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?

No explicit guidance on when to use this tool versus alternatives like query_topic or device_info. The description implies listing all topics, but does not state when to avoid it or prerequisites. Minimal usage context.

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