FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-sdk/src/mcp/shared/progress.py at main · rppth/python-sdk · GitHub
rppth
/
python-sdk
Public
forked from
modelcontextprotocol/python-sdk
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
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
/
src
/
mcp
/
shared
/
progress.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
84 lines (73 loc) · 1.86 KB
Breadcrumbs
python-sdk
/
src
/
mcp
/
shared
/
progress.py
Copy path
File metadata and controls
84 lines (73 loc) · 1.86 KB
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
from
collections
.
abc
import
Generator
from
contextlib
import
contextmanager
from
dataclasses
import
dataclass
,
field
from
typing
import
Generic
from
pydantic
import
BaseModel
from
mcp
.
shared
.
context
import
LifespanContextT
,
RequestContext
from
mcp
.
shared
.
session
import
(
BaseSession
,
ReceiveNotificationT
,
ReceiveRequestT
,
SendNotificationT
,
SendRequestT
,
SendResultT
,
)
from
mcp
.
types
import
ProgressToken
class
Progress
(
BaseModel
):
progress
:
float
total
:
float
|
None
@
dataclass
class
ProgressContext
(
Generic
[
SendRequestT
,
SendNotificationT
,
SendResultT
,
ReceiveRequestT
,
ReceiveNotificationT
,
]
):
session
:
BaseSession
[
SendRequestT
,
SendNotificationT
,
SendResultT
,
ReceiveRequestT
,
ReceiveNotificationT
,
]
progress_token
:
ProgressToken
total
:
float
|
None
current
:
float
=
field
(
default
=
0.0
,
init
=
False
)
async
def
progress
(
self
,
amount
:
float
)
->
None
:
self
.
current
+=
amount
await
self
.
session
.
send_progress_notification
(
self
.
progress_token
,
self
.
current
,
total
=
self
.
total
)
@
contextmanager
def
progress
(
ctx
:
RequestContext
[
BaseSession
[
SendRequestT
,
SendNotificationT
,
SendResultT
,
ReceiveRequestT
,
ReceiveNotificationT
,
],
LifespanContextT
,
],
total
:
float
|
None
=
None
,
)
->
Generator
[
ProgressContext
[
SendRequestT
,
SendNotificationT
,
SendResultT
,
ReceiveRequestT
,
ReceiveNotificationT
,
],
None
,
]:
if
ctx
.
meta
is
None
or
ctx
.
meta
.
progressToken
is
None
:
raise
ValueError
(
"No progress token provided"
)
progress_ctx
=
ProgressContext
(
ctx
.
session
,
ctx
.
meta
.
progressToken
,
total
)
try
:
yield
progress_ctx
finally
:
pass
Back
|
FazBrowse Home
|
New Git URL