{"id":46162,"date":"2025-07-30T02:33:14","date_gmt":"2025-07-29T18:33:14","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/46162.html"},"modified":"2025-07-30T02:33:14","modified_gmt":"2025-07-29T18:33:14","slug":"%e5%9f%ba%e4%ba%8esse%e4%bc%a0%e8%be%93%e7%9a%84mcp%e6%9c%8d%e5%8a%a1%e5%99%a8%e5%ae%9e%e7%8e%b0","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/46162.html","title":{"rendered":"\u57fa\u4e8eSSE\u4f20\u8f93\u7684MCP\u670d\u52a1\u5668\u5b9e\u73b0"},"content":{"rendered":"<h3>\u57fa\u4e8eSSE\u4f20\u8f93\u7684MCP\u670d\u52a1\u5668\u5b9e\u73b0<\/h3>\n<p>MCP\u534f\u8bae\u652f\u6301\u591a\u79cd\u4f20\u8f93\u673a\u5236&#xff0c;\u5176\u4e2d\u5305\u62ecstdio\u3001Server-Sent Events&#xff08;SSE&#xff09; \u548cStreamable HTTP\u3002<\/p>\n<p>\u4f46\u76ee\u524dMCP SDK\u53ea\u63d0\u4f9b\u4e86stdio\u548cSSE\u4e24\u79cd\u4f20\u8f93\u65b9\u5f0f\u7684\u5f00\u53d1\u5e93&#xff0c;\u800c\u6682\u65f6\u8fd8\u6ca1\u6709\u63d0\u4f9b\u57fa\u4e8e\u6d41\u5f0fHTTP\u4f20\u8f93\u7684\u5f00\u53d1\u5de5\u5177\u3002\u56e0\u6b64\u5728\u8fdb\u884cMCP\u5f00\u53d1\u8fc7\u7a0b\u4e2d&#xff0c;\u76ee\u524d\u53ea\u8003\u8651\u5b9e\u73b0stdio\u548cSSE\u4f20\u8f93\u65b9\u5f0f\u3002<\/p>\n<p>\u5728\u4f7f\u7528MCP Python SDK\u5f00\u53d1MCP\u670d\u52a1\u5668\u65f6&#xff0c;\u53ea\u9700\u8981\u5728\u6b64\u5904\u8fdb\u884c\u8bbe\u7f6e&#xff0c;\u5373\u53ef\u8ba9MCP\u670d\u52a1\u5668\u5f00\u542fSSE\u6a21\u5f0f\u3002<\/p>\n<p>mcp<span class=\"token punctuation\">.<\/span>run<span class=\"token punctuation\">(<\/span>transport<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#039;sse&#039;<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>\u672c\u6587\u4ee5\u521b\u5efa\u4e00\u4e2a\u67e5\u8be2\u5929\u6c14\u7684MCP\u670d\u52a1\u5668\u4e3a\u4f8b\u8fdb\u884c\u5f00\u53d1\u3002<\/p>\n<h2>1. \u73af\u5883\u51c6\u5907<\/h2>\n<p>\u672c\u6587\u4f7f\u7528Ubuntu22.04\u4f5c\u4e3a\u5f00\u53d1\u73af\u5883\u3002<\/p>\n<h3>1.1 nodejs\u5b89\u88c5<\/h3>\n<p>\u5728Ubuntu\u4e0a\u5b89\u88c5Node.js\u53ef\u4ee5\u901a\u8fc7\u591a\u79cd\u65b9\u6cd5\u6765\u5b9e\u73b0&#xff0c;\u4ee5\u4e0b\u662f\u4e09\u79cd\u5e38\u7528\u7684\u65b9\u6cd5&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u4f7f\u7528Ubuntu\u5b58\u50a8\u5e93<\/p>\n<\/li>\n<li>\n<p>\u901a\u8fc7NodeSource PPA<\/p>\n<\/li>\n<li>\n<p>\u4f7f\u7528nvm (Node Version Manager)<\/p>\n<\/li>\n<\/ul>\n<p>\u5728Ubuntu 22.04&#xff0c;apt \u9ed8\u8ba4\u7684nodejs \u7248\u672c\u662f v12&#xff0c;\u800c\u6700\u65b0\u7684 nodejs\u90fd\u5df2\u7ecf v20&#043;\u4e86&#xff0c;&#xff0c;\u56e0\u6b64\u4f7f\u7528\u7b2c\u4e00\u79cd\u65b9\u5f0f\u5b89\u88c5\u7684nodejs\u7248\u672c\u8f83\u8001&#xff0c;\u540e\u7eed\u6267\u884cnpm\u547d\u4ee4\u6267\u884c\u4f1a\u62a5\u9519&#xff08;\u5df2\u6d4b\u8bd5&#xff09;\u3002<\/p>\n<p>\u4f7f\u7528\u7b2c\u4e8c\u79cd\u65b9\u5f0f\u8fdb\u884cnodejs\u7684\u5b89\u88c5\u3002<\/p>\n<p><span class=\"token comment\"># \u5b89\u88c5Node.js 20.x\u7248\u672c<\/span><br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">apt<\/span> update<br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">apt<\/span> <span class=\"token function\">install<\/span> <span class=\"token function\">curl<\/span><br \/>\n<span class=\"token function\">curl<\/span> -fsSL https:\/\/deb.nodesource.com\/setup_20.x <span class=\"token operator\">|<\/span> <span class=\"token function\">sudo<\/span> <span class=\"token function\">bash<\/span> &#8211;<br \/>\n<span class=\"token function\">sudo<\/span> <span class=\"token function\">apt<\/span> <span class=\"token function\">install<\/span> -y nodejs<br \/>\nnode -v<br \/>\n<span class=\"token function\">npm<\/span> -v<\/p>\n<h3>1.2 uv\u5b89\u88c5<\/h3>\n<p>MCP\u5f00\u53d1\u8981\u501f\u52a9uv\u8fdb\u884c\u865a\u62df\u73af\u5883\u521b\u5efa\u548c\u4f9d\u8d56\u7ba1\u7406\u3002uv \u662f\u4e00\u4e2aPython\u4f9d\u8d56\u7ba1\u7406\u5de5\u5177&#xff0c;\u7c7b\u4f3c\u4e8e pip \u548c conda&#xff0c;\u4f46\u5b83\u66f4\u5feb\u3001\u66f4\u9ad8\u6548&#xff0c;\u5e76\u4e14\u53ef\u4ee5\u66f4\u597d\u5730\u7ba1\u7406Python\u865a\u62df\u73af\u5883\u548c\u4f9d\u8d56\u9879\u3002\u5b83\u7684\u6838\u5fc3\u76ee\u6807\u662f\u66ff\u4ee3pip\u3001venv \u548cpip-tools&#xff0c;\u63d0\u4f9b\u66f4\u597d\u7684\u6027\u80fd\u548c\u66f4\u4f4e\u7684\u7ba1\u7406\u5f00\u9500\u3002<\/p>\n<p>uv \u7684\u7279\u70b9&#xff1a;<\/p>\n<ul>\n<li>\u901f\u5ea6\u66f4\u5feb&#xff1a;\u76f8\u6bd4 pip&#xff0c;uv \u91c7\u7528Rust \u7f16\u5199&#xff0c;\u6027\u80fd\u66f4\u4f18\u3002<\/li>\n<li>\u652f\u6301PEP 582&#xff1a;\u65e0\u9700 virtualenv&#xff0c;\u53ef\u4ee5\u76f4\u63a5\u4f7f\u7528 __pypackages__ \u8fdb\u884c\u7ba1\u7406\u3002<\/li>\n<li>\u517c\u5bb9pip&#xff1a;\u652f\u6301 requirements.txt \u548c pyproject.toml \u4f9d\u8d56\u7ba1\u7406\u3002<\/li>\n<li>\u66ff\u4ee3 venv&#xff1a;\u63d0\u4f9b uv venv \u8fdb\u884c\u865a\u62df\u73af\u5883\u7ba1\u7406&#xff0c;\u6bd4 venv \u66f4\u8f7b\u91cf\u3002<\/li>\n<li>\u8de8\u5e73\u53f0&#xff1a;\u652f\u6301 Windows\u3001macOS \u548c Linux\u3002<\/li>\n<\/ul>\n<p>\u4f7f\u7528pip\u5b89\u88c5uv&#xff1a;<\/p>\n<p>pip install uv<\/p>\n<h3>1.3 OpenWeather\u79d8\u94a5\u83b7\u53d6<\/h3>\n<p>\u83b7\u53d6\u5929\u6c14\u7684\u63a5\u53e3&#xff0c;\u4f7f\u7528OpenWeather\u63d0\u4f9b\u7684\u63a5\u53e3&#xff0c;\u5b98\u65b9\u5730\u5740&#xff1a;http:\/\/openweathermap.org\/<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729183254-688913d6b8d8a.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h3>1.4 pypi \u79d8\u94a5\u83b7\u53d6<\/h3>\n<p>\u5c06\u5f00\u53d1\u6d4b\u8bd5\u5b8c\u7684\u4f9d\u8d56\u5e93&#xff0c;\u9700\u8981pypi\u7684\u79d8\u94a5&#xff0c;\u5b98\u65b9\u5730\u5740&#xff1a;https:\/\/pypi.org\/<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729183255-688913d73acf1.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u8be5\u8fc7\u7a0b\u9700\u8981VPN&#xff0c;\u5177\u4f53\u6b65\u9aa4\u53ef\u53c2\u8003&#xff1a;https:\/\/blog.csdn.net\/qq_53545309\/article\/details\/140788076<\/p>\n<h2>2. \u4ee3\u7801\u7f16\u5199<\/h2>\n<h3>2.1 \u521d\u59cb\u5316\u73af\u5883<\/h3>\n<ul>\n<li>\n<p>\u521b\u5efa\u9879\u76ee\u4e3b\u76ee\u5f55<\/p>\n<p><span class=\"token builtin class-name\">cd<\/span> \/root\/autodl-tmp\/mcp<br \/>\n<span class=\"token function\">mkdir<\/span> mcp-sse-test<br \/>\n<span class=\"token builtin class-name\">cd<\/span> mcp-sse-test<\/p>\n<\/li>\n<li>\n<p>\u521b\u5efa\u57fa\u7840\u9879\u76ee\u7ed3\u6784<\/p>\n<p>uv init mcp-get-weather-scorpios<br \/>\n<span class=\"token builtin class-name\">cd<\/span> mcp-get-weather-scorpios<\/p>\n<p><span class=\"token comment\"># \u521b\u5efa\u865a\u62df\u73af\u5883<\/span><br \/>\nuv venv<\/p>\n<p><span class=\"token comment\"># \u6fc0\u6d3b\u865a\u62df\u73af\u5883<\/span><br \/>\n<span class=\"token builtin class-name\">source<\/span> .venv\/bin\/activate<\/p>\n<p>uv <span class=\"token function\">add<\/span> mcp httpx<\/p>\n<\/li>\n<\/ul>\n<p>\u521b\u5efa\u5b8c\u7684\u76ee\u5f55\u7ed3\u6784\u5982\u4e0b&#xff1a;<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729183256-688913d84d2fe.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n\u5404\u6587\u4ef6\u89e3\u91ca\u5982\u4e0b&#xff1a;<\/p>\n<table>\n<tr>\u6587\u4ef6\/\u6587\u4ef6\u5939\u4f5c\u7528<\/tr>\n<tbody>\n<tr>\n<td>.git\/<\/td>\n<td>Git \u7248\u672c\u63a7\u5236\u76ee\u5f55<\/td>\n<\/tr>\n<tr>\n<td>.venv\/<\/td>\n<td>\u865a\u62df\u73af\u5883<\/td>\n<\/tr>\n<tr>\n<td>.gitignore<\/td>\n<td>Git \u5ffd\u7565\u89c4\u5219<\/td>\n<\/tr>\n<tr>\n<td>.python-version<\/td>\n<td>Python\u7248\u672c\u58f0\u660e<\/td>\n<\/tr>\n<tr>\n<td>main.py<\/td>\n<td>\u4e3b\u7a0b\u5e8f\u5165\u53e3<\/td>\n<\/tr>\n<tr>\n<td>pyproject.toml<\/td>\n<td>\u9879\u76ee\u914d\u7f6e\u6587\u4ef6<\/td>\n<\/tr>\n<tr>\n<td>README.md<\/td>\n<td>\u9879\u76ee\u8bf4\u660e\u6587\u6863<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>2.2 \u4ee3\u7801\u7f16\u5199<\/h3>\n<p>\u5220\u9664\u4e3b\u76ee\u5f55\u4e0b\u7684main.py\u6587\u4ef6&#xff0c;\u5e76\u521b\u5efa\u4ee3\u7801\u6587\u4ef6\u5939&#xff1a;<\/p>\n<p><span class=\"token function\">mkdir<\/span> -p .\/src\/mcp_get_weather<br \/>\n<span class=\"token builtin class-name\">cd<\/span> .\/src\/mcp_get_weather<\/p>\n<p>\u4e0b\u9762\u521b\u5efa\u670d\u52a1\u5668\u6838\u5fc3\u4ee3\u7801&#xff0c; \u5728src\/mcp_get_weather\u4e2d\u521b\u5efa\u4e09\u4e2a\u4ee3\u7801\u6587\u4ef6&#xff1a;<br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729183256-688913d89668f.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/>\u5176\u4e2dserver.py\u4e3b\u8981\u8d1f\u8d23\u8fdb\u884c\u5929\u6c14\u67e5\u8be2&#xff0c;\u4ee3\u7801\u5982\u4e0b&#xff1a;<\/p>\n<p><span class=\"token keyword\">import<\/span> json<br \/>\n<span class=\"token keyword\">import<\/span> httpx<br \/>\n<span class=\"token keyword\">import<\/span> argparse<br \/>\n<span class=\"token keyword\">from<\/span> typing <span class=\"token keyword\">import<\/span> Any<br \/>\n<span class=\"token keyword\">from<\/span> mcp<span class=\"token punctuation\">.<\/span>server<span class=\"token punctuation\">.<\/span>fastmcp <span class=\"token keyword\">import<\/span> FastMCP<\/p>\n<p><span class=\"token comment\"># \u521d\u59cb\u5316 MCP \u670d\u52a1\u5668<\/span><br \/>\nmcp <span class=\"token operator\">&#061;<\/span> FastMCP<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;WeatherServer&#034;<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token comment\"># OpenWeather API \u914d\u7f6e<\/span><br \/>\nOPENWEATHER_API_BASE <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;https:\/\/api.openweathermap.org\/data\/2.5\/weather&#034;<\/span><br \/>\nAPI_KEY <span class=\"token operator\">&#061;<\/span> <span class=\"token boolean\">None<\/span><br \/>\nUSER_AGENT <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;weather-app\/1.0&#034;<\/span><\/p>\n<p><span class=\"token keyword\">async<\/span> <span class=\"token keyword\">def<\/span> <span class=\"token function\">fetch_weather<\/span><span class=\"token punctuation\">(<\/span>city<span class=\"token punctuation\">:<\/span> <span class=\"token builtin\">str<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token operator\">&gt;<\/span> <span class=\"token builtin\">dict<\/span><span class=\"token punctuation\">[<\/span><span class=\"token builtin\">str<\/span><span class=\"token punctuation\">,<\/span> Any<span class=\"token punctuation\">]<\/span> <span class=\"token operator\">|<\/span> <span class=\"token boolean\">None<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token triple-quoted-string string\">&#034;&#034;&#034;<br \/>\n    \u4ece OpenWeather API \u83b7\u53d6\u5929\u6c14\u4fe1\u606f\u3002<br \/>\n    &#034;&#034;&#034;<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> API_KEY <span class=\"token keyword\">is<\/span> <span class=\"token boolean\">None<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token string\">&#034;error&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string\">&#034;API_KEY \u672a\u8bbe\u7f6e&#xff0c;\u8bf7\u63d0\u4f9b\u6709\u6548\u7684 OpenWeather API Key\u3002&#034;<\/span><span class=\"token punctuation\">}<\/span><\/p>\n<p>    params <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n        <span class=\"token string\">&#034;q&#034;<\/span><span class=\"token punctuation\">:<\/span> city<span class=\"token punctuation\">,<\/span><br \/>\n        <span class=\"token string\">&#034;appid&#034;<\/span><span class=\"token punctuation\">:<\/span> API_KEY<span class=\"token punctuation\">,<\/span><br \/>\n        <span class=\"token string\">&#034;units&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string\">&#034;metric&#034;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n        <span class=\"token string\">&#034;lang&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string\">&#034;zh_cn&#034;<\/span><br \/>\n    <span class=\"token punctuation\">}<\/span><br \/>\n    headers <span class=\"token operator\">&#061;<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token string\">&#034;User-Agent&#034;<\/span><span class=\"token punctuation\">:<\/span> USER_AGENT<span class=\"token punctuation\">}<\/span><\/p>\n<p>    <span class=\"token keyword\">async<\/span> <span class=\"token keyword\">with<\/span> httpx<span class=\"token punctuation\">.<\/span>AsyncClient<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">as<\/span> client<span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">try<\/span><span class=\"token punctuation\">:<\/span><br \/>\n            response <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">await<\/span> client<span class=\"token punctuation\">.<\/span>get<span class=\"token punctuation\">(<\/span>OPENWEATHER_API_BASE<span class=\"token punctuation\">,<\/span> params<span class=\"token operator\">&#061;<\/span>params<span class=\"token punctuation\">,<\/span> headers<span class=\"token operator\">&#061;<\/span>headers<span class=\"token punctuation\">,<\/span> timeout<span class=\"token operator\">&#061;<\/span><span class=\"token number\">30.0<\/span><span class=\"token punctuation\">)<\/span><br \/>\n            response<span class=\"token punctuation\">.<\/span>raise_for_status<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n            <span class=\"token keyword\">return<\/span> response<span class=\"token punctuation\">.<\/span>json<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token keyword\">except<\/span> httpx<span class=\"token punctuation\">.<\/span>HTTPStatusError <span class=\"token keyword\">as<\/span> e<span class=\"token punctuation\">:<\/span><br \/>\n            <span class=\"token keyword\">return<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token string\">&#034;error&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string-interpolation\"><span class=\"token string\">f&#034;HTTP \u9519\u8bef: <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>e<span class=\"token punctuation\">.<\/span>response<span class=\"token punctuation\">.<\/span>status_code<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">&#034;<\/span><\/span><span class=\"token punctuation\">}<\/span><br \/>\n        <span class=\"token keyword\">except<\/span> Exception <span class=\"token keyword\">as<\/span> e<span class=\"token punctuation\">:<\/span><br \/>\n            <span class=\"token keyword\">return<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token string\">&#034;error&#034;<\/span><span class=\"token punctuation\">:<\/span> <span class=\"token string-interpolation\"><span class=\"token string\">f&#034;\u8bf7\u6c42\u5931\u8d25: <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span><span class=\"token builtin\">str<\/span><span class=\"token punctuation\">(<\/span>e<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">&#034;<\/span><\/span><span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token keyword\">def<\/span> <span class=\"token function\">format_weather<\/span><span class=\"token punctuation\">(<\/span>data<span class=\"token punctuation\">:<\/span> <span class=\"token builtin\">dict<\/span><span class=\"token punctuation\">[<\/span><span class=\"token builtin\">str<\/span><span class=\"token punctuation\">,<\/span> Any<span class=\"token punctuation\">]<\/span> <span class=\"token operator\">|<\/span> <span class=\"token builtin\">str<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token operator\">&gt;<\/span> <span class=\"token builtin\">str<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token triple-quoted-string string\">&#034;&#034;&#034;<br \/>\n    \u5c06\u5929\u6c14\u6570\u636e\u683c\u5f0f\u5316\u4e3a\u6613\u8bfb\u6587\u672c\u3002<br \/>\n    &#034;&#034;&#034;<\/span><br \/>\n    <span class=\"token keyword\">if<\/span> <span class=\"token builtin\">isinstance<\/span><span class=\"token punctuation\">(<\/span>data<span class=\"token punctuation\">,<\/span> <span class=\"token builtin\">str<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">try<\/span><span class=\"token punctuation\">:<\/span><br \/>\n            data <span class=\"token operator\">&#061;<\/span> json<span class=\"token punctuation\">.<\/span>loads<span class=\"token punctuation\">(<\/span>data<span class=\"token punctuation\">)<\/span><br \/>\n        <span class=\"token keyword\">except<\/span> Exception <span class=\"token keyword\">as<\/span> e<span class=\"token punctuation\">:<\/span><br \/>\n            <span class=\"token keyword\">return<\/span> <span class=\"token string-interpolation\"><span class=\"token string\">f&#034;\u65e0\u6cd5\u89e3\u6790\u5929\u6c14\u6570\u636e: <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>e<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">&#034;<\/span><\/span><\/p>\n<p>    <span class=\"token keyword\">if<\/span> <span class=\"token string\">&#034;error&#034;<\/span> <span class=\"token keyword\">in<\/span> data<span class=\"token punctuation\">:<\/span><br \/>\n        <span class=\"token keyword\">return<\/span> <span class=\"token string-interpolation\"><span class=\"token string\">f&#034;\u26a0\ufe0f <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>data<span class=\"token punctuation\">[<\/span><span class=\"token string\">&#039;error&#039;<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">&#034;<\/span><\/span><\/p>\n<p>    city <span class=\"token operator\">&#061;<\/span> data<span class=\"token punctuation\">.<\/span>get<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;name&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;\u672a\u77e5&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    country <span class=\"token operator\">&#061;<\/span> data<span class=\"token punctuation\">.<\/span>get<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;sys&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>get<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;country&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;\u672a\u77e5&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    temp <span class=\"token operator\">&#061;<\/span> data<span class=\"token punctuation\">.<\/span>get<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;main&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>get<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;temp&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;N\/A&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    humidity <span class=\"token operator\">&#061;<\/span> data<span class=\"token punctuation\">.<\/span>get<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;main&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>get<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;humidity&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;N\/A&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    wind_speed <span class=\"token operator\">&#061;<\/span> data<span class=\"token punctuation\">.<\/span>get<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;wind&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">{<\/span><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>get<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;speed&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;N\/A&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    weather_list <span class=\"token operator\">&#061;<\/span> data<span class=\"token punctuation\">.<\/span>get<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;weather&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token punctuation\">[<\/span><span class=\"token punctuation\">{<\/span><span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    description <span class=\"token operator\">&#061;<\/span> weather_list<span class=\"token punctuation\">[<\/span><span class=\"token number\">0<\/span><span class=\"token punctuation\">]<\/span><span class=\"token punctuation\">.<\/span>get<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;description&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;\u672a\u77e5&#034;<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>    <span class=\"token keyword\">return<\/span> <span class=\"token punctuation\">(<\/span><br \/>\n        <span class=\"token string-interpolation\"><span class=\"token string\">f&#034;&#x1f30d; <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>city<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">, <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>country<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">\\\\n&#034;<\/span><\/span><br \/>\n        <span class=\"token string-interpolation\"><span class=\"token string\">f&#034;&#x1f321; \u6e29\u5ea6: <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>temp<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">\u00b0C\\\\n&#034;<\/span><\/span><br \/>\n        <span class=\"token string-interpolation\"><span class=\"token string\">f&#034;&#x1f4a7; \u6e7f\u5ea6: <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>humidity<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">%\\\\n&#034;<\/span><\/span><br \/>\n        <span class=\"token string-interpolation\"><span class=\"token string\">f&#034;&#x1f32c; \u98ce\u901f: <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>wind_speed<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\"> m\/s\\\\n&#034;<\/span><\/span><br \/>\n        <span class=\"token string-interpolation\"><span class=\"token string\">f&#034;&#x1f324; \u5929\u6c14: <\/span><span class=\"token interpolation\"><span class=\"token punctuation\">{<\/span>description<span class=\"token punctuation\">}<\/span><\/span><span class=\"token string\">\\\\n&#034;<\/span><\/span><br \/>\n    <span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token decorator annotation punctuation\">&#064;mcp<span class=\"token punctuation\">.<\/span>tool<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n<span class=\"token keyword\">async<\/span> <span class=\"token keyword\">def<\/span> <span class=\"token function\">query_weather<\/span><span class=\"token punctuation\">(<\/span>city<span class=\"token punctuation\">:<\/span> <span class=\"token builtin\">str<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token operator\">&#8211;<\/span><span class=\"token operator\">&gt;<\/span> <span class=\"token builtin\">str<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    <span class=\"token triple-quoted-string string\">&#034;&#034;&#034;<br \/>\n    \u8f93\u5165\u6307\u5b9a\u57ce\u5e02\u7684\u82f1\u6587\u540d\u79f0&#xff0c;\u8fd4\u56de\u4eca\u65e5\u5929\u6c14\u67e5\u8be2\u7ed3\u679c\u3002<br \/>\n    &#034;&#034;&#034;<\/span><br \/>\n    data <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">await<\/span> fetch_weather<span class=\"token punctuation\">(<\/span>city<span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">return<\/span> format_weather<span class=\"token punctuation\">(<\/span>data<span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token keyword\">def<\/span> <span class=\"token function\">main<\/span><span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    parser <span class=\"token operator\">&#061;<\/span> argparse<span class=\"token punctuation\">.<\/span>ArgumentParser<span class=\"token punctuation\">(<\/span>description<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;Weather Server&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    parser<span class=\"token punctuation\">.<\/span>add_argument<span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;&#8211;api_key&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token builtin\">type<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token builtin\">str<\/span><span class=\"token punctuation\">,<\/span> required<span class=\"token operator\">&#061;<\/span><span class=\"token boolean\">True<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token builtin\">help<\/span><span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#034;\u4f60\u7684 OpenWeather API Key&#034;<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    args <span class=\"token operator\">&#061;<\/span> parser<span class=\"token punctuation\">.<\/span>parse_args<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><br \/>\n    <span class=\"token keyword\">global<\/span> API_KEY<br \/>\n    API_KEY <span class=\"token operator\">&#061;<\/span> args<span class=\"token punctuation\">.<\/span>api_key<br \/>\n    mcp<span class=\"token punctuation\">.<\/span>run<span class=\"token punctuation\">(<\/span>transport<span class=\"token operator\">&#061;<\/span><span class=\"token string\">&#039;sse&#039;<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p><span class=\"token keyword\">if<\/span> __name__ <span class=\"token operator\">&#061;&#061;<\/span> <span class=\"token string\">&#034;__main__&#034;<\/span><span class=\"token punctuation\">:<\/span><br \/>\n    main<span class=\"token punctuation\">(<\/span><span class=\"token punctuation\">)<\/span><\/p>\n<p>\u91c7\u7528\u4e86fastmcp\u8fdb\u884c\u521b\u5efa&#xff0c;\u800c\u5728mcp.run\u4e2d\u8bbe\u7f6e\u4e86\u4f7f\u7528sse\u65b9\u5f0f\u8fdb\u884c\u4f20\u8f93\u3002<\/p>\n<p>mcp.run(transport&#061;&#039;sse&#039;)<\/p>\n<p>\u5728__init__.py\u4e2d\u5199\u5165<\/p>\n<p>from .server import main<\/p>\n<p>\u5728__main__.py\u4e2d\u5199\u5165&#xff1a;<\/p>\n<p>from mcp_get_weather import main<\/p>\n<p>main()<\/p>\n<p>\u540c\u65f6\u56de\u5230\u4e3b\u76ee\u5f55&#xff0c;\u4fee\u6539\u9879\u76ee\u914d\u7f6e\u6587\u4ef6pyproject.toml&#xff1a;<\/p>\n<p><span class=\"token punctuation\">[<\/span>build<span class=\"token punctuation\">&#8211;<\/span>system<span class=\"token punctuation\">]<\/span><br \/>\nrequires &#061; <span class=\"token punctuation\">[<\/span><span class=\"token string\">&#034;setuptools&gt;&#061;61.0&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;wheel&#034;<\/span><span class=\"token punctuation\">]<\/span><br \/>\nbuild<span class=\"token punctuation\">&#8211;<\/span>backend &#061; &#034;setuptools.build_meta&#034;<\/p>\n<p><span class=\"token punctuation\">[<\/span>project<span class=\"token punctuation\">]<\/span><br \/>\nname &#061; &#034;mcp<span class=\"token punctuation\">&#8211;<\/span>get<span class=\"token punctuation\">&#8211;<\/span>weather<span class=\"token punctuation\">&#8211;<\/span>scorpios&#034;<br \/>\nversion &#061; &#034;0.1.0&#034;<br \/>\ndescription &#061; &#034;\u8f93\u5165OpenWeather<span class=\"token punctuation\">&#8211;<\/span>API<span class=\"token punctuation\">&#8211;<\/span>KEY&#xff0c;\u83b7\u53d6\u5929\u6c14\u4fe1\u606f\u3002&#034;<br \/>\nreadme &#061; &#034;README.md&#034;<br \/>\nrequires<span class=\"token punctuation\">&#8211;<\/span>python &#061; &#034;<span class=\"token punctuation\">&gt;<\/span>&#061;3.10&#034;<br \/>\ndependencies &#061; <span class=\"token punctuation\">[<\/span><br \/>\n    <span class=\"token string\">&#034;httpx&gt;&#061;0.28.1&#034;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n    <span class=\"token string\">&#034;mcp&gt;&#061;1.11.0&#034;<\/span><span class=\"token punctuation\">,<\/span><br \/>\n<span class=\"token punctuation\">]<\/span><\/p>\n<p><span class=\"token punctuation\">[<\/span>project.scripts<span class=\"token punctuation\">]<\/span><br \/>\nmcp<span class=\"token punctuation\">&#8211;<\/span>get<span class=\"token punctuation\">&#8211;<\/span>weather &#061; &#034;mcp_get_weather<span class=\"token punctuation\">:<\/span>main&#034;<\/p>\n<p><span class=\"token punctuation\">[<\/span>tool.setuptools<span class=\"token punctuation\">]<\/span><br \/>\npackage<span class=\"token punctuation\">&#8211;<\/span>dir &#061; <span class=\"token punctuation\">{<\/span>&#034;&#034; &#061; &#034;src&#034;<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token punctuation\">[<\/span>tool.setuptools.packages.find<span class=\"token punctuation\">]<\/span><br \/>\nwhere &#061; <span class=\"token punctuation\">[<\/span><span class=\"token string\">&#034;src&#034;<\/span><span class=\"token punctuation\">]<\/span><\/p>\n<h2>3. \u4ee3\u7801\u6d4b\u8bd5<\/h2>\n<p>\u5bf9\u7f16\u5199\u5b8c\u7684SSE MCP\u670d\u52a1\u8fdb\u884c\u6d4b\u8bd5&#xff0c;\u4f7f\u7528MCP\u63d0\u4f9b\u7684Inspector\u8fdb\u884c\u670d\u52a1\u5668\u6027\u80fd\u6d4b\u8bd5&#xff0c;\u9700\u8981\u5148\u5f00\u542fMCP\u670d\u52a1\u5668&#xff0c;\u7136\u540e\u518d\u5f00\u542fInspector&#xff1a;<\/p>\n<p>\u5728stdio\u6a21\u5f0f\u4e0b\u662f\u5f00\u542fInspector\u65f6\u540c\u6b65\u5f00\u542fMCP Server<\/p>\n<ul>\n<li>\u5f00\u542fSSE MCP\u670d\u52a1\u5668&#xff1a;<\/li>\n<\/ul>\n<p># \u56de\u5230\u9879\u76ee\u4e3b\u76ee\u5f55<br \/>\n# cd \/root\/autodl-tmp\/mcp\/mcp-sse-test\/mcp-get-weather-scorpios<\/p>\n<p>uv run .\/src\/mcp_get_weather\/server.py &#8211;api_key YOUR_KEY<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729183257-688913d94404e.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<ul>\n<li>\u5f00\u542fInspector<\/li>\n<\/ul>\n<p># \u56de\u5230\u9879\u76ee\u4e3b\u76ee\u5f55<br \/>\n# cd \/root\/autodl-tmp\/mcp\/mcp-sse-test\/mcp-get-weather-scorpios<\/p>\n<p>npx -y &#064;modelcontextprotocol\/inspector uv run .\/src\/mcp_get_weather\/server.py &#8211;api_key YOUR_KEY<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729183258-688913da48079.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<ul>\n<li>\u8fdb\u884c\u6d4b\u8bd5<\/li>\n<\/ul>\n<p>\u6253\u5f00Inspector&#xff0c;\u5e76\u9009\u62e9SSE\u6a21\u5f0f&#xff0c;\u9009\u62e9\u9ed8\u8ba4\u8fd0\u884c\u5730\u5740&#xff1a;http:\/\/localhost:8000\/sse&#xff0c;\u518d\u914d\u7f6e\u4e0b\u4ee3\u7406\u7f51\u5173\u548c\u79d8\u94a5&#xff08;\u4f7f\u7528AutoDL\u670d\u52a1\u5668\u9700\u8981&#xff09;&#xff0c;\u7136\u540e\u70b9\u51fbconnect&#xff0c;\u8f93\u5165\u5730\u540d\u8fdb\u884c\u6d4b\u8bd5&#xff1a;&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729183259-688913dbaf75d.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<ul>\n<li>\u9009\u62e9SSE\u548c\u586b\u5199\u5730\u5740<\/li>\n<li>\u914d\u7f6e\u76f8\u5173\u53c2\u6570<\/li>\n<li>\u9009\u62e9Tools\u3001tools-list<\/li>\n<li>\u8f93\u5165\u5730\u5740\u8fdb\u884c\u8c03\u8bd5<\/li>\n<\/ul>\n<p>\u6d4b\u8bd5\u5b8c\u6210\u540e&#xff0c;\u5373\u53ef\u4e0a\u7ebf\u53d1\u5e03\u3002<\/p>\n<h2>4. \u6253\u5305\u4e0a\u4f20<\/h2>\n<p># \u56de\u5230\u9879\u76ee\u4e3b\u76ee\u5f55<br \/>\n# cd \/root\/autodl-tmp\/mcp\/mcp-sse-test\/mcp-get-weather-scorpios<\/p>\n<p>pip install build<br \/>\nuv pip install build twine<br \/>\npython -m build<br \/>\npython -m twine upload dist\/*<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729183301-688913dd474ad.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729183301-688913ddf16ab.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729183303-688913dfcab5f.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729183305-688913e140a4e.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729183306-688913e2afdaa.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n\u67e5\u770b\u53d1\u5e03\u7684\u5e93&#xff1a;https:\/\/pypi.org\/search\/?q&#061;mcp-get-weather-scorpios<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729183306-688913e2e5bec.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<h2>5. \u4e0b\u8f7d\u9a8c\u8bc1<\/h2>\n<ul>\n<li>\u672c\u5730\u5b89\u88c5&#xff1a;<\/li>\n<\/ul>\n<p>pip install mcp-get-weather-scorpios -i https:\/\/pypi.org\/simple\/<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729183307-688913e3a2537.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729183307-688913e3e87c5.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<ul>\n<li>\n<p>\u5f00\u542f\u670d\u52a1&#xff1a;<\/p>\n<p>uv run mcp-get-weather &#8211;api_key 36d\u2026\u2026\u2026\u2026\u2026\u2026b<\/p>\n<\/li>\n<\/ul>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729183308-688913e439ecf.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n\u7136\u540e\u5373\u53ef\u6253\u5f00\u6d4f\u89c8\u5668\u8f93\u5165http:\/\/localhost:8000\/sse\u6d4b\u8bd5\u8fde\u63a5\u60c5\u51b5<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729183308-688913e469a46.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n<p>\u6ce8\u610f&#xff0c;\u8fd9\u91cc\u5728\u670d\u52a1\u5668\u4e0a\u5f00\u542f\u670d\u52a1\u7136\u540e\u672c\u5730\u8fde\u63a5\u4e5f\u53ef\u4ee5&#xff0c;\u548cstdio\u4e0d\u540c&#xff0c;SSE\u6a21\u5f0f\u4e0b\u7684MCP\u670d\u52a1\u5668\u5e76\u4e0d\u9700\u8981\u672c\u5730\u8fd0\u884c\u3002<\/p>\n<h2>6. CherryStudio \u9a8c\u8bc1<\/h2>\n<p>\u4f7f\u7528Cherry studio\u8fde\u63a5SSE\u6a21\u5f0f\u4e0b\u7684MCP\u670d\u52a1\u5668&#xff0c;\u53ea\u9700\u8981\u8f93\u5165\u670d\u52a1\u5668\u5730\u5740\u5373\u53ef&#xff1a;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729183308-688913e47dd6f.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729183309-688913e5e5ce3.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><br \/>\n<img decoding=\"async\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729183312-688913e8375b7.jpg\" alt=\"\u5728\u8fd9\u91cc\u63d2\u5165\u56fe\u7247\u63cf\u8ff0\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb906\u6b21\uff0c\u70b9\u8d5e19\u6b21\uff0c\u6536\u85cf13\u6b21\u3002\u57fa\u4e8eSSE\u4f20\u8f93\u7684MCP\u670d\u52a1\u5668\u5b9e\u73b0_mcp sse \u914d\u7f6e<\/p>\n","protected":false},"author":2,"featured_media":46142,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[73,234,50],"topic":[],"class_list":["post-46162","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-mcp","tag-sse","tag-50"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u57fa\u4e8eSSE\u4f20\u8f93\u7684MCP\u670d\u52a1\u5668\u5b9e\u73b0 - \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\/46162.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u57fa\u4e8eSSE\u4f20\u8f93\u7684MCP\u670d\u52a1\u5668\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb906\u6b21\uff0c\u70b9\u8d5e19\u6b21\uff0c\u6536\u85cf13\u6b21\u3002\u57fa\u4e8eSSE\u4f20\u8f93\u7684MCP\u670d\u52a1\u5668\u5b9e\u73b0_mcp sse \u914d\u7f6e\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/46162.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-07-29T18:33:14+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729183254-688913d6b8d8a.jpg\" \/>\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=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/46162.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/46162.html\",\"name\":\"\u57fa\u4e8eSSE\u4f20\u8f93\u7684MCP\u670d\u52a1\u5668\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-07-29T18:33:14+00:00\",\"dateModified\":\"2025-07-29T18:33:14+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/46162.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/46162.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/46162.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u57fa\u4e8eSSE\u4f20\u8f93\u7684MCP\u670d\u52a1\u5668\u5b9e\u73b0\"}]},{\"@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":"\u57fa\u4e8eSSE\u4f20\u8f93\u7684MCP\u670d\u52a1\u5668\u5b9e\u73b0 - \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\/46162.html","og_locale":"zh_CN","og_type":"article","og_title":"\u57fa\u4e8eSSE\u4f20\u8f93\u7684MCP\u670d\u52a1\u5668\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb906\u6b21\uff0c\u70b9\u8d5e19\u6b21\uff0c\u6536\u85cf13\u6b21\u3002\u57fa\u4e8eSSE\u4f20\u8f93\u7684MCP\u670d\u52a1\u5668\u5b9e\u73b0_mcp sse \u914d\u7f6e","og_url":"https:\/\/www.wsisp.com\/helps\/46162.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-07-29T18:33:14+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/07\/20250729183254-688913d6b8d8a.jpg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/46162.html","url":"https:\/\/www.wsisp.com\/helps\/46162.html","name":"\u57fa\u4e8eSSE\u4f20\u8f93\u7684MCP\u670d\u52a1\u5668\u5b9e\u73b0 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-07-29T18:33:14+00:00","dateModified":"2025-07-29T18:33:14+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/46162.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/46162.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/46162.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u57fa\u4e8eSSE\u4f20\u8f93\u7684MCP\u670d\u52a1\u5668\u5b9e\u73b0"}]},{"@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\/46162","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=46162"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/46162\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/46142"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=46162"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=46162"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=46162"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=46162"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}