Skip to main content
Glama
MCP-YNU FastMCP Server

MCP-YNU FastMCP Server

Official
by ynu

MCP-YNU - Servidor FastMCP

Una implementación de servidor MCP dinámico que utiliza FastMCP que carga automáticamente herramientas, recursos y avisos desde los directorios respectivos.

Características

  • Carga dinámica de módulos desde los directorios tools/ , resources/ y prompts/

  • Descubrimiento y registro automático de módulos

  • Configuración sencilla y extensibilidad

  • Sugerencias de tipo para una mejor claridad del código y análisis estático

  • Registro completo para supervisar la actividad del servidor

Related MCP server: xmcp Application

Actualizaciones recientes

  • Se agregaron sugerencias de tipo en todo el código base

  • Manejo mejorado de instancias de MCP

  • Se agregó funcionalidad de registro

  • Se agregó licencia MIT

  • Documentación actualizada con enlaces de referencia

Estructura del directorio

mcp-ynu/
├── tools/          # Directory for tool modules
│   ├── __init__.py
│   ├── example.py
├── resources/      # Directory for resource modules
│   ├── __init__.py
│   ├── example.py
├── prompts/        # Directory for prompt modules
│   ├── __init__.py
│   ├── example.py
├── logger.py       # Logger implementation
├── main.py         # Main implementation
├── mcp_server.py   # MCP server implementation
├── README.md       # Project documentation
├── LICENSE         # MIT License
└── pyproject.toml  # Project configuration

Uso

  1. Crear módulos en los directorios apropiados

  2. Importar mcp mediante from mcp_server import mcp

  3. Ejecutar el servidor:

python main.py

Módulos de ejemplo

Ejemplo de módulo de herramientas (tools/example.py)

from mcp_server import mcp
import httpx

@mcp.tool()
def calculate_bmi(weight_kg: float, height_m: float) -> float:
    """Calculate BMI given weight in kg and height in meters"""
    return weight_kg / (height_m**2)


@mcp.tool()
async def fetch_weather(city: str) -> str:
    """Fetch current weather for a city"""
    async with httpx.AsyncClient() as client:
        response = await client.get(f"https://api.weather.com/{city}")
        return response.text

Ejemplo de módulo de recursos (resources/example.py)

from mcp_server import mcp

@mcp.resource("config://app")
def get_config() -> str:
    """Static configuration data"""
    return "App configuration here"


@mcp.resource("users://{user_id}/profile")
def get_user_profile(user_id: str) -> str:
    """Dynamic user data"""
    return f"Profile data for user {user_id}"

Ejemplo de módulo de indicaciones (prompts/example.py)

from mcp_server import mcp
from mcp.server.fastmcp.prompts import base

@mcp.prompt()
def review_code(code: str) -> str:
    return f"Please review this code:\n\n{code}"


@mcp.prompt()
def debug_error(error: str) -> list[base.Message]:
    return [
        base.UserMessage("I'm seeing this error:"),
        base.UserMessage(error),
        base.AssistantMessage("I'll help debug that. What have you tried so far?"),
    ]

Depuración

  1. Actualice MCP_TRANSPORT_TYPE en .env , ejecute python main.py para iniciar el servidor mcp

  2. Ejecute npx @modelcontextprotocol/inspector para abrir la inspección .

  3. Elija el tipo de transporte SSE con la URL http://localhost:<mcp_server_port>/sse o elija el tipo de transporte STDIO con el comando python y los argumentos /path/to/main.py

@modelcontextprotocol/inspector

Requisitos

  • Python >= 3.10

  • FastMCP

Enlaces de referencia

Licencia

Este proyecto está licenciado bajo la licencia MIT: consulte el archivo de LICENCIA para obtener más detalles.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      A basic MCP server template that provides a foundation for building custom tools, resources, and prompts. Serves as a starting point for developers to create their own MCP server functionality.
      -
    • F
      license
      Not graded
      quality
      D
      maintenance
      A template/starter project for building MCP servers with structured directories for tools, prompts, and resources that are automatically discovered and registered.
      5
      -
    • A
      license
      B
      quality
      D
      maintenance
      An MCP server that registers customizable prompt templates as tools for natural language interaction. It supports hot-reloading and easy extension via YAML or JSON files to automate tasks like code review, refactoring, and content summarization.
      2
      8 npm
      1
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      A Model Context Protocol server built with FastMCP that features dynamic tool loading and modular management via a dedicated tool directory. It supports both stdio and HTTP transport modes, enabling efficient development and deployment of custom MCP tools.
      -