mcpField
M
MCP Demo Server

MCP Demo Server

Local
github.com/KennyKang7012Developer Tools0Updated 71w ago

About MCP Demo Server

MCP Demo Server is a basic Python MCP server example for learning and testing simple tools. It provides integer addition and personalized greetings, with a VS Code configuration included.

Key features

  1. 01Python MCP server example
  2. 02Integer addition tool
  3. 03Personalized greeting tool
  4. 04VS Code configuration
  5. 05Development mode with hot reload

Use cases

  1. 01Learn to implement basic MCP tools
  2. 02Test client calls for addition and greetings
  3. 03Run and debug the server in VS Code

MCP support

The MCP server exposes the `add` and `say_hello` tools to compatible clients. The project includes VS Code configuration for use with GitHub Copilot.

Configuration

Local server config is the same for every client. Copy it into your client’s MCP config file.

No install method listed yet

We haven’t collected a package or remote endpoint for this server. Follow the instructions in the project README.

Repository

Tools

No tool list yet

Local servers expose tools only once running on your machine, and the maintainer has not provided a tool list.

Details

From the project README

MCP Demo Server

這是一個簡單的 Model Context Protocol (MCP) 伺服器示例專案。此專案展示了如何使用 Python 建立基本的 MCP 工具。

功能特點

本專案實現了兩個簡單的 MCP 工具:

  • add: 一個簡單的加法函數,接受兩個整數並返回其總和
  • say_hello: 一個問候函數,接受名字參數並返回問候語

技術需求

  • Python 3.x
  • MCP (Model Context Protocol) 庫
  • uv (Python 套件管理工具)

安裝步驟

  1. 克隆此專案:
git clone [repository-url]
cd mcp-demo
  1. 建立虛擬環境並安裝依賴:
python -m venv .venv
source .venv/bin/activate  # On Windows use: .venv\Scripts\activate
pip install mcp[cli]

使用方法

要啟動 MCP 伺服器,請執行:

uv run --with mcp[cli] mcp run server.py

專案結構

mcp-demo/
├── server.py        # MCP 伺服器主程式
├── .gitignore      # Git 忽略檔案
└── README.md       # 本文件

開發說明

伺服器實現了兩個基本工具:

  1. add(a: int, b: int) -> int

    • 功能:將兩個整數相加
    • 參數:
      • a: 第一個整數
      • b: 第二個整數
    • 返回:兩數之和
  2. say_hello(name: str) -> str

    • 功能:生成個人化的問候語
    • 參數:
      • name: 要問候的人名
    • 返回:包含問候語的字串

配置

專案包含 VS Code 配置文件 (.vscode/mcp.json),可直接在 VS Code 中執行和測試 MCP 伺服器

測試伺服器

在開發模式下測試 MCP 伺服器:

mcp dev server.py

這個命令會:

  1. 在開發模式下啟動伺服器
  2. 自動重新載入程式碼變更
  3. 提供更詳細的除錯資訊

GitHub Copilot 設定

要在 GitHub Copilot 中使用此 MCP 伺服器,請在 VS Code 中設定以下步驟:

  1. 在專案根目錄建立 .vscode 資料夾(如果還沒有的話)

  2. 在 .vscode 資料夾中建立 mcp.json 檔案,內容如下:

{
    "servers": {
      "Demo": {
        "command": "uv",
        "args": [
          "run",
          "--with",
          "mcp[cli]",
          "mcp",
          "run",
          "${workspaceFolder}/server.py"
        ]
      }
    }
}
  1. 設定完成後,GitHub Copilot 將能夠自動連接到您的 MCP 伺服器,並使用其提供的工具功能。

注意:

  • 確保已正確安裝 uv 套件管理工具
  • ${workspaceFolder} 會自動被替換為您的專案根目錄路徑
  • 如果使用不同的 Python 環境管理工具,可以根據需要調整 command 和 args

授權

MIT License

致謝

MCP-Demo-Server 已由以下機構索引和認證 MCP 評論。

Comments

Markdown supported

New to MCP?

From what the protocol is to installing your first server, these answers cover most first questions.

An open protocol that defines how AI applications connect to external tools and data in a uniform way. Clients talk to the model; MCP servers provide tools, resources and prompt templates. They exchange standard messages, so one server can be reused by many clients.