48 lines
1.3 KiB
Python
48 lines
1.3 KiB
Python
"""
|
||
Git MCP 服务器
|
||
整合所有 Git 工具为 MCP Server
|
||
|
||
设计说明:
|
||
- GitServer 继承自 McpServer,提供 Git 相关的工具
|
||
- 在 __init__ 中直接实例化并赋值工具列表
|
||
- 工具定义在各自的文件中,git_server 负责组装
|
||
"""
|
||
import asyncio
|
||
from app.tools.base_mcp_server import BaseMcpServer
|
||
from app.tools.git.git_clone_tool import GitCloneTool
|
||
from app.tools.git.git_checkout_tool import GitCheckoutTool
|
||
from app.tools.git.git_add_tool import GitAddTool
|
||
from app.tools.git.git_commit_tool import GitCommitTool
|
||
from app.tools.git.git_push_tool import GitPushTool
|
||
|
||
|
||
class GitMcpServer(BaseMcpServer):
|
||
"""
|
||
Git MCP 服务器
|
||
|
||
继承 McpServer,在 __init__ 中直接赋值 Git 工具实例列表。
|
||
"""
|
||
|
||
def __init__(self):
|
||
# 初始化父类,设置服务器名称和版本
|
||
super().__init__(server_name="git-mcp", version="1.0.0")
|
||
|
||
# 直接赋值工具实例列表
|
||
self.tools = [
|
||
GitCloneTool(),
|
||
GitCheckoutTool(),
|
||
GitAddTool(),
|
||
GitCommitTool(),
|
||
GitPushTool(),
|
||
]
|
||
|
||
|
||
async def main():
|
||
"""启动 Git MCP 服务器"""
|
||
server = GitMcpServer()
|
||
await server.run_stdio()
|
||
|
||
|
||
if __name__ == "__main__":
|
||
asyncio.run(main())
|