Skip to main content
Glama

get_elapsed_time

Retrieve the elapsed time for any tracked activity using its unique identifier, enabling precise duration monitoring within the Chronos Protocol MCP server.

Instructions

Get the elapsed time for an ongoing or completed activity

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
activityIdYesUnique identifier of the activity log

Implementation Reference

  • Main handler function in TimeServer that retrieves activity log from database and calculates elapsed time, returning formatted duration for both ongoing and completed activities.
    def get_elapsed_time(self, activity_id: str) -> Dict[str, Any]:
        """Get elapsed time for an activity"""
        log_data = self.db.get_activity_log(activity_id)
        if not log_data:
            raise ValueError(f"Activity log with ID {activity_id} not found")
    
        start_time = datetime.fromisoformat(log_data['startTime'].replace('Z', '+00:00'))
    
        if log_data['status'] == 'completed':
            end_time = datetime.fromisoformat(log_data['endTime'].replace('Z', '+00:00'))
            elapsed_seconds = int((end_time - start_time).total_seconds())
            return {
                'activityId': activity_id,
                'startTime': log_data['startTime'],
                'endTime': log_data['endTime'],
                'elapsedTime': format_duration(elapsed_seconds),
                'elapsedSeconds': elapsed_seconds,
                'status': 'completed'
            }
        else:
            current_time = datetime.now(ZoneInfo('UTC'))
            elapsed_seconds = int((current_time - start_time).total_seconds())
            return {
                'activityId': activity_id,
                'startTime': log_data['startTime'],
                'currentTime': current_time.isoformat(timespec="seconds"),
                'elapsedTime': format_duration(elapsed_seconds),
                'elapsedSeconds': elapsed_seconds,
                'status': 'ongoing'
            }
  • Registers the get_elapsed_time tool with the MCP server in list_tools(), defining name, description, and input schema requiring activityId.
    Tool(
        name=TimeTools.GET_ELAPSED_TIME.value,
        description="Get the elapsed time for an ongoing or completed activity",
        inputSchema={
            "type": "object",
            "properties": {
                "activityId": {
                    "type": "string",
                    "description": "Unique identifier of the activity log",
                },
            },
            "required": ["activityId"],
        },
    ),
  • In _execute_tool match statement, handles tool calls for get_elapsed_time by extracting activityId and invoking the TimeServer.get_elapsed_time handler.
    case TimeTools.GET_ELAPSED_TIME.value:
        activity_id = arguments.get("activityId")
        if not activity_id:
            raise ValueError("Missing required argument: activityId")
    
        result = time_server.get_elapsed_time(activity_id)
  • Pydantic model defining the structure of activity logs used by get_elapsed_time, including activityId, startTime, endTime, status essential for elapsed time calculation.
    class ActivityLog(BaseModel):
        activityId: str  # Changed from timeId for better naming
        activityType: str
        task_scope: TaskScope
        description: Optional[str] = None
        tags: Optional[List[str]] = None
        startTime: str
        endTime: Optional[str] = None
        duration: Optional[str] = None
        durationSeconds: Optional[int] = None
        result: Optional[str] = None
        notes: Optional[str] = None
        status: str  # "started", "completed"
  • Utility function used by the handler to format elapsed seconds into human-readable string (e.g., '2h 30m 45s').
    def format_duration(seconds: int) -> str:
        """Format duration in seconds to human-readable format"""
        if seconds < 60:
            return f"{seconds}s"
        elif seconds < 3600:
            minutes = seconds // 60
            remaining_seconds = seconds % 60
            return f"{minutes}m {remaining_seconds}s"
        else:
            hours = seconds // 3600
            remaining_minutes = (seconds % 3600) // 60
            remaining_seconds = seconds % 60
            return f"{hours}h {remaining_minutes}m {remaining_seconds}s"
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states what the tool does but lacks details on traits like whether it requires specific permissions, how it handles errors, if it's read-only or has side effects, or what the return format looks like. This leaves significant gaps for an agent to understand its behavior.

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 unnecessary words. It is front-loaded and appropriately sized, 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.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the lack of annotations and output schema, the description is incomplete. It does not explain what the tool returns (e.g., time format, units), error conditions, or behavioral nuances. For a tool that retrieves data, more context is needed to guide effective usage by an agent.

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, with 'activityId' clearly documented. The description does not add any additional meaning beyond the schema, such as format examples or constraints. With high schema coverage, the baseline score of 3 is appropriate as the schema handles the parameter documentation adequately.

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 ('Get') and resource ('elapsed time'), and specifies the target ('ongoing or completed activity'). However, it does not explicitly differentiate from sibling tools like 'get_activity_logs' or 'end_activity_log', which might also relate to activity timing or status.

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 does not mention prerequisites, context, or exclusions, such as whether it's for real-time monitoring, post-analysis, or how it differs from siblings like 'get_activity_logs' or 'check_time_reminders'.

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/n0zer0d4y/chronos-protocol'

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