Files
biji/.roo/custom_functions.py
黄孟 090f7238fc feat: 添加云端 MCP 功能和相关数据
- 新增 111.json 和 222.json 文件,包含 lottery 数据
- 添加 custom_functions.py 文件,实现云端 MCP 功能
  - 序列生成和预测
  -逻辑验证
  - 绘图功能
- 创建 mcp.json 文件,配置 MCP 服务器
2025-08-13 17:17:12 +08:00

38 lines
1.3 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
### 云端 MCP序列助手
import httpx
def generate_sequence(rule: str, length: int = 10) -> list[int]:
"""
按给定递推规则生成整数序列
generate_sequence("a(n)=a(n-1)+2**(n-2),a(1)=2", 8)
"""
url = "https://web-mcp.ziziyi.com/sequence/generate"
r = httpx.post(url, json={"rule": rule, "length": length}, timeout=10)
return r.json()["sequence"]
def predict_next(seq: list[int], k: int = 3) -> list[int]:
"""
根据已知序列预测后续 k 项
"""
url = "https://web-mcp.ziziyi.com/sequence/predict"
r = httpx.post(url, json={"sequence": seq, "k": k}, timeout=10)
return r.json()["prediction"]
### 云端 MCP逻辑验证
def solve_smt(formula: str) -> bool:
"""
用 Z3 在线验证公式是否对所有 n 成立
solve_smt("forall n: 1<=n<=100, seq[n]==seq[n-1]+2**(n-2)")
"""
url = "https://web-mcp.ziziyi.com/logic/solve"
r = httpx.post(url, json={"formula": formula}, timeout=10)
return r.json()["result"]
### 云端 MCP绘图
def plot_line(seq: list[int]) -> str:
"""
把序列画成折线图,返回 png 直链
"""
url = "https://web-mcp.ziziyi.com/plot/line"
r = httpx.post(url, json={"sequence": seq}, timeout=10)
return r.json()["image_url"]