FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-sdk/docs_src/progress/tutorial002.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
/
progress
/
tutorial002.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
21 lines (15 loc) · 631 Bytes
Breadcrumbs
python-sdk
/
docs_src
/
progress
/
tutorial002.py
Copy path
File metadata and controls
21 lines (15 loc) · 631 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
from
collections
.
abc
import
AsyncIterator
from
mcp
.
server
import
MCPServer
from
mcp
.
server
.
mcpserver
import
Context
mcp
=
MCPServer
(
"Bookshop"
)
async
def
fetch_records
(
feed_url
:
str
)
->
AsyncIterator
[
str
]:
for
title
in
(
"Dune"
,
"Neuromancer"
,
"Hyperion"
):
yield
f"
{
feed_url
}
#
{
title
}
"
@
mcp
.
tool
()
async
def
import_feed
(
feed_url
:
str
,
ctx
:
Context
)
->
str
:
"""Import every record a catalog feed yields."""
imported
=
0
async
for
record
in
fetch_records
(
feed_url
):
imported
+=
1
await
ctx
.
report_progress
(
imported
,
message
=
f"Imported
{
record
}
"
)
return
f"Imported
{
imported
}
records."
Back
|
FazBrowse Home
|
New Git URL