Skip to content

Conversation

@oskar-korczak
Copy link

Summary

This PR adds support for human-readable datetime formats across all time-based parameters (from, to, start, end, until), making it much easier for LLMs to specify time ranges without calculating epoch timestamps.

Supported Formats

Format Example Description
Epoch seconds 1732713600 Traditional Unix timestamp (number) - backward compatible
now now Current time
Relative time now-1h, now-30m, now-7d, now-2w Time relative to now (s/m/h/d/w)
ISO 8601 2025-11-28T12:00:00Z, 2025-11-28 Standard datetime format
Shortcuts yesterday, today, last week, last month Common time references

Example Usage

# Get logs from the last hour
from: "now-1h", to: "now"

# Get logs from yesterday
from: "yesterday", to: "today"

# Get logs for a specific date range
from: "2025-11-01", to: "2025-11-28"

Changes

  • New: src/utils/datetime-parser.ts - Centralized datetime parsing utility
  • Updated: All schema files to accept number | string union types for time parameters
  • Updated: All tool implementations to use the datetime parser before API calls
  • Added: 24 tests for the datetime parser
  • Updated: README with documentation for new datetime formats

Motivation

LLMs struggle with epoch timestamp calculations. This change allows natural language-like time specifications while maintaining full backward compatibility with numeric timestamps.

Test plan

  • All existing tests pass
  • New datetime parser tests pass (24 tests)
  • Build compiles successfully
  • Tested with Claude Code - LLM-friendly formats work correctly

🤖 Generated with Claude Code

- Add datetime parser utility that accepts multiple formats:
  - Epoch seconds (number) for backward compatibility
  - Relative time: now, now-1h, now-30m, now-7d, now-2w
  - ISO 8601: 2025-11-28T12:00:00Z, 2025-11-28
  - Shortcuts: yesterday, today, last week, last month

- Update all schema files to accept number | string union types
- Update all tool implementations to use the datetime parser
- Add comprehensive tests for the datetime parser
- Update README with documentation for new datetime formats

This makes it much easier for LLMs to specify time ranges without
needing to calculate epoch timestamps manually.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
oskar-korczak and others added 4 commits November 28, 2025 17:14
This ensures the TypeScript is compiled when installing via npx github:...

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Add chrono-node for natural language date parsing
- Support shorthand offsets: -1d, 2h, +1w
- Support abbreviated formats: 1d ago, 2h ago, in 1d
- Support "minus/plus" expressions: minus 1 day, plus 2 hours
- Maintain backward compatibility with now-1h format
- Expand unit aliases: s/sec/secs, m/min/mins, h/hr/hrs, etc.
- Update tests to cover new formats

Now supports all common LLM-generated datetime expressions.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
- Rename package to @oskar-korczak-complexio/mcp-server-datadog
- Update repository URL to fork
- Bump version to 1.8.0 (LLM-friendly datetime formats)
- Update publish workflow for OIDC (no NPM_TOKEN needed)
- Add test step to CI before publishing
- Switch from pnpm publish to npm publish (OIDC support)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant