Skip to content

Commit cd9886c

Browse files
committed
test
1 parent 639f3c4 commit cd9886c

File tree

3 files changed

+50
-0
lines changed

3 files changed

+50
-0
lines changed

test

Whitespace-only changes.

test-mcp.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from fastmcp import FastMCP
2+
import time
3+
4+
app = FastMCP()
5+
6+
@app.tool("say")
7+
def say(input: str) -> str:
8+
"""Says something."""
9+
time.sleep(5)
10+
return f"{input}!"
11+
12+
if __name__ == "__main__":
13+
app.run(transport="http", host="localhost", port=8080)
14+
# app.run()

test.py

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
from datetime import timedelta
2+
from strands.tools.mcp import MCPClient
3+
from mcp.client.streamable_http import streamablehttp_client
4+
from strands import Agent
5+
import logging
6+
import asyncio
7+
8+
logging.getLogger("strands.tools.mcp").setLevel(logging.DEBUG)
9+
10+
# Add a handler to see the logs
11+
logging.basicConfig(
12+
format="%(levelname)s | %(name)s | %(message)s",
13+
handlers=[logging.StreamHandler()]
14+
)
15+
16+
client = MCPClient(lambda: streamablehttp_client(
17+
sse_read_timeout=2,
18+
url="http://localhost:8080/mcp"))
19+
20+
with client as mcp:
21+
try:
22+
# mcp.call_tool_sync(tool_use_id="123", name="say", arguments={"input": "Hello!"})
23+
agent = Agent(tools=[mcp.list_tools_sync()])
24+
while True:
25+
26+
agent(input("\nInput: "))
27+
except Exception as e:
28+
print(f"\n\n\n\n\nHERE: {e}")
29+
30+
# async def call_say_tool():
31+
# await mcp.call_tool_async(tool_use_id="123", name="say", arguments={"input": "Hello!"})
32+
33+
# asyncio.run(call_say_tool())
34+
# agent = Agent(tools=[mcp.list_tools_sync()])
35+
# agent("Use the say tool three times in one request to say the world \"Hello\" \"there\" \"world!\"")
36+
# print(agent.messages)

0 commit comments

Comments
 (0)