SAkizuki commited on
Commit
f6fee5c
·
verified ·
1 Parent(s): 020dc3a

Auto-sync from GitHub Actions

Browse files
Files changed (2) hide show
  1. mcp_server.py +16 -0
  2. ui_nicegui.py +6 -3
mcp_server.py CHANGED
@@ -67,6 +67,22 @@ logging.getLogger("mcp.server").addFilter(_disconnect_filter)
67
  logging.getLogger("uvicorn.error").addFilter(_disconnect_filter)
68
 
69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
70
  mcp = FastMCP(
71
  name="danbooru-searcher",
72
  transport_security=TransportSecuritySettings(enable_dns_rebinding_protection=False),
 
67
  logging.getLogger("uvicorn.error").addFilter(_disconnect_filter)
68
 
69
 
70
+ # ── 过滤 Trae 非标准会话结束通知产生的校验噪音 ─────────────────────────────
71
+ class _SuppressTraeSessionStopNoise(logging.Filter):
72
+ _MARKERS = (
73
+ "Failed to validate notification",
74
+ "notifications/trae/session_stop",
75
+ )
76
+
77
+ def filter(self, record: logging.LogRecord) -> bool:
78
+ message = record.getMessage()
79
+ return not all(marker in message for marker in self._MARKERS)
80
+
81
+
82
+ # MCP 依赖在 shared.session 中直接使用根 logger 记录此校验警告。
83
+ logging.getLogger().addFilter(_SuppressTraeSessionStopNoise())
84
+
85
+
86
  mcp = FastMCP(
87
  name="danbooru-searcher",
88
  transport_security=TransportSecuritySettings(enable_dns_rebinding_protection=False),
ui_nicegui.py CHANGED
@@ -57,12 +57,15 @@ class _SuppressMCPNoise(logging.Filter):
57
 
58
  logging.getLogger("uvicorn.error").addFilter(_SuppressMCPNoise())
59
 
60
- # suppress MCP OAuth discovery 404 noise (clients probing .well-known/oauth-authorization-server)
61
  class _SuppressOAuthNoise(logging.Filter):
62
- _MARKER = ".well-known/oauth-authorization-server"
 
 
 
63
 
64
  def filter(self, record: logging.LogRecord) -> bool:
65
- if self._MARKER in record.getMessage():
66
  return False
67
  return True
68
 
 
57
 
58
  logging.getLogger("uvicorn.error").addFilter(_SuppressMCPNoise())
59
 
60
+ # suppress MCP OAuth discovery 404 noise (clients probing .well-known OAuth endpoints)
61
  class _SuppressOAuthNoise(logging.Filter):
62
+ _MARKERS = (
63
+ ".well-known/oauth-authorization-server",
64
+ ".well-known/oauth-protected-resource",
65
+ )
66
 
67
  def filter(self, record: logging.LogRecord) -> bool:
68
+ if any(marker in record.getMessage() for marker in self._MARKERS):
69
  return False
70
  return True
71