SM

sontallive/mcp-server-python-template

开发工具

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

18 stars 16 forks 质量 51 趋势 22MIT

本模板为在Python构建"模型背景协议"(MCP)服务器提供了精简的基础. 其设计旨在使人工智能辅助开发MCP工具更方便更有效率.

概览

本模板为在Python构建"模型背景协议"(MCP)服务器提供了精简的基础. 其设计旨在使人工智能辅助开发MCP工具更方便更有效率. - 准备使用 MCP 服务器执行 - 可配置的传输模式(stdio, SSE) - 实例天气服务集成(NWS API) - 干净,有详细记录的代码结构 - 最小依赖性 - 用于改进AI工具的理解 这个项目使用Cursor规则来改进AI编码协助,模式取自Super Cursor规则. - :内置的清洁码规则有助于保持一致性和质量 - :规则提供上下文,帮助AI助手生成更好的代码 - :遵循MCP服务器执行的既定最佳做法 Cursor规则帮助AI编码助理和人文开发者保持高代码质量标准并遵循最佳做法. 本模板包括项目中直接提供的综合多CP文件: - (标注/mcp.

概述(AI 翻译)

受MCP官方教程启发

□ 概览

本模板为在Python构建"模型背景协议"(MCP)服务器提供了精简的基础. 其设计旨在使人工智能辅助开发MCP工具更方便更有效率.

□ 特性

  • MCP服务器随时可用
  • 可配置的运输模式(stdio、SSE)
  • 气象服务整合实例
  • 干净、文件齐全的代码结构
  • 最低依赖性
  • ** 用于改进AI工具理解的嵌入式MCP规格和文件**

□ 光标规则集成

这个项目使用Cursor规则来改进AI编码协助,模式取自Super Cursor规则.

  • ** 清码准则**: 内建的清洁码规则有助于保持一致性和质量
  • ** 加强大赦国际的理解**: 规则提供上下文,帮助AI助手生成更好的代码
  • ** 标准化模式**:遵循执行MCP服务器的既定最佳做法

Cursor规则帮助AI编码助理和人文开发者保持高代码质量标准并遵循最佳做法.

□ 综合 MCP 文档

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

README

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

MCP Server template for better AI Coding

Inspired by MCP Official Tutorial

Overview

This template provides a streamlined foundation for building Model Context Protocol (MCP) servers in Python. It’s designed to make AI-assisted development of MCP tools easier and more efficient.

Features

  • Ready-to-use MCP server implementation
  • Configurable transport modes (stdio, SSE)
  • Example weather service integration (NWS API)
  • Clean, well-documented code structure
  • Minimal dependencies
  • Embedded MCP specifications and documentation for improved AI tool understanding

Cursor Rules Integration

This project uses Cursor Rules for improved AI coding assistance, with patterns from Awesome Cursor Rules.

  • Clean Code Guidelines: Built-in clean code rules help maintain consistency and quality
  • Enhanced AI Understanding: Rules provide context that helps AI assistants generate better code
  • Standardized Patterns: Follow established best practices for MCP server implementation

Cursor Rules help both AI coding assistants and human developers maintain high code quality standards and follow best practices.

Integrated MCP Documentation

This template includes comprehensive MCP documentation directly in the project:

  • Complete MCP Specification (protocals/mcp.md): The full Model Context Protocol specification that defines how AI models can interact with external tools and resources. This helps AI assistants understand MCP concepts and implementation details without requiring external references.

  • Python SDK Guide (protocals/sdk.md): Detailed documentation for the MCP Python SDK, making it easier for AI tools to provide accurate code suggestions and understand the library’s capabilities.

  • Example Implementation (protocals/example_weather.py): A practical weather service implementation demonstrating real-world MCP server patterns and best practices.

Having these resources embedded in the project enables AI coding assistants to better understand MCP concepts and provide more accurate, contextually relevant suggestions during development.

Requirements

  • Python 3.12+
  • Dependencies:
    • mcp>=1.4.1
    • httpx>=0.28.1
    • starlette>=0.46.1
    • uvicorn>=0.34.0

Getting Started

Installation

  1. Clone this repository:

    git clone https://github.com/yourusername/mcp-server-python-template.git
    cd mcp-server-python-template
    
  2. Create a virtual environment and install dependencies:

    python -m venv .venv
    source .venv/bin/activate  # On Windows: .venv\Scripts\activate
    pip install -e .
    

Running the Example Server

The template includes a weather service example that demonstrates how to build MCP tools:

# Run with stdio transport (for CLI tools)
python server.py --transport stdio
在 GitHub 查看完整 README

安装

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

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