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.5.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.5-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: yu_terms_mcp_server-1.0.5.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.5.tar.gz
Algorithm Hash digest
SHA256 c9d70487d7759a272baa89fe449698e749950ab8bf279c9711abbcb3a661c649
MD5 a0d7b2214b6b30b50f4af24cb4136b09
BLAKE2b-256 4579a0fbdac09797e9272689686e8d967342497cb3c216638a1981b0f9d3060d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for yu_terms_mcp_server-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 969137b2e383939cc1a4d60e1278b17bdbfa33f2ac0d01b4e8d6fd0fb027c3db
MD5 e1e2055edce7828dbf87b8e15af7783c
BLAKE2b-256 63117e8988840d856c74a1f1416922e425f551f383d39eea78611ef59feb604f

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