AI agent, MCP server

Indeed for some MCP clients (mobile, or like the voice client you showed above) I believe a version accessible via the internet is necessary.

Thanks for the information, I’ll try to implement it too, it could be really cool to have local access to it for those who are starting with Gladys.

Wow! Pierre-Gilles is super fast, thanks! I’ll integrate it too.

2 Likes

I just pushed local authentication; the image is being built. To access the MCP you now need to generate an API key from the integration interface and then configure your MCP client to send an Authorization header with the generated key as its value.

For example, to use it via GitHub Copilot in VS Code, here is the configuration

{
  "servers": {
    "gladys": {
      "url": "http://\u003cgladyslocalip\u003e:1443/api/v1/service/mcp/proxy",
      "type": "http",
      "headers": {
        "Authorization": "\u003cclé-api\u003e"
      }
    }
  },
  "inputs": []
}

1 Like

A new version of the image is available. This time we’re adding access to the server via Gladys Plus. To access it you need to generate an API key from your Gladys Plus account https://gladysassistant.com/fr/docs/plus/open-api/#g%C3%A9n%C3%A9rer-une-cl%C3%A9-dapi

Then enter this URL in your MCP client https://api.gladysgateway.com/v1/api/mcp/\u003cOPEN_API_KEY\u003e replacing \u003cOPEN_API_KEY\u003e with the newly generated key.

For example, on Le Chat de Mistral, go to IntelligenceConnectors

Click on Add a connector

In the Custom MCP Connector tab fill out the form

You can now interact with Gladys data in Le Chat

6 Likes

Hi @bertrandda :slight_smile:

Thanks for the PR, I’m testing it!

With Mistral, it’s working perfectly :ok_hand:

Do you know how often the resource list is refreshed on the client side?

I created a plug for testing, but the plug doesn’t seem to be found:

Second question, what types of sensors are supported?

The documentation mentions:

:thermometer: Retrieve device states (temperature, humidity, open/closed, light…)

I don’t know what’s included in the “…” :smiley:

For example, is this supposed to work:

Indeed it may not happen immediately; there are two things to take into account. First, on the Gladys side the schema is generated at service startup — we can add a « Restart » button like we did for HomeKit to regenerate the schema if the user has just added a new device. For the client side, it depends on the implementation. Generally what I’ve noticed is that the client checks the schema at startup and if you modify the MCP configuration in your client and save.

Normally I think I’ve included all sensor types, but a few may be missing.

I’ll clarify that: it’s all sensors plus compatible controllable devices (currently light, switch).

Could you give me the category and the type of feature associated with this functionality please? I’ll check

Yes, even automatically!

[quote=« bertrandda, post:25, topic:9656 »]
Could you give me the category and the feature

A few types of sensors were missing; I added, among others, level, light, and rain sensors if you want to try again

Recently I’ve been learning on YouTube how to create an AI agent with N8N. If I understood the MCP’s operation correctly, this server would allow me to connect Gladys to my AI agent and talk with it to launch scenes, retrieve sensor information and control my plugs and lights without going through Google Home or Alexa, which are very limited?

Yes, that’s correct, any agent, if it’s MCP-compatible (that’s the case for n8n), will be able to connect to it.

I’ve just updated the PR to automatically reload the schema if a new device is created.

4 Likes

Thanks @bertrandda, it works perfectly :heart_eyes:

I should point out that it works perfectly on the « Le Chat » mobile app on iOS:

Very, very nice job!!

I’ve left you a few comments on the PR:

Otherwise I think we can publish this quickly to PROD!

4 Likes

Can you add a listener for a device name change as well? :slight_smile:
I just ran into that!

I pushed the requested changes. For info, I also made a small update to find the correct device requested by the user — if the exact name doesn’t exist we perform a check for similar names using the Levenshtein distance. In most cases this shouldn’t be necessary since the whole schema is based on enums, but some MCP clients don’t seem to take them into account. After a quick test with 11ai that you mentioned above, it doesn’t seem to handle enums correctly, and these small changes, although not perfect, should help a bit (an improvement on 11ai’s side would be much more effective).

1 Like

Great!

I don’t know if you’ve seen my reply to your comment?

@bertrandda I looked at your PR, I just have one very small remark about a line of code that I think dates from the old implementation:

Other than that it’s great, I tested updating a device’s name and it works very well :slight_smile: Well done!

Indeed, a small oversight in the last fix, it’s fixed now.

1 Like

Thanks!

I noticed a small bug when deleting an API key:

it doesn’t work when the key has just been created

Good catch, it’s fixed!

1 Like

Great, looks good to me!

It’s merged and will be included in the next Gladys release :white_check_mark:

Nice work :clap:

6 Likes

Hello,

I just updated my Gladys, and the service is experiencing a startup error on my production environment. Apparently due to a device that may not have a room (I suppose).

compose-gladys-1      | 2025-11-03T16:18:35+0100 \u003cinfo\u003e index.js:27 (Object.start) Starting MCP service
compose-gladys-1      | 2025-11-03T16:18:35+0100 \u003cwarn\u003e service.start.js:44 (Service.start) Unable to start service mcp TypeError: Cannot read properties of null (reading 'selector')
compose-gladys-1      |     at /src/server/services/mcp/lib/buildSchemas.js:41:28
compose-gladys-1      |     at Array.forEach (\u003canonymous\u003e)
compose-gladys-1      |     at MCPHandler.getAllResources (/src/server/services/mcp/lib/buildSchemas.js:28:17)
compose-gladys-1      |     at MCPHandler.createServer (/src/server/services/mcp/lib/createServer.js:26:4)
compose-gladys-1      |     at Object.start (/src/server/services/mcp/index.js:29:5)
compose-gladys-1      |     at Service.start (/src/server/lib/service/service.start.js:33:7)
compose-gladys-1      |     at start (/src/server/api/controllers/service.controller.js:22:21)

However, I still can’t find the device in question, I’ll check the DB to see if I can find it :slight_smile:

Edit:

It’s the device linked to the Enedis service that’s causing the problem, I’ll delete it for now I don’t use it :wink:

@bertrandda I have the same issue as @JeuFore on my instance as well :

2025-11-03T15:04:03+0100 \u003cwarn\u003e service.start.js:44 (Service.start) Unable to start service mcp TypeError: Cannot read properties of null (reading 'selector')
    at /src/server/services/mcp/lib/buildSchemas.js:41:28
    at Array.forEach (\u003canonymous\u003e)
    at MCPHandler.getAllResources (/src/server/services/mcp/lib/buildSchemas.js:28:17)
    at MCPHandler.createServer (/src/server/services/mcp/lib/createServer.js:26:4)
    at Object.start (/src/server/services/mcp/index.js:29:5)
    at Service.start (/src/server/lib/service/service.start.js:33:7)