Skip to main content
Glama

MCP-YNU FastMCP Server

Official
by ynu

MCP-YNU - FastMCP 服务器

使用 FastMCP 的动态 MCP 服务器实现,可自动从相应目录加载工具、资源和提示。

特征

  • tools/resources/prompts/目录动态加载模块

  • 自动发现和注册模块

  • 简单的配置和可扩展性

  • 类型提示可提高代码清晰度和静态分析能力

  • 用于监控服务器活动的综合日志记录

最近更新

  • 在整个代码库中添加了类型提示

  • 改进了 MCP 实例处理

  • 增加了日志记录功能

  • 添加 MIT 许可证

  • 更新了带有参考链接的文档

目录结构

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

用法

  1. 在适当的目录中创建模块

  2. 通过from mcp_server import mcp

  3. 运行服务器:

python main.py

示例模块

工具模块示例(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

资源模块示例(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}"

提示模块示例(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?"), ]

调试

  1. 更新.env中的MCP_TRANSPORT_TYPE ,执行python main.py启动 mcp 服务器

  2. 执行npx @modelcontextprotocol/inspector打开检查

  3. 选择SSE传输类型,URL 为http://localhost:<mcp_server_port>/sse或选择STDIO传输类型,命令为python ,参数为/path/to/main.py

@modelcontextprotocol/检查器

要求

  • Python >= 3.10

  • FastMCP

参考链接

执照

该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅LICENSE文件。

-
security - not tested
A
license - permissive license
-
quality - not tested

Related MCP Servers

  • A
    security
    A
    license
    A
    quality
    MCP server that builds itself by creating new tools as needed based on user requests (Requires restart of Claude Desktop to use newly created tools).
    Last updated -
    4
    27
    The Unlicense
  • -
    security
    F
    license
    -
    quality
    A configurable MCP server that dynamically loads capabilities from a remote configuration to bridge MCP clients with remote APIs for executing actions, accessing resources, and utilizing prompt templates.
    Last updated -
    371
    5
  • A
    security
    A
    license
    A
    quality
    A tool that dynamically generates and configures MCP servers by automatically creating necessary directories and files according to user specifications.
    Last updated -
    1
    19
    20
    MIT License
  • A
    security
    F
    license
    A
    quality
    An MCP server that allows users to create custom tools on the fly by stitching together actions from multiple MCP tools into reusable routines.
    Last updated -
    4
    0
    1

View all related MCP servers

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ynu/mcp-ynu'

If you have feedback or need assistance with the MCP directory API, please join our Discord server