Fledge MCP Server

Integrations

  • Enables building and deploying the Fledge MCP server using Docker containers, supporting deployment to Smithery.ai for enhanced scalability and availability.

  • Supports deployment behind an Nginx reverse proxy for production environments, enhancing security and performance for the Fledge MCP server.

  • Allows generation of React components for Fledge data visualization, enabling the creation of custom UI elements to display sensor data from Fledge instances.

Fledge MCP 服务器

这是一个模型上下文协议 (MCP) 服务器,它将 Fledge 功能连接到 Cursor AI,允许 AI 通过自然语言命令与 Fledge 实例进行交互。

先决条件

  • Fledge 本地安装或通过 API 访问(默认值: http://localhost:8081
  • 已安装光标 AI
  • Python 3.8+

安装

  1. 克隆此存储库:
git clone https://github.com/Krupalp525/fledge-mcp.git cd fledge-mcp
  1. 安装依赖项:
pip install -r requirements.txt

运行服务器

  1. 确保 Fledge 正在运行:
fledge start
  1. 启动 MCP 服务器:
python mcp_server.py

使用 API 密钥认证进行安全操作:

python secure_mcp_server.py
  1. 通过访问健康端点来验证它是否正常工作:
curl http://localhost:8082/health

您应该会收到“Fledge MCP 服务器正在运行”作为响应。

连接到光标

  1. 在 Cursor 中,前往“设置”>“MCP 服务器”
  2. 添加新服务器:
  3. 对于安全服务器,使用安全服务器启动时生成的 api_key.txt 文件中的值配置“X-API-Key”标头。
  4. 测试它:打开 Cursor 的 Composer(Ctrl+I),输入“检查 Fledge API 是否可访问”,AI 应该调用validate_api_connection工具。

可用工具

数据访问和管理

  1. get_sensor_data :从 Fledge 获取传感器数据,并可选择按时间范围和限制进行过滤
  2. list_sensors :列出 Fledge 中所有可用的传感器
  3. ingest_test_data :将测试数据导入 Fledge,并可选批处理计数

服务控制

  1. get_service_status :获取所有 Fledge 服务的状态
  2. start_stop_service :按类型启动或停止 Fledge 服务
  3. update_config :更新 Fledge 配置参数

前端代码生成

  1. generate_ui_component :为 Fledge 数据可视化生成 React 组件
  2. fetch_sample_frontend :获取不同框架的示例前端模板
  3. suggest_ui_improvements :获取 AI 支持的 UI 代码改进建议

实时数据流

  1. subscribe_to_sensor :设置传感器数据更新订阅
  2. get_latest_reading :获取特定传感器的最新读数

调试和验证

  1. validate_api_connection :检查 Fledge API 是否可访问
  2. 模拟前端请求:使用不同的方法和有效负载测试 API 请求

文档和架构

  1. get_api_schema :获取有关可用 Fledge API 端点的信息
  2. list_plugins :列出可用的 Fledge 插件

先进的人工智能辅助功能

  1. generate_mock_data :生成真实的模拟传感器数据用于测试

测试 API

您可以使用附带的测试脚本测试服务器:

# For standard server python test_mcp.py # For secure server with API key python test_secure_mcp.py

安全选项

安全服务器(secure_mcp_server.py)添加API密钥认证:

  1. 首次运行时,它会生成一个存储在 api_key.txt 中的 API 密钥
  2. 所有请求都必须在 X-API-Key 标头中包含此密钥
  3. 无需身份验证即可访问健康检查端点

API 请求示例

# Validate API connection curl -X POST -H "Content-Type: application/json" -d '{"name": "validate_api_connection"}' http://localhost:8082/tools # Generate mock data curl -X POST -H "Content-Type: application/json" -d '{"name": "generate_mock_data", "parameters": {"sensor_id": "temp1", "count": 5}}' http://localhost:8082/tools # Generate React chart component curl -X POST -H "Content-Type: application/json" -d '{"name": "generate_ui_component", "parameters": {"component_type": "chart", "sensor_id": "temp1"}}' http://localhost:8082/tools # For secure server, add API key header curl -X POST -H "Content-Type: application/json" -H "X-API-Key: YOUR_API_KEY" -d '{"name": "list_sensors"}' http://localhost:8082/tools

扩展服务器

要添加更多工具:

  1. 将工具定义添加到tools.json
  2. mcp_server.pysecure_mcp_server.py中实现工具处理程序

生产注意事项

对于生产部署:

  • 使用 HTTPS
  • 部署在 Nginx 等反向代理后面
  • 实现更强大的身份验证(JWT、OAuth)
  • 添加速率限制
  • 为订阅设置持久数据存储

在 Smithery.ai 上部署

Fledge MCP 服务器可以部署在 Smithery.ai 上,以增强可扩展性和可用性。请按照以下步骤进行部署:

  1. 先决条件
    • 本地机器上安装的 Docker
    • Smithery.ai 帐户
    • Smithery CLI 工具已安装
  2. 构建和部署
    # Build the Docker image docker build -t fledge-mcp . # Deploy to Smithery.ai smithery deploy
  3. 配置smithery.json文件包含您的部署配置:
    • 端口 8082 上的 WebSocket 传输
    • 可配置的 Fledge API URL
    • 工具定义和参数
    • 超时设置
  4. 环境变量在 Smithery.ai 仪表板中设置以下环境变量:
    • FLEDGE_API_URL :您的 Fledge API 端点
    • API_KEY :您的安全 API 密钥(如果使用安全模式)
  5. 验证部署后,验证您的服务器是否正在运行:
    smithery status fledge-mcp
  6. 监控通过 Smithery.ai 仪表板监控您的部署:
    • 实时日志
    • 性能指标
    • 错误追踪
    • 资源使用情况
  7. 更新要更新您的部署:
    # Build new image docker build -t fledge-mcp . # Deploy updates smithery deploy --update

JSON-RPC 协议支持

服务端使用 JSON-RPC 2.0 通过 WebSocket 实现模型上下文协议 (MCP)。支持以下方法:

  1. 初始化
    { "jsonrpc": "2.0", "method": "initialize", "params": {}, "id": "1" }
    回复:
    { "jsonrpc": "2.0", "result": { "serverInfo": { "name": "fledge-mcp", "version": "1.0.0", "description": "Fledge Model Context Protocol (MCP) Server", "vendor": "Fledge", "capabilities": { "tools": true, "streaming": true, "authentication": "api_key" } }, "configSchema": { "type": "object", "properties": { "fledge_api_url": { "type": "string", "description": "Fledge API URL", "default": "http://localhost:8081/fledge" } } } }, "id": "1" }
  2. 工具/列表
    { "jsonrpc": "2.0", "method": "tools/list", "params": {}, "id": "2" }
    响应:返回可用工具及其参数的列表。
  3. 工具/调用
    { "jsonrpc": "2.0", "method": "tools/call", "params": { "name": "get_sensor_data", "parameters": { "sensor_id": "temp1", "limit": 10 } }, "id": "3" }

错误代码

服务器遵循标准 JSON-RPC 2.0 错误代码:

  • -32700:解析错误
  • -32600: 无效请求
  • -32601:未找到方法
  • -32602:无效参数
  • -32000:服务器错误
-
security - not tested
A
license - permissive license
-
quality - not tested

hybrid server

The server is able to function both locally and remotely, depending on the configuration or use case.

将 Fledge 功能连接到 Cursor AI,允许通过自然语言命令与 Fledge 实例进行交互。

  1. 先决条件
    1. 安装
      1. 运行服务器
        1. 连接到光标
          1. 可用工具
            1. 数据访问和管理
            2. 服务控制
            3. 前端代码生成
            4. 实时数据流
            5. 调试和验证
            6. 文档和架构
            7. 先进的人工智能辅助功能
          2. 测试 API
            1. 安全选项
              1. API 请求示例
                1. 扩展服务器
                  1. 生产注意事项
                    1. 在 Smithery.ai 上部署
                      1. JSON-RPC 协议支持
                        1. 错误代码

                      Related MCP Servers

                      • -
                        security
                        A
                        license
                        -
                        quality
                        Acts as a bridge between Claude's desktop application and the Cursor editor, enabling seamless AI-powered automation and multi-instance management across platforms with standardized communication and secure token-based authentication.
                        Last updated -
                        21
                        46
                        TypeScript
                        MIT License
                        • Apple
                        • Linux
                      • A
                        security
                        A
                        license
                        A
                        quality
                        An MCP server integration that enables Cursor AI to communicate with Figma, allowing users to read designs and modify them programmatically through natural language commands.
                        Last updated -
                        19
                        5,185
                        3,528
                        JavaScript
                        MIT License
                        • Apple
                        • Linux
                      • -
                        security
                        F
                        license
                        -
                        quality
                        Enables AI assistants to interact with Metabase, providing access to dashboards, questions, databases, and tools for executing queries and viewing data through natural language.
                        Last updated -
                        JavaScript
                        • Apple
                      • -
                        security
                        F
                        license
                        -
                        quality
                        Enables Cursor AI to interact with Figma designs, allowing users to read design information and programmatically modify elements through natural language commands.
                        Last updated -
                        TypeScript

                      View all related MCP servers

                      ID: 4a3t88dbgq