跳到正文
DEV Community· kawasaki031677·· 10 天前AI 評分48

透過實測 GitHub MCP Server 瞭解 MCP

What is MCP? Trying Out GitHub MCP Server

AI 導讀

作者透過 GitHub MCP Server 實測 MCP,示範 Copilot 如何直接存取 GitHub 並建立 PR。實測在 VSCode 環境進行,作者確認 PR 已在 GitHub 建立,並指出 MCP 可讓 AI 不只提供建議,也能採取行動。

正文

Introduction

I've been seeing the term "MCP" quite frequently lately.

It seems to be a new technology related to AI, but when I read the explanations, I don't really understand it... lol

So I decided to skip the complicated theory and just try it out to understand it.

Using GitHub's official GitHub MCP Server,
I'll experience "what MCP can do".

What is MCP?

MCP (Model Context Protocol) is
a set of rules that gives AI permission to "go ahead and operate".

Until now, generative AI could only provide advice,
but with MCP, AI can now operate directly.

What can it do?

Let me use GitHub as an example.

Normally, if you ask Copilot to "create a PR",
it will only teach you how to do it, and you have to do the actual work yourself.

However, with MCP,
Copilot can actually access GitHub and create PRs directly.

Trying out GitHub MCP Server

Here's what I used this time:

https://github.com/github/github-mcp-server

I'll try to enable Copilot to operate GitHub from the familiar VSCode environment.

Preparation

  • Prepare a repository on GitHub
  • Clone it locally
  • Create a test branch
  • Edit README.md a bit

Install MCP Extension

In VSCode's extensions, search for @mcp GitHub and install it.

MCP extension installation

Then, .vscode/mcp.json will be created in the project.

mcp.json

{
    "servers": {
        "io.github.github/github-mcp-server": {
            "type": "stdio",
            "command": "docker",
            "args": [
                "run",
                "-i",
                "--rm",
                "-e",
                "GITHUB_PERSONAL_ACCESS_TOKEN=${input:token}",
                "ghcr.io/github/github-mcp-server:0.30.2"
            ],
            "gallery": "https://api.mcp.github.com",
            "version": "0.30.2"
        }
    },
    "inputs": [
        {
            "id": "token",
            "type": "promptString",
            "description": "",
            "password": true
        }
    ]
}

Warning: mcp.json is "the list of things AI is allowed to do". AI cannot perform operations that are not listed here.

Give Copilot Instructions

I give Copilot the following instruction:

Copilot instruction

Results

After waiting a while, it seems Copilot created the PR for me.

Copilot result

I accessed the GitHub page and confirmed it was actually created!

PR created on GitHub

MCP really does the job...!

My Impressions After Using It

By using MCP,
I really felt that AI becomes "an entity that not only thinks but actually takes action"
rather than just providing advice. It's like having a talented colleague! (lol)

Summary

MCP is difficult to understand just by reading the explanation.
But when you actually try it, you realize "oh, that's what it is" all at once.

If you're interested in MCP,
I recommend trying GitHub MCP Server first.

Info: In this article, I tried GitHub MCP Server, but there are many other types of MCP. I plan to try others later as well.

來源:DEV Community · dev.to