提醒服务服务器

一个基于Spring、OpenAPI和SQLite的提醒服务服务器,用于存储和管理提醒事项,并与Open WebUI集成。

  • by darthpetter
  • Java
  • 本地部署
  • 更新于
在 GitHub 查看 darthpetter/mcp-reminder

使用说明

提醒MCP服务器使用Spring+OpenAPI+SQLite进行开放式WebUI

saveMinder+获取当前时间

在这个应用程序中,我们将提醒存储在SQLite数据库中。在储蓄之前,我们总是打电话 getCurrentTime 以检索当前日期和时间。这确保了任何相对 dueDate (如“明天”或“下周五”)相对于实际当前日期和时间正确计算。

解释

Open WebUI通过我们的REST API的OpenAPI定义实现MCP。

我们构建了一个通用的RestAPI,但使用Swagger+OpenAPI将每个端点公开为 Tool.

例如:

@Operation(
summary = "Sum two numbers",
description = """
    This tool takes two numbers as input (`a` and `b`) and returns their sum.

    When this tool is available, the model can perform addition by calling this function instead of calculating internally.

    Input:
    - `a`: first integer
    - `b`: second integer

    Output:
    - `result`: the sum of `a + b`
    - `ok`: a boolean indicating success

    Example:
    Request: { "a": 3, "b": 5 }
    Response: { "ok": true, "result": 8 }
"""
)
@PostMapping
public ResponseEntity<Object> saveReminder(int a,int b)
{
    return ResponseEntity.internalServerError()
    .body(Map.of(
        "ok",true,
        "result",a+b
    ));
}

开放式WebUI集成

现在我们的REST API(“MCP”)已经准备好了,下面是如何在Open WebUI中连接它。

  1. 在Open WebUI中,转到 设置>工具>管理工具服务器.
  2. 点击 添加服务器 (或 编辑 如果你正在更新)。
  3. 输入您的MCP服务器URL。
  4. 如果启用了Spring Security,请将API密钥粘贴到 API密钥 现场。
  5. 保存您的更改。

一旦完成,Open WebUI将把你的REST API当作MCP工具,你可以开始直接调用你的端点。

赋予LLM权力

更新RAG模板/系统提示,我们可以指示模型从这些新功能中获得授权,并自信地使用可用的工具。这可以防止像“我是一个人工智能,没有为此受过训练”这样的回答

# MCP Tools
You are an intelligent assistant with access to specialized tools (MCP Tools). These tools represent your own capabilities.
If a tool is available, you must use it naturally and confidently, as if you were performing the action yourself. You must not say "I can't", "I don't have that ability", or "I don't have access" unless there is explicitly no tool available for the task.