Skip to main content

通过 Copilot 对话助手 使用 GitHub MCP 服务器

从GitHub 中的Copilot 对话助手直接执行GitHub任务,例如创建分支、合并拉取请求和搜索用户,而无需设置。

在本文中

          GitHub MCP 服务器在 GitHub 中的Copilot 对话助手 中已预先配置了一组有限的技能,因此您可以立即使用。 指示 Copilot 对话助手 代表你执行创建分支或合并拉取请求等任务。

有关可用技能的完整列表,请参阅 GitHub Copilot Chat 速查表。 有关 MCP 的详细信息,请参阅 关于模型上下文协议 (MCP)

使用 GitHub MCP 服务器

  1. 导航到 https://github.com/copilot

  2. 键入请求,然后按 Enter。 例如:

           <code id="1099795093">在存储库 [OWNER/REPO-NAME] 中创建名为 [BRANCH-NAME] 的新分支。</code><a href="https://github.com/copilot?prompt=%E5%9C%A8%E5%AD%98%E5%82%A8%E5%BA%93%20%5BOWNER%2FREPO-NAME%5D%20%E4%B8%AD%E5%88%9B%E5%BB%BA%E5%90%8D%E4%B8%BA%20%5BBRANCH-NAME%5D%20%E7%9A%84%E6%96%B0%E5%88%86%E6%94%AF%E3%80%82" target="_blank" class="tooltipped tooltipped-n ml-1 copilot-prompt-long" aria-label="Run this prompt in Copilot Chat" aria-describedby="1099795093" style="text-decoration:none;"><svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-copilot" aria-hidden="true"><path d="M7.998 15.035c-4.562 0-7.873-2.914-7.998-3.749V9.338c.085-.628.677-1.686 1.588-2.065.013-.07.024-.143.036-.218.029-.183.06-.384.126-.612-.201-.508-.254-1.084-.254-1.656 0-.87.128-1.769.693-2.484.579-.733 1.494-1.124 2.724-1.261 1.206-.134 2.262.034 2.944.765.05.053.096.108.139.165.044-.057.094-.112.143-.165.682-.731 1.738-.899 2.944-.765 1.23.137 2.145.528 2.724 1.261.566.715.693 1.614.693 2.484 0 .572-.053 1.148-.254 1.656.066.228.098.429.126.612.012.076.024.148.037.218.924.385 1.522 1.471 1.591 2.095v1.872c0 .766-3.351 3.795-8.002 3.795Zm0-1.485c2.28 0 4.584-1.11 5.002-1.433V7.862l-.023-.116c-.49.21-1.075.291-1.727.291-1.146 0-2.059-.327-2.71-.991A3.222 3.222 0 0 1 8 6.303a3.24 3.24 0 0 1-.544.743c-.65.664-1.563.991-2.71.991-.652 0-1.236-.081-1.727-.291l-.023.116v4.255c.419.323 2.722 1.433 5.002 1.433ZM6.762 2.83c-.193-.206-.637-.413-1.682-.297-1.019.113-1.479.404-1.713.7-.247.312-.369.789-.369 1.554 0 .793.129 1.171.308 1.371.162.181.519.379 1.442.379.853 0 1.339-.235 1.638-.54.315-.322.527-.827.617-1.553.117-.935-.037-1.395-.241-1.614Zm4.155-.297c-1.044-.116-1.488.091-1.681.297-.204.219-.359.679-.242 1.614.091.726.303 1.231.618 1.553.299.305.784.54 1.638.54.922 0 1.28-.198 1.442-.379.179-.2.308-.578.308-1.371 0-.765-.123-1.242-.37-1.554-.233-.296-.693-.587-1.713-.7Z"></path><path d="M6.25 9.037a.75.75 0 0 1 .75.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 .75-.75Zm4.25.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 1.5 0Z"></path></svg></a><a href="https://github.com/copilot?prompt=%E5%9C%A8%E5%AD%98%E5%82%A8%E5%BA%93%20%5BOWNER%2FREPO-NAME%5D%20%E4%B8%AD%E5%88%9B%E5%BB%BA%E5%90%8D%E4%B8%BA%20%5BBRANCH-NAME%5D%20%E7%9A%84%E6%96%B0%E5%88%86%E6%94%AF%E3%80%82" target="_blank" class="tooltipped tooltipped-n ml-1 copilot-prompt-short" aria-label="Run prompt" aria-describedby="1099795093" style="text-decoration:none;"><svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-copilot" aria-hidden="true"><path d="M7.998 15.035c-4.562 0-7.873-2.914-7.998-3.749V9.338c.085-.628.677-1.686 1.588-2.065.013-.07.024-.143.036-.218.029-.183.06-.384.126-.612-.201-.508-.254-1.084-.254-1.656 0-.87.128-1.769.693-2.484.579-.733 1.494-1.124 2.724-1.261 1.206-.134 2.262.034 2.944.765.05.053.096.108.139.165.044-.057.094-.112.143-.165.682-.731 1.738-.899 2.944-.765 1.23.137 2.145.528 2.724 1.261.566.715.693 1.614.693 2.484 0 .572-.053 1.148-.254 1.656.066.228.098.429.126.612.012.076.024.148.037.218.924.385 1.522 1.471 1.591 2.095v1.872c0 .766-3.351 3.795-8.002 3.795Zm0-1.485c2.28 0 4.584-1.11 5.002-1.433V7.862l-.023-.116c-.49.21-1.075.291-1.727.291-1.146 0-2.059-.327-2.71-.991A3.222 3.222 0 0 1 8 6.303a3.24 3.24 0 0 1-.544.743c-.65.664-1.563.991-2.71.991-.652 0-1.236-.081-1.727-.291l-.023.116v4.255c.419.323 2.722 1.433 5.002 1.433ZM6.762 2.83c-.193-.206-.637-.413-1.682-.297-1.019.113-1.479.404-1.713.7-.247.312-.369.789-.369 1.554 0 .793.129 1.171.308 1.371.162.181.519.379 1.442.379.853 0 1.339-.235 1.638-.54.315-.322.527-.827.617-1.553.117-.935-.037-1.395-.241-1.614Zm4.155-.297c-1.044-.116-1.488.091-1.681.297-.204.219-.359.679-.242 1.614.091.726.303 1.231.618 1.553.299.305.784.54 1.638.54.922 0 1.28-.198 1.442-.379.179-.2.308-.578.308-1.371 0-.765-.123-1.242-.37-1.554-.233-.296-.693-.587-1.713-.7Z"></path><path d="M6.25 9.037a.75.75 0 0 1 .75.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 .75-.75Zm4.25.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 1.5 0Z"></path></svg></a>
    
    
           <code id="655992068">合并存储库 [OWNER/REPO-NAME] 中的拉取请求 [PR-NUMBER]。</code><a href="https://github.com/copilot?prompt=%E5%90%88%E5%B9%B6%E5%AD%98%E5%82%A8%E5%BA%93%20%5BOWNER%2FREPO-NAME%5D%20%E4%B8%AD%E7%9A%84%E6%8B%89%E5%8F%96%E8%AF%B7%E6%B1%82%20%5BPR-NUMBER%5D%E3%80%82" target="_blank" class="tooltipped tooltipped-n ml-1 copilot-prompt-long" aria-label="Run this prompt in Copilot Chat" aria-describedby="655992068" style="text-decoration:none;"><svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-copilot" aria-hidden="true"><path d="M7.998 15.035c-4.562 0-7.873-2.914-7.998-3.749V9.338c.085-.628.677-1.686 1.588-2.065.013-.07.024-.143.036-.218.029-.183.06-.384.126-.612-.201-.508-.254-1.084-.254-1.656 0-.87.128-1.769.693-2.484.579-.733 1.494-1.124 2.724-1.261 1.206-.134 2.262.034 2.944.765.05.053.096.108.139.165.044-.057.094-.112.143-.165.682-.731 1.738-.899 2.944-.765 1.23.137 2.145.528 2.724 1.261.566.715.693 1.614.693 2.484 0 .572-.053 1.148-.254 1.656.066.228.098.429.126.612.012.076.024.148.037.218.924.385 1.522 1.471 1.591 2.095v1.872c0 .766-3.351 3.795-8.002 3.795Zm0-1.485c2.28 0 4.584-1.11 5.002-1.433V7.862l-.023-.116c-.49.21-1.075.291-1.727.291-1.146 0-2.059-.327-2.71-.991A3.222 3.222 0 0 1 8 6.303a3.24 3.24 0 0 1-.544.743c-.65.664-1.563.991-2.71.991-.652 0-1.236-.081-1.727-.291l-.023.116v4.255c.419.323 2.722 1.433 5.002 1.433ZM6.762 2.83c-.193-.206-.637-.413-1.682-.297-1.019.113-1.479.404-1.713.7-.247.312-.369.789-.369 1.554 0 .793.129 1.171.308 1.371.162.181.519.379 1.442.379.853 0 1.339-.235 1.638-.54.315-.322.527-.827.617-1.553.117-.935-.037-1.395-.241-1.614Zm4.155-.297c-1.044-.116-1.488.091-1.681.297-.204.219-.359.679-.242 1.614.091.726.303 1.231.618 1.553.299.305.784.54 1.638.54.922 0 1.28-.198 1.442-.379.179-.2.308-.578.308-1.371 0-.765-.123-1.242-.37-1.554-.233-.296-.693-.587-1.713-.7Z"></path><path d="M6.25 9.037a.75.75 0 0 1 .75.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 .75-.75Zm4.25.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 1.5 0Z"></path></svg></a><a href="https://github.com/copilot?prompt=%E5%90%88%E5%B9%B6%E5%AD%98%E5%82%A8%E5%BA%93%20%5BOWNER%2FREPO-NAME%5D%20%E4%B8%AD%E7%9A%84%E6%8B%89%E5%8F%96%E8%AF%B7%E6%B1%82%20%5BPR-NUMBER%5D%E3%80%82" target="_blank" class="tooltipped tooltipped-n ml-1 copilot-prompt-short" aria-label="Run prompt" aria-describedby="655992068" style="text-decoration:none;"><svg version="1.1" width="16" height="16" viewBox="0 0 16 16" class="octicon octicon-copilot" aria-hidden="true"><path d="M7.998 15.035c-4.562 0-7.873-2.914-7.998-3.749V9.338c.085-.628.677-1.686 1.588-2.065.013-.07.024-.143.036-.218.029-.183.06-.384.126-.612-.201-.508-.254-1.084-.254-1.656 0-.87.128-1.769.693-2.484.579-.733 1.494-1.124 2.724-1.261 1.206-.134 2.262.034 2.944.765.05.053.096.108.139.165.044-.057.094-.112.143-.165.682-.731 1.738-.899 2.944-.765 1.23.137 2.145.528 2.724 1.261.566.715.693 1.614.693 2.484 0 .572-.053 1.148-.254 1.656.066.228.098.429.126.612.012.076.024.148.037.218.924.385 1.522 1.471 1.591 2.095v1.872c0 .766-3.351 3.795-8.002 3.795Zm0-1.485c2.28 0 4.584-1.11 5.002-1.433V7.862l-.023-.116c-.49.21-1.075.291-1.727.291-1.146 0-2.059-.327-2.71-.991A3.222 3.222 0 0 1 8 6.303a3.24 3.24 0 0 1-.544.743c-.65.664-1.563.991-2.71.991-.652 0-1.236-.081-1.727-.291l-.023.116v4.255c.419.323 2.722 1.433 5.002 1.433ZM6.762 2.83c-.193-.206-.637-.413-1.682-.297-1.019.113-1.479.404-1.713.7-.247.312-.369.789-.369 1.554 0 .793.129 1.171.308 1.371.162.181.519.379 1.442.379.853 0 1.339-.235 1.638-.54.315-.322.527-.827.617-1.553.117-.935-.037-1.395-.241-1.614Zm4.155-.297c-1.044-.116-1.488.091-1.681.297-.204.219-.359.679-.242 1.614.091.726.303 1.231.618 1.553.299.305.784.54 1.638.54.922 0 1.28-.198 1.442-.379.179-.2.308-.578.308-1.371 0-.765-.123-1.242-.37-1.554-.233-.296-.693-.587-1.713-.7Z"></path><path d="M6.25 9.037a.75.75 0 0 1 .75.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 .75-.75Zm4.25.75v1.501a.75.75 0 0 1-1.5 0V9.787a.75.75 0 0 1 1.5 0Z"></path></svg></a>
    
  3. 单击 “允许” 确认操作。

  4.        Copilot 对话助手 执行操作并显示结果。
    

局限性

MCP GitHub 服务器在 GitHub 中的Copilot 对话助手 中支持一组有限的功能。 如果不支持请求的操作,Copilot 对话助手 将提供指导,但无法直接执行。

若要访问完整的工具集,请在 IDE 中设置 GitHub MCP 服务器。 请参阅“在 IDE 中使用 GitHub MCP 服务器”。

还可以配合使用 GitHub MCP 服务器与 Copilot云代理。 默认情况下,它启用只读访问,并且可以自定义以实现更广泛的访问。 请参阅“使用模型上下文协议(MCP)扩展GitHub Copilot云代理”。

延伸阅读

  •         [AUTOTITLE](/copilot/tutorials/enhancing-copilot-agent-mode-with-mcp)