IoT连接管理协议服务器

一个通过自然语言使AI代理与1NCE IoT连接管理平台交互的模型上下文协议(MCP)服务器,提供产品管理、订单跟踪、SIM卡监控等功能。

  • by 1NCE-GmbH
  • Python
  • 本地部署
  • 1 星标
  • 更新于
在 GitHub 查看 1nce-gmbh/1nce-mcp-server

使用说明

1NCE物联网平台MCP服务器

模型上下文协议(MCP)服务器,使AI代理能够通过自然语言与1NCE IoT连接管理平台进行交互。

概述

该项目提供了一个中间件层,将大型语言模型(LLM)连接到1NCE API,用于管理物联网连接。它允许AI助手:

  • 检索产品信息
  • 管理订单
  • 监控SIM卡状态
  • 检查数据和短信配额
  • 更新SIM卡配置
  • 查看连接信息

通过模型上下文协议公开这些功能,人工智能代理可以使用自然语言与物联网基础设施进行交互,简化了对连接设备的管理。

特性

  • 认证:使用1NCE API进行基于OAuth 2.0令牌的安全身份验证
  • 产品管理:查询可用的物联网连接产品
  • 订单管理:创建和跟踪订单
  • SIM卡管理:监控和配置SIM卡
  • 资源:直接访问SIM卡状态和产品数据
  • 鼓励:用于常见任务的预定义交互模板

先决条件

  • Python 3.8+
  • FastMCP v2
  • 具有API证书的1NCE帐户

安装

  1. 克隆此存储库
git clone https://github.com/yourusername/1nce-mcp-server.git
cd 1nce-mcp-server
  1. 安装所需的依赖项
pip install fastmcp httpx
  1. 使用1NCE API凭据设置环境变量
export ONCE_CLIENT_ID="your_client_id"
export ONCE_CLIENT_SECRET="your_client_secret"

用法

使用FastMCP进行安装

建议使用此MCP服务器的方法是使用FastMCP CLI安装它:

fastmcp install 1nce_mcp.py

这将使服务器可用于兼容的MCP客户端,包括Claude Desktop。

直接运行

对于开发或测试,您可以直接运行服务器:

python 1nce_mcp.py

与客户端一起使用

您可以使用FastMCP客户端以编程方式与服务器交互:

from fastmcp import Client

async with Client("1nce_mcp.py") as client:
    # Get list of products
    products = await client.call_tool("get_all_products")
    print(products)
    
    # Check SIM status
    sim_status = await client.call_tool("get_sim_status", {"iccid": "your_sim_iccid"})
    print(sim_status)

可用工具

产品工具

  • get_all_products() -检索所有可用的1NCE产品

订购工具

  • get_all_orders(page, page_size, sort) -获取带分页的订单列表
  • get_order_by_number(order_number) -获取特定订单的详细信息
  • create_order(products, delivery_address, customer_reference) -创建新订单

SIM卡工具

  • get_all_sims(page, page_size, query, sort) -列出带有过滤选项的SIM卡
  • get_sim_details(iccid) -获取特定SIM卡的详细信息
  • get_sim_status(iccid) -检查SIM卡的连接状态
  • get_sim_data_quota(iccid) -检查SIM卡的剩余数据配额
  • get_sim_sms_quota(iccid) -检查SIM卡的剩余短信配额
  • update_sim_status(iccid, status, label, imei_lock) -更新SIM卡配置
  • get_sim_usage(iccid, start_date, end_date) -获取一段时间内的使用统计数据
  • get_sim_events(iccid, page, page_size, sort) -获取SIM卡的事件历史记录
  • reset_sim_connectivity(iccid) -触发SIM卡的连接重置

例子

检查SIM卡状态

from fastmcp import Client

async with Client("1nce_mcp.py") as client:
    # Check SIM status
    sim_status = await client.call_tool("get_sim_status", {
        "iccid": "8988303000123456789"
    })
    print(f"SIM Status: {sim_status.get('status')}")
    
    # Check data quota
    quota = await client.call_tool("get_sim_data_quota", {
        "iccid": "8988303000123456789"
    })
    print(f"Remaining data: {quota.get('volume')} MB")
    print(f"Expires on: {quota.get('expiry_date')}")

创建订单

from fastmcp import Client

async with Client("1nce_mcp.py") as client:
    # Create an order for 5 SIM cards
    order = await client.call_tool("create_order", {
        "products": [{"productId": 1001, "quantity": 5}],
        "customer_reference": "IoT-Project-XYZ"
    })
    print(f"Order created with number: {order.get('order_number')}")

安全

  • MCP服务器需要1NCE API证书才能设置为环境变量
  • 使用OAuth 2.0和基本身份验证执行身份验证
  • 访问令牌是动态获得的,而不是持久存储的
  • 服务器只公开必要的API操作,读取操作优先于写入操作

贡献

欢迎投稿!请随时提交拉取请求。

许可证

此项目根据MIT许可证获得许可-有关详细信息,请参阅许可证文件。

致谢

  • 1NCE 用于提供物联网连接API
  • FastMCP 用于MCP服务器框架
  • Anthropic Claude AI助手功能