FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-sdk/docs_src/authorization/tutorial001.py at main · stophobia/python-sdk · GitHub
stophobia
/
python-sdk
Public
forked from
modelcontextprotocol/python-sdk
Notifications
You must be signed in to change notification settings
Fork
0
Star
1
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-sdk
/
docs_src
/
authorization
/
tutorial001.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
31 lines (23 loc) · 852 Bytes
Breadcrumbs
python-sdk
/
docs_src
/
authorization
/
tutorial001.py
Copy path
File metadata and controls
31 lines (23 loc) · 852 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from
pydantic
import
AnyHttpUrl
from
mcp
.
server
import
MCPServer
from
mcp
.
server
.
auth
.
provider
import
AccessToken
,
TokenVerifier
from
mcp
.
server
.
auth
.
settings
import
AuthSettings
KNOWN_TOKENS
=
{
"alice-token"
:
AccessToken
(
token
=
"alice-token"
,
client_id
=
"alice"
,
scopes
=
[
"notes:read"
]),
}
class
StaticTokenVerifier
(
TokenVerifier
):
async
def
verify_token
(
self
,
token
:
str
)
->
AccessToken
|
None
:
return
KNOWN_TOKENS
.
get
(
token
)
mcp
=
MCPServer
(
"Notes"
,
token_verifier
=
StaticTokenVerifier
(),
auth
=
AuthSettings
(
issuer_url
=
AnyHttpUrl
(
"https://auth.example.com"
),
resource_server_url
=
AnyHttpUrl
(
"http://127.0.0.1:8000/mcp"
),
required_scopes
=
[
"notes:read"
],
),
)
@
mcp
.
tool
()
def
list_notes
()
->
list
[
str
]:
"""List every note in the notebook."""
return
[
"Buy milk"
,
"Ship the release"
]
Back
|
FazBrowse Home
|
New Git URL