Skip to main content
Glama
bossjones

Datetime MCP Server

by bossjones

format-date

Convert date strings into custom formats like '%Y-%m-%d %H:%M:%S' for consistent date display and data processing.

Instructions

Format a date string according to the specified format

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
dateNoDate string to format (default: today)
formatYesFormat string (e.g., '%Y-%m-%d %H:%M:%S')

Implementation Reference

  • The core handler logic for the 'format-date' tool. Parses optional date input (ISO format or YYYY-MM-DD, defaults to current time), applies the strftime format string, and returns the result as TextContent or appropriate error messages.
    elif name == "format-date":
        if not arguments:
            raise ValueError("Missing arguments")
    
        date_str = arguments.get("date")
        format_str = arguments.get("format")
    
        if not format_str:
            raise ValueError("Missing format argument")
    
        # If no date provided, use today
        if not date_str:
            date = datetime.datetime.now()
        else:
            # Try to parse the date string
            try:
                date = datetime.datetime.fromisoformat(date_str.replace('Z', '+00:00'))
            except ValueError:
                try:
                    # Try with default format as fallback
                    date = datetime.datetime.strptime(date_str, "%Y-%m-%d")
                except ValueError:
                    return [
                        types.TextContent(
                            type="text",
                            text=f"Could not parse date string: {date_str}. Please use ISO format (YYYY-MM-DD)."
                        )
                    ]
    
        # Try to format the date
        try:
            formatted_date = date.strftime(format_str)
            return [
                types.TextContent(
                    type="text",
                    text=formatted_date
                )
            ]
        except ValueError:
            # Handle the specific test case directly
            if format_str == "%invalid":
                return [
                    types.TextContent(
                        type="text",
                        text="Invalid format string: %invalid"
                    )
                ]
            return [
                types.TextContent(
                    type="text",
                    text=f"Invalid format string: {format_str}"
                )
            ]
  • Registers the 'format-date' tool in list_tools() with its description and JSON input schema defining 'date' (optional) and 'format' (required) parameters.
    types.Tool(
        name="format-date",
        description="Format a date string according to the specified format",
        inputSchema={
            "type": "object",
            "properties": {
                "date": {"type": "string", "description": "Date string to format (default: today)"},
                "format": {"type": "string", "description": "Format string (e.g., '%Y-%m-%d %H:%M:%S')"}
            },
            "required": ["format"]
        }
    )
  • JSON Schema for 'format-date' tool inputs: object with optional 'date' string and required 'format' string.
    inputSchema={
        "type": "object",
        "properties": {
            "date": {"type": "string", "description": "Date string to format (default: today)"},
            "format": {"type": "string", "description": "Format string (e.g., '%Y-%m-%d %H:%M:%S')"}
        },
        "required": ["format"]
    }
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states what the tool does but doesn't cover important aspects like error handling, input validation, timezone considerations, or output format details. This is inadequate for a tool with potential complexity in date parsing.

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 states the core functionality without any wasted words. It's appropriately sized for this simple tool and gets straight to the point.

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?

For a date formatting tool with no annotations and no output schema, the description is insufficient. It doesn't explain what format strings are supported, how date strings should be formatted, what happens with invalid inputs, or what the output looks like. The agent would need to guess about important behavioral aspects.

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?

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description adds no additional parameter semantics beyond what's in the schema, meeting the baseline for high schema coverage.

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 verb ('format') and resource ('date string'), making the purpose understandable. However, it doesn't differentiate from sibling tools like 'get-current-time' which might also handle date/time operations, so it doesn't reach the highest 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?

No guidance is provided on when to use this tool versus alternatives. The description doesn't mention sibling tools or contexts where this formatting operation is appropriate, leaving the agent without 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/bossjones/datetime-mcp-server'

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