FM

fulfilio/mcp-utils

Developer tools

Эта страница переведена автоматически. Технические детали смотрите в оригинале. Открыть оригинал

5 stars 6 forks Качество 61 Тренд 13MIT

Python utilities to work with MCP servers

Обзор

A Python utility package for building Model Context Protocol (MCP) servers. mcp-utils provides utilities and helpers for building MCP-compliant servers in Python, with a focus on synchronous implementations using Flask. This package is designed for developers who want to implement MCP servers in their existing Python applications without the complexity of asynchronous code. - Basic utilities for MCP server implementation - Server-Sent Events (SSE) support - Simple decorators for MCP endpoints - Synchronous implementation - HTTP protocol support - Redis response queue - Comprehensive Pydantic models for MCP schema - Built-in validation and documentation - Flask (for web server) - Gunicorn (for production deployment) - Redis (for response queue) Here's a simple example of creating an MCP server: For production use, you can use a simple Flask app with the mcp server and support Streamable HTTP from version 2025-06-18.

README

Показан фрагмент оригинального README. Открыть оригинал.

mcp-utils

A Python utility package for building Model Context Protocol (MCP) servers.

Table of Contents

Overview

mcp-utils provides utilities and helpers for building MCP-compliant servers in Python, with a focus on synchronous implementations using Flask. This package is designed for developers who want to implement MCP servers in their existing Python applications without the complexity of asynchronous code.

Key Features

  • Basic utilities for MCP server implementation
  • Server-Sent Events (SSE) support
  • Simple decorators for MCP endpoints
  • Synchronous implementation
  • HTTP protocol support
  • Redis response queue
  • Comprehensive Pydantic models for MCP schema
  • Built-in validation and documentation

Installation

pip install mcp-utils

Requirements

  • Python 3.10+
  • Pydantic 2

Optional Dependencies

  • Flask (for web server)
  • Gunicorn (for production deployment)
  • Redis (for response queue)

Usage

Basic MCP Server

Here’s a simple example of creating an MCP server:

from mcp_utils.core import MCPServer
from mcp_utils.schema import GetPromptResult, Message, TextContent, CallToolResult

# Create a basic MCP server
mcp = MCPServer("example", "1.0")

@mcp.prompt()
def get_weather_prompt(city: str) -> GetPromptResult:
    return GetPromptResult(
        description="Weather prompt",
        messages=[
            Message(
                role="user",
                content=TextContent(
                    text=f"What is the weather like in {city}?",
                ),
            )
        ],
    )

@mcp.tool()
def get_weather(city: str) -> str:
    return "sunny"

Flask Example

For production use, you can use a simple Flask app with the mcp server and support Streamable HTTP

Открыть полный README на GitHub

Установка

npx -y @smithery/cli install mcp-proxy --client claude
Новичок в MCP? Начните с руководства на mcpskill.org →

Конфигурация

{ "mcpServers": { "server-name": { "url": "http://localhost:9000/mcp" } } }