Skip to content

Commit 5ee238f

Browse files
committed
chore: add pre-commit hooks and auto-format codebase
- Add pre-commit configuration with comprehensive hooks - Configure markdown linting with 120 char line limit - Add hooks for trailing whitespace, end-of-file, and line endings - Add Rust quality checks: cargo fmt, clippy, and check - Add TOML formatting and validation - Auto-format all files per pre-commit rules - Update README with pre-commit documentation
1 parent 601bc1e commit 5ee238f

File tree

23 files changed

+279
-142
lines changed

23 files changed

+279
-142
lines changed

.claude/settings.local.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818
],
1919
"deny": []
2020
}
21-
}
21+
}

.github/workflows/release-npm.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,17 +75,17 @@ jobs:
7575
run: |
7676
VERSION=${{ github.event.release.tag_name || github.event.inputs.version }}
7777
FILE="dist/timedate-mcp-server-${VERSION}-${{ matrix.target }}.${{ matrix.archive }}"
78-
78+
7979
# Check if release exists, create if not
8080
if ! gh release view "${VERSION}" >/dev/null 2>&1; then
8181
gh release create "${VERSION}" --title "Release ${VERSION}" --notes "Auto-generated release for ${VERSION}"
8282
fi
83-
83+
8484
# Upload or update asset
8585
if gh release view "${VERSION}" --json assets --jq '.assets[].name' | grep -q "timedate-mcp-server-${VERSION}-${{ matrix.target }}.${{ matrix.archive }}"; then
8686
gh release delete-asset "${VERSION}" "timedate-mcp-server-${VERSION}-${{ matrix.target }}.${{ matrix.archive }}" --yes
8787
fi
88-
88+
8989
gh release upload "${VERSION}" "${FILE}"
9090
9191
publish-npm:
@@ -108,7 +108,7 @@ jobs:
108108
VERSION=${{ github.event.release.tag_name || github.event.inputs.version }}
109109
# Remove 'v' prefix if present
110110
VERSION=${VERSION#v}
111-
111+
112112
# Update main package version and optionalDependencies
113113
jq --arg version "$VERSION" '
114114
.version = $version |
@@ -183,18 +183,18 @@ jobs:
183183
VERSION=${{ github.event.release.tag_name || github.event.inputs.version }}
184184
ARCHIVE_EXT=${{ matrix.target == 'x86_64-pc-windows-msvc' && 'zip' || 'tar.gz' }}
185185
ASSET_NAME="timedate-mcp-server-${VERSION}-${{ matrix.target }}.${ARCHIVE_EXT}"
186-
186+
187187
# Download the release asset
188188
gh release download "${VERSION}" --pattern "${ASSET_NAME}" --dir ./temp
189-
189+
190190
# Extract the binary
191191
cd temp
192192
if [[ "${ARCHIVE_EXT}" == "zip" ]]; then
193193
unzip "${ASSET_NAME}"
194194
else
195195
tar -xzf "${ASSET_NAME}"
196196
fi
197-
197+
198198
# Move binary to platform package directory
199199
mv "${{ matrix.binary }}" "../timedate-mcp-server/platform-packages/${{ matrix.platform }}/"
200200
@@ -204,7 +204,7 @@ jobs:
204204
VERSION=${{ github.event.release.tag_name || github.event.inputs.version }}
205205
# Remove 'v' prefix if present
206206
VERSION=${VERSION#v}
207-
207+
208208
# Update platform package version
209209
jq --arg version "$VERSION" '.version = $version' package.json > package.json.tmp && mv package.json.tmp package.json
210210
@@ -215,4 +215,4 @@ jobs:
215215
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
216216

217217
- name: Clean up
218-
run: rm -rf temp
218+
run: rm -rf temp

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ build/
2828
bin/
2929

3030
# Authentication
31-
~/.pulseengine/
31+
~/.pulseengine/

.markdownlint.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"default": true,
3+
"MD013": {
4+
"line_length": 120,
5+
"code_blocks": false,
6+
"tables": false
7+
},
8+
"MD033": false,
9+
"MD041": false
10+
}

.pre-commit-config.yaml

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# Pre-commit hooks configuration
2+
# Install: pip install pre-commit
3+
# Setup: pre-commit install
4+
# Run manually: pre-commit run --all-files
5+
6+
repos:
7+
# General file checks
8+
- repo: https://github.com/pre-commit/pre-commit-hooks
9+
rev: v5.0.0
10+
hooks:
11+
- id: trailing-whitespace
12+
exclude: '\.lock$'
13+
- id: end-of-file-fixer
14+
exclude: '\.lock$'
15+
- id: check-yaml
16+
args: ['--unsafe'] # Allow custom YAML tags
17+
- id: check-json
18+
- id: check-toml
19+
- id: check-added-large-files
20+
args: ['--maxkb=1000']
21+
- id: check-merge-conflict
22+
- id: check-case-conflict
23+
- id: mixed-line-ending
24+
args: ['--fix=lf']
25+
26+
# Markdown linting
27+
- repo: https://github.com/igorshubovych/markdownlint-cli
28+
rev: v0.42.0
29+
hooks:
30+
- id: markdownlint
31+
args: ['--fix']
32+
33+
# Rust formatting
34+
- repo: local
35+
hooks:
36+
- id: cargo-fmt
37+
name: cargo fmt
38+
entry: cargo fmt
39+
language: system
40+
types: [rust]
41+
pass_filenames: false
42+
43+
# Rust linting
44+
- repo: local
45+
hooks:
46+
- id: cargo-clippy
47+
name: cargo clippy
48+
entry: cargo clippy
49+
args: ['--all-targets', '--all-features', '--', '-D', 'warnings']
50+
language: system
51+
types: [rust]
52+
pass_filenames: false
53+
54+
# Rust security audit (optional - can be slow)
55+
- repo: local
56+
hooks:
57+
- id: cargo-check
58+
name: cargo check
59+
entry: cargo check
60+
args: ['--all-targets', '--all-features']
61+
language: system
62+
types: [rust]
63+
pass_filenames: false
64+
65+
# TOML sorting and formatting
66+
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
67+
rev: v2.14.0
68+
hooks:
69+
- id: pretty-format-toml
70+
args: ['--autofix']

Cargo.toml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
[workspace]
22
members = [
3-
"timedate-mcp-server"
3+
"timedate-mcp-server"
44
]
55
resolver = "2"
66

77
[workspace.dependencies]
8-
tokio = { version = "1.0", features = ["full"] }
9-
serde = { version = "1.0", features = ["derive"] }
10-
serde_json = "1.0"
11-
chrono = { version = "0.4", features = ["serde"] }
12-
chrono-tz = "0.10"
13-
tracing = "0.1"
14-
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
158
anyhow = "1.0"
16-
thiserror = "1.0"
17-
clap = { version = "4.0", features = ["derive"] }
189
async-trait = "0.1"
19-
schemars = { version = "1.0", features = ["chrono04"] }
20-
# Use published framework version 0.11.0
21-
pulseengine-mcp-server = { version = "0.11.0", features = ["stdio-logging"] }
10+
chrono = {version = "0.4", features = ["serde"]}
11+
chrono-tz = "0.10"
12+
clap = {version = "4.0", features = ["derive"]}
2213
pulseengine-mcp-macros = "0.11.0"
2314
pulseengine-mcp-protocol = "0.11.0"
15+
# Use published framework version 0.11.0
16+
pulseengine-mcp-server = {version = "0.11.0", features = ["stdio-logging"]}
2417
pulseengine-mcp-transport = "0.11.0"
18+
schemars = {version = "1.0", features = ["chrono04"]}
19+
serde = {version = "1.0", features = ["derive"]}
20+
serde_json = "1.0"
21+
thiserror = "1.0"
22+
tokio = {version = "1.0", features = ["full"]}
23+
tracing = "0.1"
24+
tracing-subscriber = {version = "0.3", features = ["env-filter"]}

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1818
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
21+
SOFTWARE.

README.md

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# TimeDate MCP Server
22

3-
A Model Context Protocol (MCP) server providing comprehensive time and date operations with timezone support, built with Rust and the PulseEngine MCP framework.
3+
A Model Context Protocol (MCP) server providing comprehensive time and date operations with timezone support,
4+
built with Rust and the PulseEngine MCP framework.
45

56
## Features
67

78
- **Current Time**: Get current time in any timezone
89
- **Time Calculations**: Add/subtract time from dates
9-
- **Timezone Conversion**: Convert time between different timezones
10+
- **Timezone Conversion**: Convert time between different timezones
1011
- **Timezone Information**: Get detailed timezone data including DST status
1112
- **Time Format Detection**: Detect and work with 12-hour/24-hour formats
1213
- **Timezone Listing**: Browse available timezones with filtering
@@ -29,44 +30,56 @@ timedate-mcp-server
2930
## Available Tools
3031

3132
### `get_current_time`
33+
3234
Get the current time in the specified timezone (defaults to system timezone).
3335

3436
**Parameters:**
37+
3538
- `timezone` (optional): Target timezone (e.g., "America/New_York", "Europe/London")
3639

3740
### `get_time_at`
41+
3842
Get time at a specific date and timezone.
3943

4044
**Parameters:**
45+
4146
- `date_time`: Date/time string (RFC3339, "YYYY-MM-DD HH:MM:SS", or "YYYY-MM-DD")
4247
- `timezone` (optional): Target timezone
4348

4449
### `calculate_time_offset`
50+
4551
Add or subtract time from a given date.
4652

4753
**Parameters:**
54+
4855
- `base_time`: Base time ("now" or date string)
4956
- `offset_hours`: Hours to add (positive) or subtract (negative)
5057
- `timezone` (optional): Target timezone
5158

5259
### `get_timezone_info`
60+
5361
Get information about the current system timezone.
5462

5563
### `convert_timezone`
64+
5665
Convert time between different timezones.
5766

5867
**Parameters:**
68+
5969
- `time`: Time to convert ("now" or date string)
6070
- `from_timezone`: Source timezone
6171
- `to_timezone`: Target timezone
6272

6373
### `get_time_format`
74+
6475
Detect time format preference (12-hour vs 24-hour).
6576

6677
### `list_timezones`
78+
6779
List available timezones with optional filtering.
6880

6981
**Parameters:**
82+
7083
- `filter` (optional): Filter string to match timezone names
7184

7285
## Example Usage
@@ -75,10 +88,10 @@ List available timezones with optional filtering.
7588
// Get current time in Tokyo
7689
await server.get_current_time({ timezone: "Asia/Tokyo" });
7790

78-
// Convert New York time to London time
91+
// Convert New York time to London time
7992
await server.convert_timezone({
8093
time: "2024-01-15 14:30:00",
81-
from_timezone: "America/New_York",
94+
from_timezone: "America/New_York",
8295
to_timezone: "Europe/London"
8396
});
8497

@@ -93,6 +106,7 @@ await server.calculate_time_offset({
93106
## Response Format
94107

95108
All time responses include:
109+
96110
- `timestamp`: ISO 8601/RFC3339 formatted time
97111
- `timezone`: Timezone identifier
98112
- `utc_offset`: UTC offset (e.g., "+0900", "-0500")
@@ -132,9 +146,35 @@ npm run build:darwin-arm64
132146
npm run build:win32-x64
133147
```
134148

149+
### Pre-commit Hooks
150+
151+
This project uses pre-commit hooks to ensure code quality:
152+
153+
```bash
154+
# Install pre-commit (if not already installed)
155+
pip install pre-commit
156+
157+
# Install git hooks
158+
pre-commit install
159+
160+
# Run manually on all files
161+
pre-commit run --all-files
162+
```
163+
164+
**Hooks included:**
165+
166+
- Trailing whitespace removal
167+
- End-of-file fixing
168+
- YAML/JSON/TOML validation
169+
- Markdown linting
170+
- Rust formatting (cargo fmt)
171+
- Rust linting (cargo clippy)
172+
- Rust compilation check
173+
135174
## Architecture
136175

137176
Built using:
177+
138178
- **Rust**: Core implementation for performance and safety
139179
- **PulseEngine MCP Framework**: MCP protocol implementation with macros
140180
- **Chrono & Chrono-TZ**: Comprehensive timezone and datetime handling
@@ -146,4 +186,4 @@ MIT License - see [LICENSE](LICENSE) for details.
146186

147187
## Contributing
148188

149-
Contributions welcome! Please read our contributing guidelines and submit pull requests to our [GitHub repository](https://github.com/pulseengine/timedate-mcp).
189+
Contributions welcome! Please read our contributing guidelines and submit pull requests to our [GitHub repository](https://github.com/pulseengine/timedate-mcp).

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "A Model Context Protocol server for time and date operations with timezone support",
55
"keywords": [
66
"mcp",
7-
"model-context-protocol",
7+
"model-context-protocol",
88
"time",
99
"date",
1010
"timezone",
@@ -35,7 +35,7 @@
3535
"build": "cargo build --release",
3636
"build:all": "npm run build:linux-x64 && npm run build:darwin-x64 && npm run build:darwin-arm64 && npm run build:win32-x64",
3737
"build:linux-x64": "cargo build --release --target x86_64-unknown-linux-gnu",
38-
"build:darwin-x64": "cargo build --release --target x86_64-apple-darwin",
38+
"build:darwin-x64": "cargo build --release --target x86_64-apple-darwin",
3939
"build:darwin-arm64": "cargo build --release --target aarch64-apple-darwin",
4040
"build:win32-x64": "cargo build --release --target x86_64-pc-windows-gnu",
4141
"test": "cargo test",
@@ -51,11 +51,11 @@
5151
},
5252
"optionalDependencies": {
5353
"@pulseengine/timedate-mcp-server-linux-x64": "0.1.0",
54-
"@pulseengine/timedate-mcp-server-darwin-x64": "0.1.0",
54+
"@pulseengine/timedate-mcp-server-darwin-x64": "0.1.0",
5555
"@pulseengine/timedate-mcp-server-darwin-arm64": "0.1.0",
5656
"@pulseengine/timedate-mcp-server-win32-x64": "0.1.0"
5757
},
5858
"publishConfig": {
5959
"access": "public"
6060
}
61-
}
61+
}

0 commit comments

Comments
 (0)