Merge pull request #23 from modelcontextprotocol/zack-lee/updates
Updated Python guide
This commit is contained in:
commit
2cfd5fdb92
1 changed files with 8 additions and 8 deletions
|
|
@ -67,6 +67,7 @@ Let's build your first MCP server in Python! We'll create a weather server that
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
from collections.abc import Sequence
|
from collections.abc import Sequence
|
||||||
from functools import lru_cache
|
from functools import lru_cache
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
@ -78,7 +79,7 @@ Let's build your first MCP server in Python! We'll create a weather server that
|
||||||
TextContent,
|
TextContent,
|
||||||
ImageContent,
|
ImageContent,
|
||||||
EmbeddedResource,
|
EmbeddedResource,
|
||||||
LoggingLevel,
|
LoggingLevel
|
||||||
)
|
)
|
||||||
from pydantic import AnyUrl
|
from pydantic import AnyUrl
|
||||||
|
|
||||||
|
|
@ -94,13 +95,12 @@ Let's build your first MCP server in Python! We'll create a weather server that
|
||||||
if not API_KEY:
|
if not API_KEY:
|
||||||
raise ValueError("OPENWEATHER_API_KEY environment variable required")
|
raise ValueError("OPENWEATHER_API_KEY environment variable required")
|
||||||
|
|
||||||
API_BASE_URL = "http://api.openweathermap.org/data/2.5"
|
API_BASE_URL = "http://api.openweathermap.org/data/2.5"
|
||||||
DEFAULT_CITY = "London"
|
DEFAULT_CITY = "London"
|
||||||
CURRENT_WEATHER_ENDPOINT = "weather"
|
CURRENT_WEATHER_ENDPOINT = "weather"
|
||||||
FORECAST_ENDPOINT = "forecast"
|
FORECAST_ENDPOINT = "forecast"
|
||||||
|
|
||||||
async def mcp_server():
|
# The rest of our server implementation will go here
|
||||||
# our server implementation will go here
|
|
||||||
```
|
```
|
||||||
</Step>
|
</Step>
|
||||||
|
|
||||||
|
|
@ -803,4 +803,4 @@ uv run pyright src
|
||||||
<Card title="Python SDK" icon="python" href="/api-reference/python/class-reference">
|
<Card title="Python SDK" icon="python" href="/api-reference/python/class-reference">
|
||||||
Read more about the Python SDK
|
Read more about the Python SDK
|
||||||
</Card>
|
</Card>
|
||||||
</CardGroup>
|
</CardGroup>
|
||||||
Loading…
Reference in a new issue