yeepay_yop_product_detail_and_associated_apis
Retrieve product documentation, usage instructions, and associated API lists for Yeepay Open Platform (YOP) products to support integration development.
Instructions
通过此工具,获取易宝支付开放平台(YOP)指定产品的产品介绍,使用说明、相关的API接口列表,内容中包含链接时可以调用工具yeepay_yop_link_detail进一步获取其详细内容
Args: product_code: str - 产品编码(产品的唯一标识)
Returns: str: 易宝支付开放平台(YOP)指定产品的产品介绍,使用说明、相关的API接口列表(markdown格式)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| product_code | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- yop_mcp/main.py:40-62 (handler)The handler function for 'yeepay_yop_product_detail_and_associated_apis' tool, registered via @mcp.tool(). It strips the product_code, downloads content from the specific product URL, and falls back to product overview if failed. The docstring provides input/output schema.
@mcp.tool() def yeepay_yop_product_detail_and_associated_apis(product_code: str) -> str: """ 通过此工具,获取易宝支付开放平台(YOP)指定产品的产品介绍,使用说明、相关的API接口列表,内容中包含链接时可以调用工具yeepay_yop_link_detail进一步获取其详细内容 Args: product_code: str - 产品编码(产品的唯一标识) Returns: str: 易宝支付开放平台(YOP)指定产品的产品介绍,使用说明、相关的API接口列表(markdown格式) """ product_code = product_code.strip() # https://open.yeepay.com/docs-v3/product/user-scan/llms.txt response = HttpUtils.download_content( "https://open.yeepay.com/docs-v3/product/" + product_code + "/llms.txt" ) # 如果返回错误,则调用备用地址 if response.startswith("HTTP请求失败"): return HttpUtils.download_content( "https://open.yeepay.com/docs-v3/product/llms.txt" ) return response - tools/http_utils.py:14-37 (helper)Supporting utility method HttpUtils.download_content used by the tool handler to fetch markdown content from Yeepay YOP URLs, handling HTTP requests with httpx and error cases.
def download_content(url: str, timeout: Optional[int] = None) -> str: """ 同步下载文件(无进度显示)并返回文件内容 Args: url: 下载地址 timeout: 超时时间(秒) Returns: str: 下载的文本内容 """ try: with httpx.Client(http2=True, timeout=timeout) as client: # 启用HTTP/2加速 response = client.get(url) response.raise_for_status() # 自动检测4xx/5xx错误 content = response.text print(f"已获取内容,长度: {len(content)} 字符") return content except httpx.HTTPStatusError as e: print(f"HTTP错误 {e.response.status_code}") return f"HTTP请求失败: HTTP {e.response.status_code}" except Exception as e: # 保持通用异常处理以支持测试 print(f"请求失败:{str(e)}") return f"HTTP请求失败: {str(e)}"