FIWARE MCP Server

by dncampo
Verified

hybrid server

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

Integrations

  • Supports loading environment variables from .env files to configure the MCP server settings and Context Broker connection details

FIWARE MCP 服务器

这是 FIWARE 模型上下文协议 (MCP) 服务器的首次实现,该服务器在上下文代理和其他服务之间架起了桥梁。该服务器实现了与 FIWARE 上下文代理交互的基本操作。

目标

  • 为 FIWARE 创建基本的 MCP 服务器实现
  • 提供用于 Context Broker 交互的简单工具
  • 使用 Context Broker 演示基本意图 CRUD 操作
  • 为更复杂的 MCP 实现奠定基础

特征

  • Context Broker 版本检查
  • Context Broker 的查询功能
  • 实体发布和更新

先决条件

  • Python 3.7 或更高版本
  • pip(Python 包安装程序)
  • 访问 FIWARE Context Broker 实例

安装

  1. 克隆此存储库:
git clone <repository-url> cd FIWARE_MCP_01
  1. 安装所需的依赖项:
pip install -r requirements.txt

Claude 桌面集成

mcp install server.py # Custom name mcp install server.py --name "FIWARE MCP Server" # Environment variables, if any mcp install server.py -v API_KEY=abc123 -v DB_URL=postgres://... mcp install server.py -f .env

用法

启动 MCP 服务器:

python server.py # or mcp run server.py

服务器默认从127.0.0.1:5001启动。

可用工具

  1. CB_版本
    • 检查 Context Broker 的版本
    • 默认参数:address="localhost",port=1026
    • 返回:包含版本信息的 JSON 字符串
  2. 查询_CB
    • 查询上下文代理
    • 参数:
      • 地址(默认值:“localhost”)
      • 端口(默认值:1026)
      • 查询(默认值:“”)
    • 返回:包含查询结果的 JSON 字符串
  3. 发布到 CB
    • 在 Context Broker 中发布或更新实体
    • 参数:
      • 地址(默认值:“localhost”)
      • 端口(默认值:1026)
      • entity_data(必需:包含实体信息的字典)
    • 返回:带有操作状态的 JSON 字符串

示例用法

# Example entity data entity_data = { "id": "urn:ngsi-ld:TemperatureSensor:001", "type": "TemperatureSensor", "temperature": { "type": "Property", "value": 25.5 }, "@context": "https://uri.etsi.org/ngsi-ld/v1/ngsi-ld-core-context.jsonld" } # Publish to Context Broker result = publish_to_CB(entity_data=entity_data)

配置

可以通过修改server.py中的以下参数来配置服务器:

  • 主机地址
  • 端口号
  • 超时设置

错误处理

该服务器包括针对以下方面的全面错误处理:

  • 网络连接问题
  • 来自上下文代理的无效响应
  • 格式错误的实体数据
  • 服务器关闭

贡献

请随时提交问题和增强请求!

执照

该项目采用 Apache License 2.0 许可。

-
security - not tested
A
license - permissive license
-
quality - not tested

Context Broker 与其他服务之间的桥梁,实现 FIWARE 环境中实体发布、更新和查询的基本操作。

  1. Objectives
    1. Features
      1. Prerequisites
        1. Installation
          1. Claude Desktop integration
            1. Usage
              1. Available Tools
              2. Example Usage
            2. Configuration
              1. Error Handling
                1. Contributing
                  1. License
                    ID: y2m7ax73b4