generated from amazon-archives/__template_Apache-2.0
-
Notifications
You must be signed in to change notification settings - Fork 617
[MCP Server] Add tool registration step #11346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
rithin-pullela-aws
wants to merge
1
commit into
opensearch-project:main
Choose a base branch
from
rithin-pullela-aws:mcp-server-update-doc
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -63,7 +63,47 @@ asyncio.run(main()) | |||||
|
||||||
While not required for normal usage, you can manually invoke the MCP server using JSON-RPC calls over HTTP. The following example presents typical MCP client behavior. | ||||||
|
||||||
#### Step 1: Initialize a connection | ||||||
#### Step 1: Register tools | ||||||
|
||||||
Before connecting to the MCP server, you can register custom tools using the register API. Here's how to register a list index tool: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
```json | ||||||
POST /_plugins/_ml/mcp/register | ||||||
{ | ||||||
"tools": [ | ||||||
{ | ||||||
"name": "ListIndexTool", | ||||||
"type": "ListIndexTool", | ||||||
"description": "This tool returns information about indices in the OpenSearch cluster along with the index `health`, `status`, `index`, `uuid`, `pri`, `rep`, `docs.count`, `docs.deleted`, `store.size`, `pri.store. size `, `pri.store.size`, `pri.store`. Optional arguments: 1. `indices`, a comma-delimited list of one or more indices to get information from (default is an empty list meaning all indices). Use only valid index names. 2. `local`, whether to return information from the local node only instead of the cluster manager node (Default is false)", | ||||||
"inputSchema": { | ||||||
"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 | ||||||
} | ||||||
} | ||||||
] | ||||||
} | ||||||
``` | ||||||
{% include copy-curl.html %} | ||||||
|
||||||
The server responds with confirmation that the tool was registered: | ||||||
|
||||||
```json | ||||||
200 OK | ||||||
{ | ||||||
"message": "Tool 'ListIndexTool' registered successfully" | ||||||
} | ||||||
``` | ||||||
|
||||||
#### Step 2: Initialize a connection | ||||||
|
||||||
Send an `initialize` method with your client information and capabilities. Note that the `protocolVersion` must match the MCP specification version: | ||||||
|
||||||
|
@@ -121,7 +161,7 @@ The server responds with its capabilities and server information. The `tools.lis | |||||
} | ||||||
``` | ||||||
|
||||||
#### Step 2: Send an initialization complete notification | ||||||
#### Step 3: Send an initialization complete notification | ||||||
|
||||||
Send a notification to indicate that initialization is complete. This notification does not expect a response payload: | ||||||
|
||||||
|
@@ -141,7 +181,7 @@ The server acknowledges the notification with a `202 Accepted` status: | |||||
202 Accepted | ||||||
``` | ||||||
|
||||||
#### Step 3: List available tools | ||||||
#### Step 4: List available tools | ||||||
|
||||||
Use the `tools/list` method to discover available tools: | ||||||
|
||||||
|
@@ -189,7 +229,7 @@ The server returns an array of available tools with their names, descriptions, a | |||||
} | ||||||
``` | ||||||
|
||||||
#### Step 4: Call a tool | ||||||
#### Step 5: Call a tool | ||||||
|
||||||
Use the `tools/call` method to invoke a specific tool. Provide the tool name and arguments that match the tool's input schema: | ||||||
|
||||||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.