Skip to main content

mcp_rs_publish_stdio

Project description

最简单的MCP服务器

这是一个基于Python实现的最简单的MCP(Model Context Protocol)服务器,提供了基础的工具函数。

功能特性

该MCP服务器包含以下工具:

1. echo - 消息回显

  • 功能: 回显输入的消息
  • 参数: message (字符串) - 要回显的消息
  • 示例: 输入 "Hello World" 会返回 "回显: Hello World"

2. calculate - 数学计算

  • 功能: 执行简单的数学表达式
  • 参数: expression (字符串) - 数学表达式
  • 示例: 输入 "2 + 3 * 4" 会返回 "计算结果: 2 + 3 * 4 = 14"

3. get_time - 获取时间

  • 功能: 获取当前系统时间
  • 参数: 无
  • 示例: 返回当前时间,如 "当前时间: 2024-01-15 14:30:25"

4. reverse_text - 文本反转

  • 功能: 反转输入的文本内容
  • 参数: text (字符串) - 要反转的文本
  • 示例: 输入 "Hello" 会返回 "反转结果: olleH"

安装和运行

环境要求

  • Python 3.13+
  • 已安装 mcp[cli]

运行方式

方式1: 直接运行

python mcp_rs_publish/command.py

方式2: 作为模块运行

python -m mcp_rs_publish.command

方式3: 使用项目脚本

mcp_rs_publish

配置说明

config.json 文件中配置MCP服务器:

{
  "mcpServers": {
    "simple-mcp-server": {
      "command": "python",
      "args": ["-m", "mcp_rs_publish.command"],
      "env": {
        "PYTHONPATH": "."
      }
    }
  }
}

技术架构

  • 框架: 使用 mcp Python库
  • 通信: 基于stdio的标准输入输出通信
  • 异步: 使用 asyncio 实现异步处理
  • 日志: 内置日志系统,便于调试

扩展开发

要添加新的工具,只需在 SimpleMCPServer 类的 _setup_handlers 方法中:

  1. handle_list_tools 中添加工具定义
  2. handle_call_tool 中添加工具实现逻辑

注意事项

  • 数学计算功能使用 eval() 函数,请确保输入安全
  • 服务器使用stdio通信,适合与支持MCP协议的客户端集成
  • 所有工具调用都是异步的,支持并发处理

许可证

本项目采用MIT许可证。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_rs_publish_stdio-0.1.8.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_rs_publish_stdio-0.1.8-py3-none-any.whl (3.9 kB view details)

Uploaded Python 3

File details

Details for the file mcp_rs_publish_stdio-0.1.8.tar.gz.

File metadata

  • Download URL: mcp_rs_publish_stdio-0.1.8.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for mcp_rs_publish_stdio-0.1.8.tar.gz
Algorithm Hash digest
SHA256 b3decc1325485ff83f787c2dc91b08f951b79bd8c208614136dd544677917307
MD5 b83ab4804815751578d9871dc9353cd6
BLAKE2b-256 c5a971a81020ed2b465e42bdeb921c26d1352dc75773f989ed51cc2cb74fbd44

See more details on using hashes here.

File details

Details for the file mcp_rs_publish_stdio-0.1.8-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_rs_publish_stdio-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 8935d3b9235b702bb215604271df879c16634969e008a7bc9503656b7732580f
MD5 5e594d3f7f88e7026795f2abc7855c66
BLAKE2b-256 eef6695b3e419d04e15dcb14204e25d5f2a65496c2e7f33640437606dc350d97

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page