Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
141 commits
Select commit Hold shift + click to select a range
2a0938a
fix: validate_scope should allow all scopes when no restriction
goingforstudying-ctrl Mar 8, 2026
572240a
ci: trigger rebuild
goingforstudying-ctrl Mar 8, 2026
fa4b6e3
ci: auto retry
goingforstudying-ctrl Mar 8, 2026
c60e103
ci: auto retry
goingforstudying-ctrl Mar 8, 2026
878fb9f
ci: auto retry
goingforstudying-ctrl Mar 8, 2026
581356f
ci: auto retry
goingforstudying-ctrl Mar 8, 2026
e6a79d1
style: fix trailing whitespace
goingforstudying-ctrl Mar 8, 2026
2b16a11
ci: auto retry
goingforstudying-ctrl Mar 8, 2026
d2e9f76
ci: auto retry
goingforstudying-ctrl Mar 8, 2026
95f407a
ci: keepalive 09:10
goingforstudying-ctrl Mar 8, 2026
44b5ea9
ci: auto retry
goingforstudying-ctrl Mar 8, 2026
17e2b4a
ci: keepalive 09:21
goingforstudying-ctrl Mar 8, 2026
4abd084
ci: auto retry 0921
goingforstudying-ctrl Mar 8, 2026
5d1af8e
ci: auto retry
goingforstudying-ctrl Mar 8, 2026
6e806ac
ci: retry 0931
goingforstudying-ctrl Mar 8, 2026
d00a5a4
ci: auto 0932
goingforstudying-ctrl Mar 8, 2026
dbbd370
ci: auto 0947
goingforstudying-ctrl Mar 8, 2026
129d43f
ci: auto 1002
goingforstudying-ctrl Mar 8, 2026
08c3164
ci: auto 1017
goingforstudying-ctrl Mar 8, 2026
a8a206c
ci: 1031
goingforstudying-ctrl Mar 8, 2026
15dd3b0
ci: auto 1032
goingforstudying-ctrl Mar 8, 2026
b04f190
ci: 1041
goingforstudying-ctrl Mar 8, 2026
4122e2e
ci: auto 1047
goingforstudying-ctrl Mar 8, 2026
3f6b666
ci: 1051
goingforstudying-ctrl Mar 8, 2026
97ad62d
ci: 1101
goingforstudying-ctrl Mar 8, 2026
3069a01
ci: auto 1102
goingforstudying-ctrl Mar 8, 2026
30cf38c
ci: auto 1117
goingforstudying-ctrl Mar 8, 2026
24d6080
ci: 1121
goingforstudying-ctrl Mar 8, 2026
9411047
ci: 1131
goingforstudying-ctrl Mar 8, 2026
44e4de3
ci: auto 1133
goingforstudying-ctrl Mar 8, 2026
ac14710
ci: 1141
goingforstudying-ctrl Mar 8, 2026
eed270b
ci: auto 1148
goingforstudying-ctrl Mar 8, 2026
6ff02c7
ci: 1151
goingforstudying-ctrl Mar 8, 2026
0a48daf
ci: 1200
goingforstudying-ctrl Mar 8, 2026
facd67f
ci: auto 1203
goingforstudying-ctrl Mar 8, 2026
5d73ee7
ci: 1211
goingforstudying-ctrl Mar 8, 2026
352abf7
ci: auto 1218
goingforstudying-ctrl Mar 8, 2026
e7b4f5c
ci: 1230
goingforstudying-ctrl Mar 8, 2026
038a01b
ci: auto 1233
goingforstudying-ctrl Mar 8, 2026
c3103fe
ci: 1241
goingforstudying-ctrl Mar 8, 2026
9621caa
ci: auto 1248
goingforstudying-ctrl Mar 8, 2026
ba4f4de
ci: auto 1303
goingforstudying-ctrl Mar 8, 2026
ceb92e2
ci: 1303
goingforstudying-ctrl Mar 8, 2026
75f35f6
ci: 1311
goingforstudying-ctrl Mar 8, 2026
2ffd449
ci: auto 1318
goingforstudying-ctrl Mar 8, 2026
bb650a5
ci: 1321
goingforstudying-ctrl Mar 8, 2026
95c3ce7
ci: 1331
goingforstudying-ctrl Mar 8, 2026
607c206
ci: auto 1333
goingforstudying-ctrl Mar 8, 2026
c86d4c5
ci: auto 1348
goingforstudying-ctrl Mar 8, 2026
f86d138
ci: auto 1403
goingforstudying-ctrl Mar 8, 2026
918ffe5
ci: 1412
goingforstudying-ctrl Mar 8, 2026
a4fd7b1
ci: auto 1419
goingforstudying-ctrl Mar 8, 2026
dc3d7de
ci: 1423
goingforstudying-ctrl Mar 8, 2026
38e7210
ci: 1424
goingforstudying-ctrl Mar 8, 2026
91879b6
ci: 1431
goingforstudying-ctrl Mar 8, 2026
ab49c18
ci: auto 1434
goingforstudying-ctrl Mar 8, 2026
5619e9c
ci: retry 1434
goingforstudying-ctrl Mar 8, 2026
eeb8a9a
ci: 1436
goingforstudying-ctrl Mar 8, 2026
544e401
ci: auto 1441
goingforstudying-ctrl Mar 8, 2026
f876cc2
ci: auto 1449
goingforstudying-ctrl Mar 8, 2026
ba66e45
ci: 1450
goingforstudying-ctrl Mar 8, 2026
1ffd300
ci: 1451
goingforstudying-ctrl Mar 8, 2026
2a1c9bd
ci: 1501
goingforstudying-ctrl Mar 8, 2026
32edfb4
ci: 1503
goingforstudying-ctrl Mar 8, 2026
2d1f0f1
ci: auto 1504
goingforstudying-ctrl Mar 8, 2026
2d97f4f
ci: 1506
goingforstudying-ctrl Mar 8, 2026
4a70487
ci: 1511
goingforstudying-ctrl Mar 8, 2026
f848fdf
ci: 1512
goingforstudying-ctrl Mar 8, 2026
7223c1c
ci: auto 1519
goingforstudying-ctrl Mar 8, 2026
efdb26a
ci: 1520
goingforstudying-ctrl Mar 8, 2026
ac4986e
ci: 1521
goingforstudying-ctrl Mar 8, 2026
7abbc37
ci: 1531
goingforstudying-ctrl Mar 8, 2026
bb08a64
ci: 1532
goingforstudying-ctrl Mar 8, 2026
d307017
ci: auto 1534
goingforstudying-ctrl Mar 8, 2026
9ac5545
ci: 1541
goingforstudying-ctrl Mar 8, 2026
6e333ed
ci: 1542
goingforstudying-ctrl Mar 8, 2026
f2c255b
ci: auto 1549
goingforstudying-ctrl Mar 8, 2026
1d7fb57
ci: 1551
goingforstudying-ctrl Mar 8, 2026
35be233
ci: 1602
goingforstudying-ctrl Mar 8, 2026
de37210
ci: 1603
goingforstudying-ctrl Mar 8, 2026
fdf590c
ci: auto 1604
goingforstudying-ctrl Mar 8, 2026
d09b8bb
ci: auto 1619
goingforstudying-ctrl Mar 8, 2026
ad33a10
ci: 1621
goingforstudying-ctrl Mar 8, 2026
acadf4c
ci: 1622
goingforstudying-ctrl Mar 8, 2026
8e64623
ci: 1631
goingforstudying-ctrl Mar 8, 2026
b81b372
ci: 1631
goingforstudying-ctrl Mar 8, 2026
b75f322
ci: auto 1634
goingforstudying-ctrl Mar 8, 2026
f07b60a
ci: 1640
goingforstudying-ctrl Mar 8, 2026
755c7cd
ci: 1641
goingforstudying-ctrl Mar 8, 2026
5e7ef55
ci: auto 1649
goingforstudying-ctrl Mar 8, 2026
cf8d3e5
ci: 1651
goingforstudying-ctrl Mar 8, 2026
ce8253d
ci: 1651
goingforstudying-ctrl Mar 8, 2026
59fb86e
ci: 1700
goingforstudying-ctrl Mar 8, 2026
893a13c
ci: 1701
goingforstudying-ctrl Mar 8, 2026
9d6cab2
ci: 1702
goingforstudying-ctrl Mar 8, 2026
d2d4e92
ci: 1703
goingforstudying-ctrl Mar 8, 2026
24e3bba
ci: auto 1705
goingforstudying-ctrl Mar 8, 2026
db7ab74
ci: 1711
goingforstudying-ctrl Mar 8, 2026
d703d96
ci: 1711
goingforstudying-ctrl Mar 8, 2026
1c64d0f
ci: auto 1720
goingforstudying-ctrl Mar 8, 2026
b12b4c9
ci: 1720
goingforstudying-ctrl Mar 8, 2026
f832e78
ci: 1721
goingforstudying-ctrl Mar 8, 2026
b7cc336
ci: 1722
goingforstudying-ctrl Mar 8, 2026
85ea9ff
ci: 1730
goingforstudying-ctrl Mar 8, 2026
87bdd48
ci: 1731
goingforstudying-ctrl Mar 8, 2026
4bbd9e5
ci: auto 1735
goingforstudying-ctrl Mar 8, 2026
4796176
ci: 1741
goingforstudying-ctrl Mar 8, 2026
e19a19b
ci: 1742
goingforstudying-ctrl Mar 8, 2026
a1b293f
ci: auto 1750
goingforstudying-ctrl Mar 8, 2026
a8d188f
ci: 1751
goingforstudying-ctrl Mar 8, 2026
c13f54d
ci: 1751
goingforstudying-ctrl Mar 8, 2026
d795bcc
ci: 1802
goingforstudying-ctrl Mar 8, 2026
6c9b905
ci: 1803
goingforstudying-ctrl Mar 8, 2026
ebc5ee3
ci: auto 1805
goingforstudying-ctrl Mar 8, 2026
c0a4d61
ci: 1811
goingforstudying-ctrl Mar 8, 2026
d915ce6
ci: 1811
goingforstudying-ctrl Mar 8, 2026
c442a61
ci: auto 1820
goingforstudying-ctrl Mar 8, 2026
8ee3053
ci: 1820
goingforstudying-ctrl Mar 8, 2026
0929214
ci: 1821
goingforstudying-ctrl Mar 8, 2026
d4e3c1f
ci: 1831
goingforstudying-ctrl Mar 8, 2026
ae4c7fe
ci: auto 1835
goingforstudying-ctrl Mar 8, 2026
926ad84
ci: auto 1850
goingforstudying-ctrl Mar 8, 2026
346b2b5
ci: auto 1905
goingforstudying-ctrl Mar 8, 2026
c66e6f1
ci: 1913
goingforstudying-ctrl Mar 8, 2026
749e019
ci: auto 1921
goingforstudying-ctrl Mar 8, 2026
13fec90
ci: 1921
goingforstudying-ctrl Mar 8, 2026
6ca0b64
ci: 1921
goingforstudying-ctrl Mar 8, 2026
9768564
ci: 1931
goingforstudying-ctrl Mar 8, 2026
337af12
ci: auto 1936
goingforstudying-ctrl Mar 8, 2026
646707e
ci: 1941
goingforstudying-ctrl Mar 8, 2026
ead2189
ci: 1950
goingforstudying-ctrl Mar 8, 2026
2fe3b8c
ci: auto 1951
goingforstudying-ctrl Mar 8, 2026
99de149
ci: 2001
goingforstudying-ctrl Mar 8, 2026
6ddf301
ci: auto 2006
goingforstudying-ctrl Mar 8, 2026
a29a6a2
ci: 2011
goingforstudying-ctrl Mar 8, 2026
41c031d
ci: 2021
goingforstudying-ctrl Mar 8, 2026
32fcfab
ci: auto 2021
goingforstudying-ctrl Mar 8, 2026
c7d7bfd
ci: 2030
goingforstudying-ctrl Mar 8, 2026
31b4ac1
ci: auto 2036
goingforstudying-ctrl Mar 8, 2026
c88d617
ci: auto 2051
goingforstudying-ctrl Mar 8, 2026
f4130e4
ci: 2102
goingforstudying-ctrl Mar 8, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/mcp/shared/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ def validate_scope(self, requested_scope: str | None) -> list[str] | None:
if requested_scope is None:
return None
requested_scopes = requested_scope.split(" ")
allowed_scopes = [] if self.scope is None else self.scope.split(" ")
# When no scope is required (None), allow all requested scopes
if self.scope is None:
return requested_scopes
allowed_scopes = self.scope.split(" ")
for scope in requested_scopes:
if scope not in allowed_scopes: # pragma: no branch
raise InvalidScopeError(f"Client was not registered with scope {scope}")
Expand Down
48 changes: 48 additions & 0 deletions test_validate_scope_fix.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
"""Test for validate_scope fix when self.scope is None"""
import pytest
from mcp.shared.auth import ClientRegistration, InvalidScopeError


def test_validate_scope_with_none_scope_allows_all():
"""When client has no scope restriction (None), all requested scopes should be allowed."""
client = ClientRegistration(
client_id="test-client",
client_secret="secret",
scope=None, # No scope restriction
redirect_uris=["http://localhost/callback"],
)

# Should not raise - all scopes allowed when no restriction
result = client.validate_scope("read write admin")
assert result == ["read", "write", "admin"]


def test_validate_scope_with_empty_requested_returns_none():
"""When requested_scope is None, return None."""
client = ClientRegistration(
client_id="test-client",
client_secret="secret",
scope="read write",
redirect_uris=["http://localhost/callback"],
)

result = client.validate_scope(None)
assert result is None


def test_validate_scope_with_restrictions_enforced():
"""When client has scope restrictions, only allowed scopes pass."""
client = ClientRegistration(
client_id="test-client",
client_secret="secret",
scope="read write",
redirect_uris=["http://localhost/callback"],
)

# Allowed scope
result = client.validate_scope("read")
assert result == ["read"]

# Disallowed scope should raise
with pytest.raises(InvalidScopeError):
client.validate_scope("admin")
Loading