OpenSearch 3.1 MCP AI interface

2025.08.16

Things are moving very quickly in the Artificial Inteliigence world at the moment. OpenSearch's implementation of the Model Context Protocol, which allows LLMs to discover subsystem functionlaity is in its infancy. An illustration of this is in the current documtation where the examples essentially don't work.

At this point attempting to get the OpenSearch builtin experimental MCP interface up and running so it can be used by Ollama under Docker is frustrated by an inability to register the available functions. The fix is shown below curtesy of https://github.com/opensearch-project/ml-commons/issues/3834. All fields need to be defined as the defaults are not usable.

_register endpoint doesn't work as documented

PUT /_cluster/settings/
{
    "persistent": {
        "plugins.ml_commons.mcp_server_enabled": "true"
    }
}

POST /_plugins/_ml/mcp/tools/_register
{
    "tools": [
        {
            "type": "ListIndexTool",
            "name": "My_ListIndexTool",
            "description": "Lists index of Opensearch CLuster A",
            "attributes": {
                "input_schema": {
                    "type": "object",
                    "properties": {
                        "input": {
                            "indices": {
                                "type": "array",
                                "items": {
                                    "type": "string"
                                },
                                "description": "OpenSearch index name list, separated by comma. for example: [\"index1\", \"index2\"], use empty array [] to list all indices in the cluster"
                            }
                        }
                    },
                    "additionalProperties": false
                }
            }
        }
    ]
}

POST /_plugins/_ml/mcp/tools/_register
{
    "tools": [
        {
          "name": "SearchIndexTool",
          "type": "SearchIndexTool",
          "description": "Use this tool to search an index by providing two parameters: 'index' for the index name, and 'query' for the OpenSearch DSL formatted query. Only use this tool when both index name and DSL query is available.",
          "attributes": {
            "input_schema": {
              "type": "object",
              "properties": {
                "input": {
                  "type": "object",
                  "properties": {
                    "index": {
                      "type": "string"
                    },
                    "query": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": false
                },
                "additionalProperties": false
              }
            }
          }
        }
    ]
}

GET /_plugins/_ml/mcp/tools/_list

_remove endpoint doesn't work as documented

The _remove endpoint won't work as documented within the OpenSearch Dashboards dev environment. It was found the only way to make it work was with a call using CURL with the -d payload option set as documented.

curl -X POST \
 -H "Content-Type: application/json" \
 -u "userid:password" \
 -d '["My_ListIndexTool"]' \
 -k https://opensearch-node-coord.mynetwork:9200/_plugins/_ml/mcp/tools/_remove