Skip to content

Commit 0524d11

Browse files
YangSen-qnYangSen-qn
andauthored
change doc and add version tool (#4)
Co-authored-by: YangSen-qn <yangsen@qiniu.com>
1 parent c1fc769 commit 0524d11

File tree

7 files changed

+55
-10
lines changed

7 files changed

+55
-10
lines changed

CHANGELOG.md

Whitespace-only changes.

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,14 @@ uv --directory . run qiniu-mcp-server --transport sse --port 8000
8383
## 开发
8484

8585
扩展功能,首先在 core 目录下新增一个业务目录(eg: 存储 -> storage),在此业务目录下完成功能拓展。
86-
在业务目录下新建一个 `loader.py` 文件,在此文件中定义 load 函数用于注册业务工具或者资源,最后在 `core` 目录下的 `__init__.py`
86+
在业务包目录下的 `__init__.py` 文件中定义 load 函数用于注册业务工具或者资源,最后在 `core` 目录下的 `__init__.py`
8787
中调用此 load 函数完成工具和资源的注册。
8888

8989
```shell
9090
core
9191
├── __init__.py # 各个业务工具或者资源加载
9292
└── storage # 存储业务目录
93-
├── __init__.py
94-
├── loader.py # 加载存储工具或者资源
93+
├── __init__.py # 加载存储工具或者资源
9594
├── resource.py # 存储资源扩展
9695
├── storage.py # 存储工具类
9796
└── tools.py # 存储工具扩展

mcp_server/core/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,19 @@
22
from .storage import load as load_storage
33
from .media_processing import load as load_media_processing
44
from .cdn import load as load_cdn
5+
from .version import load as load_version
56

67

78
def load():
89
# 加载配置
910
cfg = config.load_config()
1011

12+
# 版本
13+
load_version(cfg)
1114
# 存储业务
1215
load_storage(cfg)
1316
# CDN
1417
load_cdn(cfg)
1518
# 智能多媒体
1619
load_media_processing(cfg)
20+

mcp_server/core/storage/tools.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def __init__(self, storage: StorageService):
1717

1818
@tools.tool_meta(
1919
types.Tool(
20-
name="ListBuckets", # https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListBuckets.html
20+
name="ListBuckets",
2121
description="Returns a list of all buckets owned by the authenticated sender of the request. To grant IAM permission to use this operation, you must add the s3:ListAllMyBuckets policy action.",
2222
inputSchema={
2323
"type": "object",
@@ -37,7 +37,7 @@ async def list_buckets(self, **kwargs) -> list[types.TextContent]:
3737

3838
@tools.tool_meta(
3939
types.Tool(
40-
name="ListObjects", # https://docs.aws.amazon.com/AmazonS3/latest/API/API_ListObjectsV2.html
40+
name="ListObjects",
4141
description="Each request will return some or all (up to 100) objects in the bucket. You can use request parameters as selection criteria to return some objects in the bucket. If you want to continue listing, set start_after to the key of the last file in the last listing result so that you can list new content. To get a list of buckets, see ListBuckets.",
4242
inputSchema={
4343
"type": "object",
@@ -69,7 +69,7 @@ async def list_objects(self, **kwargs) -> list[types.TextContent]:
6969

7070
@tools.tool_meta(
7171
types.Tool(
72-
name="GetObject", # https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html
72+
name="GetObject",
7373
description="Retrieves an object from Amazon S3. In the GetObject request, specify the full key name for the object. General purpose buckets - Both the virtual-hosted-style requests and the path-style requests are supported. For a virtual hosted-style request example, if you have the object photos/2006/February/sample.jpg, specify the object key name as /photos/2006/February/sample.jpg. For a path-style request example, if you have the object photos/2006/February/sample.jpg in the bucket named examplebucket, specify the object key name as /examplebucket/photos/2006/February/sample.jpg. Directory buckets - Only virtual-hosted-style requests are supported. For a virtual hosted-style request example, if you have the object photos/2006/February/sample.jpg in the bucket named examplebucket--use1-az5--x-s3, specify the object key name as /photos/2006/February/sample.jpg. Also, when you make requests to this API operation, your requests are sent to the Zonal endpoint. These endpoints support virtual-hosted-style requests in the format https://bucket_name.s3express-az_id.region.amazonaws.com/key-name . Path-style requests are not supported.",
7474
inputSchema={
7575
"type": "object",
@@ -109,8 +109,8 @@ async def get_object(self, **kwargs) -> list[ImageContent] | list[TextContent]:
109109

110110
@tools.tool_meta(
111111
types.Tool(
112-
name="GetObjectURL", # https://docs.aws.amazon.com/AmazonS3/latest/API/API_GetObject.html
113-
description="获取文件下载的 URL",
112+
name="GetObjectURL",
113+
description="Get the file download URL, and note that the Bucket where the file is located must be bound to a domain name. If using Qiniu's test domain, HTTPS access will not be available, and users need to make adjustments for this themselves.",
114114
inputSchema={
115115
"type": "object",
116116
"properties": {
@@ -124,11 +124,11 @@ async def get_object(self, **kwargs) -> list[ImageContent] | list[TextContent]:
124124
},
125125
"disable_ssl": {
126126
"type": "boolean",
127-
"description": "是否禁用 SSL,默认不禁用使用 HTTP 协议,禁用后使用 HTTP 协议",
127+
"description": "Whether to disable SSL. By default, it is not disabled (HTTP protocol is used). If disabled, the HTTP protocol will be used.",
128128
},
129129
"expires": {
130130
"type": "integer",
131-
"description": "下载链接中 Token 有效期,单位是秒;当空间是私有空间时,访问文件对象时需要对文件链接签名 Token,公有空间不签 Token",
131+
"description": "Token expiration time (in seconds) for download links. When the bucket is private, a signed Token is required to access file objects. Public buckets do not require Token signing.",
132132
},
133133
},
134134
"required": ["bucket", "key"],
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
from .tools import register_tools
2+
from ...config import config
3+
4+
5+
def load(cfg: config.Config):
6+
register_tools()
7+
8+
9+
__all__ = ["load"]

mcp_server/core/version/tools.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
from mcp import types
3+
4+
from . import version
5+
from ...tools import tools
6+
7+
8+
class _ToolImpl:
9+
def __init__(self):
10+
pass
11+
12+
@tools.tool_meta(
13+
types.Tool(
14+
name="Version",
15+
description="qiniu mcp server version info.",
16+
inputSchema={
17+
"type": "object",
18+
"required": [],
19+
}
20+
)
21+
)
22+
def version(self, **kwargs) -> list[types.TextContent]:
23+
return [types.TextContent(type="text", text=version.VERSION)]
24+
25+
def register_tools():
26+
tool_impl = _ToolImpl()
27+
tools.auto_register_tools(
28+
[
29+
tool_impl.version,
30+
]
31+
)

mcp_server/core/version/version.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
VERSION = '0.1.0'

0 commit comments

Comments
 (0)