电器控制MCP服务器

通过MCP协议连接AI聊天机器人与伊莱克斯家电,实现智能问答和设备控制。

  • by alestmej
  • Kotlin
  • 本地部署
  • 更新于
在 GitHub 查看 alestmej/mcp-stdio-server

使用说明

控制伊莱克斯电器的简单MCP服务器

动机

快速的AI聊天,可以回答以下问题:

  • "我有多少台伊莱克斯电器?“或
  • "我的伊莱克斯空气净化器是什么颜色的?"

虽然LLM模型没有为此进行训练,但你会得到 正确的 答案!

怎么用?运行此代码并感到惊讶。

建筑

+------------------------+      MCP Protocol      +-----------------+      REST API       +--------------------+                    +-----------------------------------+
|     AI Chat (LLM)      | <--------------------> |   MCP Server    | <-----------------> |  Electrolux Cloud  |<-----------------> |          Home Appliance           |
| (Claude, ChatGPT, ...) |                        |   (This Code)   |                     |                    |                    | (Vacuum, Oven, Air Purifier, ...) |
+------------------------+                        +-----------------+                     +--------------------+                    +-----------------------------------+
flowchart LR
    A["AI Chat (LLM)<br>(Claude, ChatGPT, ...)"]
    B["MCP Server<br>(This Code)"]
    C["Electrolux Cloud"]
    D["Home Appliance<br>(Vacuum, Oven, Air Purifier, ...)"]

    A <--- "MCP Protocol" ---> B
    B <--- "REST API" ---> C
    C <--- " " ---> D

    style A fill:#f9f,stroke:#333,stroke-width:2px
    style B fill:#bbf,stroke:#333,stroke-width:2px
    style C fill:#ccf,stroke:#333,stroke-width:2px
    style D fill:#ddf,stroke:#333,stroke-width:2px

参考文献

如何跑步

1.建设项目

 * ./mvnw clean install -DskipTests

2.集成到克劳德桌面

要与Claude Desktop集成,请将以下配置添加到文件中 claude_desktop_config.json.

典型位置 claude_desktop_config.json:

  • 窗户: C: \用户<YourUser>\AppData\Roaming\Claude\Claude_desktop_config json
  • macOS: ~/库/应用支持/Claude/Claude_desktop_config json
  • Linux: ~/.config/Claude/Claude_desktop_config json
{
  "mcpServers": {
    "mcp-stdio-server": {
      "command": "java",
      "args": [
        "-Dspring.ai.mcp.server.stdio=true",
        "-Dspring.main.web-application-type=none",
        "-Dlogging.pattern.console=",
        "-jar",
        "<ABSOLUTE-PATH-TO-PROJECT>\\target\\mcp-stdio-server-0.0.1-SNAPSHOT.jar"
      ]
    }
  }
}

为了进行身份验证,伊莱克斯API需要API密钥和JWT令牌。AI聊天助手会在第一次互动时询问他们。 登录到 伊莱克斯开发者门户 为了得到他们。

3.使用提供的McpClient而不是AI Assistant进行测试

TODO

  • []执行“打开空气净化器”、“如果我的客厅已经两天没有打扫了,现在就打扫”等命令。
  • []实现流式HTTP传输(目前仅支持stdio)
  • []尝试更多助手,而不仅仅是Claude Desktop