Skip to content

Commit 40aac4d

Browse files
feat: initial draft of the exercise
1 parent 2c77229 commit 40aac4d

File tree

20 files changed

+1296
-0
lines changed

20 files changed

+1296
-0
lines changed

.devcontainer/devcontainer.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "Python 3",
3+
"image": "mcr.microsoft.com/vscode/devcontainers/python:3.13",
4+
"features": {
5+
"ghcr.io/devcontainers/features/node:1": {
6+
"version": "latest"
7+
}
8+
},
9+
"forwardPorts": [8000],
10+
"postCreateCommand": "pip install -r requirements.txt",
11+
"customizations": {
12+
"vscode": {
13+
"extensions": [
14+
"GitHub.copilot",
15+
"ms-python.python",
16+
"ms-python.debugpy",
17+
"dbaeumer.vscode-eslint"
18+
]
19+
}
20+
}
21+
}

.github/steps/1-step.md

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
## Step 1: Introduction to MCP and environment setup
2+
3+
Welcome to the **"Integrate Model Context Protocol with GitHub Copilot"** exercise! :robot:
4+
5+
In this exercise, you'll learn how Model Context Protocol (MCP) enhances the way you use GitHub Copilot.
6+
7+
> [!IMPORTANT]
8+
> This exercise may not explain the basics that were taught in the [Getting Started with Copilot](https://github.com/skills/getting-started-with-github-copilot) exercise. If you are new to Copilot we recommend starting with that one.
9+
10+
11+
### What is Model Context Protocol (MCP)?
12+
13+
[Model Context Protocol (MCP)](https://modelcontextprotocol.io/introduction) is an open standard that bridges AI models with external data sources and tools. It provides a universal interface for connecting AI assistants like GitHub Copilot to various system allowing them to access real-time data, perform actions in external systems, and leverage specialized tools beyond their built-in capabilities.
14+
### :keyboard: Activity: Get to know your environment
15+
16+
Let's start up our development environment and familiarize with the environment.
17+
18+
We are using the same web application as in the [Getting Started with Copilot](https://github.com/skills/getting-started-with-github-copilot) exercise - the Mergington High School's extracurricular activities website.
19+
20+
1. Right-click the below button to open the **Create Codespace** page in a new tab. Use the default configuration.
21+
22+
[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/{{full_repo_name}}?quickstart=1)
23+
24+
1. Validate the Copilot Chat extension is installed
25+
1. In the left sidebar, select the `Run and Debug` tab and then press the **Start Debugging** icon.
26+
27+
<img width="300" alt="image" src="https://github.com/user-attachments/assets/50b27f2a-5eab-4827-9343-ab5bce62357e" />
28+
29+
1. Throughout the exercise, you can access the website link from the `ports` tab on port `8000`.
30+
31+
### :keyboard: Activity: Set up a MCP server for your project
32+
33+
1. Inside your codespace, create a new file named `mcp.json` in the `.vscode` directory and paste the following contents:
34+
35+
```json
36+
// .vscode/mcp.json
37+
{
38+
"servers": {
39+
"github": {
40+
"command": "npx",
41+
"args": ["-y", "@modelcontextprotocol/server-github"],
42+
"envFile": "${workspaceFolder}/.env"
43+
}
44+
}
45+
}
46+
```
47+
48+
1. Save the file and you should see `Start` button show up like so:
49+
50+
<!-- TODO: Add screenshot with start button -->
51+
52+
1. Validate the MCP Server is running.
53+
1. The `.vscode/mcp.json` file should show if the server you started is running
54+
<!-- TODO: Add screenshot -->
55+
1. You should see additional tools available in Copilot Agent Mode
56+
<!-- TODO: Add screenshot -->
57+
1. You can use the VSCode command palette `Ctrl+Shift+P` or `Command+Shift+P` on Mac.
58+
Start typing `> MCP` to see different MCP commands, such as listing active servers.
59+
<!-- TODO: Add screenshot -->
60+
61+
1. Commit and push the `.vscode/mcp.json` file to the `main` branch
62+
63+
64+
<details>
65+
<summary>Having trouble?</summary><br/>
66+
67+
Make sure you:
68+
69+
- Properly uncommented the contents of `.vscode/mcp.json` file
70+
- Pushed your changes to the `main` branch
71+
72+
</details>

.github/steps/2-step.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
## Step 2: Using Copilot Agent Mode with GitHub MCP Server
2+
3+
You have just connected a first external MCP server to Copilot Chat!
4+
5+
GitHub MCP Server exposes multiple tools for Copilot to use. Examples include searching GitHub, managing repositories, issues, pull requests and much more.
6+
7+
You interact with Copilot in natural language, and Copilot determines if what you are asking for is something that can be done through any MCP Servers you have currently running in your environment. Isn't that cool?
8+
9+
> [!NOTE]
10+
> The GitHub MCP Server is limited to operations permitted by the `GITHUB_TOKEN` scope in your `.vscode/mcp.json` configuration.
11+
12+
### :keyboard: Activity: Use Copilot for issue resolution
13+
14+
In the background your repository just received a [bug report]({{{bug_report_url}}}) issue from one of the Mergington High School students trying to access the website.
15+
16+
Let's use GitHub Copilot Agent Mode together with GitHub MCP server to work on that issue.
17+
18+
1. Open the **Copilot Chat Agent Mode** panel in VS Code and ensure that GitHub MCP Server is active, and the tools are enabled
19+
20+
<!-- TODO: Add screenshot -->
21+
22+
1. Ask Copilot if there are any open bug reports on your repository:
23+
24+
> <img width="13px" src="https://github.com/user-attachments/assets/98fd5d2e-ea29-4a4a-9212-c7050e177a69" /> **Prompt**
25+
>
26+
> ```prompt
27+
> Are there any open bug report issues on my repository ({{{full_repo_name}}}) ?
28+
> ```
29+
30+
> 🪧 **Note:** We explicitly include the repository name to add it to Copilot's session context. For subsequent prompts, this context will be preserved in the conversation.
31+
32+
> ✨ **Bonus:** You are welcome to try the prompt without it and if Copilot chooses to list issues in a different repository, guide it your way.
33+
34+
1. Once Copilot identifies a bug report, ask it to implement a fix:
35+
36+
> <img width="13px" src="https://github.com/user-attachments/assets/98fd5d2e-ea29-4a4a-9212-c7050e177a69" /> **Prompt**
37+
>
38+
> ```prompt
39+
> Okay, let's start working on the bug report.
40+
> Comment on the issue that I will take a look at the issue and try to fix it.
41+
> Create a new branch, introduce the changes and raise a pull request to the `main` branch
42+
> ```
43+
44+
> ⚠️ **Warning:** Always verify the information that Copilot passes to the MCP server before accepting.
45+
46+
1. Follow Copilot's guidance to create a pull request with the fix.
47+
48+
> 🪧 **Note:** Remember that Copilot is conversational, and you are power of guiding the AI assistant to implement what's on your mind.
49+
50+
1. Once the pull request is created, Mona will start checking your work. Give her a moment and keep watch of the comments. You will see her respond with progress info and the next step!
51+
52+
<details>
53+
<summary>Having trouble?</summary><br/>
54+
55+
If you encounter issues:
56+
57+
- Make sure your MCP configuration is properly set up from Step 1
58+
- Verify that the tools are executed on your repository ({{{full_repo_name}}}). Whenever a MCP tool is invoked you can inspect what Copilot passes to the MCP Server.
59+
60+
</details>

.github/steps/3-step.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
## Step 3: Validating AI-generated code
2+
3+
Great work on implementing the fix with Copilot!
4+
5+
While AI assistants like GitHub Copilot can dramatically improve productivity, it's essential to remember that you are responsible for reviewing and validating all generated code.
6+
7+
> [!tip]
8+
> Whenever working on real projects, use [GitHub Actions](https://github.com/features/actions) to setup automated testing for your projects.
9+
10+
### :keyboard: Activity: Review and merge the AI solution
11+
12+
1. Examine the [pull request]({{{pull_request_url}}}) Copilot helped you create.
13+
14+
> **Bonus:** If your access is sufficient, you can ask Copilot to review your code.
15+
16+
1. Once you're satisfied with the changes, merge the pull request
17+
18+
> 🪧 **Note:** If you are not satisfied, go back to the codespace and work with Copilot to introduce the changes. Remember, coding is an iterative process.
19+
20+
<details>
21+
<summary>Having trouble?</summary><br/>
22+
23+
If you encounter issues:
24+
25+
- Make sure the PR was created correctly in the previous step
26+
- If needed, you can navigate directly to your repository on GitHub.com to find the PR
27+
- Remember that while MCP helps Copilot understand your repo better, human review is still essential
28+
29+
</details>

.github/steps/4-step.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
## Step 4: Wrap up on the bug report
2+
3+
4+
### :keyboard: Activity: Wrap up the bug report
5+
6+
1. Open the **Copilot Chat Agent Mode** session in VS Code.
7+
1. Ask Copilot to comment on the bug report issue we just worked on. And include a little bonus for the proactive student!
8+
9+
> <img width="13px" src="https://github.com/user-attachments/assets/98fd5d2e-ea29-4a4a-9212-c7050e177a69" /> **Prompt**
10+
>
11+
> ```prompt
12+
> Add a closing comment on the bug report issue that the issue has been resolved.
13+
> Include a sneak peek of what to expect in the extracurricular GitHub Skills activity (top 5 most starred repositories in GitHub `skills` organization)
14+
> ```
15+
16+
<details>
17+
<summary>Having trouble? 🤷</summary><br/>
18+
19+
Some things to check
20+
- Is your MCP Server still running?
21+
- Check what information is passed to the MCP server calls - is Copilot using the correct repository?
22+
- Did Copilot comment on the bug report?
23+
</details>
24+

.github/steps/x-review.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
## Review
2+
3+
_Congratulations, you've completed this Exercise and joined the world of developers!_
4+
5+
<img src=https://octodex.github.com/images/collabocats.jpg alt=celebrate width=300 align=right>
6+
7+
Here's a recap of your accomplishments:
8+
9+
10+
### What's next?
11+
12+
13+
Check out these resources to learn more or get involved:
14+
15+
- [Take another GitHub Skills exercise](https://skills.github.com).
16+
_
17+
18+
__
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
name: Step 0 # Start Exercise
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
permissions:
9+
contents: write # Update Readme
10+
actions: write # Disable/enable workflows
11+
issues: write # Create issue and comment on issues
12+
13+
14+
env:
15+
STEP_1_FILE: ".github/steps/1-step.md"
16+
17+
jobs:
18+
start_exercise:
19+
if: |
20+
!github.event.repository.is_template
21+
name: Start Exercise
22+
uses: skills/exercise-toolkit/.github/workflows/[email protected]
23+
with:
24+
exercise-title: "Integrate MCP with Copilot"
25+
intro-message: "Welcome to the exercise! This exercise will help you learn how to integrate the Model Context Protocol (MCP) with GitHub Copilot."
26+
27+
28+
post_next_step_content:
29+
name: Post next step content
30+
runs-on: ubuntu-latest
31+
needs: [start_exercise]
32+
env:
33+
ISSUE_URL: ${{ needs.start_exercise.outputs.issue-url }}
34+
35+
36+
steps:
37+
- name: Checkout
38+
uses: actions/checkout@v4
39+
40+
- name: Get response templates
41+
uses: actions/checkout@v4
42+
with:
43+
repository: skills/exercise-toolkit
44+
path: exercise-toolkit
45+
ref: v0.1.0
46+
47+
- name: Build comment - add step content
48+
id: build-comment
49+
uses: skills/action-text-variables@v1
50+
with:
51+
template-file: ${{ env.STEP_1_FILE }}
52+
template-vars: |
53+
full_repo_name=${{ github.repository }}
54+
55+
- name: Create comment - add step content
56+
run: |
57+
gh issue comment "$ISSUE_URL" \
58+
--body "$ISSUE_BODY"
59+
env:
60+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
ISSUE_BODY: ${{ steps.build-comment.outputs.updated-text }}
62+
63+
- name: Create comment - watching for progress
64+
run: |
65+
gh issue comment "$ISSUE_URL" \
66+
--body-file exercise-toolkit/markdown-templates/step-feedback/watching-for-progress.md
67+
env:
68+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
69+
70+
- name: Disable current workflow and enable next one
71+
run: |
72+
gh workflow enable "Step 1"
73+
env:
74+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)