66from strands .tools .mcp import MCPClient
77import streamlit as st
88
9+
910def remove_html_tags (text_with_html ):
1011 text_with_out_html = re .sub (r"<[^>]+>" , "" , text_with_html )
1112 return text_with_out_html
1213
14+
1315async def stream_result (stream ):
1416 result = ""
1517 placeholder = st .empty ()
1618 async for chunk in stream :
17- if ' data' in chunk :
18- result += chunk [' data' ]
19+ if " data" in chunk :
20+ result += chunk [" data" ]
1921 result = remove_html_tags (result )
2022 placeholder .write (result )
2123
@@ -26,33 +28,23 @@ def __init__(self):
2628
2729 server_params = {
2830 "command" : "npx" ,
29- "args" : [
30- "-y" ,
31- "kubernetes-mcp-server@latest"
32- ],
33- "env" : {
34- "KUBECONFIG" : "k3s.yaml"
35- }
31+ "args" : ["-y" , "kubernetes-mcp-server@latest" ],
32+ "env" : {"KUBECONFIG" : "k3s.yaml" },
3633 }
37-
38- self .stdio_mcp_client = MCPClient (lambda : stdio_client (
39- StdioServerParameters (
40- ** server_params
41- )
42- ))
34+
35+ self .stdio_mcp_client = MCPClient (
36+ lambda : stdio_client (StdioServerParameters (** server_params ))
37+ )
4338
4439 with self .stdio_mcp_client :
4540 # Get the tools from the MCP server
4641 tools = self .stdio_mcp_client .list_tools_sync ()
4742
4843 # Create an agent with these tools
4944 self .agent = Agent (
50- callback_handler = None ,
51- model = "us.amazon.nova-micro-v1:0" ,
52- tools = tools
45+ callback_handler = None , model = "us.amazon.nova-micro-v1:0" , tools = tools
5346 )
5447
55-
5648 async def send_prompt (self , prompt ):
5749 with self .stdio_mcp_client :
5850 stream = self .agent .stream_async (prompt )
0 commit comments