Skip to main content
Glama

FastMCP Server

by zmzhace

MCP 服务器

一个功能丰富的 MCP (Model Context Protocol) 服务器,提供多种实用工具。

🚀 功能特性

基础工具

  • hello - 返回问候消息
  • getTime - 获取当前时间
  • calculate - 执行基本数学计算

外部服务

  • getWeather - 获取天气信息
  • translate - 翻译文本

文件操作

  • fileRead - 读取本地文件
  • fileWrite - 写入本地文件
  • fileList - 列出目录内容

实用工具

  • hashText - 计算文本哈希值
  • base64Encode - Base64 编码/解码

系统信息

  • getSystemInfo - 获取系统信息
  • getProcessInfo - 获取进程信息

网络工具

  • checkNetwork - 检查网络连接

娱乐工具

  • getJoke - 获取笑话

🔧 基础工具

  1. hello - 返回问候消息
    • 参数:name (字符串) - 要问候的人名
  2. getTime - 获取当前时间
    • 参数:format (可选) - 时间格式 ('iso', 'local', 'timestamp')
  3. calculate - 执行基本数学计算
    • 参数:
      • operation (字符串) - 运算类型 ('add', 'subtract', 'multiply', 'divide')
      • a (数字) - 第一个数字
      • b (数字) - 第二个数字

🌤️ 网络服务

  1. getWeather - 获取天气信息
    • 参数:
      • city (字符串) - 城市名称
      • country (可选) - 国家代码,默认 "CN"
  2. translate - 翻译文本
    • 参数:
      • text (字符串) - 要翻译的文本
      • target_lang (字符串) - 目标语言,默认 "en"
      • source_lang (可选) - 源语言,默认 "auto"
  3. checkNetwork - 检查网络连接
    • 参数:
  4. getJoke - 获取笑话
    • 参数:
      • category (可选) - 笑话类别,默认 "any"

📁 文件操作

  1. fileRead - 读取本地文件
    • 参数:
      • path (字符串) - 文件路径
      • encoding (可选) - 文件编码,默认 "utf-8"
  2. fileWrite - 写入本地文件
    • 参数:
      • path (字符串) - 文件路径
      • content (字符串) - 文件内容
      • encoding (可选) - 文件编码,默认 "utf-8"
  3. fileList - 列出目录内容
    • 参数:
      • path (字符串) - 目录路径,默认 "."

🔐 加密工具

  1. hashText - 对文本进行哈希计算
    • 参数:
      • text (字符串) - 要哈希的文本
      • algorithm (字符串) - 哈希算法 ('md5', 'sha1', 'sha256', 'sha512'),默认 "md5"
  2. base64Encode - Base64编码或解码
    • 参数:
      • text (字符串) - 要处理的文本
      • encode (布尔值) - 是否编码,默认 true

💻 系统信息

  1. getSystemInfo - 获取系统信息
    • 参数:无
  2. getProcessInfo - 获取进程信息
    • 参数:
      • name (可选) - 进程名称,不提供则显示所有进程

安装

# 安装 uv (如果还没有安装) curl -LsSf https://astral.sh/uv/install.sh | sh # 创建 Python 3.10 虚拟环境 source $HOME/.local/bin/env uv venv --python 3.10 # 激活虚拟环境并安装依赖 source .venv/bin/activate uv pip install -r requirements.txt

运行

方法1:使用启动脚本

./start_server.sh

方法2:手动启动

source $HOME/.local/bin/env source .venv/bin/activate python main.py

后台运行

# 在后台启动服务器 nohup python main.py > mcp.log 2>&1 & # 或者使用启动脚本 nohup ./start_server.sh > mcp.log 2>&1 &

测试

基本测试

# 运行基本测试(检查配置、依赖、启动) python test_basic.py

停止服务器

./stop_server.sh

使用示例

基础工具

{ "name": "hello", "arguments": { "name": "张三" } }
{ "name": "calculate", "arguments": { "operation": "add", "a": 10, "b": 5 } }

网络服务

