Qarnot MCP服务器

Qarnot MCP服务器是一个允许AI客户端(如Claude)通过Anthropic MCP Python SDK与Qarnot任务交互的服务,提供任务创建、状态查询、结果下载等功能。

  • by chloepilonv
  • Python
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 chloepilonv/mcp-server-qarnot

使用说明

Qarnot MCP服务器

一个MCP(模型上下文协议)服务器,允许AI客户端(此处为Claude)使用Anthropic MCP Python SDK与您的Qarnot任务进行交互。 当你将它连接到你的人工智能助手(个人聊天机器人、克劳德等)时,你就可以自然地与它交互,以检索有关你在Qarnot上运行的任务的信息(例如:我上一个任务的状态是什么?)。

它做什么

允许客户端访问这些工具:

  • 创建任务(测试版) -创建一个任务,您可以在其中指定配置文件、调度类型、输入桶、快照等。
  • list_tasks -列出您的所有Qarnot任务
  • get_task_status -获取详细状态+SSH连接信息
  • get_task_stdout -获取任务输出
  • get_task_str -获取任务错误
  • cancel_task -取消正在运行的任务
  • list_buckets -列出所有存储桶
  • list_bucket_files -列出存储桶中的文件
  • download_result -从bucket下载文件
  • list_profiles -列出可用的硬件配置文件

真正酷的是:你可以在24小时后要求代理取消任务。列出您的配置文件,然后使用特定配置文件创建任务。获取任务输出,并在任务收敛时取消任务等。

设置

  1. 安装依赖项:

    pip install qarnot "mcp[cli]" python-dotenv
    
  2. 创建 .env 使用您的Qarnot令牌的文件:

    QARNOT_TOKEN="your-token-here"
    

用法

使用克劳德代码(CLI)(本地)

要使Claude能够使用MCP服务器中的工具,您可以:

claude mcp add qarnot python3 /path/to/mcp_server.py

然后重新启动Claude Code。然后,您可以提出您的请求(例如: “列出我的Qarnot任务”)克劳德。

与克劳德·韦伯(在线)

在服务器(Qarnot、AWS、OVH等)上安装MCP服务器后,添加到连接器中。团队和企业工作流程解释如下: https://support.claude.com/en/articles/11175166-getting-started-with-custom-connectors-using-remote-mcp

调试或手动测试

mcp dev mcp_server.py

可以使用交互式MCP检查器(https://modelcontextprotocol.io/docs/tools/inspector)以测试他们的MCP服务器。

工具定义

简而言之,工具是AI代理可以通过MCP执行的操作。例如,“列出任务”是一个可以由代理执行的操作,如果你要求它列出你当前的任务。 要添加新工具,请转到mcp_server.py并使用以下格式(此处为list_tasks示例):

@mcp.tool() #the Anthropic decorator to create a MCP tool
def list_tasks() -> str: # name of the tool and expected output
    """List all Qarnot tasks for your account.""" #Docstring description, very important for the LLM 
    conn = get_connection() #Qarnot Python SDK related to the tool 
    tasks = conn.tasks() #Qarnot Python SDK related to the tool 

    #Any in-between actions should be added here

    result = [] #Empty format of the output
    for task in tasks: #Build the reponse
        result.append({
            "uuid": task.uuid,
            "name": task.name,
            "state": task.state,
        })

    import json 
    return json.dumps(result, indent=2) #Return JSON for the AI Agent that can then answer your query