mcp-datetime 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- mcp_datetime-0.1.0/.gitignore +22 -0
- mcp_datetime-0.1.0/LICENSE +21 -0
- mcp_datetime-0.1.0/PKG-INFO +188 -0
- mcp_datetime-0.1.0/README.md +168 -0
- mcp_datetime-0.1.0/README_ja.md +168 -0
- mcp_datetime-0.1.0/__init__.py +0 -0
- mcp_datetime-0.1.0/pyproject.toml +36 -0
- mcp_datetime-0.1.0/src/mcp_datetime/__init__.py +9 -0
- mcp_datetime-0.1.0/src/mcp_datetime/__main__.py +6 -0
- mcp_datetime-0.1.0/src/mcp_datetime/server.py +130 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Python-generated files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[oc]
|
|
4
|
+
build/
|
|
5
|
+
dist/
|
|
6
|
+
wheels/
|
|
7
|
+
*.egg-info
|
|
8
|
+
|
|
9
|
+
# Virtual environments
|
|
10
|
+
.venv/
|
|
11
|
+
venv/
|
|
12
|
+
ENV/
|
|
13
|
+
|
|
14
|
+
# LSP/IDE tools
|
|
15
|
+
pyrightconfig.json
|
|
16
|
+
.pylintrc
|
|
17
|
+
.vscode/
|
|
18
|
+
.idea/
|
|
19
|
+
|
|
20
|
+
# Package management
|
|
21
|
+
uv.lock
|
|
22
|
+
pip-log.txt
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 ZeparHyfar
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: mcp-datetime
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A MCP server for datetime formatting and file name generation.
|
|
5
|
+
Project-URL: Repository, https://github.com/ZeparHyfar/mcp-datetime.git
|
|
6
|
+
Author-email: ZeparHyfar <zeparhyfar@gmail.com>
|
|
7
|
+
License: MIT
|
|
8
|
+
Keywords: claude,datetime,format,mcp,time,timezone
|
|
9
|
+
Classifier: Development Status :: 3 - Alpha
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Requires-Python: >=3.12
|
|
15
|
+
Requires-Dist: mcp>=1.1.1
|
|
16
|
+
Provides-Extra: dev
|
|
17
|
+
Requires-Dist: pylint>=3.0.3; extra == 'dev'
|
|
18
|
+
Requires-Dist: pytest>=8.0.0; extra == 'dev'
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# mcp-datetime
|
|
22
|
+
|
|
23
|
+
[](https://www.python.org/downloads/)
|
|
24
|
+
[](https://github.com/anaisbetts/mcp)
|
|
25
|
+
[](LICENSE)
|
|
26
|
+
|
|
27
|
+
English | [日本語](README_ja.md)
|
|
28
|
+
|
|
29
|
+
A datetime formatting service implemented as an MCP server for the Claude Desktop Application. Supports generation of datetime strings in various formats.
|
|
30
|
+
|
|
31
|
+
## Features
|
|
32
|
+
|
|
33
|
+
- ✨ Support for various datetime formats
|
|
34
|
+
- 🇯🇵 Japanese language support
|
|
35
|
+
- 📁 Optimized formats for filename generation
|
|
36
|
+
- 🌏 Accurate timezone handling
|
|
37
|
+
- 🔧 Seamless integration with Claude Desktop App
|
|
38
|
+
|
|
39
|
+
## MCP Server Components
|
|
40
|
+
|
|
41
|
+
### Tools
|
|
42
|
+
|
|
43
|
+
The server implements one tool:
|
|
44
|
+
|
|
45
|
+
- `get_datetime`: Get current date and time in various formats
|
|
46
|
+
- Takes "format" as a required string argument
|
|
47
|
+
- Returns formatted datetime string based on specified format
|
|
48
|
+
- Supports multiple format types including standard, Japanese, and ISO formats
|
|
49
|
+
|
|
50
|
+
## Usage with Claude Desktop App
|
|
51
|
+
|
|
52
|
+
Add the following to your config file:
|
|
53
|
+
|
|
54
|
+
- Config file location:
|
|
55
|
+
|
|
56
|
+
- MacOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
57
|
+
- Windows: `%APPDATA%/Claude/claude_desktop_config.json`
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"mcpServers": {
|
|
62
|
+
"mcp-datetime": {
|
|
63
|
+
"command": "uvx",
|
|
64
|
+
"args": ["mcp-datetime"]
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
## About Installation
|
|
71
|
+
|
|
72
|
+
No installation is required for normal use. You can use this package by simply adding the configuration to your Claude Desktop App config file. The uvx command will automatically download and execute the package as needed.
|
|
73
|
+
|
|
74
|
+
If you need to install the package directly (e.g., for development or source code inspection), you can use one of these methods:
|
|
75
|
+
|
|
76
|
+
- Install from PyPI
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
pip install mcp-datetime
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
- Install from GitHub Source
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
git clone https://github.com/ZeparHyfar/mcp-datetime.git
|
|
86
|
+
cd mcp-datetime
|
|
87
|
+
pip install -e .
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
- `claude_desktop_config.json` for manual installation
|
|
91
|
+
|
|
92
|
+
```json
|
|
93
|
+
{
|
|
94
|
+
"mcpServers": {
|
|
95
|
+
"mcp-datetime": {
|
|
96
|
+
"command": "python",
|
|
97
|
+
"args": ["-m", "mcp_datetime"],
|
|
98
|
+
"env": {
|
|
99
|
+
"PYTHON": "/path/to/your/python"
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
- Replace "/path/to/your/python" with your actual Python interpreter path.
|
|
107
|
+
|
|
108
|
+
- Examples:
|
|
109
|
+
- MacOS: "/usr/local/bin/python3" or "/Users/username/.pyenv/versions/3.12.0/bin/python3"
|
|
110
|
+
- Windows: "C:\Python312\python.exe"
|
|
111
|
+
|
|
112
|
+
## Basic Examples
|
|
113
|
+
|
|
114
|
+
- Command format
|
|
115
|
+
|
|
116
|
+
```
|
|
117
|
+
# Standard datetime format
|
|
118
|
+
call datetime-service.get_datetime {"format": "datetime"}
|
|
119
|
+
# Result: 2024-12-10 00:54:01
|
|
120
|
+
|
|
121
|
+
# Japanese format
|
|
122
|
+
call datetime-service.get_datetime {"format": "datetime_jp"}
|
|
123
|
+
# Result: 2024年12月10日 00時54分01秒
|
|
124
|
+
|
|
125
|
+
# Filename format
|
|
126
|
+
call datetime-service.get_datetime {"format": "filename_md"}
|
|
127
|
+
# Result: 20241210005401.md
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
- Claude Desktop App prompt examples
|
|
131
|
+
|
|
132
|
+
- User
|
|
133
|
+
|
|
134
|
+
```
|
|
135
|
+
Please tell me the current time in date_slash format
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
- Claude
|
|
139
|
+
|
|
140
|
+
```
|
|
141
|
+
I'll get the current date in date_slash format.
|
|
142
|
+
|
|
143
|
+
The current date is 2024/12/12
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Supported Formats
|
|
147
|
+
|
|
148
|
+
| Format Name | Example | Description |
|
|
149
|
+
| ------------ | --------------------------- | ------------------------ |
|
|
150
|
+
| date | 2024-12-10 | Standard date format |
|
|
151
|
+
| date_slash | 2024/12/10 | Date with slashes |
|
|
152
|
+
| date_jp | 2024年12月10日 | Japanese date format |
|
|
153
|
+
| datetime | 2024-12-10 00:54:01 | Standard datetime |
|
|
154
|
+
| datetime_jp | 2024年12月10日 00時54分01秒 | Japanese datetime |
|
|
155
|
+
| datetime_t | 2024-12-10T00:54:01 | DateTime with T separator|
|
|
156
|
+
| compact | 20241210005401 | Compact format for IDs |
|
|
157
|
+
| compact_date | 20241210 | Compact date only |
|
|
158
|
+
| compact_time | 005401 | Compact time only |
|
|
159
|
+
| filename_md | 20241210005401.md | Markdown filename |
|
|
160
|
+
| filename_txt | 20241210005401.txt | Text filename |
|
|
161
|
+
| filename_log | 20241210005401.log | Log filename |
|
|
162
|
+
| iso | 2024-12-10T00:54:01+0900 | ISO 8601 format |
|
|
163
|
+
| iso_basic | 20241210T005401+0900 | Basic ISO format |
|
|
164
|
+
| log | 2024-12-10 00:54:01.123456 | Log format with microseconds|
|
|
165
|
+
| log_compact | 20241210_005401 | Compact log format |
|
|
166
|
+
| time | 00:54:01 | Time only |
|
|
167
|
+
| time_jp | 00時54分01秒 | Japanese time format |
|
|
168
|
+
|
|
169
|
+
## Debugging
|
|
170
|
+
|
|
171
|
+
Since MCP servers run over stdio, debugging can be challenging. We recommend using the [MCP Inspector](https://github.com/modelcontextprotocol/inspector):
|
|
172
|
+
|
|
173
|
+
- Using PyPI package
|
|
174
|
+
|
|
175
|
+
```
|
|
176
|
+
npx @modelcontextprotocol/inspector uvx mcp-datetime
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
- Using downloaded source code from GitHub
|
|
180
|
+
|
|
181
|
+
```
|
|
182
|
+
git clone https://github.com/ZeparHyfar/mcp-datetime.git
|
|
183
|
+
npx @modelcontextprotocol/inspector uvx --directory ./mcp-datetime run mcp-datetime
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
## License
|
|
187
|
+
|
|
188
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# mcp-datetime
|
|
2
|
+
|
|
3
|
+
[](https://www.python.org/downloads/)
|
|
4
|
+
[](https://github.com/anaisbetts/mcp)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
7
|
+
English | [日本語](README_ja.md)
|
|
8
|
+
|
|
9
|
+
A datetime formatting service implemented as an MCP server for the Claude Desktop Application. Supports generation of datetime strings in various formats.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- ✨ Support for various datetime formats
|
|
14
|
+
- 🇯🇵 Japanese language support
|
|
15
|
+
- 📁 Optimized formats for filename generation
|
|
16
|
+
- 🌏 Accurate timezone handling
|
|
17
|
+
- 🔧 Seamless integration with Claude Desktop App
|
|
18
|
+
|
|
19
|
+
## MCP Server Components
|
|
20
|
+
|
|
21
|
+
### Tools
|
|
22
|
+
|
|
23
|
+
The server implements one tool:
|
|
24
|
+
|
|
25
|
+
- `get_datetime`: Get current date and time in various formats
|
|
26
|
+
- Takes "format" as a required string argument
|
|
27
|
+
- Returns formatted datetime string based on specified format
|
|
28
|
+
- Supports multiple format types including standard, Japanese, and ISO formats
|
|
29
|
+
|
|
30
|
+
## Usage with Claude Desktop App
|
|
31
|
+
|
|
32
|
+
Add the following to your config file:
|
|
33
|
+
|
|
34
|
+
- Config file location:
|
|
35
|
+
|
|
36
|
+
- MacOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
37
|
+
- Windows: `%APPDATA%/Claude/claude_desktop_config.json`
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"mcpServers": {
|
|
42
|
+
"mcp-datetime": {
|
|
43
|
+
"command": "uvx",
|
|
44
|
+
"args": ["mcp-datetime"]
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## About Installation
|
|
51
|
+
|
|
52
|
+
No installation is required for normal use. You can use this package by simply adding the configuration to your Claude Desktop App config file. The uvx command will automatically download and execute the package as needed.
|
|
53
|
+
|
|
54
|
+
If you need to install the package directly (e.g., for development or source code inspection), you can use one of these methods:
|
|
55
|
+
|
|
56
|
+
- Install from PyPI
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pip install mcp-datetime
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
- Install from GitHub Source
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
git clone https://github.com/ZeparHyfar/mcp-datetime.git
|
|
66
|
+
cd mcp-datetime
|
|
67
|
+
pip install -e .
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
- `claude_desktop_config.json` for manual installation
|
|
71
|
+
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"mcpServers": {
|
|
75
|
+
"mcp-datetime": {
|
|
76
|
+
"command": "python",
|
|
77
|
+
"args": ["-m", "mcp_datetime"],
|
|
78
|
+
"env": {
|
|
79
|
+
"PYTHON": "/path/to/your/python"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
- Replace "/path/to/your/python" with your actual Python interpreter path.
|
|
87
|
+
|
|
88
|
+
- Examples:
|
|
89
|
+
- MacOS: "/usr/local/bin/python3" or "/Users/username/.pyenv/versions/3.12.0/bin/python3"
|
|
90
|
+
- Windows: "C:\Python312\python.exe"
|
|
91
|
+
|
|
92
|
+
## Basic Examples
|
|
93
|
+
|
|
94
|
+
- Command format
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
# Standard datetime format
|
|
98
|
+
call datetime-service.get_datetime {"format": "datetime"}
|
|
99
|
+
# Result: 2024-12-10 00:54:01
|
|
100
|
+
|
|
101
|
+
# Japanese format
|
|
102
|
+
call datetime-service.get_datetime {"format": "datetime_jp"}
|
|
103
|
+
# Result: 2024年12月10日 00時54分01秒
|
|
104
|
+
|
|
105
|
+
# Filename format
|
|
106
|
+
call datetime-service.get_datetime {"format": "filename_md"}
|
|
107
|
+
# Result: 20241210005401.md
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
- Claude Desktop App prompt examples
|
|
111
|
+
|
|
112
|
+
- User
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
Please tell me the current time in date_slash format
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
- Claude
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
I'll get the current date in date_slash format.
|
|
122
|
+
|
|
123
|
+
The current date is 2024/12/12
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Supported Formats
|
|
127
|
+
|
|
128
|
+
| Format Name | Example | Description |
|
|
129
|
+
| ------------ | --------------------------- | ------------------------ |
|
|
130
|
+
| date | 2024-12-10 | Standard date format |
|
|
131
|
+
| date_slash | 2024/12/10 | Date with slashes |
|
|
132
|
+
| date_jp | 2024年12月10日 | Japanese date format |
|
|
133
|
+
| datetime | 2024-12-10 00:54:01 | Standard datetime |
|
|
134
|
+
| datetime_jp | 2024年12月10日 00時54分01秒 | Japanese datetime |
|
|
135
|
+
| datetime_t | 2024-12-10T00:54:01 | DateTime with T separator|
|
|
136
|
+
| compact | 20241210005401 | Compact format for IDs |
|
|
137
|
+
| compact_date | 20241210 | Compact date only |
|
|
138
|
+
| compact_time | 005401 | Compact time only |
|
|
139
|
+
| filename_md | 20241210005401.md | Markdown filename |
|
|
140
|
+
| filename_txt | 20241210005401.txt | Text filename |
|
|
141
|
+
| filename_log | 20241210005401.log | Log filename |
|
|
142
|
+
| iso | 2024-12-10T00:54:01+0900 | ISO 8601 format |
|
|
143
|
+
| iso_basic | 20241210T005401+0900 | Basic ISO format |
|
|
144
|
+
| log | 2024-12-10 00:54:01.123456 | Log format with microseconds|
|
|
145
|
+
| log_compact | 20241210_005401 | Compact log format |
|
|
146
|
+
| time | 00:54:01 | Time only |
|
|
147
|
+
| time_jp | 00時54分01秒 | Japanese time format |
|
|
148
|
+
|
|
149
|
+
## Debugging
|
|
150
|
+
|
|
151
|
+
Since MCP servers run over stdio, debugging can be challenging. We recommend using the [MCP Inspector](https://github.com/modelcontextprotocol/inspector):
|
|
152
|
+
|
|
153
|
+
- Using PyPI package
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
npx @modelcontextprotocol/inspector uvx mcp-datetime
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
- Using downloaded source code from GitHub
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
git clone https://github.com/ZeparHyfar/mcp-datetime.git
|
|
163
|
+
npx @modelcontextprotocol/inspector uvx --directory ./mcp-datetime run mcp-datetime
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## License
|
|
167
|
+
|
|
168
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# mcp-datetime
|
|
2
|
+
|
|
3
|
+
[](https://www.python.org/downloads/)
|
|
4
|
+
[](https://github.com/anaisbetts/mcp)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
7
|
+
[English](README.md) | 日本語
|
|
8
|
+
|
|
9
|
+
Claude Desktop Application用のMCPサーバーとして実装された日時フォーマットサービスです。様々な形式での日時文字列生成をサポートしています。
|
|
10
|
+
|
|
11
|
+
## 特徴
|
|
12
|
+
|
|
13
|
+
- ✨ 各種の日時フォーマットをサポート
|
|
14
|
+
- 🇯🇵 日本語対応
|
|
15
|
+
- 📁 ファイル名生成に最適化された形式
|
|
16
|
+
- 🌏 タイムゾーンの正確な処理
|
|
17
|
+
- 🔧 Claude Desktop Appとのシームレスな連携
|
|
18
|
+
|
|
19
|
+
## MCPサーバーコンポーネント
|
|
20
|
+
|
|
21
|
+
### ツール
|
|
22
|
+
|
|
23
|
+
このサーバーは1つのツールを実装しています:
|
|
24
|
+
|
|
25
|
+
- `get_datetime`: 現在の日時を様々な形式で取得
|
|
26
|
+
- "format"を必須の文字列引数として受け取ります
|
|
27
|
+
- 指定された形式でフォーマットされた日時文字列を返します
|
|
28
|
+
- 標準形式、日本語形式、ISO形式など、複数の形式タイプをサポート
|
|
29
|
+
|
|
30
|
+
## Claude Desktop Appでの使用方法
|
|
31
|
+
|
|
32
|
+
設定ファイルに以下を追加してください:
|
|
33
|
+
|
|
34
|
+
- 設定ファイルの場所:
|
|
35
|
+
|
|
36
|
+
- MacOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
37
|
+
- Windows: `%APPDATA%/Claude/claude_desktop_config.json`
|
|
38
|
+
|
|
39
|
+
```json
|
|
40
|
+
{
|
|
41
|
+
"mcpServers": {
|
|
42
|
+
"mcp-datetime": {
|
|
43
|
+
"command": "uvx",
|
|
44
|
+
"args": ["mcp-datetime"]
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## インストールについて
|
|
51
|
+
|
|
52
|
+
通常はインストール作業は必要ありません。Claude デスクトップアプリの設定ファイルに設定を追加するだけで使用できます。 uvxが必要に応じてパッケージを自動的にダウンロードし実行します。
|
|
53
|
+
|
|
54
|
+
ソースコードの確認や開発目的など、パッケージを直接インストールする必要がある場合は、以下の方法でインストールできます:
|
|
55
|
+
|
|
56
|
+
- PyPIからインストール
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
pip install mcp-datetime
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
- GitHubのソースコードからインストール
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
git clone https://github.com/ZeparHyfar/mcp-datetime.git
|
|
66
|
+
cd mcp-datetime
|
|
67
|
+
pip install -e .
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
- 手動でインストールした場合の`claude_desktop_config.json`
|
|
71
|
+
|
|
72
|
+
```json
|
|
73
|
+
{
|
|
74
|
+
"mcpServers": {
|
|
75
|
+
"mcp-datetime": {
|
|
76
|
+
"command": "python",
|
|
77
|
+
"args": ["-m", "mcp_datetime"],
|
|
78
|
+
"env": {
|
|
79
|
+
"PYTHON": "/path/to/your/python"
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
- "/path/to/your/python"は実際のPythonインタプリタのパスに置き換えてください。
|
|
87
|
+
|
|
88
|
+
- 例:
|
|
89
|
+
- MacOS: "/usr/local/bin/python3" や "/Users/username/.pyenv/versions/3.12.0/bin/python3"
|
|
90
|
+
- Windows: "C:\Python312\python.exe"
|
|
91
|
+
|
|
92
|
+
## 基本的な使用例
|
|
93
|
+
|
|
94
|
+
- コマンド形式
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
# 標準的な日時形式
|
|
98
|
+
call datetime-service.get_datetime {"format": "datetime"}
|
|
99
|
+
# 結果: 2024-12-10 00:54:01
|
|
100
|
+
|
|
101
|
+
# 日本語形式
|
|
102
|
+
call datetime-service.get_datetime {"format": "datetime_jp"}
|
|
103
|
+
# 結果: 2024年12月10日 00時54分01秒
|
|
104
|
+
|
|
105
|
+
# ファイル名形式
|
|
106
|
+
call datetime-service.get_datetime {"format": "filename_md"}
|
|
107
|
+
# 結果: 20241210005401.md
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
- Claudeデスクトップアプリのプロンプト例
|
|
111
|
+
|
|
112
|
+
- User
|
|
113
|
+
|
|
114
|
+
```
|
|
115
|
+
今の時刻をdate_slash形式で教えてください
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
- Claude
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
date_slash形式で現在の日付を取得します。
|
|
122
|
+
|
|
123
|
+
現在の日付は 2024/12/12 です。
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## サポートされている形式
|
|
127
|
+
|
|
128
|
+
| 形式名 | 例 | 説明 |
|
|
129
|
+
| ------------ | --------------------------- | ------------------------ |
|
|
130
|
+
| date | 2024-12-10 | 標準的な日付形式 |
|
|
131
|
+
| date_slash | 2024/12/10 | スラッシュ区切りの日付 |
|
|
132
|
+
| date_jp | 2024年12月10日 | 日本語の日付形式 |
|
|
133
|
+
| datetime | 2024-12-10 00:54:01 | 標準的な日時形式 |
|
|
134
|
+
| datetime_jp | 2024年12月10日 00時54分01秒 | 日本語の日時形式 |
|
|
135
|
+
| datetime_t | 2024-12-10T00:54:01 | T区切りの日時形式 |
|
|
136
|
+
| compact | 20241210005401 | ID用のコンパクト形式 |
|
|
137
|
+
| compact_date | 20241210 | 日付のみのコンパクト形式 |
|
|
138
|
+
| compact_time | 005401 | 時刻のみのコンパクト形式 |
|
|
139
|
+
| filename_md | 20241210005401.md | Markdownファイル名形式 |
|
|
140
|
+
| filename_txt | 20241210005401.txt | テキストファイル名形式 |
|
|
141
|
+
| filename_log | 20241210005401.log | ログファイル名形式 |
|
|
142
|
+
| iso | 2024-12-10T00:54:01+0900 | ISO 8601形式 |
|
|
143
|
+
| iso_basic | 20241210T005401+0900 | 基本ISO形式 |
|
|
144
|
+
| log | 2024-12-10 00:54:01.123456 | マイクロ秒付きログ形式 |
|
|
145
|
+
| log_compact | 20241210_005401 | コンパクトなログ形式 |
|
|
146
|
+
| time | 00:54:01 | 時刻のみの形式 |
|
|
147
|
+
| time_jp | 00時54分01秒 | 日本語の時刻形式 |
|
|
148
|
+
|
|
149
|
+
## デバッグ
|
|
150
|
+
|
|
151
|
+
MCPサーバーはstdioを介して実行されるため、デバッグが難しい場合があります。[MCP Inspector](https://github.com/modelcontextprotocol/inspector)の使用を推奨します:
|
|
152
|
+
|
|
153
|
+
- PyPIパッケージを使用する場合
|
|
154
|
+
|
|
155
|
+
```
|
|
156
|
+
npx @modelcontextprotocol/inspector uvx mcp-datetime
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
- GitHubからダウンロードしたソースコードを使用する場合
|
|
160
|
+
|
|
161
|
+
```
|
|
162
|
+
git clone https://github.com/ZeparHyfar/mcp-datetime.git
|
|
163
|
+
npx @modelcontextprotocol/inspector uvx --directory ./mcp-datetime run mcp-datetime
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## ライセンス
|
|
167
|
+
|
|
168
|
+
このプロジェクトはMITライセンスの下で提供されています - 詳細は[LICENSE](LICENSE)ファイルを参照してください。
|
|
File without changes
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "mcp-datetime"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "A MCP server for datetime formatting and file name generation."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.12"
|
|
7
|
+
dependencies = ["mcp>=1.1.1"]
|
|
8
|
+
license = "MIT"
|
|
9
|
+
keywords = ["claude", "mcp", "datetime", "time", "format", "timezone"]
|
|
10
|
+
classifiers = [
|
|
11
|
+
"Development Status :: 3 - Alpha",
|
|
12
|
+
"Intended Audience :: Developers",
|
|
13
|
+
"License :: OSI Approved :: MIT License",
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"Programming Language :: Python :: 3.12",
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
[[project.authors]]
|
|
19
|
+
name = "ZeparHyfar"
|
|
20
|
+
email = "zeparhyfar@gmail.com"
|
|
21
|
+
|
|
22
|
+
[build-system]
|
|
23
|
+
requires = ["hatchling"]
|
|
24
|
+
build-backend = "hatchling.build"
|
|
25
|
+
|
|
26
|
+
[project.scripts]
|
|
27
|
+
mcp-datetime = "mcp_datetime:main"
|
|
28
|
+
|
|
29
|
+
[project.optional-dependencies]
|
|
30
|
+
dev = [
|
|
31
|
+
"pytest>=8.0.0",
|
|
32
|
+
"pylint>=3.0.3",
|
|
33
|
+
]
|
|
34
|
+
|
|
35
|
+
[project.urls]
|
|
36
|
+
Repository = "https://github.com/ZeparHyfar/mcp-datetime.git"
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
import logging
|
|
3
|
+
from collections.abc import Sequence
|
|
4
|
+
from datetime import datetime, timezone
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from mcp.server import Server
|
|
8
|
+
from mcp.server.stdio import stdio_server
|
|
9
|
+
from mcp.types import EmbeddedResource, ImageContent, TextContent, Tool
|
|
10
|
+
|
|
11
|
+
# Prepare logging
|
|
12
|
+
logging.basicConfig(level=logging.INFO)
|
|
13
|
+
logger = logging.getLogger("mcp-datetime")
|
|
14
|
+
|
|
15
|
+
# Prepare server
|
|
16
|
+
server = Server("mcp-datetime")
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
# Datetime formatting function
|
|
20
|
+
def format_datetime(format_type: str) -> str:
|
|
21
|
+
# Generate a new time object each time, considering timezone
|
|
22
|
+
current_time = datetime.now(timezone.utc).astimezone()
|
|
23
|
+
formats = {
|
|
24
|
+
# Basic date formats
|
|
25
|
+
"date": "%Y-%m-%d", # 2024-12-10
|
|
26
|
+
"date_slash": "%Y/%m/%d", # 2024/12/10
|
|
27
|
+
"date_jp": "%Y年%m月%d日", # 2024年12月10日
|
|
28
|
+
# Basic datetime formats
|
|
29
|
+
"datetime": "%Y-%m-%d %H:%M:%S", # 2024-12-10 00:54:01
|
|
30
|
+
"datetime_jp": "%Y年%m月%d日 %H時%M分%S秒", # 2024年12月10日 00時54分01秒
|
|
31
|
+
"datetime_t": "%Y-%m-%dT%H:%M:%S", # 2024-12-10T00:54:01
|
|
32
|
+
# Compact formats for filenames or IDs
|
|
33
|
+
"compact": "%Y%m%d%H%M%S", # 20241210005401
|
|
34
|
+
"compact_date": "%Y%m%d", # 20241210
|
|
35
|
+
"compact_time": "%H%M%S", # 005401
|
|
36
|
+
# Filename formats
|
|
37
|
+
"filename_md": "%Y%m%d%H%M%S.md", # 20241210005401.md
|
|
38
|
+
"filename_txt": "%Y%m%d%H%M%S.txt", # 20241210005401.txt
|
|
39
|
+
"filename_log": "%Y%m%d%H%M%S.log", # 20241210005401.log
|
|
40
|
+
# ISO 8601 formats
|
|
41
|
+
"iso": "%Y-%m-%dT%H:%M:%S%z", # 2024-12-10T00:54:01+0900
|
|
42
|
+
"iso_basic": "%Y%m%dT%H%M%S%z", # 20241210T005401+0900
|
|
43
|
+
# Log formats
|
|
44
|
+
"log": "%Y-%m-%d %H:%M:%S.%f", # 2024-12-10 00:54:01.123456
|
|
45
|
+
"log_compact": "%Y%m%d_%H%M%S", # 20241210_005401
|
|
46
|
+
# Time-only formats
|
|
47
|
+
"time": "%H:%M:%S", # 00:54:01
|
|
48
|
+
"time_jp": "%H時%M分%S秒", # 00時54分01秒
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if format_type not in formats:
|
|
52
|
+
raise ValueError(f"Unknown format type: {format_type}")
|
|
53
|
+
|
|
54
|
+
try:
|
|
55
|
+
return current_time.strftime(formats[format_type])
|
|
56
|
+
except Exception as e:
|
|
57
|
+
logger.error("Format error: %s", str(e))
|
|
58
|
+
raise RuntimeError(f"Error formatting date: {str(e)}") from e
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
# Get list of available tools
|
|
62
|
+
@server.list_tools()
|
|
63
|
+
async def list_tools() -> list[Tool]:
|
|
64
|
+
return [
|
|
65
|
+
Tool(
|
|
66
|
+
name="get_datetime",
|
|
67
|
+
description="Get current date and time in various formats",
|
|
68
|
+
inputSchema={
|
|
69
|
+
"type": "object",
|
|
70
|
+
"properties": {
|
|
71
|
+
"format": {
|
|
72
|
+
"type": "string",
|
|
73
|
+
"description": """
|
|
74
|
+
Available formats:
|
|
75
|
+
- date: 2024-12-10
|
|
76
|
+
- date_slash: 2024/12/10
|
|
77
|
+
- date_jp: 2024年12月10日
|
|
78
|
+
- datetime: 2024-12-10 00:54:01
|
|
79
|
+
- datetime_jp: 2024年12月10日 00時54分01秒
|
|
80
|
+
- datetime_t: 2024-12-10T00:54:01
|
|
81
|
+
- compact: 20241210005401
|
|
82
|
+
- compact_date: 20241210
|
|
83
|
+
- compact_time: 005401
|
|
84
|
+
- filename_md: 20241210005401.md
|
|
85
|
+
- filename_txt: 20241210005401.txt
|
|
86
|
+
- filename_log: 20241210005401.log
|
|
87
|
+
- iso: 2024-12-10T00:54:01+0900
|
|
88
|
+
- iso_basic: 20241210T005401+0900
|
|
89
|
+
- log: 2024-12-10 00:54:01.123456
|
|
90
|
+
- log_compact: 20241210_005401
|
|
91
|
+
- time: 00:54:01
|
|
92
|
+
- time_jp: 00時54分01秒
|
|
93
|
+
""",
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
"required": ["format"],
|
|
97
|
+
},
|
|
98
|
+
)
|
|
99
|
+
]
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
# Tool call handler
|
|
103
|
+
@server.call_tool()
|
|
104
|
+
async def call_tool(
|
|
105
|
+
name: str, arguments: Any
|
|
106
|
+
) -> Sequence[TextContent | ImageContent | EmbeddedResource]:
|
|
107
|
+
if name == "get_datetime":
|
|
108
|
+
try:
|
|
109
|
+
format_type = arguments.get("format")
|
|
110
|
+
if not format_type:
|
|
111
|
+
raise ValueError("Format type is required")
|
|
112
|
+
formatted_time = format_datetime(format_type)
|
|
113
|
+
return [TextContent(type="text", text=formatted_time)]
|
|
114
|
+
except ValueError as e:
|
|
115
|
+
logger.error("Format error: %s", str(e))
|
|
116
|
+
raise RuntimeError(str(e)) from e
|
|
117
|
+
else:
|
|
118
|
+
raise ValueError(f"Unknown tool: {name}")
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
# Main function
|
|
122
|
+
async def main():
|
|
123
|
+
async with stdio_server() as (read_stream, write_stream):
|
|
124
|
+
await server.run(
|
|
125
|
+
read_stream, write_stream, server.create_initialization_options()
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
if __name__ == "__main__":
|
|
130
|
+
asyncio.run(main())
|