-
Notifications
You must be signed in to change notification settings - Fork 49
feat: Add new toolset for OpenSearch Agentic Memory API #138
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
base: main
Are you sure you want to change the base?
feat: Add new toolset for OpenSearch Agentic Memory API #138
Conversation
Signed-off-by: Jiri Oujezdsky <oujezdsky2@gmail.com>
Signed-off-by: Jiri Oujezdsky <oujezdsky2@gmail.com>
Signed-off-by: Jiri Oujezdsky <oujezdsky2@gmail.com>
Signed-off-by: Jiri Oujezdsky <oujezdsky2@gmail.com>
Signed-off-by: Jiri Oujezdsky <oujezdsky2@gmail.com>
Signed-off-by: Jiri Oujezdsky <oujezdsky2@gmail.com>
Signed-off-by: Jiri Oujezdsky <oujezdsky2@gmail.com>
Signed-off-by: Jiri Oujezdsky <oujezdsky2@gmail.com>
Signed-off-by: Jiri Oujezdsky <oujezdsky2@gmail.com>
…uster_name param Signed-off-by: Jiri Oujezdsky <oujezdsky2@gmail.com>
Signed-off-by: Jiri Oujezdsky <oujezdsky2@gmail.com>
Signed-off-by: Jiri Oujezdsky <oujezdsky2@gmail.com>
Signed-off-by: Jiri Oujezdsky <oujezdsky2@gmail.com>
Signed-off-by: Jiri Oujezdsky <oujezdsky2@gmail.com>
Signed-off-by: Jiri Oujezdsky <oujezdsky2@gmail.com>
Signed-off-by: Jiri Oujezdsky <oujezdsky2@gmail.com>
…Tool Signed-off-by: Jiri Oujezdsky <oujezdsky2@gmail.com>
Signed-off-by: Jiri Oujezdsky <oujezdsky2@gmail.com>
…moryTool Signed-off-by: Jiri Oujezdsky <oujezdsky2@gmail.com>
|
Hello, This PR is ready for review again. 5 new commits that address issues:
Thank you for the review and apologies for the inconvenience. |
|
Hi @oujezdsky thanks for the PR! Few high level thoughts before I review the PR:
|
|
Hello @rithin-pullela-aws, Regarding the Readme and Userguide—no problem, I’ll add the new tools there as well. thanks |
…Tool Signed-off-by: Jiri Oujezdsky <oujezdsky2@gmail.com>
Signed-off-by: Jiri Oujezdsky <oujezdsky2@gmail.com>
Signed-off-by: Jiri Oujezdsky <oujezdsky2@gmail.com>
Signed-off-by: Jiri Oujezdsky <oujezdsky2@gmail.com>
|
This PR has been updated to address all comments and is now ready for re-review.
|
nathaliellenaa
left a comment
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.
Thanks for raising this PR @oujezdsky! Added some comments
CHANGELOG.md
Outdated
|
|
||
| ### Fixed | ||
| - Fix AWS auth issues for cat based tools, pin OpenSearchPy to 2.18.0 ([#135](https://github.com/opensearch-project/opensearch-mcp-server-py/pull/135)) | ||
| - Add new toolset for the OpenSearch Agentic Memory API: `CreateAgenticMemoryContainerTool`, `CreateAgenticMemorySessionTool`, `AddAgenticMemoriesTool`, `GetAgenticMemoryTool`, `UpdateAgenticMemoryTool`, `DeleteAgenticMemoryByIDTool`, `DeleteAgenticMemoryByQueryTool`, and `SearchAgenticMemoryTool`. ([#113](https://github.com/opensearch-project/opensearch-mcp-server-py/pull/138)) |
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.
| - Add new toolset for the OpenSearch Agentic Memory API: `CreateAgenticMemoryContainerTool`, `CreateAgenticMemorySessionTool`, `AddAgenticMemoriesTool`, `GetAgenticMemoryTool`, `UpdateAgenticMemoryTool`, `DeleteAgenticMemoryByIDTool`, `DeleteAgenticMemoryByQueryTool`, and `SearchAgenticMemoryTool`. ([#113](https://github.com/opensearch-project/opensearch-mcp-server-py/pull/138)) | |
| - Add new toolset for the OpenSearch Agentic Memory API: `CreateAgenticMemoryContainerTool`, `CreateAgenticMemorySessionTool`, `AddAgenticMemoriesTool`, `GetAgenticMemoryTool`, `UpdateAgenticMemoryTool`, `DeleteAgenticMemoryByIDTool`, `DeleteAgenticMemoryByQueryTool`, and `SearchAgenticMemoryTool`. ([#138](https://github.com/opensearch-project/opensearch-mcp-server-py/pull/138)) |
README.md
Outdated
| - `messages` (conditional): A list of messages. Required when `payload_type` is `conversational`. *(Body Parameter)* | ||
| - `structured_data` (conditional): Structured data content. Required when `payload_type` is `data`. *(Body Parameter)* | ||
| - `binary_data` (optional): Binary data content encoded as a Base64 string for binary payloads. *(Body Parameter)* | ||
| - `payload_type` (required): The type of payload. Valid values are `conversational` or `data`. See [See Payload types](https://docs.opensearch.org/latest/ml-commons-plugin/agentic-memory/#payload-types). *(Body Parameter)* |
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.
| - `payload_type` (required): The type of payload. Valid values are `conversational` or `data`. See [See Payload types](https://docs.opensearch.org/latest/ml-commons-plugin/agentic-memory/#payload-types). *(Body Parameter)* | |
| - `payload_type` (required): The type of payload. Valid values are `conversational` or `data`. See [Payload types](https://docs.opensearch.org/latest/ml-commons-plugin/agentic-memory/#payload-types). *(Body Parameter)* |
README.md
Outdated
| - `namespace` (optional): The [namespace](https://docs.opensearch.org/latest/ml-commons-plugin/agentic-memory/#namespaces) context for organizing memories (for example, `user_id`, `session_id`, or `agent_id`). If `session_id` is not specified in the namespace field and `disable_session`: `false` (default is `true`), a new session with a new session ID is created. *(Body Parameter)* | ||
| - `metadata` (optional): Additional metadata for the memory (for example, `status`, `branch`, or custom fields). *(Body Parameter)* | ||
| - `tags` (optional): Tags for categorizing memories. *(Body Parameter)* | ||
| - `infer` (optional): Whether to use an LLM to extract key information (default: `false`). When `true`, the LLM extracts key information from the original text and stores it as a memory. [See Inference mode](https://docs.opensearch.org/latest/ml-commons-plugin/agentic-memory/#inference-mode). *(Body Parameter)* |
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.
| - `infer` (optional): Whether to use an LLM to extract key information (default: `false`). When `true`, the LLM extracts key information from the original text and stores it as a memory. [See Inference mode](https://docs.opensearch.org/latest/ml-commons-plugin/agentic-memory/#inference-mode). *(Body Parameter)* | |
| - `infer` (optional): Whether to use an LLM to extract key information (default: `false`). When `true`, the LLM extracts key information from the original text and stores it as a memory. See [Inference mode](https://docs.opensearch.org/latest/ml-commons-plugin/agentic-memory/#inference-mode). *(Body Parameter)* |
src/opensearch/helper.py
Outdated
| """Create a new agentic memory session in the specified memory container. | ||
| Args: | ||
| args: CreateSessionArgs containing memory_container_id and optional session_id, summary, metadata, namespace |
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.
Nit:
| args: CreateSessionArgs containing memory_container_id and optional session_id, summary, metadata, namespace | |
| args: CreateAgenticMemorySessionArgs containing memory_container_id and optional session_id, summary, metadata, namespace |
src/tools/agentic_memory/actions.py
Outdated
| return [{'type': 'text', 'text': f'Error updating memory: {str(error_to_report)}'}] | ||
|
|
||
|
|
||
| async def delete_agentic_memoryby_ID_tool( |
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.
Function name be should be delete_agentic_memory_by_id_tool to make it consistent with other function names
src/tools/agentic_memory/actions.py
Outdated
| if container_id: | ||
| message = f'Successfully created memory container. ID: {container_id}. Response: {json.dumps(result)}' | ||
| else: | ||
| message = ( | ||
| f'Memory container created, but no ID was returned. Response: {json.dumps(result)}' | ||
| ) |
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.
Should we keep a consistent message formatting? We can follow the format in create_agentic_memory_session_tool, for example
message = (
f'Successfully created memory container. ID: {container_id}. Response: {json.dumps(result)}'
if container_id
else f'Memory container created, but no ID was returned. Response: {json.dumps(result)}'
)
src/tools/agentic_memory/params.py
Outdated
| @model_validator(mode='after') | ||
| def validate_embedding_configuration(self) -> 'AgenticMemoryConfigurationArgs': | ||
| """Validate embedding model configuration.""" | ||
| if self.embedding_model_type == 'TEXT_EMBEDDING' and self.embedding_dimension is None: |
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.
Can we do if self.embedding_model_type == EmbeddingModelType.text_embedding?
src/tools/tools.py
Outdated
| 'function': create_agentic_memory_session_tool, | ||
| 'args_model': CreateAgenticMemorySessionArgs, | ||
| 'min_version': '3.3.0', # Agentic memory APIs requires OpenSearch 3.3+ | ||
| 'http_methods': 'UPDATE', |
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.
The http_methods should be the actual REST API method being called, so in this case it should be POST. The same should be applied for the other agentic memory tools
Signed-off-by: Jiri Oujezdsky <oujezdsky2@gmail.com>
Signed-off-by: Jiri Oujezdsky <oujezdsky2@gmail.com>
Signed-off-by: Jiri Oujezdsky <oujezdsky2@gmail.com>
…tency Signed-off-by: Jiri Oujezdsky <oujezdsky2@gmail.com>
Signed-off-by: Jiri Oujezdsky <oujezdsky2@gmail.com>
Signed-off-by: Jiri Oujezdsky <oujezdsky2@gmail.com>
|
@nathaliellenaa Thanks for the feedback! I've addressed all the comments. |
|
Thanks for the PR! Overall the changes look good to me from a tools perspective. One question is that when using these MCP tools with an agent, e.g. Claude desktop or Q/Kiro CLI, is it able to recognize that it needs to create a container before it can use the other Agentic Memory tools? Or would the user need to guide it through prompt to create container then add/get/update/delete memory? |
Description
This pull request introduces a set of 7 new tools to support the OpenSearch Agentic Memory API (released in 3.3). This allows agents using the MCP server to create, manage, and interact with agentic memories.
Key changes include:
CreateAgenticMemoryContainerTool,CreateAgenticMemorySessionTool,AddAgenticMemoriesTool,GetAgenticMemoryTool,UpdateAgenticMemoryArgsTool,DeleteAgenticMemoryByIDTool,DeleteAgenticMemoryByQueryTool, andSearchAgenticMemoryTool.asynchelper functions insrc/opensearch/helper.py.HelperOperationErrorto provide better, contextualized error logging.pytest.mark.parametrizefor all happy paths andpytest.raisesfor Pydantic validation.Issues Resolved
Closes #113
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.