Spaces:
Sleeping
Sleeping
Commit ·
6796ce4
1
Parent(s): d8f9bd2
feat: Introduce `MCPClient` for multi-server MCP communication with mock support, update `gradio` dependency, and add logging verification scripts.
Browse files- repro_logging.py +15 -0
- src/credentialwatch_agent/__pycache__/mcp_client.cpython-313.pyc +0 -0
- src/credentialwatch_agent/mcp_client.py +0 -6
- uv.lock +1 -1
- verify_fix.py +16 -0
repro_logging.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
+
|
| 3 |
+
# Simulate main.py
|
| 4 |
+
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
| 5 |
+
|
| 6 |
+
# Simulate mcp_client.py behavior
|
| 7 |
+
logger = logging.getLogger("mcp_client")
|
| 8 |
+
if not logger.handlers:
|
| 9 |
+
handler = logging.StreamHandler()
|
| 10 |
+
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
| 11 |
+
handler.setFormatter(formatter)
|
| 12 |
+
logger.addHandler(handler)
|
| 13 |
+
logger.setLevel(logging.INFO)
|
| 14 |
+
|
| 15 |
+
logger.info("This should be printed twice if bug exists.")
|
src/credentialwatch_agent/__pycache__/mcp_client.cpython-313.pyc
CHANGED
|
Binary files a/src/credentialwatch_agent/__pycache__/mcp_client.cpython-313.pyc and b/src/credentialwatch_agent/__pycache__/mcp_client.cpython-313.pyc differ
|
|
|
src/credentialwatch_agent/mcp_client.py
CHANGED
|
@@ -23,12 +23,6 @@ class MCPClient:
|
|
| 23 |
|
| 24 |
# Configure logger
|
| 25 |
self.logger = logging.getLogger("mcp_client")
|
| 26 |
-
if not self.logger.handlers:
|
| 27 |
-
handler = logging.StreamHandler()
|
| 28 |
-
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
| 29 |
-
handler.setFormatter(formatter)
|
| 30 |
-
self.logger.addHandler(handler)
|
| 31 |
-
self.logger.setLevel(logging.INFO)
|
| 32 |
|
| 33 |
async def connect(self):
|
| 34 |
"""Establishes connections to all MCP servers."""
|
|
|
|
| 23 |
|
| 24 |
# Configure logger
|
| 25 |
self.logger = logging.getLogger("mcp_client")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
async def connect(self):
|
| 28 |
"""Establishes connections to all MCP servers."""
|
uv.lock
CHANGED
|
@@ -350,7 +350,7 @@ dependencies = [
|
|
| 350 |
|
| 351 |
[package.metadata]
|
| 352 |
requires-dist = [
|
| 353 |
-
{ name = "gradio", extras = ["mcp"], specifier = ">=
|
| 354 |
{ name = "httpx", specifier = ">=0.25.0" },
|
| 355 |
{ name = "langchain-mcp-adapters", specifier = ">=0.0.1" },
|
| 356 |
{ name = "langchain-openai", specifier = ">=0.0.5" },
|
|
|
|
| 350 |
|
| 351 |
[package.metadata]
|
| 352 |
requires-dist = [
|
| 353 |
+
{ name = "gradio", extras = ["mcp"], specifier = ">=6.0.1" },
|
| 354 |
{ name = "httpx", specifier = ">=0.25.0" },
|
| 355 |
{ name = "langchain-mcp-adapters", specifier = ">=0.0.1" },
|
| 356 |
{ name = "langchain-openai", specifier = ">=0.0.5" },
|
verify_fix.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import logging
|
| 2 |
+
import sys
|
| 3 |
+
import os
|
| 4 |
+
|
| 5 |
+
# Add src to path so we can import credentialwatch_agent
|
| 6 |
+
sys.path.append(os.path.join(os.getcwd(), "src"))
|
| 7 |
+
|
| 8 |
+
from credentialwatch_agent.mcp_client import mcp_client
|
| 9 |
+
|
| 10 |
+
# Configure root logger as main.py does
|
| 11 |
+
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
| 12 |
+
|
| 13 |
+
# Log something via mcp_client
|
| 14 |
+
print("--- START LOG TEST ---")
|
| 15 |
+
mcp_client.logger.info("This should appear exactly ONCE.")
|
| 16 |
+
print("--- END LOG TEST ---")
|