Skip to content

Commit 9ceeac6

Browse files
authored
Merge pull request modelcontextprotocol#56 from modelcontextprotocol/davidsp/python-sdk-77
Fix docs on resource template usage
2 parents 8fe8271 + 08d35a0 commit 9ceeac6

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

docs/first-server/python.mdx

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -638,18 +638,15 @@ uvicorn.run(app, host="0.0.0.0", port=8000)
638638

639639
<Step title="Add resource templates">
640640
```python
641-
@self.list_resources()
642-
async def list_resources(self) -> ListResourcesResult:
643-
return ListResourcesResult(
644-
resources=[...],
645-
resourceTemplates=[
646-
ResourceTemplate(
647-
uriTemplate="weather://{city}/current",
648-
name="Current weather for any city",
649-
mimeType="application/json"
650-
)
651-
]
652-
)
641+
@app.list_resource_templates()
642+
async def list_resource_templates() -> list[ResourceTemplate]:
643+
return [
644+
ResourceTemplate(
645+
uriTemplate="weather://{city}/current",
646+
name="Current weather for any city",
647+
mimeType="application/json"
648+
)
649+
]
653650
```
654651
</Step>
655652
</Steps>

0 commit comments

Comments
 (0)