1NCE IoT Platform MCP Server

1NCE IoT Platform MCP Server

site icon
2025.04.22 0
Python物联网管理AI代理交互开发效率内容生成
1NCE IoT Platform MCP Server 是一个中间件层,通过自然语言使AI代理能够与1NCE物联网连接管理平台进行交互。它简化了连接设备的管理,提供了产品信息检索、订单管理、SIM卡状态监控等功能。
View on GitHub

Overview

基本能力

产品定位

1NCE IoT Platform MCP Server 是一个中间件层,通过自然语言使AI代理能够与1NCE物联网连接管理平台进行交互。

核心功能

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

适用场景

  • 物联网设备连接管理
  • SIM卡状态监控
  • 数据配额检查
  • 订单创建和跟踪

工具列表

产品工具

  • 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卡的连接重置

使用教程

使用依赖

  • Python 3.8+
  • FastMCP v2
  • 1NCE账户和API凭证

安装教程

  1. 克隆仓库
git clone https://github.com/yourusername/1nce-mcp-server.git
cd 1nce-mcp-server
  1. 安装依赖
pip install fastmcp httpx
  1. 设置环境变量
export ONCE_CLIENT_ID="your_client_id"
export ONCE_CLIENT_SECRET="your_client_secret"

调试方式

使用FastMCP安装

fastmcp install 1nce_mcp.py

直接运行

python 1nce_mcp.py

使用客户端

from fastmcp import Client

async with Client("1nce_mcp.py") as client:
    # 获取产品列表
    products = await client.call_tool("get_all_products")
    print(products)

    # 检查SIM卡状态
    sim_status = await client.call_tool("get_sim_status", {"iccid": "your_sim_iccid"})
    print(sim_status)

许可证

该项目遵循 MIT 开源许可条款,请参阅 MIT 了解完整条款。