FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-sdk/docs_src/deploy/tutorial004.py at main · modelcontextprotocol/python-sdk · GitHub
modelcontextprotocol
python-sdk
Repository navigation
Code
Issues
247
(247)
Pull requests
106
(106)
Actions
Projects
Security and quality
12
(12)
Insights
Expand file tree
Breadcrumbs
python-sdk
/
docs_src
/
deploy
/
tutorial004.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
23 lines (17 loc) · 699 Bytes
Breadcrumbs
python-sdk
/
docs_src
/
deploy
/
tutorial004.py
Copy path
File metadata and controls
23 lines (17 loc) · 699 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
from
mcp
.
server
.
mcpserver
import
Context
,
MCPServer
from
mcp
.
server
.
subscriptions
import
SubscriptionBus
NOTES
=
{
"todo"
:
"buy milk"
}
def
make_server
(
bus
:
SubscriptionBus
)
->
MCPServer
:
"""Every replica gets its own server object; all of them hold the same bus."""
mcp
=
MCPServer
(
"Notebook"
,
subscriptions
=
bus
)
@
mcp
.
resource
(
"note://{name}"
)
def
note
(
name
:
str
)
->
str
:
"""One note, by name."""
return
NOTES
[
name
]
@
mcp
.
tool
()
async
def
edit_note
(
name
:
str
,
text
:
str
,
ctx
:
Context
)
->
str
:
"""Replace a note's text."""
NOTES
[
name
]
=
text
await
ctx
.
notify_resource_updated
(
f"note://
{
name
}
"
)
return
"saved"
return
mcp
Back
|
FazBrowse Home
|
New Git URL