Skip to main content

A Python MCP server for terms management functionality

Project description

Yu Terms MCP Server

一个基于Python的MCP (Model Context Protocol) 服务器,用于条款管理功能。这是Java Spring AI实现的Python等价版本。

功能特性

  • 条款更新工具: 提供更新条款要素的接口
  • MCP协议支持: 完全兼容MCP协议规范
  • 异步处理: 基于asyncio的高性能异步处理
  • 易于扩展: 模块化设计,便于添加新的工具和功能
  • 完整日志: 详细的日志记录,便于调试和监控

安装

从PyPI安装

pip install yu-terms-mcp-server

从源码安装

git clone https://github.com/yourusername/yu-terms-mcp-server.git
cd yu-terms-mcp-server
pip install -e .

使用方法

命令行启动

yu-terms-mcp-server

程序化使用

import asyncio
from yu_terms_mcp_server import TermsMcpServer

async def main():
    server = TermsMcpServer()
    await server.run()

if __name__ == "__main__":
    asyncio.run(main())

工具说明

terms_updated

更新条款要素的主要工具。

参数:

  • query (string): 更新参数

返回:

  • 成功时返回: "更新成功!"
  • 失败时返回: 错误信息

示例:

{
  "name": "terms_updated",
  "arguments": {
    "query": "更新条款内容"
  }
}

开发

环境设置

# 克隆仓库
git clone https://github.com/yourusername/yu-terms-mcp-server.git
cd yu-terms-mcp-server

# 创建虚拟环境
python -m venv venv
source venv/bin/activate  # Linux/Mac
# 或
venv\Scripts\activate  # Windows

# 安装开发依赖
pip install -e ".[dev]"

运行测试

pytest

代码格式化

black yu_terms_mcp_server/
isort yu_terms_mcp_server/

类型检查

mypy yu_terms_mcp_server/

项目结构

yu_terms_mcp_server/
├── __init__.py          # 包初始化
├── main.py             # 主入口点
├── server.py           # MCP服务器实现
└── tools.py            # 工具实现

与Java版本的对应关系

Java组件 Python组件 说明
TermsUpdatedTool.java tools.py 条款更新工具实现
YuImageSearchMcpServerApplication.java server.py 主应用程序和服务器配置
@Tool 注解 get_tool_definition() 工具定义和注册
@Service 注解 类实例化 服务组件管理
SpringApplication.run() server.run() 应用程序启动

配置

服务器默认使用stdio进行通信,这是MCP协议的标准方式。如需自定义配置,可以修改server.py中的相关设置。

日志

应用程序使用Python标准logging模块。日志级别默认为INFO,输出到stderr。

许可证

MIT License

贡献

欢迎提交Issue和Pull Request!

更新日志

v1.0.0

  • 初始版本发布
  • 实现基础的条款更新功能
  • 完整的MCP协议支持

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

yu_terms_mcp_server-1.0.4.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

yu_terms_mcp_server-1.0.4-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file yu_terms_mcp_server-1.0.4.tar.gz.

File metadata

  • Download URL: yu_terms_mcp_server-1.0.4.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.9

File hashes

Hashes for yu_terms_mcp_server-1.0.4.tar.gz
Algorithm Hash digest
SHA256 ba5c96171d9424887d9ecb6c85dc939a032f809cd53c4e6a7ebabc5f5dc80be4
MD5 5a7b9c53892c4d1fc6ec46f99750ae93
BLAKE2b-256 32cf11ea43d332c1411541810683aa1d52506c805fbec738ec70ad170d28000f

See more details on using hashes here.

File details

Details for the file yu_terms_mcp_server-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for yu_terms_mcp_server-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 35a17a35fee5157ac6511b6cc1ed0b9d12afb5afce380e88c00ae458daa2b5ba
MD5 f4a0ec475cddd0d6f82eb8614b890aa3
BLAKE2b-256 6048687eb29f6d7bba8254d298f4842e97f855d06fe29fd54477cf376766291b

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