File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ async def process_query(self, query: str) -> str:
9797 tool_results = []
9898 final_text = []
9999
100- for content in response .content :
100+ for content in response .content : # each tool call will handle seperately
101101 if content .type == "text" :
102102 final_text .append (content .text )
103103 elif content .type == "tool_use" :
@@ -129,17 +129,19 @@ async def chat_loop(self):
129129 """Run an interactive chat loop"""
130130 print ("\n MCP Client Started!" )
131131 print ("Type your queries or 'quit' to exit." )
132- reply_history = ""
132+ reply_history = "" # this variable stores memory
133133 while True :
134134 try :
135135 query = input ("\n Interact with Excel File here: " ).strip ()
136+ # below the history is assembled
136137 query_with_history = (
137138 f"Previous conversation:\n { reply_history } \n Query: { query } "
138139 )
139140 if query .lower () == "quit" :
140141 break
141142
142143 response = await self .process_query (query_with_history )
144+ # here is response is apended to history
143145 reply_history += f"Query: { query } \n Response: { response } \n "
144146 print ("\n " + response )
145147
@@ -153,7 +155,8 @@ async def cleanup(self):
153155
154156async def main ():
155157 if len (sys .argv ) < 2 :
156- print ("Usage: python mcpclient.py mcpserver.py" )
158+ # we use uv package manager so uv run mcpclient.py mcpserver.py
159+ print ("Usage: uv run mcpclient.py server.py" )
157160 sys .exit (1 )
158161
159162 client = MCPClient ()
You can’t perform that action at this time.
0 commit comments