- curl (2025-11-25 and earlier)
-
The following curl request shows an example request to get a prompt called myTarget___code_review through a gateway with the ID mygateway-abcdefghij. Set the MCP-Protocol-Version header to a version that your gateway supports.
curl -X POST \
https://mygateway-abcdefghij.gateway.bedrock-agentcore.us-west-2.amazonaws.com/mcp \
-H "Accept: application/json, text/event-stream" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "MCP-Protocol-Version: 2025-11-25" \
-d '{
"jsonrpc": "2.0",
"id": "get-prompt-request",
"method": "prompts/get",
"params": {
"name": "myTarget___code_review",
"arguments": {
"language": "python",
"code": "print(\"hello\")"
}
}
}'
- curl (2026-07-28)
-
On version 2026-07-28, include the Mcp-Method and Mcp-Name request-metadata headers and the _meta version fields in the body. The MCP-Protocol-Version header must match _meta.io.modelcontextprotocol/protocolVersion. Your gateway’s supportedVersions must include 2026-07-28.
curl -X POST \
https://mygateway-abcdefghij.gateway.bedrock-agentcore.us-west-2.amazonaws.com/mcp \
-H "Accept: application/json, text/event-stream" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
-H "MCP-Protocol-Version: 2026-07-28" \
-H "Mcp-Method: prompts/get" \
-H "Mcp-Name: myTarget___code_review" \
-d '{
"jsonrpc": "2.0",
"id": "get-prompt-request",
"method": "prompts/get",
"params": {
"name": "myTarget___code_review",
"arguments": {
"language": "python",
"code": "print(\"hello\")"
},
"_meta": {
"io.modelcontextprotocol/protocolVersion": "2026-07-28",
"io.modelcontextprotocol/clientInfo": {
"name": "my-agent",
"version": "1.0.0"
},
"io.modelcontextprotocol/clientCapabilities": {}
}
}
}'
- Python requests package (2025-11-25 and earlier)
-
Set the MCP-Protocol-Version header to a version that your gateway supports.
import requests
import json
def get_prompt(gateway_url, access_token, prompt_name, arguments):
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {access_token}",
"MCP-Protocol-Version": "2025-11-25"
}
payload = {
"jsonrpc": "2.0",
"id": "get-prompt-request",
"method": "prompts/get",
"params": {
"name": prompt_name,
"arguments": arguments
}
}
response = requests.post(gateway_url, headers=headers, json=payload)
return response.json()
# Example usage
gateway_url = "https://${GatewayEndpoint}/mcp" # Replace with your actual gateway endpoint
access_token = "${AccessToken}" # Replace with your actual access token
result = get_prompt(
gateway_url,
access_token,
"myTarget___code_review", # Replace with {targetName}___{promptName}
{"language": "python", "code": "print('hello')"}
)
print(json.dumps(result, indent=2))
- Python requests package (2026-07-28)
-
On version 2026-07-28, include the Mcp-Method and Mcp-Name request-metadata headers and the _meta version fields in the body. The MCP-Protocol-Version header must match _meta.io.modelcontextprotocol/protocolVersion. Your gateway’s supportedVersions must include 2026-07-28.
import requests
import json
def get_prompt(gateway_url, access_token, prompt_name, arguments):
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {access_token}",
"MCP-Protocol-Version": "2026-07-28",
"Mcp-Method": "prompts/get",
"Mcp-Name": prompt_name
}
payload = {
"jsonrpc": "2.0",
"id": "get-prompt-request",
"method": "prompts/get",
"params": {
"name": prompt_name,
"arguments": arguments,
"_meta": {
"io.modelcontextprotocol/protocolVersion": "2026-07-28",
"io.modelcontextprotocol/clientInfo": {"name": "my-agent", "version": "1.0.0"},
"io.modelcontextprotocol/clientCapabilities": {}
}
}
}
response = requests.post(gateway_url, headers=headers, json=payload)
return response.json()
# Example usage
gateway_url = "https://${GatewayEndpoint}/mcp" # Replace with your actual gateway endpoint
access_token = "${AccessToken}" # Replace with your actual access token
result = get_prompt(
gateway_url,
access_token,
"myTarget___code_review", # Replace with {targetName}___{promptName}
{"language": "python", "code": "print('hello')"}
)
print(json.dumps(result, indent=2))
- MCP Client
-
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client
import asyncio
async def execute_mcp(
url,
token,
prompt_name,
prompt_arguments,
headers=None
):
default_headers = {
"Authorization": f"Bearer {token}"
}
headers = {**default_headers, **(headers or {})}
async with streamablehttp_client(
url=url,
headers=headers,
) as (
read_stream,
write_stream,
callA,
):
async with ClientSession(read_stream, write_stream) as session:
# 1. Perform initialization handshake
print("Initializing MCP...")
_init_response = await session.initialize()
print(f"MCP Server Initialize successful! - {_init_response}")
# 2. Get specific prompt
print(f"Getting prompt: {prompt_name}")
prompt_response = await session.get_prompt(
name=prompt_name,
arguments=prompt_arguments
)
print(f"Prompt response: {prompt_response}")
return prompt_response
async def main():
url = "https://${GatewayEndpoint}/mcp"
token = "your_bearer_token_here"
prompt_name = "myTarget___code_review"
prompt_arguments = {
"language": "python",
"code": "print('hello')"
}
await execute_mcp(
url=url,
token=token,
prompt_name=prompt_name,
prompt_arguments=prompt_arguments
)
if __name__ == "__main__":
asyncio.run(main())
- LangGraph MCP Client
-
NOTE: LangGraph MCP adapter prompt support might vary. Use the MCP Client approach shown previously for the most reliable prompts/get implementation.
import asyncio
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client
async def get_prompt(url, token, prompt_name, arguments):
headers = {"Authorization": f"Bearer {token}"}
async with streamablehttp_client(url=url, headers=headers) as (
read_stream, write_stream, callA
):
async with ClientSession(read_stream, write_stream) as session:
await session.initialize()
response = await session.get_prompt(
name=prompt_name,
arguments=arguments
)
for message in response.messages:
print(f"{message.role}: {message.content}")
asyncio.run(get_prompt(
"https://${GatewayEndpoint}/mcp",
"${AccessToken}",
"myTarget___code_review",
{"language": "python", "code": "print('hello')"}
))