FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-sdk/docs_src/handling_errors/tutorial003.py at main · uuzzrm/python-sdk · GitHub
uuzzrm
python-sdk
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-sdk
/
docs_src
/
handling_errors
/
tutorial003.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
14 lines (10 loc) · 456 Bytes
Breadcrumbs
python-sdk
/
docs_src
/
handling_errors
/
tutorial003.py
Copy path
File metadata and controls
14 lines (10 loc) · 456 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
from
mcp
.
server
import
MCPServer
from
mcp
.
server
.
mcpserver
.
exceptions
import
ResourceNotFoundError
mcp
=
MCPServer
(
"Bookshop"
)
CATALOG
=
{
"Dune"
:
"Frank Herbert"
,
"Neuromancer"
:
"William Gibson"
}
@
mcp
.
resource
(
"books://{title}"
)
def
book
(
title
:
str
)
->
str
:
"""The catalog entry for one book."""
if
title
not
in
CATALOG
:
raise
ResourceNotFoundError
(
f"No book titled
{
title
!r
}
in the catalog."
)
return
f"
{
title
}
by
{
CATALOG
[
title
]
}
"
Back
|
FazBrowse Home
|
New Git URL