Visual Studio Code and GitHub Copilot can act as a client and consume an MCP Server.
Why would we want to do that you might ask?
Well, that means whatever features the MCP Server has can now be used from within your IDE.
Imagine you adding for example GitHub's MCP server, this would allow for controlling GitHub via prompts over typing specific commands in the terminal.
Or imagine anything in general that could improve your developer experience all controlled by natural language.
Now you start to see the win right?
This lesson covers how to use Visual Studio Code and GitHub Copilot's Agent mode as a client for your MCP Server.
By the end of this lesson, you will be able to:
You can control your MCP server in two different ways:
code exectuable:To add an MCP server to your user profile, use the --add-mcp command line option, and provide the JSON server configuration in the form {\"name\":\"server-name\",\"command\":...}.
```
code --add-mcp "{\"name\":\"my-server\",\"command\": \"uvx\",\"args\": [\"mcp-server-fetch\"]}"
```
Let's talk more about how we use the visual interface in the next sections.
Here's how we need to approach this at high level:
Great, now that we understand the flow, let's try use an MCP Server through Visual Studio Code through an exercise.
In this exercise, we will configure Visual Studio Code to find your MCP server so that it can be used from GitHub Copilot Chat interface.
You may need to enable discovery of MCP Servers.
1. Go to File -> Preferences -> Settings in Visual Studio Code.
1. Search for "MCP" and enable chat.mcp.discovery.enabled in the settings.json file.
Start by creating a config file in your project root, you will need a file called MCP.json and to place it in a folder called .vscode. It should look like so:
.vscode
|-- mcp.json
Next, let's see how we can add a server entry.
Add the following content to *mcp.json*:
{
"inputs": [],
"servers": {
"hello-mcp": {
"command": "node",
"args": [
"build/index.js"
]
}
}
}
Here's a simple example above how to start a server written in Node.js, for other runtimes point out the proper command for starting the server using command and args.
Now that you've added an entry, let's start the server:
1. Locate your entry in *mcp.json* and make sure you find the "play" icon:
!Starting server in Visual Studio Code
1.
Click the "play" icon, you should see the tools icon in the GitHub Copilot Chat increase the number of available tools.
If you click said tools icon, you will see a list of registered tools.
You can check/uncheck each tool depending if you want GitHub Copilot to use them as context:
!Starting server in Visual Studio Code
1. To run a tool, type a prompt that you know will match the description of one of your tools, for example a prompt like so "add 22 to 1":
!Running a tool from GitHub Copilot
You should see a response saying 23.
Try adding a server entry to your *mcp.json* file and make sure you can start/stop the server. Make sure you can also communicate with the tools on your server via GitHub Copilot Chat interface.
The takeaways from this chapter is the following:
Visual Studio Code와 GitHub Copilot은 클라이언트 역할을 하며 MCP 서버를 사용할 수 있습니다.
왜 이런 기능이 필요할까요?
MCP 서버의 모든 기능을 IDE 내에서 사용할 수 있다는 뜻입니다.
예를 들어 GitHub의 MCP 서버를 추가하면 터미널에서 특정 명령어를 입력하는 대신 프롬프트를 통해 GitHub을 제어할 수 있습니다.
또는 개발자 경험을 개선할 수 있는 모든 것을 자연어로 제어할 수 있다고 상상해 보세요.
이제 이 기능의 장점을 이해할 수 있겠죠?
이 강의에서는 Visual Studio Code와 GitHub Copilot의 에이전트 모드를 사용하여 MCP 서버를 클라이언트로 활용하는 방법을 다룹니다.
이 강의를 마치면 다음을 할 수 있습니다:
MCP 서버를 제어하는 방법은 두 가지가 있습니다:
code 실행 파일을 사용하여 터미널에서 제어할 수 있습니다. 사용자 프로필에 MCP 서버를 추가하려면 --add-mcp 명령줄 옵션을 사용하고 JSON 서버 설정을 다음 형식으로 제공하세요: {\"name\":\"server-name\",\"command\":...}.
```
code --add-mcp "{\"name\":\"my-server\",\"command\": \"uvx\",\"args\": [\"mcp-server-fetch\"]}"
```
다음 섹션에서 시각적 인터페이스를 사용하는 방법에 대해 더 알아보겠습니다.
다음은 고수준에서 접근해야 할 방법입니다:
좋습니다, 이제 흐름을 이해했으니 Visual Studio Code를 통해 MCP 서버를 사용하는 연습을 해봅시다.
이 연습에서는 Visual Studio Code를 설정하여 MCP 서버를 찾아 GitHub Copilot 채팅 인터페이스에서 사용할 수 있도록 합니다.
MCP 서버 검색을 활성화해야 할 수도 있습니다.
1. Visual Studio Code에서 파일 -> 기본 설정 -> 설정으로 이동합니다.
1. "MCP"를 검색하고 settings.json 파일에서 chat.mcp.discovery.enabled를 활성화합니다.
프로젝트 루트에 설정 파일을 생성하세요. MCP.json이라는 파일을 생성하고 .vscode 폴더에 배치해야 합니다. 다음과 같이 보일 것입니다:
.vscode
|-- mcp.json
다음으로 서버 항목을 추가하는 방법을 알아봅시다.
*mcp.json*에 다음 내용을 추가하세요:
{
"inputs": [],
"servers": {
"hello-mcp": {
"command": "node",
"args": [
"build/index.js"
]
}
}
}
위의 예는 Node.js로 작성된 서버를 시작하는 간단한 예입니다.
다른 런타임의 경우 command와 args를 사용하여 서버를 시작하는 적절한 명령을 지정하세요.
항목을 추가했으니 이제 서버를 시작해봅시다:
1. *mcp.json*에서 항목을 찾아 "재생" 아이콘을 확인하세요:
1. "재생" 아이콘을 클릭하면 GitHub Copilot 채팅의 도구 아이콘에 사용 가능한 도구 수가 증가하는 것을 볼 수 있습니다. 해당 도구 아이콘을 클릭하면 등록된 도구 목록이 표시됩니다. 각 도구를 체크하거나 체크 해제하여 GitHub Copilot이 이를 컨텍스트로 사용할지 여부를 결정할 수 있습니다:
1. 도구를 실행하려면 도구 설명과 일치하는 프롬프트를 입력하세요. 예를 들어 "22에 1을 더해줘"와 같은 프롬프트를 입력합니다:
응답으로 23이 표시될 것입니다.
*mcp.json* 파일에 서버 항목을 추가하고 서버를 시작/중지할 수 있는지 확인하세요. GitHub Copilot 채팅 인터페이스를 통해 서버의 도구와 통신할 수 있는지도 확인하세요.
이 챕터의 주요 내용은 다음과 같습니다:
---
면책 조항:
이 문서는 AI 번역 서비스 Co-op Translator를 사용하여 번역되었습니다.
정확성을 위해 최선을 다하고 있지만, 자동 번역에는 오류나 부정확성이 포함될 수 있습니다.
원본 문서의 원어 버전을 권위 있는 출처로 간주해야 합니다.
중요한 정보의 경우, 전문적인 인간 번역을 권장합니다.
이 번역 사용으로 인해 발생하는 오해나 잘못된 해석에 대해 책임을 지지 않습니다.