PM

pamelafox/mcp-python-demo

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

47 stars 16 forks 质量 64 趋势 13MIT

pamelafox/mcp-python-demo 是从 https://github.com/pamelafox/mcp-python-demo. 导入的 MCP 服务器候选。

概览

pamelafox/mcp-python-demo 是从 https://github.com/pamelafox/mcp-python-demo. 导入的 MCP 服务器候选。

概述(AI 翻译)

该仓库演示了Model Context Protocol(MCP)SDK for Python的使用。

布置

如果使用开发容器(推荐)

如果你用的是开发容器(带Docker的VS Code),一切都已经为你设置好了!容器里包含Python、uv和所有必要的工具。

如果是本地运行

  1. 如果还没安装UV,请安装

  2. 创建虚拟环境:

  3. 激活虚拟环境:

  • macOS/Linux:

  • 在Windows上:

  1. 从 pyproject.toml 安装依赖:

正在执行开发检查员

运行开发检查员:

安装 Claude

要在 Claude 中安装此 MCP 插件:

  1. 执行此命令:

  2. 重启Claude

  3. 排查:如果出现错误,请在配置中将uv路径修正为绝对路径:

然后用绝对路径更新配置。

在GitHub Copilot中安装

📺 如果你更喜欢通过视频学习,可以看看Burke Holland的这个视频或James Montemagno的这个视频。

如果你已经安装在Claude Desktop里

启用“chat.mcp.discovery”。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

MCP Python Demo

This repository demonstrates the use of Model Context Protocol (MCP) SDK for Python.

Setup

If you’re using the dev container (VS Code with Docker), everything is already set up for you! The container includes Python, uv, and all necessary tools.

If running locally

  1. Install uv if you haven’t already

  2. Create a virtual environment:

    uv venv
    
  3. Activate the virtual environment:

    • On macOS/Linux:

      source .venv/bin/activate
      
    • On Windows:

      .venv\Scripts\activate
      
  4. Install dependencies from pyproject.toml:

    uv sync --dev
    

Running Development Inspector

To run the development inspector:

mcp dev server.py

Installing in Claude

To install this MCP plugin in Claude:

  1. Run this command:

    mcp install server.py
    
  2. Restart Claude

  3. Troubleshooting: If you get an error, fix the uv path in the config to an absolute path:

    which uv
    

    Then update the configuration with the absolute path.

Installing in GitHub Copilot

📺 If you prefer learning from videos, watch this video from Burke Holland or this video from James Montemagno.

If you already installed in Claude Desktop

Enable chat.mcp.discovery.enabled: true in your settings and VS Code will discover existing MCP server lists, and proceed to use the tool in GitHub Copilot Agent mode.

If you did not install in Claude Desktop

  • If you want to associate the MCP server only with a particular repo, create a .vscode/mcp.json file with this content:

    {
    "inputs": [
    ],
    "servers": {
          "pamelas-mcp": {
             "command": "PATH/TO/uv",
             "args": [
                "--directory",
                "/PATH/TO/mcp-python-demo",
                "run",
                "server.py"
             ]
          }
    }
    }
    
  • Alternatively, if you want to associate the MCP server with all repos, add to your VS Code User Settings JSON:

    {
    "mcp": {
       "inputs": [],
       "servers": {
          "pamelas-mcp": {
          "command": "/PATH/TO/uv",
          "args": [
             "--directory",
             "/PATH/TO/mcp-python-demo",
             "run",
             "server.py"
          ]
          }
       }
    }
    }
    

    Another way to update settings is to run this command in the terminal:

    code-insiders --add-mcp "{\"name\":\"pamelas-mcp\",\"command\":\"/PATH/TO/uv\",\"args\":[\"--directory\",\"/PATH/TO/mcp-python-demo\",\"run\",\"server.py\"]}"
    

Using tools in Copilot

  1. Now that the mcp server is discoverable, open GitHub Copilot and select the Agent mode (not Chat or Edits).
在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →