Token导航 LogoToken导航TokenDH.com
Example Agent Tool Background Job logo
AI代理stdio官方级别未说明来源级核验

Example Agent Tool Background Job

MCP Server

一个基于Resonate和MCP的最小化异步定时器AI代理工具示例,用于设置和获取定时器状态。

工具数

2

提示词数

0

GitHub Stars

0

资源数

0
AI代理PythonClaudeClaude DesktopClaude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

resonatehq-examples

提供方

resonatehq-examples

最后核验

2026/5/17 20:19

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

uv run proxy.py

详细介绍

异步定时器AI代理工具|共振示例应用程序

此示例显示了谐振+MCP的最小示例。

要在MCP服务器中使用Resonate,需要使用“流式http”作为传输来运行MCP服务器。

因此,您需要一个运行stdio->streaming的http代理,以便Claude与之通信。

代理

from fastmcp import FastMCP

# Create a proxy to a remote server
proxy = FastMCP.as_proxy(
    "http://localhost:5001/mcp",  # URL of the remote server
    name="Remote Server Proxy"
)

if __name__ == "__main__":
    proxy.run()  # Runs via STDIO for Claude Desktop

要运行代理,请执行以下操作:

uv run proxy.py

claude_desktop_config json

确保Claude的配置指向代理。

{
  "mcpServers": {
    "timer": {
      "command": "uv", // or /opt/homebrew/bin/uv
      "args": [
        "--directory",
        "/FULL/PATH/TO/YOUR/TOOL/DIRECTORY/example-agent-tool-async-timer",
        "run",
        "proxy.py"
      ]
    }
  }
}

更改此配置后,您应该重新启动Claude桌面。

在MCP服务器上,确保返回promise ID,而不是阻塞结果。 然后,Claude可以在稍后的任何时候使用promise ID检查结果。

定时器mcp服务器

后面运行的功能用 @resonate.register.

定时器函数

@resonate.register
def timer(ctx, timer_name, seconds):
    yield ctx.sleep(int(seconds))
    return "complete"

Claude与之交互的功能以以下方式装饰 @mcp.tool

设置计时器工具

@mcp.tool()
def set_timer(timer_name, seconds):
    # tool description

    _ = timer.run(timer_name, timer_name, seconds)
    return {"promise_id": timer_name}

获取计时器状态工具

@mcp.tool()
def get_timer_status(timer_name):
    # tool description

    promise_id = f"{timer_name}"
    handle = resonate.get(promise_id)
    if not handle.done():
        return {"status": "running"}
    return {"status": handle.result()}

要运行MCP服务器,请执行以下操作:

uv run timer.py

目录标签

目录标签

AI代理PythonClaude本地部署异步定时器ResonateMCP

支持客户端

Claude DesktopClaude

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

2

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP