sxc-study-mcp 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.
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "sxc-study-mcp"
|
|
3
|
+
version = "0.1.0"
|
|
4
|
+
description = "Add your description here"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
authors = [
|
|
7
|
+
{ name = "sxc", email = "m19884357268@163.com" }
|
|
8
|
+
]
|
|
9
|
+
requires-python = ">=3.13"
|
|
10
|
+
dependencies = [
|
|
11
|
+
"mcp[cli]>=1.28.0",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
[project.scripts]
|
|
15
|
+
sxc-study-mcp = "sxc_study_mcp:main"
|
|
16
|
+
|
|
17
|
+
[build-system]
|
|
18
|
+
requires = ["uv_build>=0.11.24,<0.12.0"]
|
|
19
|
+
build-backend = "uv_build"
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"""
|
|
2
|
+
FastMCP quickstart example.
|
|
3
|
+
|
|
4
|
+
Run from the repository root:
|
|
5
|
+
uv run examples/snippets/servers/fastmcp_quickstart.py
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from mcp.server.fastmcp import FastMCP
|
|
9
|
+
|
|
10
|
+
# Create an MCP server
|
|
11
|
+
mcp = FastMCP("Demo", json_response=True) #使用FastMCP初始化一个MCP对象
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# Add an addition tool
|
|
15
|
+
@mcp.tool() #python装饰申明,表示下面的是函数工具
|
|
16
|
+
def add(a: int, b: int) -> int: #参数修饰符也一定要写,能帮助大模型更好的判断用什么函数工具
|
|
17
|
+
"""Add two numbers""" #这个必须加,是用来告诉大模型这个函数的功能的
|
|
18
|
+
return a + b
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# Add a dynamic greeting resource
|
|
22
|
+
@mcp.resource("greeting://{name}") #为大模型提供只读数据
|
|
23
|
+
def get_greeting(name: str) -> str:
|
|
24
|
+
"""Get a personalized greeting"""
|
|
25
|
+
return f"Hello, {name}!"
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# # Add a prompt
|
|
29
|
+
# @mcp.prompt()
|
|
30
|
+
# def greet_user(name: str, style: str = "friendly") -> str:
|
|
31
|
+
# """Generate a greeting prompt"""
|
|
32
|
+
# styles = {
|
|
33
|
+
# "friendly": "Please write a warm, friendly greeting",
|
|
34
|
+
# "formal": "Please write a formal, professional greeting",
|
|
35
|
+
# "casual": "Please write a casual, relaxed greeting",
|
|
36
|
+
# }
|
|
37
|
+
|
|
38
|
+
# return f"{styles.get(style, styles['friendly'])} for someone named {name}."
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
# Run with streamable HTTP transport
|
|
42
|
+
# if __name__ == "__main__":
|
|
43
|
+
# mcp.run(transport="streamable-http") #http协议
|
|
44
|
+
|
|
45
|
+
# if __name__ == "__main__":
|
|
46
|
+
# mcp.run(transport="stdio") #stdio协议,标准输入输出,适合在终端中使用
|
|
47
|
+
|
|
48
|
+
# if __name__ == "__main__":
|
|
49
|
+
# mcp.run(transport="sse") #sse协议,流式传输,适合在浏览器中使用
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def main() -> None:
|
|
56
|
+
mcp.run(transport="stdio")
|