python+fastmcp搭建支持stdio本地的mcp服务代码

代码语言:python

所属分类:其他

代码描述:python+fastmcp搭建支持stdio本地的mcp服务代码

代码标签: python fastmcp 搭建 支持 stdio 本地 mcp 服务 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

#!/usr/local/python3/bin/python3
# -*- coding: utf-8 -*
from typing import Any
import httpx
from mcp.server.fastmcp import FastMCP

# Initialize FastMCP server
mcp = FastMCP("weather")

# Constants
NWS_API_BASE = "https://api.weather.gov"
USER_AGENT = "weather-app/1.0"


async def make_nws_request(url: str) -> dict[str, Any] | None:
    """Make a request to the NWS API with proper error handling."""
    headers = {
        "User-Agent": USER_AGENT,
        "Accept": "application/geo+json"
    }
    async with http.........完整代码请登录后点击上方下载按钮下载查看

网友评论0