FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-sdk/docs_src/client/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
/
client
/
tutorial004.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
22 lines (15 loc) · 682 Bytes
Breadcrumbs
python-sdk
/
docs_src
/
client
/
tutorial004.py
Copy path
File metadata and controls
22 lines (15 loc) · 682 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
import
anyio
from
mcp
import
Client
from
mcp
.
types
import
TextResourceContents
async
def
main
()
->
None
:
async
with
Client
(
"http://localhost:8000/mcp"
)
as
client
:
listed
=
await
client
.
list_resources
()
print
([
resource
.
uri
for
resource
in
listed
.
resources
])
templates
=
await
client
.
list_resource_templates
()
print
([
template
.
uri_template
for
template
in
templates
.
resource_templates
])
result
=
await
client
.
read_resource
(
"catalog://genres/poetry"
)
for
contents
in
result
.
contents
:
if
isinstance
(
contents
,
TextResourceContents
):
print
(
contents
.
text
)
if
__name__
==
"__main__"
:
anyio
.
run
(
main
)
Back
|
FazBrowse Home
|
New Git URL