mcp-workshop
A simple MCP server that provides a hello world greeting and a tool to add two numbers.
README
Build your first MCP server
This workshop is for beginners. You do not need to have used GitHub Copilot or MCP before.
By the end, you will have:
- used two example tools;
- created a Python tool of your own; and
- asked Copilot to run your tool.
What are Copilot, MCP, and tools?
- GitHub Copilot is an AI assistant inside VS Code. You can type requests into Copilot Chat.
- An MCP server is a small program that gives Copilot extra abilities.
- A tool is one of those abilities. In this project, each tool is a Python function.
For example, this server has an add_numbers tool. Copilot can choose that
tool, send it two numbers, and show you the answer.
Part 1: Open the workshop
Use GitHub Codespaces so that everything is installed for you.
- Open this repository on GitHub.
- Select the green Code button.
- Select the Codespaces tab.
- Select Create codespace on main.
- Wait until VS Code appears and the terminal says:
Devcontainer setup complete.
You are now using VS Code in your browser. The files are on the left, the code editor is in the middle, and the terminal is at the bottom.
If GitHub asks you to sign in or enable Copilot, follow the message on screen. Ask your teacher if your account does not have access to Copilot.
Part 2: Open Copilot Chat
-
Find the Copilot icon near the top of VS Code.
-
Select it to open Copilot Chat.
-
If asked to sign in, sign in with your GitHub account.
-
Type this prompt into the chat box and press <kbd>Enter</kbd>:
Say hello in one short sentence.
If Copilot replies, it is ready.
Part 3: Try the MCP server
This project is already configured to connect the server to Copilot.
-
Reload VS Code: open the Command Palette with <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd>, type
Developer: Reload Window, and press <kbd>Enter</kbd>. -
Open Copilot Chat again.
-
Type this prompt:
Use the hello_world tool from mcp-workshop. -
Copilot may ask for permission to use the tool. Select Allow or Continue.
-
You should see
Hello, world!. -
Now type this prompt:
Use the add_numbers tool from mcp-workshop to add 7 and 5.
You should get 12.
Part 4: Create your own tool
Open src/mcp_workshop/server.py from the file list on the left.
Find the comment that says STEP 3. Directly above that comment, copy and
paste this tool:
@mcp.tool()
def favourite_colour(name: str) -> str:
"""Tell someone your favourite colour."""
return f"{name}, my favourite colour is blue!"
Change blue to your favourite colour, then save the file with
<kbd>Ctrl</kbd>+<kbd>S</kbd>.
What each line means:
@mcp.tool()tells the server that Copilot is allowed to use the function.def favourite_colour...gives the tool a name and one input calledname.strmeans the input and answer are text.- The text inside
"""explains the tool to Copilot. returngives the answer back to Copilot.
Part 5: Use your tool
-
Reload VS Code again using
Developer: Reload Window. -
Open Copilot Chat.
-
Type this prompt:
Use the favourite_colour tool from mcp-workshop. My name is Alex. -
Allow the tool if Copilot asks for permission.
You have built and used your first MCP tool.
Create a tool of your own
Choose something small and fun. For example, your tool could:
- create a superhero name;
- convert minutes to seconds;
- recommend a film genre;
- calculate the area of a rectangle; or
- give a random study suggestion.
Use this template:
@mcp.tool()
def your_tool_name(your_input: str) -> str:
"""Explain clearly what your tool does."""
return "Replace this with your answer"
Change the function name, input, explanation, and returned answer. Save the file, reload VS Code, and ask Copilot to use the new tool.
If something does not work
Try these checks in order:
- Copilot does not open: make sure you are signed in to GitHub and ask your teacher to check that you have Copilot access.
- Your tool does not appear: save
server.py, then reload VS Code. - Copilot does not use the tool: ask it to
Use the TOOL_NAME tool from mcp-workshop. - There is a red line in your code: compare your tool with the template. Check the brackets, colon, quotation marks, and indentation.
- The server reports an error: undo your latest change with <kbd>Ctrl</kbd>+<kbd>Z</kbd>, save, and reload VS Code.
- It still does not work: show your code and the complete error message to your teacher.
Optional: run the tests
In the terminal at the bottom of VS Code, enter:
pytest
The result should say 2 passed.
Optional: work without Codespaces
Install Python 3.10 or newer, open a terminal in this repository, and run:
python -m venv .venv
source .venv/bin/activate
pip install -e .[dev]
On Windows PowerShell, replace the second command with:
.venv\Scripts\Activate.ps1
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。