Skip to main content

一个简单的MCP加法服务示例

Project description

加法 MCP 服务

这是一个简单的 Model Context Protocol (MCP) 服务示例,提供基本的加法计算功能和问候语生成功能。

功能介绍

本服务提供以下功能:

  1. 加法计算工具:计算两个整数的和
  2. 问候语资源:根据提供的名称生成个性化问候语
  3. 问候语提示词模板:根据不同风格生成问候语提示词

安装与配置

前提条件

  • Python 3.6 或更高版本
  • MCP 库

配置步骤

  1. 将服务配置添加到 CodeBuddy 的 MCP 设置文件中:

    "加法服务": {
      "disabled": false,
      "timeout": 60,
      "type": "stdio",
      "command": "python",
      "args": [
        "d:/mcp_ts/main.py"
      ]
    }
    
  2. 配置文件位置:c:\Users\93467\AppData\Roaming\CodeBuddy\User\globalStorage\tencent.planning-genie\settings\codebuddy_mcp_settings.json

使用方法

启动服务

python d:/mcp_ts/main.py

使用加法工具

通过 CodeBuddy 调用加法工具:

<use_mcp_tool>
<server_name>加法服务</server_name>
<tool_name>add</tool_name>
<arguments>
{
  "a": 5,
  "b": 3
}
</arguments>
</use_mcp_tool>

访问问候语资源

<access_mcp_resource>
<server_name>加法服务</server_name>
<uri>greeting://World</uri>
</access_mcp_resource>

代码结构

  • main.py: 主程序文件,包含 MCP 服务的所有功能实现

扩展开发

您可以通过以下方式扩展此服务:

  1. 添加更多数学运算工具(如减法、乘法、除法等)
  2. 增加更多资源类型
  3. 开发更复杂的提示词模板

许可证

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_ts-0.1.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

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

mcp_ts-0.1.0-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file mcp_ts-0.1.0.tar.gz.

File metadata

  • Download URL: mcp_ts-0.1.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.6

File hashes

Hashes for mcp_ts-0.1.0.tar.gz
Algorithm Hash digest
SHA256 82353051818032ade2811150790a491619e09dfe3ef232cad2662195fca65aaf
MD5 265340f1fe8c1ec5f260056675e2db55
BLAKE2b-256 19d44c4a5f17aeeb8e0f5624d0fb3f4e2add74acc9bdc8f5281e2f819ff1176c

See more details on using hashes here.

File details

Details for the file mcp_ts-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mcp_ts-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.6

File hashes

Hashes for mcp_ts-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ac2b76a5adf6ac20e4be2b070e7566796e406f0342c4a158973f0b0b88459f13
MD5 063a0c08e2b2b6ead3d3dd9033758df2
BLAKE2b-256 9d0898fb27e921f9330e1d34e729348280beaf7407528e180b856fae340462eb

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