{"id":8885,"date":"2025-04-18T17:02:25","date_gmt":"2025-04-18T09:02:25","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/8885.html"},"modified":"2025-04-18T17:02:25","modified_gmt":"2025-04-18T09:02:25","slug":"%e3%80%90%e5%a4%a7%e6%a8%a1%e5%9e%8b%e7%b3%bb%e5%88%97%e7%af%87%e3%80%91%e5%a4%a7%e6%a8%a1%e5%9e%8b%e5%9f%ba%e5%bb%ba%e5%b7%a5%e7%a8%8b%ef%bc%9a%e5%9f%ba%e4%ba%8e-fastapi-%e8%87%aa%e5%8a%a8%e6%9e%84","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/8885.html","title":{"rendered":"\u3010\u5927\u6a21\u578b\u7cfb\u5217\u7bc7\u3011\u5927\u6a21\u578b\u57fa\u5efa\u5de5\u7a0b\uff1a\u57fa\u4e8e FastAPI \u81ea\u52a8\u6784\u5efa SSE MCP \u670d\u52a1\u5668"},"content":{"rendered":"<p><span style=\"color:#0d0016\">\u4eca\u5929\u6211\u4eec\u5c06\u4f7f\u7528FastAPI\u6765\u6784\u5efa MCP \u670d\u52a1\u5668&#xff0c;Anthropic \u63a8\u51fa\u7684\u8fd9\u4e2aMCP \u534f\u8bae&#xff0c;\u76ee\u7684\u662f\u8ba9 AI \u4ee3\u7406\u548c\u4f60\u7684\u5e94\u7528\u7a0b\u5e8f\u4e4b\u95f4\u7684\u5bf9\u8bdd\u53d8\u5f97\u66f4\u987a\u7545\u3001\u66f4\u6e05\u6670\u3002FastAPI \u57fa\u4e8e Starlette \u548c Uvicorn&#xff0c;\u91c7\u7528\u5f02\u6b65\u7f16\u7a0b\u6a21\u578b&#xff0c;\u53ef\u8f7b\u677e\u5904\u7406\u9ad8\u5e76\u53d1\u8bf7\u6c42&#xff0c;\u5c24\u5176\u9002\u5408 MCP \u573a\u666f\u4e0b\u5927\u6a21\u578b\u4e0e\u5916\u90e8\u7cfb\u7edf\u7684\u5b9e\u65f6\u4ea4\u4e92\u9700\u6c42&#xff0c;\u5176\u6027\u80fd\u63a5\u8fd1 Node.js \u548c Go&#xff0c;\u5728\u6570\u636e\u5e93\u67e5\u8be2\u3001\u6587\u4ef6\u64cd\u4f5c\u7b49 I\/O \u5bc6\u96c6\u578b\u4efb\u52a1\u4e2d\u8868\u73b0\u5353\u8d8a\u3002<\/span><\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"311\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418090224-68021520350a5.png\" width=\"738\" \/><\/p>\n<p><span style=\"color:#0d0016\">\u5f00\u59cb\u4eca\u5929\u7684\u6b63\u9898\u524d&#xff0c;\u6211\u4eec\u6765\u56de\u987e\u4e0b\u76f8\u5173\u7684\u77e5\u8bc6\u5185\u5bb9&#xff1a;<\/span><\/p>\n<p><span style=\"color:#0d0016\">\u300a\u9ad8\u6027\u80fdPython Web\u670d\u52a1\u90e8\u7f72\u67b6\u6784\u89e3\u6790\u300b\u3001\u300a\u4f7f\u7528Python\u5f00\u53d1MCP Server\u53caInspector\u5de5\u5177\u8c03\u8bd5\u300b\u3001\u300a\u6784\u5efa\u667a\u80fd\u4f53MCP\u5ba2\u6237\u7aef&#xff1a;\u5b8c\u6210\u5927\u6a21\u578b\u4e0eMCP\u670d\u52a1\u7aef\u80fd\u529b\u96c6\u6210\u4e0e\u6700\u5c0f\u95ed\u73af\u9a8c\u8bc1\u300b<\/span><\/p>\n<p><span style=\"color:#0d0016\">\u00a0<\/span><\/p>\n<h3><span style=\"color:#0d0016\">FastAPI\u57fa\u7840\u77e5\u8bc6<\/span><\/h3>\n<h4><span style=\"color:#0d0016\">\u5b89\u88c5\u4f9d\u8d56<\/span><\/h4>\n<p>pip install uvicorn, fastapi <\/p>\n<h4><span style=\"color:#0d0016\">FastAPI\u670d\u52a1\u4ee3\u7801\u793a\u4f8b\u00a0<\/span><\/h4>\n<p>from fastapi import FastAPI<\/p>\n<p>app &#061; FastAPI()<\/p>\n<p>&#064;app.get(&#034;\/&#034;)<br \/>\nasync def root():<br \/>\n    return {&#034;data&#034;: &#034;Hello MCP&#xff01;&#034;} <\/p>\n<h4><span style=\"color:#0d0016\">uvicorn\u542f\u52a8server\u00a0<\/span><\/h4>\n<p>uvicorn server:app &#8211;reload <\/p>\n<p><span style=\"color:#0d0016\">\u63a5\u4e0b\u6765&#xff0c;\u6211\u4eec\u5c06\u57fa\u4e8eFastAPI\u6765\u5f00\u53d1MCP\u670d\u52a1\u5668<\/span><\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"199\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418090224-6802152050fc0.png\" width=\"800\" \/><\/p>\n<p><span style=\"color:#0d0016\">\u00a0<\/span><\/p>\n<h3><span style=\"color:#0d0016\">FastAPI\u5f00\u53d1MCP Server<\/span><\/h3>\n<p><span style=\"color:#0d0016\">FastAPI-MCP\u00a0\u4e00\u4e2a\u96f6\u914d\u7f6e\u5de5\u5177&#xff0c;\u7528\u4e8e\u81ea\u52a8\u5c06FastAPI\u7aef\u70b9\u66b4\u9732\u4e3a\u6a21\u578b\u4e0a\u4e0b\u6587\u534f\u8bae&#xff08;MCP&#xff09;\u5de5\u5177\u3002\u5176\u7279\u70b9\u5728\u4e8e\u7b80\u6d01\u6027\u548c\u9ad8\u6548\u6027&#xff0c;\u4ee5\u4e0b\u662f\u4e00\u4e9b\u4e3b\u8981\u7279\u70b9&#xff1a;<\/span><\/p>\n<ul>\n<li><span style=\"color:#0d0016\">\u76f4\u63a5\u96c6\u6210&#xff1a;\u4e0d\u9700\u8981\u590d\u6742\u7684\u8bbe\u7f6e&#xff0c;\u76f4\u63a5\u96c6\u6210\u5230FastAPI\u5e94\u7528\u4e2d\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u81ea\u52a8\u8f6c\u6362&#xff1a;\u65e0\u9700\u624b\u52a8\u7f16\u5199\u4ee3\u7801&#xff0c;\u81ea\u52a8\u5c06FastAPI\u7aef\u70b9\u8f6c\u6362\u4e3aMCP\u5de5\u5177\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u7075\u6d3b\u6027&#xff1a;\u652f\u6301\u81ea\u5b9a\u4e49MCP\u5de5\u5177&#xff0c;\u4e0e\u81ea\u52a8\u751f\u6210\u7684\u5de5\u5177\u4e00\u540c\u4f7f\u7528\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u6027\u80fd&#xff1a;\u57fa\u4e8ePython 3.10&#043;\u548cFastAPI&#xff0c;\u4fdd\u8bc1\u4e86\u9ad8\u6027\u80fd\u7684API\u670d\u52a1\u3002<\/span><\/li>\n<li><span style=\"color:#0d0016\">\u6587\u6863\u53cb\u597d&#xff1a;\u4fdd\u6301\u4e86\u539f\u6709\u7684API\u6587\u6863&#xff0c;\u65b9\u4fbf\u5f00\u53d1\u8005\u4f7f\u7528\u548c\u7406\u89e3\u3002<\/span><\/li>\n<\/ul>\n<h4><span style=\"color:#0d0016\">\u5b89\u88c5\u4f9d\u8d56<\/span><\/h4>\n<p>pip install fastapi-mcp <\/p>\n<h4><span style=\"color:#0d0016\">MCP\u670d\u52a1\u4ee3\u7801\u793a\u4f8b<\/span><\/h4>\n<p>from fastapi import FastAPI<br \/>\nfrom fastapi_mcp import add_mcp_server<br \/>\nfrom typing import Any<br \/>\nimport httpx<\/p>\n<p># \u5e38\u91cf<br \/>\nNWS_API_BASE &#061; &#034;https:\/\/api.weather.gov&#034;<br \/>\nUSER_AGENT &#061; &#034;weather-app\/1.0&#034;<\/p>\n<p>app &#061; FastAPI()<\/p>\n<p>mcp_server &#061; add_mcp_server(<br \/>\n    app,                                    # FastAPI \u5e94\u7528<br \/>\n    mount_path&#061;&#034;\/mcp&#034;,                      # MCP \u670d\u52a1\u5668\u6302\u8f7d\u7684\u4f4d\u7f6e<br \/>\n    name&#061;&#034;Weather MCP Server&#034;,              # MCP \u670d\u52a1\u5668\u7684\u540d\u5b57<br \/>\n    describe_all_responses&#061;True,            # \u9ed8\u8ba4\u662f False\u3002\u5c31\u50cf\u6253\u5f00\u4e00\u4e2a\u767e\u5b9d\u7bb1&#xff0c;\u628a\u6240\u6709\u53ef\u80fd\u7684\u54cd\u5e94\u6a21\u5f0f\u90fd\u5305\u542b\u5728\u5de5\u5177\u63cf\u8ff0\u91cc&#xff0c;\u800c\u4e0d\u53ea\u662f\u6210\u529f\u7684\u54cd\u5e94\u3002<br \/>\n    describe_full_response_schema&#061;True      # \u9ed8\u8ba4\u662f False\u3002\u628a\u5b8c\u6574\u7684 JSON \u6a21\u5f0f\u5305\u542b\u5728\u5de5\u5177\u63cf\u8ff0\u91cc&#xff0c;\u800c\u4e0d\u53ea\u662f\u4e00\u4e2a\u5bf9\u5927\u8bed\u8a00\u6a21\u578b\u53cb\u597d\u7684\u54cd\u5e94\u793a\u4f8b\u3002<br \/>\n)<\/p>\n<p>async def make_nws_request(url: str) -&gt; dict[str, Any] | None:<br \/>\n    &#034;&#034;&#034;\u5411 NWS API \u53d1\u8d77\u8bf7\u6c42&#xff0c;\u5e76\u8fdb\u884c\u9519\u8bef\u5904\u7406\u3002&#034;&#034;&#034;<br \/>\n    headers &#061; {<br \/>\n        &#034;User-Agent&#034;: USER_AGENT,<br \/>\n        &#034;Accept&#034;: &#034;application\/geo&#043;json&#034;<br \/>\n    }<br \/>\n    async with httpx.AsyncClient() as client:<br \/>\n        try:<br \/>\n            response &#061; await client.get(url, headers&#061;headers, timeout&#061;30.0)<br \/>\n            response.raise_for_status()<br \/>\n            return response.json()<br \/>\n        except Exception:<br \/>\n            return None<\/p>\n<p>&#064;mcp_server.tool()<br \/>\nasync def get_forecast(latitude: float, longitude: float) -&gt; str:<br \/>\n    &#034;&#034;&#034;\u83b7\u53d6\u5730\u70b9\u7684\u5929\u6c14\u9884\u62a5\u3002<br \/>\n    \u53c2\u6570:<br \/>\n        latitude: \u5730\u70b9\u7684\u7eac\u5ea6<br \/>\n        longitude: \u5730\u70b9\u7684\u7ecf\u5ea6<br \/>\n    &#034;&#034;&#034;<br \/>\n    points_url &#061; f&#034;{NWS_API_BASE}\/points\/{latitude},{longitude}&#034;<br \/>\n    points_data &#061; await make_nws_request(points_url)<\/p>\n<p>    if not points_data:<br \/>\n        return &#034;Unable to fetch forecast data for this location.&#034;<\/p>\n<p>    forecast_url &#061; points_data[&#034;properties&#034;][&#034;forecast&#034;]<br \/>\n    forecast_data &#061; await make_nws_request(forecast_url)<\/p>\n<p>    if not forecast_data:<br \/>\n        return &#034;Unable to fetch detailed forecast.&#034;<\/p>\n<p>    periods &#061; forecast_data[&#034;properties&#034;][&#034;periods&#034;]<br \/>\n    forecasts &#061; []<br \/>\n    for period in periods[:5]:<br \/>\n        forecast &#061; f&#034;&#034;&#034;<br \/>\n{period[&#039;name&#039;]}:<br \/>\nTemperature: {period[&#039;temperature&#039;]}\u00b0{period[&#039;temperatureUnit&#039;]}<br \/>\nWind: {period[&#039;windSpeed&#039;]} {period[&#039;windDirection&#039;]}<br \/>\nForecast: {period[&#039;detailedForecast&#039;]}<br \/>\n&#034;&#034;&#034;<br \/>\n        forecasts.append(forecast)<br \/>\n    return &#034;\\\\n&#8212;\\\\n&#034;.join(forecasts) <\/p>\n<h4><span style=\"color:#0d0016\">\u542f\u52a8 mcp server<\/span><\/h4>\n<p>uvicorn server:app &#8211;host 0.0.0.0 &#8211;port 8001 &#8211;reload <\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"222\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418090224-68021520643f5.png\" width=\"854\" \/><\/p>\n<h4><span style=\"color:#0d0016\">\u00a0\u542f\u52a8 mcp inspector \u8c03\u8bd5<\/span><\/h4>\n<p>CLIENT_PORT&#061;8081 SERVER_PORT&#061;8082  npx -y &#064;modelcontextprotocol\/inspector <\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"298\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418090224-680215207b052.png\" width=\"625\" \/><\/p>\n<p><span style=\"color:#0d0016\">\u5f53\u96c6\u6210\u4e86 MCP \u7684 FastAPI \u5e94\u7528\u8fd0\u884c\u8d77\u6765\u540e&#xff0c;\u53ef\u4ee5\u7528\u4efb\u4f55\u652f\u6301 SSE \u7684 MCP \u5ba2\u6237\u7aef\u8fde\u63a5\u5b83\u3002\u6211\u4eec\u8fd9\u91cc\u8fd8\u662f\u4f7f\u7528 mcp inspector \u8fdb\u884c\u8c03\u8bd5&#xff0c;\u901a\u8fc7 SSE \u8fde\u63a5 Weather MCP \u670d\u52a1\u5668\u3002<\/span><\/p>\n<p>SSE\u662f\u4e00\u79cd\u5355\u5411\u901a\u4fe1\u7684\u6a21\u5f0f&#xff0c;\u6240\u4ee5\u5b83\u9700\u8981\u914d\u5408HTTP Post\u6765\u5b9e\u73b0\u5ba2\u6237\u7aef\u4e0e\u670d\u52a1\u7aef\u7684\u53cc\u5411\u901a\u4fe1\u3002\u4e25\u683c\u7684\u8bf4&#xff0c;\u8fd9\u662f\u4e00\u79cdHTTP Post&#xff08;\u5ba2\u6237\u7aef-&gt;\u670d\u52a1\u7aef&#xff09; &#043; HTTP SSE&#xff08;\u670d\u52a1\u7aef-&gt;\u5ba2\u6237\u7aef&#xff09;\u7684\u4f2a\u53cc\u5de5\u901a\u4fe1\u6a21\u5f0f&#xff0c;\u533a\u522b\u4e8eWebSocket\u53cc\u5411\u901a\u4fe1\u3002<\/p>\n<p><span style=\"color:#0d0016\">\u00a0<\/span><\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"258\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418090224-680215208996f.png\" width=\"1040\" \/><\/p>\n<p><span style=\"color:#0d0016\">\u5982\u679cMCP\u5ba2\u6237\u7aef\u4e0d\u652f\u6301SSE&#xff0c;\u53ef\u4ee5\u4f7f\u7528mcp-proxy\u8fde\u63a5MCP\u670d\u52a1\u5668\u3002\u672c\u8d28\u4e0a\u662f\u672c\u5730\u901a\u8fc7stdio\u8fde\u63a5\u5230mcp-proxy&#xff0c;\u518d\u7531mcp-proxy\u901a\u8fc7SSE\u8fde\u63a5\u5230MCP Server\u4e0a\u3002<\/span><\/p>\n<p><span style=\"color:#0d0016\">mcp-proxy \u652f\u6301\u4e24\u79cd\u6a21\u5f0f&#xff0c;stdio to SSE \u548c SSE to stdio\u3002<\/span><\/p>\n<p class=\"img-center\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"230\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418090224-68021520aa76d.png\" width=\"1734\" \/><\/p>\n<p><span style=\"color:#0d0016\">\u5b89\u88c5 mcp-proxy<\/span><\/p>\n<p>uv tool install mcp-proxy <\/p>\n<p><span style=\"color:#0d0016\">\u914d\u7f6e claude_desktop_config.json\u00a0<\/span><\/p>\n<p>{<br \/>\n  &#034;mcpServers&#034;: {<br \/>\n    &#034;weather-api-mcp-proxy&#034;: {<br \/>\n        &#034;command&#034;: &#034;mcp-proxy&#034;,<br \/>\n        &#034;args&#034;: [&#034;http:\/\/127.0.0.1:8001\/mcp&#034;]<br \/>\n    }<br \/>\n  }<br \/>\n} <\/p>\n<p><span style=\"color:#0d0016\">FastAPI-MCP\u00a0\u76ee\u524d\u8fd8\u6709\u5f88\u591a\u529f\u80fd\u4e0d\u5b8c\u5584&#xff0c;\u6211\u4eec\u5c06\u6301\u7eed\u5173\u6ce8\u8fdb\u5c55\u3002\u5728\u300a\u5927\u6a21\u578b\u57fa\u5efa\u5de5\u7a0b&#xff1a;\u57fa\u4e8e FastAPI \u81ea\u52a8\u6784\u5efa SSE MCP \u670d\u52a1\u5668 \u2014\u2014 \u8fdb\u9636\u7bc7\u300b\u4e2d\u6211\u4eec\u624b\u6413\u4e86\u4e00\u4e2a\u81ea\u52a8\u6302\u8f7d\u7684\u529f\u80fd&#xff0c;\u5e76\u57fa\u4e8e\u73b0\u6709<\/span>fastapi base_url\u00a0\u5c06\u00a0api\u00a0\u6302\u8f7d\u81f3\u00a0mcp_server\u3002<\/p>\n<\/p>\n<h3 style=\"background-color:transparent\"><span style=\"color:#0d0016\">\u5927\u6a21\u578b\u57fa\u5efa\u5de5\u7a0b\u603b\u7ed3<\/span><\/h3>\n<p><span style=\"color:#0d0016\">FastAPI \u6784\u5efa MCP \u670d\u52a1\u5668\u7684\u6838\u5fc3\u4ef7\u503c\u5728\u4e8e&#xff1a;\u901a\u8fc7\u7c7b\u578b\u5b89\u5168\u7684\u5f02\u6b65\u63a5\u53e3&#xff0c;\u5c06\u4f01\u4e1a\u73b0\u6709\u80fd\u529b\u5feb\u901f\u8f6c\u5316\u4e3a\u5927\u6a21\u578b\u53ef\u8c03\u7528\u7684\u6807\u51c6\u5316\u670d\u52a1\u3002\u8fd9\u79cd\u67b6\u6784\u65e2\u4fdd\u7559\u4e86 FastAPI \u7684\u9ad8\u6548\u5f00\u53d1\u4f53\u9a8c&#xff0c;\u53c8\u901a\u8fc7 MCP \u534f\u8bae\u5b9e\u73b0\u4e86\u4e0e\u524d\u6cbf AI \u6280\u672f\u7684\u65e0\u7f1d\u5bf9\u63a5&#xff0c;\u540c\u65f6\u7ed3\u5408 Docker \u548c Kubernetes \u5b9e\u73b0\u5f39\u6027\u4f38\u7f29\u90e8\u7f72&#xff0c;\u53ef\u4ee5\u5feb\u901f\u5e94\u5bf9\u5927\u6a21\u578b\u8c03\u7528\u91cf\u7684\u7a81\u53d1\u589e\u957f&#xff0c;\u662f\u6784\u5efa\u4e0b\u4e00\u4ee3\u667a\u80fd\u7cfb\u7edf\u7684\u7406\u60f3\u9009\u62e9\u3002<\/span><\/p>\n<p class=\"img-center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418090224-68021520d47dc.gif\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.2k\u6b21\uff0c\u70b9\u8d5e22\u6b21\uff0c\u6536\u85cf13\u6b21\u3002\ud83d\udd25FastAPI \u57fa\u4e8e Starlette \u548c Uvicorn\uff0c\u91c7\u7528\u5f02\u6b65\u7f16\u7a0b\u6a21\u578b\uff0c\u53ef\u8f7b\u677e\u5904\u7406\u9ad8\u5e76\u53d1\u8bf7\u6c42\uff0c\u5c24\u5176\u9002\u5408 MCP \u573a\u666f\u4e0b\u5927\u6a21\u578b\u4e0e\u5916\u90e8\u7cfb\u7edf\u7684\u5b9e\u65f6\u4ea4\u4e92\u9700\u6c42\uff0c\u5176\u6027\u80fd\u63a5\u8fd1 Node.js \u548c Go\uff0c\u5728\u6570\u636e\u5e93\u67e5\u8be2\u3001\u6587\u4ef6\u64cd\u4f5c\u7b49 I\/O \u5bc6\u96c6\u578b\u4efb\u52a1\u4e2d\u8868\u73b0\u5353\u8d8a\u3002\u8fd9\u79cd\u67b6\u6784\u65e2\u4fdd\u7559\u4e86 FastAPI \u7684\u9ad8\u6548\u5f00\u53d1\u4f53\u9a8c\uff0c\u53c8\u901a\u8fc7 MCP \u534f\u8bae\u5b9e\u73b0\u4e86\u4e0e\u524d\u6cbf AI \u6280\u672f\u7684\u65e0\u7f1d\u5bf9\u63a5\uff0c\u540c\u65f6\u7ed3\u5408 Docker \u548c Kubernetes \u5b9e\u73b0\u5f39\u6027\u4f38\u7f29\u90e8\u7f72\uff0c\u53ef\u4ee5\u5feb\u901f\u5e94\u5bf9\u5927\u6a21\u578b\u8c03\u7528\u91cf\u7684\u7a81\u53d1\u589e\u957f\uff0c\u662f\u6784\u5efa\u4e0b\u4e00\u4ee3\u667a\u80fd\u7cfb\u7edf\u7684\u7406\u60f3\u9009\u62e9\u3002_fastapi-mcp<\/p>\n","protected":false},"author":2,"featured_media":8878,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[74,72,233,73,232,231,234,132],"topic":[],"class_list":["post-8885","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-agent","tag-fastapi","tag-fastapi-mcp","tag-mcp","tag-mcp-inspector","tag-mcp-proxy","tag-sse","tag-132"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010\u5927\u6a21\u578b\u7cfb\u5217\u7bc7\u3011\u5927\u6a21\u578b\u57fa\u5efa\u5de5\u7a0b\uff1a\u57fa\u4e8e FastAPI \u81ea\u52a8\u6784\u5efa SSE MCP \u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/8885.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010\u5927\u6a21\u578b\u7cfb\u5217\u7bc7\u3011\u5927\u6a21\u578b\u57fa\u5efa\u5de5\u7a0b\uff1a\u57fa\u4e8e FastAPI \u81ea\u52a8\u6784\u5efa SSE MCP \u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.2k\u6b21\uff0c\u70b9\u8d5e22\u6b21\uff0c\u6536\u85cf13\u6b21\u3002\ud83d\udd25FastAPI \u57fa\u4e8e Starlette \u548c Uvicorn\uff0c\u91c7\u7528\u5f02\u6b65\u7f16\u7a0b\u6a21\u578b\uff0c\u53ef\u8f7b\u677e\u5904\u7406\u9ad8\u5e76\u53d1\u8bf7\u6c42\uff0c\u5c24\u5176\u9002\u5408 MCP \u573a\u666f\u4e0b\u5927\u6a21\u578b\u4e0e\u5916\u90e8\u7cfb\u7edf\u7684\u5b9e\u65f6\u4ea4\u4e92\u9700\u6c42\uff0c\u5176\u6027\u80fd\u63a5\u8fd1 Node.js \u548c Go\uff0c\u5728\u6570\u636e\u5e93\u67e5\u8be2\u3001\u6587\u4ef6\u64cd\u4f5c\u7b49 I\/O \u5bc6\u96c6\u578b\u4efb\u52a1\u4e2d\u8868\u73b0\u5353\u8d8a\u3002\u8fd9\u79cd\u67b6\u6784\u65e2\u4fdd\u7559\u4e86 FastAPI \u7684\u9ad8\u6548\u5f00\u53d1\u4f53\u9a8c\uff0c\u53c8\u901a\u8fc7 MCP \u534f\u8bae\u5b9e\u73b0\u4e86\u4e0e\u524d\u6cbf AI \u6280\u672f\u7684\u65e0\u7f1d\u5bf9\u63a5\uff0c\u540c\u65f6\u7ed3\u5408 Docker \u548c Kubernetes \u5b9e\u73b0\u5f39\u6027\u4f38\u7f29\u90e8\u7f72\uff0c\u53ef\u4ee5\u5feb\u901f\u5e94\u5bf9\u5927\u6a21\u578b\u8c03\u7528\u91cf\u7684\u7a81\u53d1\u589e\u957f\uff0c\u662f\u6784\u5efa\u4e0b\u4e00\u4ee3\u667a\u80fd\u7cfb\u7edf\u7684\u7406\u60f3\u9009\u62e9\u3002_fastapi-mcp\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/8885.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-18T09:02:25+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418090224-68021520350a5.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/8885.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/8885.html\",\"name\":\"\u3010\u5927\u6a21\u578b\u7cfb\u5217\u7bc7\u3011\u5927\u6a21\u578b\u57fa\u5efa\u5de5\u7a0b\uff1a\u57fa\u4e8e FastAPI \u81ea\u52a8\u6784\u5efa SSE MCP \u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-18T09:02:25+00:00\",\"dateModified\":\"2025-04-18T09:02:25+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/8885.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/8885.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/8885.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010\u5927\u6a21\u578b\u7cfb\u5217\u7bc7\u3011\u5927\u6a21\u578b\u57fa\u5efa\u5de5\u7a0b\uff1a\u57fa\u4e8e FastAPI \u81ea\u52a8\u6784\u5efa SSE MCP \u670d\u52a1\u5668\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u3010\u5927\u6a21\u578b\u7cfb\u5217\u7bc7\u3011\u5927\u6a21\u578b\u57fa\u5efa\u5de5\u7a0b\uff1a\u57fa\u4e8e FastAPI \u81ea\u52a8\u6784\u5efa SSE MCP \u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/8885.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010\u5927\u6a21\u578b\u7cfb\u5217\u7bc7\u3011\u5927\u6a21\u578b\u57fa\u5efa\u5de5\u7a0b\uff1a\u57fa\u4e8e FastAPI \u81ea\u52a8\u6784\u5efa SSE MCP \u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1.2k\u6b21\uff0c\u70b9\u8d5e22\u6b21\uff0c\u6536\u85cf13\u6b21\u3002\ud83d\udd25FastAPI \u57fa\u4e8e Starlette \u548c Uvicorn\uff0c\u91c7\u7528\u5f02\u6b65\u7f16\u7a0b\u6a21\u578b\uff0c\u53ef\u8f7b\u677e\u5904\u7406\u9ad8\u5e76\u53d1\u8bf7\u6c42\uff0c\u5c24\u5176\u9002\u5408 MCP \u573a\u666f\u4e0b\u5927\u6a21\u578b\u4e0e\u5916\u90e8\u7cfb\u7edf\u7684\u5b9e\u65f6\u4ea4\u4e92\u9700\u6c42\uff0c\u5176\u6027\u80fd\u63a5\u8fd1 Node.js \u548c Go\uff0c\u5728\u6570\u636e\u5e93\u67e5\u8be2\u3001\u6587\u4ef6\u64cd\u4f5c\u7b49 I\/O \u5bc6\u96c6\u578b\u4efb\u52a1\u4e2d\u8868\u73b0\u5353\u8d8a\u3002\u8fd9\u79cd\u67b6\u6784\u65e2\u4fdd\u7559\u4e86 FastAPI \u7684\u9ad8\u6548\u5f00\u53d1\u4f53\u9a8c\uff0c\u53c8\u901a\u8fc7 MCP \u534f\u8bae\u5b9e\u73b0\u4e86\u4e0e\u524d\u6cbf AI \u6280\u672f\u7684\u65e0\u7f1d\u5bf9\u63a5\uff0c\u540c\u65f6\u7ed3\u5408 Docker \u548c Kubernetes \u5b9e\u73b0\u5f39\u6027\u4f38\u7f29\u90e8\u7f72\uff0c\u53ef\u4ee5\u5feb\u901f\u5e94\u5bf9\u5927\u6a21\u578b\u8c03\u7528\u91cf\u7684\u7a81\u53d1\u589e\u957f\uff0c\u662f\u6784\u5efa\u4e0b\u4e00\u4ee3\u667a\u80fd\u7cfb\u7edf\u7684\u7406\u60f3\u9009\u62e9\u3002_fastapi-mcp","og_url":"https:\/\/www.wsisp.com\/helps\/8885.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-18T09:02:25+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250418090224-68021520350a5.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"2 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/8885.html","url":"https:\/\/www.wsisp.com\/helps\/8885.html","name":"\u3010\u5927\u6a21\u578b\u7cfb\u5217\u7bc7\u3011\u5927\u6a21\u578b\u57fa\u5efa\u5de5\u7a0b\uff1a\u57fa\u4e8e FastAPI \u81ea\u52a8\u6784\u5efa SSE MCP \u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-18T09:02:25+00:00","dateModified":"2025-04-18T09:02:25+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/8885.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/8885.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/8885.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010\u5927\u6a21\u578b\u7cfb\u5217\u7bc7\u3011\u5927\u6a21\u578b\u57fa\u5efa\u5de5\u7a0b\uff1a\u57fa\u4e8e FastAPI \u81ea\u52a8\u6784\u5efa SSE MCP \u670d\u52a1\u5668"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/8885","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=8885"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/8885\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/8878"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=8885"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=8885"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=8885"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=8885"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}