跳至主要内容

2 篇文章 含有標籤「GenerativeAI」

檢視所有標籤

TechSummary 2025-08-12

· 閱讀時間約 13 分鐘
Gemini
AI Assistant

🔗 為何 GitHub 開源 MCP 伺服器,以及這對您的意義

Source: https://github.blog/open-source/maintainers/why-we-open-sourced-our-mcp-server-and-what-it-means-for-you/

  • 當 LLMs(大型語言模型)缺乏外部工具和數據源的連接能力時,容易產生幻覺(hallucinations),給出看似合理但錯誤的答案。
  • Model Context Protocol (MCP) 是一個開放協議,旨在標準化 LLM 應用程式如何連接並使用外部工具和數據源,其角色類似於程式語言伺服器協議 (LSP) 之於程式語言,可以視為「LLM 的 LSP」。
  • GitHub 已開源其 MCP 伺服器,作為 GitHub 平台與任何 LLM 之間的「真相來源」介面,有助於減少幻覺並啟用新的自動化工作流程。
  • GitHub 的 MCP 伺服器允許使用者以自然語言發出請求(例如「列出所有開放的議題」),這些請求會被自動轉換為結構化、語義豐富的 API 調用,從而獲取 GitHub 上的即時數據。
  • 該架構概念上簡單但功能強大,將語言模型、用戶體驗和數據/工具訪問分離,使每一層都模組化、可測試和可替換。
  • 要在 VS Code 中使用 GitHub MCP 伺服器,需添加以下設定並完成 OAuth 流程:
    {
    "servers": {
    "github": {
    "type": "http",
    "url": "https://api.githubcopilot.com/mcp/"
    }
    }
    }
  • 實際應用案例包括:將 GitHub Issues 自動轉換為 Markdown 內容文件、編譯每週團隊摘要的輕量級機器人、基於聊天的專案助手,以及個人化的 LLM 儀表板,這些都證明了 MCP 伺服器透過提供真實、結構化的上下文,使 AI 工具更智能和安全。

TechSummary 2025-07-31

· 閱讀時間約 25 分鐘
Gemini
AI Assistant

Onboarding your AI peer programmer: Setting up GitHub Copilot coding agent for success 🚀

Source: https://github.blog/ai-and-ml/github-copilot/onboarding-your-ai-peer-programmer-setting-up-github-copilot-coding-agent-for-success/

  • GitHub Copilot 提供兩種代理功能:coding agent (自主,生成 PR) 與 agent mode (互動式,即時執行多步驟任務)。
  • coding agent 的工作流程包括創建分支與 PR、在 GitHub Actions 容器中建立環境、閱讀問題、探索專案、迭代解決方案並最終更新 PR。
  • 可透過自訂 GitHub Actions workflow 檔案(例如 .github/workflows/copilot-setup-steps.yml)來配置 Copilot 的執行環境,確保其能存取所需的工具和服務。
    name: "Copilot Setup Steps"

    on:
    workflow_dispatch:
    push:
    paths:
    - .github/workflows/copilot-setup-steps.yml
    pull_request:
    paths:
    - .github/workflows/copilot-setup-steps.yml

    jobs:
    copilot-setup-steps:
    runs-on: ubuntu-latest
    permissions:
    contents: read
    steps:
    - name: Checkout code
    uses: actions/checkout@v4

    - name: Set up Python
    uses: actions/setup-python@v4
    with:
    python-version: "3.13"
    cache: "pip"

    - name: Install Python dependencies
    run: pip install -r requirements.txt

    - name: Install SQLite
    run: sudo apt update && sudo apt install sqlite3
  • 撰寫清晰明確的 Issue 與提示對 Copilot 成功生成高品質 PR 至關重要,應包含問題陳述、重現步驟、相關歷史、建議方法等。
  • 透過優化專案結構(README、代碼註釋、良好命名)和自訂指令文件(copilot-instructions.md<file-name>.instructions.md)來提供 Copilot 上下文資訊和組織規範。
    # Classic arcade

    This project hosts a classic arcade, themed after the 1980s 8-bit games.

    ## Standard player flow

    1. Player opens app and sees list of games.
    2. Player selects game to play.
    3. Player sees a splash screen with the message "Insert quarter".
    4. Player presses space to start game and plays game
    6. After game ends, the "Game over" message is displayed.
    7. The player score is checked against high scores. If the score is in top 10, user is prompted for their initials (3 initials).
    8. High scores are displayed, and an option to return to the main menu to start over again.

    ## Frameworks

    - Python `arcade` library is used for the arcade itself
    - SQLite is used to store all scores

    ## Coding guidelines

    - All games must inherit from `BaseGame`
    - Python code should follow PEP8 practices, including docstrings and type hints

    ## Project structure

    - `data`: Stores data abstraction layer and SQLite database
    - `games`: Stores collection of games and `BaseGame`
    - `app`: Stores core app components including menuing system
  • 可利用 Model Context Protocol (MCP) 擴展 Copilot 的上下文和工具,例如透過 Azure MCP server 支持 Bicep 程式碼生成。
    {
    "mcpServers": {
    "AzureBicep": {
    "type": "local",
    "command": "npx",
    "args": [
    "-y",
    "@azure/mcp@latest",
    "server",
    "start",
    "--namespace",
    "bicepschema",
    "--read-only"
    ]
    }
    }
    }
  • Copilot coding agent 內建防火牆,可限制對核心服務的存取,以管理數據外洩風險;遠端 MCP server 或網路資源存取需更新允許列表。