{ "name": "getWeather", "arguments": { "city": "北京" } }
{ "name": "translate", "arguments": { "text": "你好世界", "target_lang": "en" } }

文件操作

{ "name": "fileList", "arguments": { "path": "/Users/username/Documents" } }
{ "name": "fileWrite", "arguments": { "path": "test.txt", "content": "Hello World!" } }

加密工具

{ "name": "hashText", "arguments": { "text": "Hello World", "algorithm": "sha256" } }

系统信息

{ "name": "getSystemInfo", "arguments": {} }

配置

服务器配置在 main.py 文件中,你可以根据需要修改服务器名称、版本和描述。

添加新工具

要添加新工具,在 main.py 文件中使用装饰器:

@mcp.tool("toolName") def tool_function(params: YourParamsModel) -> str: """工具描述""" # 工具逻辑 return "返回内容"

依赖

  • fastmcp - FastMCP 框架
  • pydantic - 数据验证和设置管理
  • requests - HTTP 请求库

日志

服务器运行时会输出日志到控制台。如果使用后台运行,日志会保存到 mcp.log 文件中。

文件结构

mcp/ ├── main.py # 主服务器文件 ├── requirements.txt # Python 依赖 ├── start_server.sh # 启动脚本 ├── stop_server.sh # 停止脚本 ├── test_basic.py # 基本测试脚本 ├── README.md # 文档 ├── .gitignore # Git 忽略文件 └── .venv/ # Python 虚拟环境

注意事项

  1. 网络服务:天气、翻译、笑话等功能需要网络连接
  2. 文件权限:文件操作工具需要适当的文件系统权限
  3. 系统信息:系统信息工具在 macOS 上工作最佳
  4. API 限制:某些免费 API 可能有请求频率限制
-
security - not tested
F
license - not found
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

A feature-rich Model Context Protocol server built with FastMCP that provides various tools including basic utilities, network services, file operations, encryption tools, and system information functions.

  1. 🚀 功能特性
    1. 基础工具
    2. 外部服务
    3. 文件操作
    4. 实用工具
    5. 系统信息
    6. 网络工具
    7. 娱乐工具
    8. 🔧 基础工具
    9. 🌤️ 网络服务
    10. 📁 文件操作
    11. 🔐 加密工具
    12. 💻 系统信息
  2. 安装
    1. 运行
      1. 方法1:使用启动脚本
      2. 方法2:手动启动
      3. 后台运行
    2. 测试
      1. 基本测试
      2. 停止服务器
    3. 使用示例
      1. 基础工具
      2. 网络服务
      3. 文件操作
      4. 加密工具
      5. 系统信息
    4. 配置
      1. 添加新工具
        1. 依赖
          1. 日志
            1. 文件结构
              1. 注意事项

                Related MCP Servers

                • A
                  security
                  A
                  license
                  A
                  quality
                  A beginner-friendly Model Context Protocol (MCP) server that helps users understand MCP concepts, provides interactive examples, and lists available MCP servers. This server is designed to be a helpful companion for developers working with MCP. Also comes with a huge list of servers you can install.
                  Last updated -
                  3
                  9
                  36
                  JavaScript
                  Apache 2.0
                • -
                  security
                  A
                  license
                  -
                  quality
                  MCP Server simplifies the implementation of the Model Context Protocol by providing a user-friendly API to create custom tools and manage server workflows efficiently.
                  Last updated -
                  4
                  3
                  TypeScript
                  MIT License
                • -
                  security
                  A
                  license
                  -
                  quality
                  MCP Server provides a simpler API to interact with the Model Context Protocol by allowing users to define custom tools and services to streamline workflows and processes.
                  Last updated -
                  13
                  2
                  TypeScript
                  MIT License
                • -
                  security
                  A
                  license
                  -
                  quality
                  This server implements the Model Context Protocol (MCP) to handle asynchronous tasks with real-time status tracking, robust error handling, and automatic resource management.
                  Last updated -
                  2
                  1
                  JavaScript
                  MIT License

                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/zmzhace/mcp'

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