FIWARE Context Broker MCP server

Bridges AI assistants with FIWARE Context Brokers, enabling natural language interaction with IoT data for querying, publishing, and updating information in NGSI-LD format.
Back to servers
Provider
dncampo
Release date
Mar 24, 2025
Language
Python
Stats
3 stars

The FIWARE Model Context Protocol (MCP) Server provides a bridge between the Context Broker and other services, implementing basic operations for Context Broker interaction. It offers tools for version checking, entity queries, and data publishing within the FIWARE ecosystem.

Prerequisites

  • Python 3.7 or higher
  • pip (Python package installer)
  • Access to a FIWARE Context Broker instance

Installation

To install the MCP server, follow these steps:

  1. Clone the repository and navigate to the project directory:
git clone <repository-url>
cd FIWARE_MCP_01
  1. Install the required dependencies:
pip install -r requirements.txt

Integration with Claude Desktop

The server can be integrated with Claude Desktop using the following commands:

# Basic installation
mcp install server.py

# Installation with custom name
mcp install server.py --name "FIWARE MCP Server"

# Installation with environment variables
mcp install server.py -v API_KEY=abc123 -v DB_URL=postgres://...
mcp install server.py -f .env

Running the Server

Start the MCP server using one of the following commands:

python server.py
# or
mcp run server.py

By default, the server runs on 127.0.0.1:5001.

Available Tools

The server provides several tools for interacting with the Context Broker:

CB_version

Checks the version of the Context Broker.

  • Default parameters: address="localhost", port=1026
  • Returns: JSON string with version information

query_CB

Performs queries against the Context Broker.

  • Parameters:
    • address (default: "localhost")
    • port (default: 1026)
    • query (default: "")
  • Returns: JSON string with query results

publish_to_CB

Publishes or updates entities in the Context Broker.

  • Parameters:
    • address (default: "localhost")
    • port (default: 1026)
    • entity_data (required: dictionary with entity information)
  • Returns: JSON string with operation status

Usage Examples

Here's an example of how to publish entity data to the Context Broker:

# 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)

Configuration

You can configure the server by modifying these parameters in server.py:

  • Host address
  • Port number
  • Timeout settings

Error Handling

The server includes comprehensive error handling for:

  • Network connectivity issues
  • Invalid responses from the Context Broker
  • Malformed entity data
  • Server shutdown

How to add this MCP server to Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > MCP and click "Add new global MCP server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "cursor-rules-mcp": {
            "command": "npx",
            "args": [
                "-y",
                "cursor-rules-mcp"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explictly ask the agent to use the tool by mentioning the tool name and describing what the function does.

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later