mcp-time-server-cuc 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.
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 mcp-time-server contributors
|
|
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,71 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: mcp-time-server-cuc
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A simple MCP server that provides the current time.
|
|
5
|
+
License-Expression: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Requires-Python: >=3.13,<4.0
|
|
8
|
+
Classifier: Programming Language :: Python :: 3
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
12
|
+
Requires-Dist: mcp (>=1.30.0,<2.0.0)
|
|
13
|
+
Requires-Dist: pytz (>=2024.1)
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
|
|
16
|
+
# MCP Time Server
|
|
17
|
+
|
|
18
|
+
一个基于 FastMCP 的时间服务器,通过 STDIO 向 MCP 客户端提供 `get_current_time` 工具。
|
|
19
|
+
|
|
20
|
+
## 环境要求
|
|
21
|
+
|
|
22
|
+
- Python 3.13 或更高版本
|
|
23
|
+
- Poetry 2.x
|
|
24
|
+
|
|
25
|
+
## 安装
|
|
26
|
+
|
|
27
|
+
```powershell
|
|
28
|
+
poetry install
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## 启动
|
|
32
|
+
|
|
33
|
+
```powershell
|
|
34
|
+
poetry run mcp-time-server-cuc
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
服务使用 STDIO 传输,启动后等待 MCP 客户端连接,不会显示交互式提示符。请勿在服务终端手动输入内容。
|
|
38
|
+
|
|
39
|
+
## MCP 客户端配置
|
|
40
|
+
|
|
41
|
+
以 Cherry Studio 为例,添加 STDIO 类型的 MCP 服务器:
|
|
42
|
+
|
|
43
|
+
- 命令:`D:\miniconda3\envs\py313\python.exe`
|
|
44
|
+
- 参数:`-m poetry -C C:\Users\30492\Downloads\mcp-time-server run mcp-time-server-cuc`
|
|
45
|
+
- 工作目录:`C:\Users\30492\Downloads\mcp-time-server`
|
|
46
|
+
|
|
47
|
+
如果安装路径不同,请替换为实际的 Python 和项目路径。
|
|
48
|
+
|
|
49
|
+
## 工具
|
|
50
|
+
|
|
51
|
+
### get_current_time
|
|
52
|
+
|
|
53
|
+
返回格式化的当前时间。
|
|
54
|
+
|
|
55
|
+
- `timezone`:可选时区名称,例如 `Asia/Shanghai`、`America/New_York`。
|
|
56
|
+
- 不提供时区时,使用系统默认时区。
|
|
57
|
+
- 时区名称无效时,返回错误提示。
|
|
58
|
+
|
|
59
|
+
## 构建
|
|
60
|
+
|
|
61
|
+
```powershell
|
|
62
|
+
poetry build
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
构建产物位于 `dist/`:
|
|
66
|
+
|
|
67
|
+
- `mcp_time_server_cuc-0.1.0-py3-none-any.whl`
|
|
68
|
+
- `mcp_time_server_cuc-0.1.0.tar.gz`
|
|
69
|
+
|
|
70
|
+
发布方法见 [PUBLISH.md](PUBLISH.md)。
|
|
71
|
+
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# MCP Time Server
|
|
2
|
+
|
|
3
|
+
一个基于 FastMCP 的时间服务器,通过 STDIO 向 MCP 客户端提供 `get_current_time` 工具。
|
|
4
|
+
|
|
5
|
+
## 环境要求
|
|
6
|
+
|
|
7
|
+
- Python 3.13 或更高版本
|
|
8
|
+
- Poetry 2.x
|
|
9
|
+
|
|
10
|
+
## 安装
|
|
11
|
+
|
|
12
|
+
```powershell
|
|
13
|
+
poetry install
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## 启动
|
|
17
|
+
|
|
18
|
+
```powershell
|
|
19
|
+
poetry run mcp-time-server-cuc
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
服务使用 STDIO 传输,启动后等待 MCP 客户端连接,不会显示交互式提示符。请勿在服务终端手动输入内容。
|
|
23
|
+
|
|
24
|
+
## MCP 客户端配置
|
|
25
|
+
|
|
26
|
+
以 Cherry Studio 为例,添加 STDIO 类型的 MCP 服务器:
|
|
27
|
+
|
|
28
|
+
- 命令:`D:\miniconda3\envs\py313\python.exe`
|
|
29
|
+
- 参数:`-m poetry -C C:\Users\30492\Downloads\mcp-time-server run mcp-time-server-cuc`
|
|
30
|
+
- 工作目录:`C:\Users\30492\Downloads\mcp-time-server`
|
|
31
|
+
|
|
32
|
+
如果安装路径不同,请替换为实际的 Python 和项目路径。
|
|
33
|
+
|
|
34
|
+
## 工具
|
|
35
|
+
|
|
36
|
+
### get_current_time
|
|
37
|
+
|
|
38
|
+
返回格式化的当前时间。
|
|
39
|
+
|
|
40
|
+
- `timezone`:可选时区名称,例如 `Asia/Shanghai`、`America/New_York`。
|
|
41
|
+
- 不提供时区时,使用系统默认时区。
|
|
42
|
+
- 时区名称无效时,返回错误提示。
|
|
43
|
+
|
|
44
|
+
## 构建
|
|
45
|
+
|
|
46
|
+
```powershell
|
|
47
|
+
poetry build
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
构建产物位于 `dist/`:
|
|
51
|
+
|
|
52
|
+
- `mcp_time_server_cuc-0.1.0-py3-none-any.whl`
|
|
53
|
+
- `mcp_time_server_cuc-0.1.0.tar.gz`
|
|
54
|
+
|
|
55
|
+
发布方法见 [PUBLISH.md](PUBLISH.md)。
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
import pytz
|
|
4
|
+
from mcp.server.fastmcp import FastMCP
|
|
5
|
+
|
|
6
|
+
# 初始化 FastMCP 服务器实例
|
|
7
|
+
# 参数 "time-server" 是服务器的名称
|
|
8
|
+
mcp = FastMCP("time-server")
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
@mcp.tool()
|
|
12
|
+
def get_current_time(timezone: Optional[str] = None) -> str:
|
|
13
|
+
"""获取当前时间的工具函数
|
|
14
|
+
|
|
15
|
+
Args:
|
|
16
|
+
timezone: 可选参数,时区字符串,例如 "Asia/Shanghai"、"America/New_York"
|
|
17
|
+
如果不提供,将使用系统默认时区
|
|
18
|
+
|
|
19
|
+
Returns:
|
|
20
|
+
格式化的当前时间字符串
|
|
21
|
+
"""
|
|
22
|
+
try:
|
|
23
|
+
if timezone:
|
|
24
|
+
# 如果提供了时区参数,使用指定的时区
|
|
25
|
+
tz = pytz.timezone(timezone)
|
|
26
|
+
current_time = datetime.now(tz)
|
|
27
|
+
else:
|
|
28
|
+
# 如果没有提供时区参数,使用系统默认时区
|
|
29
|
+
current_time = datetime.now()
|
|
30
|
+
|
|
31
|
+
# 格式化时间字符串
|
|
32
|
+
# 格式:YYYY-MM-DD HH:MM:SS.SSSSSS 时区名称
|
|
33
|
+
return current_time.strftime("%Y-%m-%d %H:%M:%S.%f %Z")
|
|
34
|
+
except pytz.exceptions.UnknownTimeZoneError:
|
|
35
|
+
# 处理无效的时区参数
|
|
36
|
+
return f"错误:未知的时区 '{timezone}'"
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
def main():
|
|
40
|
+
"""主函数,启动 MCP 服务器"""
|
|
41
|
+
# 使用 STDIO 传输方式运行服务器,由 MCP 客户端直接启动和管理进程
|
|
42
|
+
mcp.run(transport="stdio")
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
if __name__ == "__main__":
|
|
46
|
+
main()
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "mcp-time-server-cuc"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "A simple MCP server that provides the current time."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
requires-python = ">=3.13,<4.0"
|
|
8
|
+
dependencies = [
|
|
9
|
+
"mcp>=1.30.0,<2.0.0",
|
|
10
|
+
"pytz>=2024.1",
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
[project.scripts]
|
|
14
|
+
mcp-time-server-cuc = "mcp_time_server.main:main"
|
|
15
|
+
|
|
16
|
+
[tool.poetry]
|
|
17
|
+
packages = [{ include = "mcp_time_server" }]
|
|
18
|
+
|
|
19
|
+
[build-system]
|
|
20
|
+
requires = ["poetry-core>=2.0.0"]
|
|
21
|
+
build-backend = "poetry.core.masonry.api"
|