Skip to content

Commit 176121e

Browse files
committed
fix:Improve code maintainability: Add a public mcp_server attribute to FastMCP, implement RootsListChangedNotification handling, simplify capability check logic, and optimize the use of the TRANSPORTS variable
1 parent fc87632 commit 176121e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/mcp/server/session.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,12 @@ def check_client_capability(self, capability: types.ClientCapabilities) -> bool:
136136
# Check roots capability
137137
if capability.roots and not client_caps.roots: # pragma: lax no cover
138138
return False
139-
if (capability.roots and capability.roots.list_changed and
140-
client_caps.roots and not client_caps.roots.list_changed): # pragma: lax no cover
139+
if (
140+
capability.roots
141+
and capability.roots.list_changed
142+
and client_caps.roots
143+
and not client_caps.roots.list_changed
144+
): # pragma: lax no cover
141145
return False
142146

143147
# Check sampling capability
@@ -158,7 +162,9 @@ def check_client_capability(self, capability: types.ClientCapabilities) -> bool:
158162
if not client_caps.experimental: # pragma: lax no cover
159163
return False
160164
for exp_key, exp_value in capability.experimental.items(): # pragma: lax no cover
161-
if exp_key not in client_caps.experimental or client_caps.experimental[exp_key] != exp_value: # pragma: lax no cover
165+
if (
166+
exp_key not in client_caps.experimental or client_caps.experimental[exp_key] != exp_value
167+
): # pragma: lax no cover
162168
return False
163169

164170
# Check tasks capability

0 commit comments

Comments
 (0)