SM

sammorrowdrums/mcp-python-starter

开发工具

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

19 stars 11 forks 质量 78 趋势 20MIT

一个用 Python 构建的入门 MCP 服务器。

概览

一个功能齐全的 Python 模型上下文协议(MCP)服务器模板,使用 FastMCP。本入门工具用简洁、Python 风格的代码演示所有主要 MCP 功能。 - Python 3.11+ - uv(推荐)或 pip 本项目包含了无缝开发的 VS Code 配置: 1. 在 VS Code 中打开项目 2.MCP 配置在 .vscode/mcp.json 3.使用 VS Code 的 MCP 工具测试服务器 1. 安装开发容器扩展 2.打开命令面板:“开发容器:在容器中重新打开” 3.一切都已预配置,随时可用! 当 uv 运行时,Python 脚本会自动重新加载。为了增强调试功能,可以使用提供 MCP Inspector 界面的 mcp dev。 MCP Inspector 是测试和调试 MCP 服务器的重要开发工具。

概述(AI 翻译)

一个功能齐全的 Python 模型上下文协议(MCP)服务器模板,使用 FastMCP。本入门工具用简洁、Python 风格的代码演示所有主要 MCP 功能。

📚 文献资料

  • 模型上下文协议
  • Python SDK
  • FastMCP 指南

✨ 特色

类别 特色 描述
工具 hello 带注释的基础工具
get_weather 工具返回结构化数据
ask_llm 调用LLM采样的工具
long_task 5秒进度更新工具
load_bonus_tool 动态加载新工具
资源 info://about 静态信息资源
file://example.md 基于文件的标记资源
模板 greeting://{name} 个性化问候语
data://items/{id} 按ID查询数据
提示词 greet 各种问候语
code_review 代码审查及重点领域

🚀 快速启动

先决条件

  • Python 3.11+
  • UV(推荐)或PIP

安装

运行服务器

市政交通(用于本地开发:

HTTP 传输(用于远程/网页部署):

🔧 VS 代码集成

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

README

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

MCP Python Starter

A feature-complete Model Context Protocol (MCP) server template in Python using the official MCP Python SDK. This starter demonstrates core MCP features with clean, Pythonic code.

📚 Documentation

✨ Features

Category Feature Description
Tools hello Basic tool with annotations
get_weather Tool returning structured data
ask_llm Tool that invokes LLM sampling
long_task Tool with 5-second progress updates
load_bonus_tool Dynamically loads a new tool
Resources info://about Static informational resource
file://example.md File-based markdown resource
Templates greeting://{name} Personalized greeting
data://items/{id} Data lookup by ID
Prompts greet Greeting in various styles
code_review Code review with focus areas

🚀 Quick Start

Prerequisites

Installation

# Clone the repository
git clone https://github.com/SamMorrowDrums/mcp-python-starter.git
cd mcp-python-starter

# Install with uv (recommended)
uv sync

# Or with pip
pip install -e .

Running the Server

stdio transport (for local development):

uv run mcp-python-starter --stdio

HTTP transport (for remote/web deployment):

uv run mcp-python-starter --http --port 3000

🔧 VS Code Integration

This project includes VS Code configuration for seamless development:

  1. Open the project in VS Code
  2. The MCP configuration is in .vscode/mcp.json
  3. Test the server using VS Code’s MCP tools

Using DevContainers

  1. Install the Dev Containers extension
  2. Open command palette: “Dev Containers: Reopen in Container”
  3. Everything is pre-configured and ready to use!

📁 Project Structure

.
├── mcp_starter/
│   ├── __init__.py
在 GitHub 查看完整 README

安装

npx @modelcontextprotocol/inspector -- uv run mcp-python-starter
新手?先看 mcpskill.org 教程 →