-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathquickstart.py
More file actions
65 lines (48 loc) · 2.39 KB
/
Copy pathquickstart.py
File metadata and controls
65 lines (48 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/usr/bin/env python3
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0
"""Minimal agent that opens Notepad and types 'Hello World' on a remote desktop.
This is a self-contained example — no imports from lib/. Copy-paste it into your
own project to integrate Amazon WorkSpaces agent access into an existing codebase.
Prerequisites:
pip install strands-agents mcp-proxy-for-aws boto3
Usage:
# Generate a streaming URL (valid 1 hour):
STREAMING_URL=$(scripts/streaming_url.sh)
# Run the agent:
python3 quickstart.py "$STREAMING_URL"
"""
import sys
from strands import Agent
from strands.models.bedrock import BedrockModel
from strands.tools.mcp import MCPClient
from mcp_proxy_for_aws.client import aws_iam_streamablehttp_client
# ─── Configuration ────────────────────────────────────────────────────────────
REGION = "us-east-1"
MCP_ENDPOINT = f"https://agentaccess-mcp.{REGION}.api.aws/mcp"
MODEL_ID = "global.anthropic.claude-sonnet-4-6"
if len(sys.argv) < 2:
print("Usage: python3 quickstart.py <STREAMING_URL>")
print(" STREAMING_URL=$(scripts/streaming_url.sh)")
sys.exit(1)
streaming_url = sys.argv[1]
# ─── 1. Connect to the Agent Access MCP Server ───────────────────────────────
mcp_client = MCPClient(lambda: aws_iam_streamablehttp_client(
endpoint=MCP_ENDPOINT,
aws_service="agentaccess-mcp",
aws_region=REGION,
headers={"X-Amzn-AgentAccess-Streaming-Session-Url": streaming_url},
))
# ─── 2. Create an agent with Claude + MCP tools ──────────────────────────────
model = BedrockModel(
model_id=MODEL_ID,
streaming=True,
)
agent = Agent(
model=model,
tools=[mcp_client],
system_prompt="You control a Windows desktop via MCP tools. Use screenshots to observe the screen and keyboard/mouse actions to interact.",
)
# ─── 3. Run a task ────────────────────────────────────────────────────────────
result = agent("Open Notepad from the Start Menu and type 'Hello World'")
print(f"\nDone. Result: {result}")