Featured image of post Git MCP Tools.md

Git MCP Tools.md

能够使用 Git 操作文件的 MCP 服务

MCP 协议 很有意思,能让大模型使用工具,来扩展大模型的能力。为了体验一下自动化的快乐,我结合 FastMCP 开发一个 MCP 服务:

这个服务可以通过我预先定义的几个命令,例如 status ,来操作指定的 git 仓库。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
  def status(self) -> str:
    import subprocess

    output = subprocess.run(
      ["git", "status"],
      cwd=self.repo_path,
      capture_output=True,
      text=True,
    )
    return output.stdout

实际使用

通过 DeepChat 进行沟通。

chat.png

可以看到,deepchat 借助大模型,帮我查看了项目 git-mcp 在我本地的情况。

遇到的问题

  1. 使用mcp.resources和使用mcp.tool是不一样的。如果不定义 tool,有时候大模型会找不到对应的资源。
comments powered by Disqus
使用 Hugo 构建
主题 StackJimmy 设计