AWS opensearch-service documentation change
Summary
Updated code examples and installation instructions for AWS MCP Server integration
Security assessment
Changes involve code refactoring and dependency updates without security-specific modifications. The updates improve clarity but don't address security vulnerabilities or document security features.
Diff
diff --git a/opensearch-service/latest/developerguide/aws-mcp-server.md b/opensearch-service/latest/developerguide/aws-mcp-server.md index cdbca31a0..9c926d88e 100644 --- a//opensearch-service/latest/developerguide/aws-mcp-server.md +++ b//opensearch-service/latest/developerguide/aws-mcp-server.md @@ -116,2 +115,0 @@ You can integrate the AWS MCP Server into Python agent frameworks for programmat - import boto3 - import os @@ -120 +118 @@ You can integrate the AWS MCP Server into Python agent frameworks for programmat - from mcp.client.streamable_http import streamablehttp_client + from mcp_proxy_for_aws.client import aws_iam_streamablehttp_client @@ -122,3 +120,2 @@ You can integrate the AWS MCP Server into Python agent frameworks for programmat - # Get credentials for signing - session = boto3.Session() - credentials = session.get_credentials().get_frozen_credentials() + ENDPOINT = "https://aws-mcp.us-east-1.api.aws/mcp" + AWS_REGION = "us-east-1" @@ -127,5 +124,4 @@ You can integrate the AWS MCP Server into Python agent frameworks for programmat - lambda: streamablehttp_client( - "https://aws-mcp.us-east-1.api.aws/mcp", - headers={ - "AWS_REGION": os.environ.get("AWS_REGION", "us-east-1"), - } + lambda: aws_iam_streamablehttp_client( + endpoint=ENDPOINT, + aws_service="aws-mcp", + aws_region=AWS_REGION, @@ -137 +133 @@ You can integrate the AWS MCP Server into Python agent frameworks for programmat - response = agent("List all OpenSearch Service domains and show the cluster health for each") + response = agent("What OpenSearch Service domains do I have?") @@ -139,0 +136,5 @@ You can integrate the AWS MCP Server into Python agent frameworks for programmat +Install the required packages: + + + pip install strands-agents mcp-proxy-for-aws + @@ -142 +143 @@ You can integrate the AWS MCP Server into Python agent frameworks for programmat -[LangGraph](https://github.com/langchain-ai/langgraph) is a low-level orchestration framework for building stateful agents. The following example uses `langchain-mcp-adapters` to load AWS MCP tools into a LangGraph ReAct agent backed by Amazon Bedrock. +[LangGraph](https://github.com/langchain-ai/langgraph) is a low-level orchestration framework for building stateful agents. The following example uses `mcp-proxy-for-aws` to provide an authenticated transport and `langchain-mcp-adapters` to load the AWS MCP tools into a LangChain agent backed by Amazon Bedrock. @@ -146 +147,3 @@ You can integrate the AWS MCP Server into Python agent frameworks for programmat - import os + from mcp import ClientSession + from mcp_proxy_for_aws.client import aws_iam_streamablehttp_client + from langchain_mcp_adapters.tools import load_mcp_tools @@ -148,2 +151,4 @@ You can integrate the AWS MCP Server into Python agent frameworks for programmat - from langchain_mcp_adapters.client import MultiServerMCPClient - from langgraph.prebuilt import create_react_agent + from langchain.agents import create_agent + + ENDPOINT = "https://aws-mcp.us-east-1.api.aws/mcp" + AWS_REGION = "us-east-1" @@ -152,12 +157,8 @@ You can integrate the AWS MCP Server into Python agent frameworks for programmat - async with MultiServerMCPClient( - { - "aws-mcp": { - "url": "https://aws-mcp.us-east-1.api.aws/mcp", - "transport": "streamable_http", - "headers": { - "AWS_REGION": os.environ.get("AWS_REGION", "us-east-1"), - }, - } - } - ) as mcp_client: - tools = mcp_client.get_tools() + async with aws_iam_streamablehttp_client( + endpoint=ENDPOINT, + aws_service="aws-mcp", + aws_region=AWS_REGION, + ) as (read_stream, write_stream, _get_session_id): + async with ClientSession(read_stream, write_stream) as session: + await session.initialize() + tools = await load_mcp_tools(session) @@ -165,2 +166,2 @@ You can integrate the AWS MCP Server into Python agent frameworks for programmat - model_id="anthropic.claude-3-5-sonnet-20241022-v2:0", - region_name=os.environ["AWS_REGION"], + model_id="us.anthropic.claude-opus-4-8", + region_name=AWS_REGION, @@ -168 +169 @@ You can integrate the AWS MCP Server into Python agent frameworks for programmat - agent = create_react_agent(model, tools) + agent = create_agent(model, tools) @@ -170 +171 @@ You can integrate the AWS MCP Server into Python agent frameworks for programmat - {"messages": [{"role": "user", "content": "Check cluster health and list all OpenSearch indexes"}]} + {"messages": [{"role": "user", "content": "What OpenSearch Service domains do I have?"}]} @@ -179 +180 @@ Install the required packages: - pip install langchain-aws langchain-mcp-adapters langgraph + pip install mcp-proxy-for-aws langchain langchain-aws langchain-mcp-adapters langgraph