Skip to main content
Glama

get-signal

Extract instances of a specific signal from a VCD file, enabling targeted analysis by defining signal name, file, and optional time range for efficient waveform parsing.

Instructions

Get all instances of a specified signal in a VCD file

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
end_timeNoEnd timestamp (optional)
file_nameYesName of the VCD file to analyze
signal_nameYesName of the signal to search for
start_timeNoStart timestamp (optional)

Implementation Reference

  • Executes the get-signal tool: extracts arguments, parses signal mappings if needed, looks up the signal character, retrieves matching lines using get_signal_lines, and returns the output or error.
    if name == "get-signal":
        file_name = arguments.get("file_name")
        signal_name = arguments.get("signal_name")
        start_time = arguments.get("start_time")
        end_time = arguments.get("end_time")
    
        if not file_name or not signal_name:
            raise ValueError("Missing required parameters")
    
        try:
            # Get or update signal mappings for this file
            if file_name not in signal_mappings:
                signal_mappings[file_name] = await parse_signal_mappings(file_name)
    
            # Look up the character for this signal
            signal_char = signal_mappings[file_name].get(signal_name)
            if not signal_char:
                return [types.TextContent(
                    type="text",
                    text=f"Signal '{signal_name}' not found in VCD file"
                )]
    
            # Get all lines containing this character within time range
            output = await get_signal_lines(file_name, signal_char, start_time, end_time)
    
            return [types.TextContent(
                type="text",
                text=output if output else "No match"
            )]
    
        except Exception as e:
            return [types.TextContent(
                type="text",
                text=str(e)
            )]
  • JSON schema defining the input parameters for the get-signal tool.
    inputSchema={
        "type": "object",
        "properties": {
            "file_name": {
                "type": "string",
                "description": "Name of the VCD file to analyze",
            },
            "signal_name": {
                "type": "string",
                "description": "Name of the signal to search for",
            },
            "start_time": {
                "type": "integer",
                "description": "Start timestamp (optional)",
            },
            "end_time": {
                "type": "integer",
                "description": "End timestamp (optional)",
            },
        },
        "required": ["file_name", "signal_name"],
    },
  • Registers the get-signal tool via the list_tools handler, including name, description, and schema.
    @server.list_tools()
    async def handle_list_tools() -> list[types.Tool]:
        """
        List available tools.
        Each tool specifies its arguments using JSON Schema validation.
        """
        return [
            types.Tool(
                name="get-signal",
                description="Get all instances of a specified signal in a VCD file",
                inputSchema={
                    "type": "object",
                    "properties": {
                        "file_name": {
                            "type": "string",
                            "description": "Name of the VCD file to analyze",
                        },
                        "signal_name": {
                            "type": "string",
                            "description": "Name of the signal to search for",
                        },
                        "start_time": {
                            "type": "integer",
                            "description": "Start timestamp (optional)",
                        },
                        "end_time": {
                            "type": "integer",
                            "description": "End timestamp (optional)",
                        },
                    },
                    "required": ["file_name", "signal_name"],
                },
            ),
        ]
  • Helper function to extract lines from VCD file containing the specific signal character within a time range.
    async def get_signal_lines(file_name: str, char: str, start_time: Optional[int] = None, end_time: Optional[int] = None) -> str:
        """Get all lines containing the specified character within the timestamp range."""
        try:
            matches = []
            current_time = 0
            with open(file_name, 'r') as f:
                for line_num, line in enumerate(f, 1):
                    line = line.rstrip()
    
                    # Update current timestamp if we see a timestamp marker
                    if line.startswith('#'):
                        try:
                            current_time = int(line[1:])
                        except ValueError:
                            continue
    
                    # Skip if we're before start_time
                    if start_time is not None and current_time < start_time:
                        continue
    
                    # Break if we're past end_time
                    if end_time is not None and current_time > end_time:
                        break
    
                    # If we're in the desired time range and line contains our character
                    if char in line:
                        matches.append(f"{line_num}:{line}")
    
            return '\n'.join(matches)
        except Exception as e:
            raise RuntimeError(f"Failed to read file: {str(e)}")
  • Helper function to parse the VCD file definitions section and map signal names to their single-character codes.
    async def parse_signal_mappings(file_name: str) -> Dict[str, str]:
        """Parse VCD file to extract signal name to character mappings."""
        mappings = {}
        try:
            with open(file_name, 'r') as f:
                for line in f:
                    if line.startswith('$enddefinitions'):
                        break
                    if line.startswith('$var'):
                        parts = line.split()
                        if len(parts) >= 5:
                            char, signal = parts[3], parts[4]
                            mappings[signal] = char
            return mappings
        except Exception as e:
            raise RuntimeError(f"Failed to parse signal mappings: {str(e)}")
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 mentions 'Get all instances' but doesn't specify whether this is a read-only operation, what permissions are needed, how results are returned (e.g., format, pagination), or any rate limits. This leaves critical behavioral traits undocumented.

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 a single, efficient sentence that directly states the tool's purpose without any unnecessary words or fluff. It is appropriately sized and front-loaded, making it easy for an agent to parse quickly.

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 moderate complexity (4 parameters, no output schema, no annotations), the description is minimally adequate. It covers the basic purpose but lacks details on usage, behavioral traits, and output format, which are important for an agent to use it effectively in the absence of structured data.

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

Parameters3/5

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

The input schema has 100% description coverage, clearly documenting all four parameters. The description adds no additional parameter details beyond what's in the schema, so it meets the baseline of 3 where the schema does the heavy lifting without compensating for any gaps.

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 action ('Get all instances') and the target ('specified signal in a VCD file'), providing a specific verb+resource combination. However, with no sibling tools mentioned, there's no opportunity to distinguish from alternatives, which prevents a perfect score.

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 offers no guidance on when to use this tool versus alternatives, prerequisites, or contextual constraints. It simply states what the tool does without any usage context, which is a significant gap in helping an agent make informed decisions.

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

Related 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/SeanMcLoughlin/mcp-vcd'

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