FastMCP Server

FastMCP Server

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.

Category
Visit Server

README

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 - 检查网络连接

    • 参数:
      • url (字符串) - 要检查的URL,默认 "https://www.google.com"
  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 可能有请求频率限制

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured