본문 바로가기
WIKI 기술 지식 베이스

Register MCP Tools API

원문 보기 위키 갱신

출처: 문서

본문

MCP Tools 등록 API

3.0에서 도입됨 {: .label .label-purple }

이 API를 사용하면 Model Context Protocol(MCP) 기반 도구를 하나 이상 등록할 수 있어요. 지원되는 도구에 대한 자세한 내용은 Tools를 참조하세요.

엔드포인트

POST /_plugins/_ml/mcp/tools/_register

요청 본문 필드

다음 표에서 사용 가능한 요청 필드를 확인할 수 있어요.

필드 데이터 타입 필수/선택 설명
tools Array 필수 도구 목록이에요.

tools 배열에는 도구 목록이 들어 있어요. 각 도구는 다음 필드를 포함해요.

필드 데이터 타입 필수/선택 설명
name String 선택 도구 이름이에요. 도구 이름은 기본적으로 type 파라미터 값으로 설정돼요. MCP 서버에 같은 타입의 도구를 여러 개 포함해야 한다면 도구마다 다른 이름을 지정하세요.
type String 필수 도구 타입이에요. 지원되는 도구 목록은 Tools를 참조하세요.
description String 선택 도구에 대한 설명이에요.
parameters Object 선택 도구의 파라미터예요. 파라미터는 도구 타입에 따라 달라져요. 특정 도구 타입에 대한 정보는 Tools를 참조하세요.
attributes Object 선택 도구의 구성 속성(attributes)이에요. 이 필드에서 가장 중요한 속성은 도구의 input_schema로, 도구가 기대하는 파라미터 형식을 정의해요. 이 스키마는 대규모 언어 모델(LLM)에 전송되어 LLM이 도구를 실행할 때 파라미터를 올바르게 형식화할 수 있게 해요.

요청 예시

내장 도구는 파라미터가 필요 없는 제로 구성(zero-configuration) 도구와 파라미터가 필요한 파라미터화된 도구로 나뉘어요. 제로 구성 도구는 표준 초기화 프로세스를 사용하고 파라미터가 필요 없기 때문에 요청 본문이 모두 같아요. 반면 파라미터화된 도구는 도구가 기대대로 동작하도록 올바른 초기화 파라미터를 제공해야 해요.

요청 예시: 제로 구성 도구

요청 예시
{
    "tools": [
        {
            "name": "ListIndexTool",
            "type": "ListIndexTool",
            "description": "This tool gets index information from the OpenSearch cluster. It takes 2 optional arguments named `indices` which is a comma-delimited list of one or more indices to get information from (default is an empty list meaning all indices), and `local` which means whether to return information from the local node only instead of the cluster manager node (default is false). The tool returns the indices information, including `health`, `status`, `index`, `uuid`, `pri`, `rep`, `docs.count`, `docs.deleted`, `store.size`, `pri.store. size `, `pri.store.size`, `pri.store`.",
            "attributes": {
                "input_schema": {
                    "type": "object",
                    "properties": {
                        "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
                }
            }
        },
        {
          "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": {
                "index": {
                  "type": "string"
                },
                "query": {
                  "type": "string"
                }
              },
              "additionalProperties": false
            }
          }
        },
        {
          "name": "IndexMappingTool",
          "type": "IndexMappingTool",
          "description": "This tool gets index mapping information from a certain index. It takes 1 required argument named 'index' which is a comma-delimited list of one or more indices to get mapping information from, which expands wildcards. It takes 1 optional argument named 'local' which means whether to return information from the local node only instead of the cluster manager node (Default is false). The tool returns a list of index mappings and settings for each index. The mappings are in JSON format under the key 'properties' which includes the field name as a key and a JSON object with field type under the key 'type'. The settings are in flattened map with 'index' as the top element and key-value pairs for each setting.",
          "attributes": {
            "input_schema": {
              "type": "object",
              "properties": {
                "index": {
                  "type": "array",
                  "description": "OpenSearch index name list, separated by comma. for example: [\"index1\", \"index2\"]",
                  "items": {
                      "type": "string"
                  }
                }
              },
              "required": [
                  "index"
              ],
              "additionalProperties": false
            }
          }
        },
        {
          "name": "SearchAlertsTool",
          "type": "SearchAlertsTool",
          "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": {
                "index": {
                  "type": "string",
                  "description": "OpenSearch index name. for example: index1"
                },
                "query": {
                  "type": "object",
                  "description": "OpenSearch search index query. You need to get index mapping to write correct search query. It must be a valid OpenSearch query. Valid value:\n{\"query\":{\"match\":{\"population_description\":\"seattle 2023 population\"}},\"size\":2,\"_source\":\"population_description\"}\nInvalid value: \n{\"match\":{\"population_description\":\"seattle 2023 population\"}}\nThe value is invalid because the match not wrapped by \"query\".",
                  "additionalProperties": false
                }
              },
              "required": ["index", "query"],
              "additionalProperties": false
            }
          }
        },
        {
          "name": "SearchAnomalyDetectorsTool",
          "type": "SearchAnomalyDetectorsTool",
          "description": "This is a tool that searches anomaly detectors. It takes 12 optional arguments named detectorName which is the explicit name of the detector (default is null), and detectorNamePattern which is a wildcard query to match detector name (default is null), and indices which defines the index or index pattern the detector is detecting over (default is null), and highCardinality which defines whether the anomaly detector is high cardinality (synonymous with multi-entity) of non-high-cardinality (synonymous with single-entity) (default is null, indicating both), and lastUpdateTime which defines the latest update time of the anomaly detector in epoch milliseconds (default is null), and sortOrder which defines the order of the results (options are asc or desc, and default is asc), and sortString which defines how to sort the results (default is name.keyword), and size which defines the size of the request to be returned (default is 20), and startIndex which defines the paginated index to start from (default is 0), and running which defines whether the anomaly detector is running (default is null, indicating both), and failed which defines whether the anomaly detector has failed (default is null, indicating both). The tool returns 2 values: a list of anomaly detectors (each containing the detector id, detector name, detector type indicating multi-entity or single-entity (where multi-entity also means high-cardinality), detector description, name of the configured index, last update time in epoch milliseconds), and the total number of anomaly detectors.",
          "attributes": {
            "input_schema": {
              "type": "object",
              "properties": {
                "detectorName": {
                  "type": "string",
                  "description": "Anomaly detector name"
                },
                "detectorNamePattern": {
                  "type": "string",
                  "description": "Anomaly detector name pattern"
                },
                "indices": {
                    "type": "string",
                    "description": "The index name that anomaly detector uses"
                },
                "highCardinality": {
                    "type": "string",
                    "description": "The value is true of false, the detector type will be set to MULTI_ENTITY if it's value is true, otherwise SINGLE_ENTITY if it's false"
                },
                "lastUpdateTime": {
                    "type": "string",
                    "description": "The last update time of the anomaly detector"
                },
                "sortString": {
                    "type": "string",
                    "description": "The sort key of the search result, default value is `name.keyword` which means the sorting is based on the detector name"
                },
                "sortOrder": {
                    "type": "string",
                    "description": "The search result order is based on this value, default is asc which means the sorting is in ascending manner."
                },
                "size": {
                    "type": "string",
                    "description": "This value controls how many search results will be fetched, default value is 20 which means at most 20 anomaly detecotrs can return"
                },
                "startIndex": {
                    "type": "string",
                    "description": "The start index of the search, default value is 0 which means starts from the beginning"
                },
                "running": {
                    "type": "string",
                    "description": "The running status of the anomaly detector, valid values are true and false, default is null"
                },
                "failed": {
                    "type": "string",
                    "description": "The failed status of the anomaly detector, valid values are true and false, default is null"
                }
              },
              "additionalProperties": false
            }
          }
        },
        {
          "name": "SearchAnomalyResultsTool",
          "type": "SearchAnomalyResultsTool",
          "description": "This is a tool that searches anomaly results. It takes 9 arguments named detectorId which defines the detector ID to filter for (default is null), and realtime which defines whether the anomaly results are from a realtime detector (set to false to only get results from historical analyses) (default is null), and anomalyGradeThreshold which defines the threshold for anomaly grade (a number between 0 and 1 that indicates how anomalous a data point is) (default is greater than 0), and dataStartTime which defines the start time of the anomaly data in epoch milliseconds (default is null), and dataEndTime which defines the end time of the anomaly data in epoch milliseconds (default is null), and sortOrder which defines the order of the results (options are asc or desc, and default is desc), and sortString which defines how to sort the results (default is data_start_time), and size which defines the number of anomalies to be returned (default is 20), and startIndex which defines the paginated index to start from (default is 0). The tool returns 2 values: a list of anomaly results (where each result contains the detector ID, the anomaly grade, and the confidence), and the total number of anomaly results.",
          "attributes": {
            "input_schema": {
              "type": "object",
              "properties": {
                "detectorId": {
                  "type": "string",
                  "description": "Anomaly detector id"
                },
                "realTime": {
                  "type": "string",
                  "description": "If the anomaly detector a real time one, valid values are true and false, default is null"
                },
                "anomalyGradeThreshold": {
                    "type": "string",
                    "description": "A float number to indicate the anomaly grade"
                },
                "dataStartTime": {
                    "type": "string",
                    "description": "Start time of the data in the anomaly detector"
                },
                "dataEndTime": {
                    "type": "string",
                    "description": "End time of the data in the anomaly detector"
                },
                "sortString": {
                    "type": "string",
                    "description": "The sort key of the search result, default value is `name.keyword` which means the sorting is based on the detector name"
                },
                "sortOrder": {
                    "type": "string",
                    "description": "The search result order is based on this value, default is asc which means the sorting is in ascending manner."
                },
                "size": {
                    "type": "string",
                    "description": "This value controls how many search results will be fetched, default value is 20 which means at most 20 anomaly detecotrs can return"
                },
                "startIndex": {
                    "type": "string",
                    "description": "The start index of the search, default value is 0 which means starts from the beginning"
                }
              },
              "additionalProperties": false
            }
          }
        },
        {
          "name": "SearchMonitorsTool",
          "type": "SearchMonitorsTool",
          "description": "This is a tool that searches alerting monitors. It takes 10 optional arguments named monitorId which defines the monitor ID to filter for (default is null), and monitorName which defines explicit name of the monitor (default is null), and monitorNamePattern which is a wildcard query to match monitor name (default is null), and enabled which defines whether the monitor is enabled (default is null, indicating both enabled and disabled), and hasTriggers which defines whether the monitor has triggers enabled (default is null, indicating both), and indices which defines the index being monitored (default is null), and sortOrder which defines the order of the results (options are asc or desc, and default is asc), and sortString which defines how to sort the results (default is name.keyword), and size which defines the size of the request to be returned (default is 20), and startIndex which defines the paginated index to start from (default is 0).  The tool returns 2 values: a list of alerting monitors (each containining monitor ID, monitor name, monitor type (indicating query-level, document-level, or bucket-level monitor types), enabled, enabled time in epoch milliseconds, last update time in epoch milliseconds), and the total number of alerting monitors.",
          "attributes": {
            "input_schema": {
              "type": "object",
              "properties": {
                "monitorId": {
                  "type": "string",
                  "description": "Alerting monitor id"
                },
                "monitorName": {
                  "type": "string",
                  "description": "Alerting monitor name"
                },
                "monitorNamePattern": {
                    "type": "string",
                    "description": "Alerting monitor name pattern"
                },
                "enabled": {
                    "type": "string",
                    "description": "If the alerting monitor enabled or not, valid values are true and false, default is null"
                },
                "hasTriggers": {
                    "type": "string",
                    "description": "If the alerting monitor has triggers, valid values are true and false, default is null"
                },
                "indices": {
                    "type": "string",
                    "description": "The index names that alerting monitor uses"
                },
                "sortString": {
                    "type": "string",
                    "description": "The sort key of the search result, default value is `name.keyword` which means the sorting is based on the detector name"
                },
                "sortOrder": {
                    "type": "string",
                    "description": "The search result order is based on this value, default is asc which means the sorting is in ascending manner."
                },
                "size": {
                    "type": "string",
                    "description": "This value controls how many search results will be fetched, default value is 20 which means at most 20 alerting monitors can return"
                },
                "startIndex": {
                    "type": "string",
                    "description": "The start index of the search, default value is 0 which means starts from the beginning"
                }
              },
              "additionalProperties": false
            }
          }
        }
      ]
}

{% include copy-curl.html %}

요청 예시: 파라미터화된 도구

다음 섹션에서는 파라미터화된 도구를 등록하는 요청 예시를 보여 줘요. 도구별 파라미터에 대한 정보는 해당 도구 문서를 참조하세요.

WebSearchTool

POST /_plugins/_ml/mcp/tools/_register
{
  "tools": [
    {
      "type": "WebSearchTool",
      "name": "GoogleSearchTool",
      "attributes": {
        "input_schema": {
          "type": "object",
          "properties": {
            "engine": {
              "type": "string",
              "description": "The search engine that will be used by the tool."
            },
            "query": {
              "type": "string",
              "description": "The search query parameter that will be used by the engine to perform the search."
            },
            "next_page": {
              "type": "string",
              "description": "The search result's next page link. If this is provided, the WebSearchTool will fetch the next page results using this link and crawl the links on the page."
            }
          },
          "required": [
            "engine",
            "query"
          ]
        },
        "strict": false
      }
    }
  ]
}

{% include copy-curl.html %}

PPLTool

POST /_plugins/_ml/mcp/tools/_register
{
  "tools": [
    {
      "type": "PPLTool",
      "name": "TransferQuestionToPPLAndExecuteTool",
      "description": "Use this tool to convert natural language into PPL queries and execute them. Use this tool after you know the index name; otherwise, call IndexRoutingTool first. The input parameters are: {index: IndexName, question: UserQuestion}",
      "parameters": {
        "model_id": "${your_model_id}",
        "model_type": "FINETUNE"
      },
      "attributes": {
        "input_schema": {
          "type": "object",
          "properties": {
            "question": {
              "type": "string",
              "description": "The user's natural language question that needs to be converted to PPL."
            },
            "index": {
              "type": "string",
              "description": "The index on which the generated PPL query will be executed."
            }
          }
        }
      }
    }
  ]
}

{% include copy-curl.html %}

응답 예시

OpenSearch는 각 노드에 대해 노드 ID와 모든 도구의 생성 상태를 응답으로 반환해요:

{
    "_ZNV5BrNTVm6ilcM7Jn1pw": {
        "created": true
    },
    "NZ9aiUCrSp2b5KBqdJGJKw": {
        "created": true
    }
}

더 알아보기 (Learn more)