MCP Demo Server

by KennyKang7012

187 downloads
Not rated
GitHub

Description

# MCP Demo Server 這是一個簡單的 Model Context Protocol (MCP) 伺服器示例專案。此專案展示了如何使用 Python 建立基本的 MCP 工具。 ## 功能特點 本專案實現了兩個簡單的 MCP 工具: - `add`: 一個簡單的加法函數,接受兩個整數並返回其總和 - `say_hello`: 一個問候函數,接受名字參數並返回問候語 ## 技術需求 - Python 3.x - MCP (Model Context Protocol) 庫 - uv (Python 套件管理工具) ## 安裝步驟 1…

About

# MCP Demo Server 這是一個簡單的 Model Context Protocol (MCP) 伺服器示例專案。此專案展示了如何使用 Python 建立基本的 MCP 工具。 ## 功能特點 本專案實現了兩個簡單的 MCP 工具: - `add`: 一個簡單的加法函數,接受兩個整數並返回其總和 - `say_hello`: 一個問候函數,接受名字參數並返回問候語 ## 技術需求 - Python 3.x - MCP (Model Context Protocol) 庫 - uv (Python 套件管理工具) ## 安裝步驟 1. 克隆此專案: ```bash git clone [repository-url]…

Details

Author
KennyKang7012
Downloads
187
Categories
Other

- Implements a simple addition tool (add)
- Implements a greeting tool (say_hello)
- Written in Python using the MCP library
- Ready-to-use with VS Code and GitHub Copilot

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name MCP Demo Server
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Clone the repository, create a virtual environment, install the mcp[cli] package, then run uv run --with mcp[cli] mcp run server.py to start the server. You can also test it in development mode with mcp dev server.py. For GitHub Copilot integration, configure a .vscode/mcp.json file with the uv command.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "mcp demo server": {
            "MCP-Demo-Server": {
                "command": "python",
                "args": [
                    "-m",
                    "venv",
                    ".venv"
                ]
            }
        }
    }
}

McpServers

{
    "MCP-Demo-Server": {
        "command": "python",
        "args": [
            "-m",
            "venv",
            ".venv"
        ]
    }
}

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

2. 建立虛擬環境並安裝依賴:

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"
]
}
}
}

3. 設定完成後,GitHub Copilot 將能夠自動連接到您的 MCP 伺服器,並使用其提供的工具功能。

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

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.