A minimal Model Context Protocol (MCP) server that provides current local datetime information. This server serves as a blueprint for building simple, single-purpose MCP servers.
- current-time: Get current local datetime in a simple single-line format
- Bun runtime
# Clone and navigate to project
git clone <repository-url>
cd mcp-datetime
# Install dependencies
bun install
# Make executable
chmod +x src/index.ts
bun run src/index.ts
Add to ~/Library/Application Support/Claude/claude_desktop_config.json
(macOS) or %APPDATA%/Claude/claude_desktop_config.json
(Windows):
{
"mcpServers": {
"datetime": {
"command": "bun",
"args": ["/absolute/path/to/mcp-datetime/src/index.ts"]
}
}
}
{
"mcp": {
"servers": {
"datetime": {
"command": "bun",
"args": ["/absolute/path/to/mcp-datetime/src/index.ts"]
}
}
}
}
{
"tool": "current-time",
"parameters": {
"timezone": "America/New_York"
}
}
Response:
Monday, January 15, 2024 at 2:30:45 PM EST
# Run server
bun run src/index.ts
# Run tests
bun test
# Build for production
bun build src/index.ts --outdir=dist
src/
├── index.ts # Main entry point
├── server/
│ └── datetime-server.ts # MCP server configuration
├── tools/
│ ├── current-time.ts # Current time tool
│ └── current-time.test.ts # Unit tests
├── utils/
│ └── datetime-utils.ts # Shared utilities
└── types/
└── datetime.types.ts # Type definitions
This minimal server is designed to be easily extended:
- Add new tools: Create
src/tools/new-tool.ts
and register indatetime-server.ts
- Add resources: Create
src/resources/new-resource.ts
and register indatetime-server.ts
- Add validation: Use Zod schemas for input validation
- Add tests: Create
.test.ts
files alongside your tools
Run the test suite:
bun test
-
Permission Denied: Make sure
src/index.ts
is executablechmod +x src/index.ts
-
Timezone Issues: Ensure valid IANA timezone identifiers are used
MIT License - see LICENSE file for details.