REST服务调用工具

一个用于通过Claude配置和调用REST服务的工具,支持本地测试和插件集成。

  • by jvermeir
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 jvermeir/mcp_server_test

使用说明

mcp服务器实验

培训:https://modelcontextprotocol.io/

mcp游乐场:https://mcpsplayground.com/--连接claud帐户

示例:https://github.com/modelcontextprotocol/quickstart-resources/tree/main

claude配置文件

~/库/应用程序支持/Claude claude_desktop_config json

日志

日志可以在以下位置找到

~/库/日志/克劳德

日志文件以工具命名:

tail -f mcp-server-callRestService.log

用于定义代理的安装文件夹

uv init plugin
cd plugin

uv venv
source .venv/bin/activate

uv add "mcp[cli]" httpx

Python测试服务器

要启动演示python程序,请在testserver文件夹中:

source .venv/bin/activate
uv run server.py

使用rest服务器插件

通过在~/Library/ApplicationSupport/claude/claude_desktop_config.json中添加以下内容,将该工具添加到claude中。替换 <absolute path to uv> <absolute path to the plugin folder> 使用您的本地设置。

{
  "mcpServers": {
    "callRestService": {
      "command": "<absolute path to uv>uv",
      "args": [
        "--directory",
        "<absolute path to the plugin folder>",
        "run",
        "rest_call.py"
      ]
    }
  }
}

在claude桌面中,使用以下提示:

call the rest service on port 3000 to GET all documents

documents 在这里至关重要,因为它会告诉claud使用 http://localhost:3000/documents

要添加文档,您必须非常具体。不起作用的提示:

add a document named 'second doc'

导致此工具调用:

{
  `method`: `POST`,
  `url`: `documents`,
  `json_body`: `{\"name\": \"second doc\"}`
}

因此,假设主体包含一个属性 name但事实并非如此。

此提示有效:

add the document with text 'third doc'

现在我们收到了这个请求

{
  `url`: `documents`,
  `method`: `POST`,
  `json_body`: `{\"name\": \"third doc\"}`
}

JSON属性 text 正确地从提示中导出。

状态

...

随意的想法

为了确保工具的输出被打印出来,claud说:

"Always display the complete output from any tool you use in a clear, formatted way (like a code block or quoted section) so I can see exactly what the tool returned."
Or more specifically for this tool:
"When using the get_it tool, always show me the raw output in a code block or clearly formatted section."
You could also add this to a custom instruction or system prompt if the interface you're using supports that, so it applies to all conversations. Something like:
"For all tool calls: Display the complete tool output in your response using appropriate formatting (code blocks, quotes, etc.) so the results are clearly visible."
This way, I'll know to always present the tool results prominently rather than just summarizing or paraphrasing them.