{"id":92248,"date":"2026-08-09T20:41:03","date_gmt":"2026-08-09T12:41:03","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/92248.html"},"modified":"2026-08-09T20:41:03","modified_gmt":"2026-08-09T12:41:03","slug":"%e6%b7%b1%e5%85%a5%e7%90%86%e8%a7%a3-ai-agent-%c2%b7-mcp-%e5%ad%90%e7%b3%bb%e5%88%97-01%ef%bc%9amcp-%e5%8d%8f%e8%ae%ae%e5%85%a8%e8%a7%a3-%e4%bb%8e%e6%b6%88%e6%81%af%e6%a0%bc%e5%bc%8f%e5%88%b0","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/92248.html","title":{"rendered":"\u6df1\u5165\u7406\u89e3 AI Agent \u00b7 MCP \u5b50\u7cfb\u5217 #01\uff1aMCP \u534f\u8bae\u5168\u89e3\u2014\u4ece\u6d88\u606f\u683c\u5f0f\u5230\u4f20\u8f93\u5c42\u7684\u5b8c\u6574\u62c6\u89e3"},"content":{"rendered":"<hr \/>\n<h2 style=\"text-align:center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260809124058-6a78755a07b23.jpg\" \/><\/h2>\n<p>\u5bfc\u8bfb&#xff1a;2024 \u5e74 11 \u6708&#xff0c;Anthropic \u53d1\u5e03\u4e86 MCP&#xff08;Model Context Protocol&#xff09;\u2014\u2014\u4e00\u4e2a\u7528\u4e8e\u6807\u51c6\u5316 LLM \u5e94\u7528\u4e0e\u5916\u90e8\u5de5\u5177\u3001\u6570\u636e\u6e90\u4e4b\u95f4\u901a\u4fe1\u7684\u5f00\u653e\u534f\u8bae\u3002\u534a\u5e74\u540e&#xff0c;MCP \u5df2\u7ecf\u6210\u4e3a AI Agent \u9886\u57df\u7684\u4e8b\u5b9e\u6807\u51c6&#xff1a;OpenAI\u3001Google\u3001LangChain\u3001Spring AI \u7b49\u4e3b\u6d41\u5e73\u53f0\u7eb7\u7eb7\u63a5\u5165\u3002MCP \u4e0d\u662f\u53c8\u4e00\u4e2a RPC \u6846\u67b6&#xff0c;\u800c\u662f\u4e13\u4e3a\u5927\u6a21\u578b\u4ea4\u4e92\u8bbe\u8ba1\u7684&#034;\u80fd\u529b\u63a5\u53e3\u89c4\u8303&#034;\u2014\u2014\u5b83\u5b9a\u4e49\u7684\u4e0d\u662f\u5de5\u5177\u600e\u4e48\u5b9e\u73b0&#xff0c;\u800c\u662f\u5de5\u5177\u600e\u4e48\u88ab\u53d1\u73b0\u3001\u88ab\u7406\u89e3\u3001\u88ab\u8c03\u7528\u3002\u672c\u6587\u5c06\u4ece\u534f\u8bae\u5c42\u9762\u5b8c\u6574\u62c6\u89e3 MCP \u7684\u8bbe\u8ba1\u903b\u8f91&#xff0c;\u5e2e\u8bfb\u8005\u5efa\u7acb\u5bf9 MCP \u7684\u7cfb\u7edf\u8ba4\u77e5\u3002<\/p>\n<hr \/>\n<h3>\u4e00\u3001\u4ece Function Calling \u5230 MCP&#xff1a;\u5de5\u5177\u8c03\u7528\u7684\u6807\u51c6\u5316\u4e4b\u8def<\/h3>\n<h4>1.1 \u788e\u7247\u5316\u7684\u5de5\u5177\u8c03\u7528\u73b0\u72b6<\/h4>\n<p>\u5728 MCP \u51fa\u73b0\u4e4b\u524d&#xff0c;LLM \u8c03\u7528\u5916\u90e8\u5de5\u5177\u8fd9\u4ef6\u4e8b\u5df2\u7ecf\u5b58\u5728\u4e86\u597d\u51e0\u5e74&#xff0c;\u4f46\u4e00\u76f4\u662f&#034;\u80fd\u7528\u4f46\u5f88\u788e&#034;\u7684\u72b6\u6001\u3002\u6bcf\u4e2a LLM \u5382\u5546\u90fd\u6709\u4e00\u5957\u81ea\u5df1\u7684\u5de5\u5177\u8c03\u7528\u683c\u5f0f&#xff1a;<\/p>\n<table>\n<tr>\u5382\u5546\u5de5\u5177\u8c03\u7528\u683c\u5f0f\u53c2\u6570 Schema<\/tr>\n<tbody>\n<tr>\n<td>OpenAI<\/td>\n<td>function<\/td>\n<td>JSON Schema&#xff08;\u81ea\u5b9a\u4e49\u5b50\u96c6&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>Anthropic<\/td>\n<td>tool_use<\/td>\n<td>JSON Schema<\/td>\n<\/tr>\n<tr>\n<td>DashScope&#xff08;\u963f\u91cc&#xff09;<\/td>\n<td>tool_use<\/td>\n<td>JSON Schema&#xff08;\u7565\u6709\u5dee\u5f02&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>Google Gemini<\/td>\n<td>function_declarations<\/td>\n<td>OpenAPI 3.0 \u5b50\u96c6<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u53c2\u6570 Schema \u7684\u683c\u5f0f\u3001\u9519\u8bef\u7801\u5b9a\u4e49\u3001\u54cd\u5e94\u7ed3\u6784\u5404\u4e0d\u76f8\u540c\u3002\u5f00\u53d1\u8005\u4e3a\u6bcf\u4e2a\u5e73\u53f0\u7ef4\u62a4\u4e00\u5957\u9002\u914d\u5c42&#xff0c;\u540c\u4e00\u5957\u5de5\u5177\u4ee3\u7801\u65e0\u6cd5\u8de8\u5e73\u53f0\u590d\u7528\u3002<\/p>\n<p>\u8fd9\u79cd\u788e\u7247\u5316\u5e26\u6765\u4e09\u4e2a\u5177\u4f53\u95ee\u9898&#xff1a;<\/p>\n<p>\u5de5\u5177\u788e\u7247\u5316\u3002 \u4e00\u4e2a\u6570\u636e\u5e93\u67e5\u8be2\u5de5\u5177&#xff0c;\u5728 LangChain \u4e2d\u53ef\u4ee5\u5de5\u4f5c&#xff0c;\u4f46\u7ed9 Spring AI \u7528\u5c31\u9700\u8981\u91cd\u65b0\u5305\u88c5\u3002\u5199\u4e00\u4e2a\u641c\u7d22\u5de5\u5177&#xff0c;\u7ed9 Claude \u7528\u4e00\u5957\u4ee3\u7801&#xff0c;\u7ed9 GPT \u7528\u53c8\u4e00\u5957\u3002\u4ee3\u7801\u91cd\u590d\u7387\u6781\u9ad8\u3002<\/p>\n<p>\u751f\u6001\u5272\u88c2\u3002 \u5de5\u5177\u5f00\u53d1\u8005\u65e0\u6cd5&#034;\u5199\u4e00\u6b21&#xff0c;\u5230\u5904\u7528&#034;\u3002\u6ca1\u6709\u4eba\u6709\u52a8\u529b\u4e3a\u6bcf\u4e2a\u5e73\u53f0\u5404\u5199\u4e00\u5957\u9002\u914d&#xff0c;\u5bfc\u81f4\u5de5\u5177\u751f\u6001\u65e0\u6cd5\u5f62\u6210\u6b63\u5411\u98de\u8f6e\u3002<\/p>\n<p>\u80fd\u529b\u53d1\u73b0\u7f3a\u5931\u3002 LLM \u5728\u8fd0\u884c\u65f6\u4e0d\u77e5\u9053\u53ef\u7528\u5de5\u5177\u6709\u54ea\u4e9b\u3001\u6bcf\u4e2a\u5de5\u5177\u7684\u53c2\u6570\u683c\u5f0f\u662f\u4ec0\u4e48\u3002\u4f20\u7edf\u505a\u6cd5\u662f\u5728 prompt \u4e2d\u624b\u52a8\u62fc\u63a5\u5de5\u5177\u63cf\u8ff0&#xff0c;\u968f\u7740\u5de5\u5177\u6570\u91cf\u589e\u957f&#xff0c;\u7ef4\u62a4\u6210\u672c\u6025\u5267\u4e0a\u5347\u3002<\/p>\n<h4>1.2 Function Calling \u2260 MCP<\/h4>\n<p>Function Calling \u548c Tool Use \u89e3\u51b3\u7684\u662f&#034;LLM \u600e\u4e48\u8868\u8fbe\u60f3\u8c03\u7528\u4ec0\u4e48\u5de5\u5177&#034;\u2014\u2014\u5c5e\u4e8e LLM \u7684\u8f93\u51fa\u683c\u5f0f\u89c4\u8303\u3002MCP \u89e3\u51b3\u7684\u662f\u66f4\u4e0a\u5c42\u7684\u95ee\u9898&#xff1a;&#034;\u5de5\u5177\u5728\u54ea\u91cc\u3001\u600e\u4e48\u53d1\u73b0\u3001\u600e\u4e48\u8c03\u7528\u3001\u600e\u4e48\u8de8\u5e73\u53f0\u5171\u4eab&#034;\u2014\u2014\u5c5e\u4e8e\u5b8c\u6574\u7684\u901a\u4fe1\u534f\u8bae\u3002<\/p>\n<table>\n<tr>\u7ef4\u5ea6Function CallingMCP<\/tr>\n<tbody>\n<tr>\n<td>\u5c42\u6b21<\/td>\n<td>LLM \u8f93\u51fa\u683c\u5f0f<\/td>\n<td>\u901a\u4fe1\u534f\u8bae<\/td>\n<\/tr>\n<tr>\n<td>\u6807\u51c6\u5316\u7a0b\u5ea6<\/td>\n<td>\u5382\u5546\u9501\u5b9a&#xff08;OpenAI \/ Anthropic \u5404\u4e00\u5957&#xff09;<\/td>\n<td>\u8de8\u5382\u5546\u5f00\u653e\u6807\u51c6<\/td>\n<\/tr>\n<tr>\n<td>\u80fd\u529b\u53d1\u73b0<\/td>\n<td>\u65e0&#xff0c;\u9700\u624b\u52a8\u4f20\u5165\u5de5\u5177\u5217\u8868<\/td>\n<td>\u5185\u7f6e\u80fd\u529b\u534f\u5546\u673a\u5236&#xff0c;\u8fd0\u884c\u65f6\u52a8\u6001\u53d1\u73b0<\/td>\n<\/tr>\n<tr>\n<td>\u751f\u6001\u590d\u7528<\/td>\n<td>\u5de5\u5177\u7ed1\u5b9a\u7279\u5b9a\u5e73\u53f0<\/td>\n<td>\u5de5\u5177\u4e00\u6b21\u5f00\u53d1&#xff0c;\u4efb\u4f55 MCP Client \u53ef\u8c03\u7528<\/td>\n<\/tr>\n<tr>\n<td>\u4f20\u8f93\u65b9\u5f0f<\/td>\n<td>\u4e0d\u6d89\u53ca&#xff08;\u7531 HTTP API \u627f\u8f7d&#xff09;<\/td>\n<td>\u652f\u6301 stdio \/ SSE \/ Streamable HTTP<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u7c7b\u6bd4\u6765\u770b&#xff1a;HTTP \u5b9a\u4e49\u4e86 Web \u670d\u52a1\u4e4b\u95f4\u600e\u4e48\u5bf9\u8bdd&#xff0c;gRPC \u5b9a\u4e49\u4e86\u5fae\u670d\u52a1\u4e4b\u95f4\u600e\u4e48\u5bf9\u8bdd&#xff0c;\u800c MCP \u5b9a\u4e49\u7684\u662f LLM Agent \u548c\u5de5\u5177\u4e4b\u95f4\u7684\u5bf9\u8bdd\u65b9\u5f0f\u3002Function Calling \u662f&#034;LLM \u8bf4\u4e86\u4ec0\u4e48&#034;&#xff0c;MCP \u662f&#034;\u6574\u6761\u901a\u4fe1\u94fe\u8def\u600e\u4e48\u5efa\u8d77\u6765&#034;\u3002\u4e24\u8005\u662f\u4e92\u8865\u5173\u7cfb&#xff0c;\u4e0d\u662f\u66ff\u4ee3\u5173\u7cfb\u3002<\/p>\n<hr \/>\n<h3>\u4e8c\u3001\u6838\u5fc3\u67b6\u6784&#xff1a;Host \/ Client \/ Server \u4e09\u89d2\u5173\u7cfb<\/h3>\n<h4>2.1 \u4e09\u4e2a\u6838\u5fc3\u89d2\u8272<\/h4>\n<p>MCP \u534f\u8bae\u5b9a\u4e49\u4e86\u4e09\u4e2a\u6838\u5fc3\u89d2\u8272&#xff0c;\u5f62\u6210\u4e00\u4e2a\u6e05\u6670\u7684\u4e09\u89d2\u5173\u7cfb&#xff1a;<\/p>\n<table>\n<tr>\u89d2\u8272\u804c\u8d23\u793a\u4f8b<\/tr>\n<tbody>\n<tr>\n<td>Host<\/td>\n<td>\u6258\u7ba1 Client \u7684\u5bbf\u4e3b\u5e94\u7528&#xff0c;\u9762\u5411\u7528\u6237\u7684\u5165\u53e3<\/td>\n<td>Claude Desktop\u3001VS Code\u3001IDE \u63d2\u4ef6<\/td>\n<\/tr>\n<tr>\n<td>Client<\/td>\n<td>\u4e0e Server \u5efa\u7acb\u8fde\u63a5&#xff0c;\u53d1\u8d77\u5de5\u5177\u8c03\u7528\u8bf7\u6c42<\/td>\n<td>LLM \u5e94\u7528\u3001Agent \u6846\u67b6\u4e2d\u7684 MCP \u6a21\u5757<\/td>\n<\/tr>\n<tr>\n<td>Server<\/td>\n<td>\u63d0\u4f9b Tools \/ Resources \/ Prompts \u7684\u670d\u52a1\u7aef<\/td>\n<td>\u641c\u7d22\u5de5\u5177\u3001\u6570\u636e\u5e93\u5de5\u5177\u3001\u6587\u4ef6\u7cfb\u7edf\u5de5\u5177<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8fd9\u4e09\u8005\u7684\u5173\u7cfb\u662f&#xff1a;Host \u662f\u7528\u6237\u76f4\u63a5\u63a5\u89e6\u7684\u5e94\u7528\u7a0b\u5e8f&#xff0c;\u5b83\u5185\u90e8\u5d4c\u5165\u4e86\u4e00\u4e2a\u6216\u591a\u4e2a Client\u3002\u6bcf\u4e2a Client \u53ef\u4ee5\u4e0e\u4e00\u4e2a\u6216\u591a\u4e2a Server \u5efa\u7acb\u8fde\u63a5&#xff0c;\u805a\u5408\u5b83\u4eec\u7684\u5de5\u5177\u80fd\u529b\u3002<\/p>\n<p>\u4ee5 Claude Desktop \u4e3a\u4f8b&#xff1a;<\/p>\n<ul>\n<li>Claude Desktop \u662f Host\u2014\u2014\u7528\u6237\u770b\u5230\u548c\u64cd\u4f5c\u7684\u5e94\u7528<\/li>\n<li>\u5b83\u5185\u90e8\u8fd0\u884c\u7740\u4e00\u4e2a MCP Client \u6a21\u5757<\/li>\n<li>\u8fd9\u4e2a Client \u53ef\u4ee5\u540c\u65f6\u8fde\u63a5\u4e00\u4e2a\u6587\u4ef6\u7cfb\u7edf Server\u3001\u4e00\u4e2a\u641c\u7d22 Server\u3001\u4e00\u4e2a\u6570\u636e\u5e93 Server<\/li>\n<li>\u5f53 LLM \u9700\u8981\u8c03\u7528\u5de5\u5177\u65f6&#xff0c;Client \u8d1f\u8d23\u5c06\u8bf7\u6c42\u8def\u7531\u5230\u6b63\u786e\u7684 Server&#xff0c;\u518d\u628a\u7ed3\u679c\u8fd4\u56de\u7ed9 LLM<\/li>\n<\/ul>\n<p>\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502                      Host&#xff08;\u7528\u6237\u53ef\u89c1&#xff09;                       \u2502<br \/>\n\u2502  \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510   \u2502<br \/>\n\u2502  \u2502              MCP Client&#xff08;\u534f\u8bae\u5f15\u64ce&#xff09;                  \u2502   \u2502<br \/>\n\u2502  \u2502         \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u253c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510                    \u2502   \u2502<br \/>\n\u2502  \u2502         \u25bc          \u25bc          \u25bc                    \u2502   \u2502<br \/>\n\u2502  \u2502   \u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510            \u2502   \u2502<br \/>\n\u2502  \u2502   \u2502 Server A \u2502\u2502 Server B \u2502\u2502 Server C \u2502            \u2502   \u2502<br \/>\n\u2502  \u2502   \u2502 \u641c\u7d22\u5de5\u5177  \u2502\u2502 \u6570\u636e\u5e93    \u2502\u2502 \u6587\u4ef6\u7cfb\u7edf  \u2502            \u2502   \u2502<br \/>\n\u2502  \u2502   \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518            \u2502   \u2502<br \/>\n\u2502  \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518   \u2502<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 <\/p>\n<h4>2.2 \u89e3\u8026\u7684\u5173\u952e\u4ef7\u503c<\/h4>\n<p>\u8fd9\u79cd\u8bbe\u8ba1\u7684\u5173\u952e\u4ef7\u503c\u5728\u4e8e\u89e3\u8026&#xff1a;<\/p>\n<ul>\n<li>\u5de5\u5177\u5f00\u53d1\u8005\u53ea\u9700\u8981\u5199\u4e00\u4e2a Server&#xff0c;\u4e0d\u7528\u5173\u5fc3 Host \u662f\u4ec0\u4e48<\/li>\n<li>Host \u5f00\u53d1\u8005\u53ea\u9700\u8981\u5b9e\u73b0 Client \u534f\u8bae&#xff0c;\u4e0d\u7528\u5173\u5fc3\u540e\u7aef\u6709\u54ea\u4e9b\u5de5\u5177<\/li>\n<li>LLM \u53ea\u4e0e Client \u4ea4\u4e92&#xff0c;\u4e0d\u611f\u77e5 Server \u7684\u62d3\u6251\u2014\u2014Server \u53ef\u4ee5\u72ec\u7acb\u90e8\u7f72\u3001\u72ec\u7acb\u6269\u7f29\u5bb9\u3001\u72ec\u7acb\u53d1\u5e03<\/li>\n<\/ul>\n<p>Client \u548c Server \u4e4b\u95f4\u7684\u901a\u4fe1\u57fa\u4e8e JSON-RPC 2.0 \u534f\u8bae&#xff0c;\u901a\u8fc7\u53ef\u63d2\u62d4\u7684\u4f20\u8f93\u5c42&#xff08;stdio \/ SSE \/ Streamable HTTP&#xff09;\u627f\u8f7d\u3002\u534f\u8bae\u7684\u8bbe\u8ba1\u5c06&#034;\u6d88\u606f\u683c\u5f0f&#034;\u548c&#034;\u4f20\u8f93\u65b9\u5f0f&#034;\u5b8c\u5168\u89e3\u8026\u2014\u2014\u540c\u4e00\u6761 JSON-RPC \u6d88\u606f\u53ef\u4ee5\u8d70\u6807\u51c6\u8f93\u5165\u8f93\u51fa\u7ba1\u9053&#xff0c;\u4e5f\u53ef\u4ee5\u8d70 HTTP \u957f\u8fde\u63a5\u3002<\/p>\n<hr \/>\n<h3>\u4e09\u3001JSON-RPC 2.0&#xff1a;MCP \u7684\u6d88\u606f\u683c\u5f0f<\/h3>\n<h4>3.1 \u4e3a\u4ec0\u4e48\u9009\u62e9 JSON-RPC 2.0<\/h4>\n<p>MCP \u7684\u5e95\u5c42\u901a\u4fe1\u57fa\u4e8e JSON-RPC 2.0 \u6807\u51c6\u3002\u9009\u62e9 JSON-RPC 2.0 \u5e76\u975e\u5076\u7136&#xff1a;<\/p>\n<table>\n<tr>\u5bf9\u6bd4\u7ef4\u5ea6JSON-RPC 2.0gRPCREST<\/tr>\n<tbody>\n<tr>\n<td>\u7f16\u8bd1\u8981\u6c42<\/td>\n<td>\u65e0\u9700 proto \u7f16\u8bd1<\/td>\n<td>\u9700\u8981 proto &#043; \u4ee3\u7801\u751f\u6210<\/td>\n<td>\u65e0\u9700<\/td>\n<\/tr>\n<tr>\n<td>\u53cc\u5411\u901a\u4fe1<\/td>\n<td>\u539f\u751f\u652f\u6301 notifications<\/td>\n<td>\u9700\u8981 streaming \u914d\u7f6e<\/td>\n<td>\u4e0d\u652f\u6301<\/td>\n<\/tr>\n<tr>\n<td>\u6279\u91cf\u8bf7\u6c42<\/td>\n<td>\u539f\u751f\u652f\u6301 batching<\/td>\n<td>\u4e0d\u652f\u6301<\/td>\n<td>\u4e0d\u652f\u6301<\/td>\n<\/tr>\n<tr>\n<td>\u5305\u4f53\u5927\u5c0f<\/td>\n<td>\u6781\u5c0f&#xff08;\u7eaf JSON&#xff09;<\/td>\n<td>\u4e2d\u7b49&#xff08;\u4e8c\u8fdb\u5236\u7f16\u7801&#xff09;<\/td>\n<td>\u8f83\u5927<\/td>\n<\/tr>\n<tr>\n<td>\u8de8\u8bed\u8a00\u652f\u6301<\/td>\n<td>\u51e0\u4e4e\u6240\u6709\u8bed\u8a00<\/td>\n<td>\u4e3b\u6d41\u8bed\u8a00<\/td>\n<td>\u6240\u6709\u8bed\u8a00<\/td>\n<\/tr>\n<tr>\n<td>\u8c03\u8bd5\u53cb\u597d\u5ea6<\/td>\n<td>\u9ad8&#xff08;\u4eba\u7c7b\u53ef\u8bfb&#xff09;<\/td>\n<td>\u4f4e&#xff08;\u4e8c\u8fdb\u5236&#xff09;<\/td>\n<td>\u9ad8<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>JSON-RPC 2.0 \u5728\u8f7b\u91cf\u6027\u548c\u529f\u80fd\u5b8c\u5907\u6027\u4e4b\u95f4\u53d6\u5f97\u4e86\u5f88\u597d\u7684\u5e73\u8861&#xff0c;\u7279\u522b\u9002\u5408 LLM Agent \u8fd9\u79cd\u9700\u8981\u9891\u7e41\u53cc\u5411\u901a\u4fe1\u7684\u573a\u666f\u3002<\/p>\n<h4>3.2 \u4e09\u79cd\u6d88\u606f\u7c7b\u578b<\/h4>\n<p>MCP \u4e2d\u7684\u6d88\u606f\u5206\u4e3a\u4e09\u79cd\u7c7b\u578b&#xff1a;\u8bf7\u6c42&#xff08;Request&#xff09;\u3001\u54cd\u5e94&#xff08;Response&#xff09; \u548c\u901a\u77e5&#xff08;Notification&#xff09;\u3002<\/p>\n<h5>\u8bf7\u6c42\u6d88\u606f&#xff08;Request&#xff09;<\/h5>\n<p>Client \u5411 Server \u53d1\u8d77\u8c03\u7528\u65f6\u53d1\u9001\u8bf7\u6c42&#xff0c;\u5fc5\u987b\u5305\u542b id \u5b57\u6bb5\u7528\u4e8e\u5339\u914d\u54cd\u5e94&#xff1a;<\/p>\n<p>{<br \/>\n  &#034;jsonrpc&#034;: &#034;2.0&#034;,<br \/>\n  &#034;id&#034;: &#034;request-1&#034;,<br \/>\n  &#034;method&#034;: &#034;tools\/call&#034;,<br \/>\n  &#034;params&#034;: {<br \/>\n    &#034;name&#034;: &#034;searchDocs&#034;,<br \/>\n    &#034;arguments&#034;: {<br \/>\n      &#034;query&#034;: &#034;MCP \u534f\u8bae\u89c4\u8303&#034;,<br \/>\n      &#034;topK&#034;: 5<br \/>\n    }<br \/>\n  }<br \/>\n} <\/p>\n<p>\u5404\u5b57\u6bb5\u8bf4\u660e&#xff1a;<\/p>\n<ul>\n<li>jsonrpc: \u56fa\u5b9a\u503c &#034;2.0&#034;&#xff0c;\u6807\u8bc6\u534f\u8bae\u7248\u672c<\/li>\n<li>id: \u8bf7\u6c42\u552f\u4e00\u6807\u8bc6&#xff0c;\u53ef\u4ee5\u662f\u5b57\u7b26\u4e32\u6216\u6574\u6570&#xff0c;\u7528\u4e8e\u5339\u914d\u54cd\u5e94<\/li>\n<li>method: \u8c03\u7528\u65b9\u6cd5\u540d&#xff0c;\u9075\u5faa namespace\/action \u547d\u540d\u7a7a\u95f4\u683c\u5f0f<\/li>\n<li>params: \u65b9\u6cd5\u53c2\u6570\u5bf9\u8c61&#xff0c;arguments \u5185\u5d4c\u5de5\u5177\u7684\u5b9e\u9645\u5165\u53c2<\/li>\n<\/ul>\n<h5>\u54cd\u5e94\u6d88\u606f&#xff08;Response&#xff09;<\/h5>\n<p>Server \u8fd4\u56de\u7ed3\u679c&#xff0c;id \u4e0e\u8bf7\u6c42\u4e00\u4e00\u5bf9\u5e94&#xff1a;<\/p>\n<p>{<br \/>\n  &#034;jsonrpc&#034;: &#034;2.0&#034;,<br \/>\n  &#034;id&#034;: &#034;request-1&#034;,<br \/>\n  &#034;result&#034;: {<br \/>\n    &#034;content&#034;: [<br \/>\n      {<br \/>\n        &#034;type&#034;: &#034;text&#034;,<br \/>\n        &#034;text&#034;: &#034;MCP \u534f\u8bae\u4f7f\u7528 JSON-RPC 2.0 \u4f5c\u4e3a\u6d88\u606f\u683c\u5f0f&#xff0c;\u8bbe\u8ba1\u76ee\u6807\u662f\u8f7b\u91cf\u3001\u53cc\u5411\u3001\u8de8\u5e73\u53f0&#8230;&#034;<br \/>\n      }<br \/>\n    ]<br \/>\n  }<br \/>\n} <\/p>\n<p>\u5982\u679c\u51fa\u73b0\u9519\u8bef&#xff0c;\u54cd\u5e94\u7528 error \u5b57\u6bb5\u66ff\u4ee3 result&#xff08;\u4e24\u8005\u4e92\u65a5&#xff0c;\u4e0d\u80fd\u540c\u65f6\u51fa\u73b0&#xff09;&#xff1a;<\/p>\n<p>{<br \/>\n  &#034;jsonrpc&#034;: &#034;2.0&#034;,<br \/>\n  &#034;id&#034;: &#034;request-1&#034;,<br \/>\n  &#034;error&#034;: {<br \/>\n    &#034;code&#034;: -32602,<br \/>\n    &#034;message&#034;: &#034;Invalid params: query is required&#034;,<br \/>\n    &#034;data&#034;: {<br \/>\n      &#034;field&#034;: &#034;query&#034;,<br \/>\n      &#034;reason&#034;: &#034;missing required parameter&#034;<br \/>\n    }<br \/>\n  }<br \/>\n} <\/p>\n<p>\u5de5\u7a0b\u63d0\u793a&#xff1a;error.data \u662f\u53ef\u9009\u7684\u9644\u52a0\u6570\u636e\u5b57\u6bb5\u3002\u5728\u5de5\u7a0b\u5b9e\u8df5\u4e2d&#xff0c;\u5efa\u8bae\u5c06\u8c03\u8bd5\u4fe1\u606f&#xff08;\u5982\u53c2\u6570\u6821\u9a8c\u5931\u8d25\u7684\u5b57\u6bb5\u540d\u3001\u5806\u6808\u6458\u8981&#xff09;\u653e\u5728 data \u4e2d&#xff0c;\u800c\u4e0d\u662f\u585e\u8fdb message \u5b57\u7b26\u4e32\u3002\u8fd9\u6837 Client \u7aef\u53ef\u4ee5\u505a\u7ed3\u6784\u5316\u7684\u9519\u8bef\u5904\u7406&#xff0c;\u800c\u4e0d\u662f\u4f9d\u8d56\u5b57\u7b26\u4e32\u89e3\u6790\u3002<\/p>\n<h5>\u901a\u77e5\u6d88\u606f&#xff08;Notification&#xff09;<\/h5>\n<p>\u901a\u77e5\u662f\u6ca1\u6709 id \u7684\u5355\u5411\u6d88\u606f&#xff0c;\u4e0d\u9700\u8981\u54cd\u5e94\u3002\u7528\u4e8e Server \u4e3b\u52a8\u63a8\u9001\u4e8b\u4ef6&#xff0c;\u4f8b\u5982\u5de5\u5177\u5217\u8868\u53d8\u66f4&#xff1a;<\/p>\n<p>{<br \/>\n  &#034;jsonrpc&#034;: &#034;2.0&#034;,<br \/>\n  &#034;method&#034;: &#034;notifications\/tools\/list_changed&#034;<br \/>\n} <\/p>\n<p>\u6ce8\u610f&#xff1a;\u901a\u77e5\u6ca1\u6709 id \u5b57\u6bb5&#xff0c;\u8fd9\u662f\u5b83\u548c\u8bf7\u6c42\u7684\u6838\u5fc3\u533a\u522b\u3002Server \u53d1\u9001\u901a\u77e5\u540e\u4e0d\u4f1a\u6536\u5230\u4efb\u4f55\u786e\u8ba4\u2014\u2014\u8fd9\u662f\u8bbe\u8ba1\u4e0a\u7684\u53d6\u820d&#xff0c;\u8ffd\u6c42\u4f4e\u5ef6\u8fdf\u800c\u975e\u53ef\u9760\u6027\u3002<\/p>\n<h4>3.3 \u65b9\u6cd5\u547d\u540d\u7a7a\u95f4<\/h4>\n<p>MCP \u5b9a\u4e49\u4e86\u6807\u51c6\u7684 method \u547d\u540d\u7a7a\u95f4&#xff0c;\u6240\u6709\u65b9\u6cd5\u540d\u9075\u5faa namespace\/action \u683c\u5f0f&#xff1a;<\/p>\n<table>\n<tr>\u65b9\u6cd5\u540d\u65b9\u5411\u7528\u9014<\/tr>\n<tbody>\n<tr>\n<td>initialize<\/td>\n<td>Client \u2192 Server<\/td>\n<td>\u521d\u59cb\u5316\u63e1\u624b<\/td>\n<\/tr>\n<tr>\n<td>initialized<\/td>\n<td>Client \u2192 Server<\/td>\n<td>\u63e1\u624b\u5b8c\u6210\u786e\u8ba4&#xff08;\u901a\u77e5&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>tools\/list<\/td>\n<td>Client \u2192 Server<\/td>\n<td>\u5217\u51fa\u6240\u6709\u5de5\u5177<\/td>\n<\/tr>\n<tr>\n<td>tools\/call<\/td>\n<td>Client \u2192 Server<\/td>\n<td>\u8c03\u7528\u6307\u5b9a\u5de5\u5177<\/td>\n<\/tr>\n<tr>\n<td>resources\/list<\/td>\n<td>Client \u2192 Server<\/td>\n<td>\u5217\u51fa\u6240\u6709\u8d44\u6e90<\/td>\n<\/tr>\n<tr>\n<td>resources\/read<\/td>\n<td>Client \u2192 Server<\/td>\n<td>\u8bfb\u53d6\u6307\u5b9a\u8d44\u6e90<\/td>\n<\/tr>\n<tr>\n<td>resources\/subscribe<\/td>\n<td>Client \u2192 Server<\/td>\n<td>\u8ba2\u9605\u8d44\u6e90\u53d8\u66f4<\/td>\n<\/tr>\n<tr>\n<td>prompts\/list<\/td>\n<td>Client \u2192 Server<\/td>\n<td>\u5217\u51fa\u6240\u6709 Prompt \u6a21\u677f<\/td>\n<\/tr>\n<tr>\n<td>prompts\/get<\/td>\n<td>Client \u2192 Server<\/td>\n<td>\u83b7\u53d6\u6307\u5b9a Prompt<\/td>\n<\/tr>\n<tr>\n<td>notifications\/tools\/list_changed<\/td>\n<td>Server \u2192 Client<\/td>\n<td>\u5de5\u5177\u5217\u8868\u5df2\u53d8\u66f4&#xff08;\u901a\u77e5&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>notifications\/resources\/list_changed<\/td>\n<td>Server \u2192 Client<\/td>\n<td>\u8d44\u6e90\u5217\u8868\u5df2\u53d8\u66f4&#xff08;\u901a\u77e5&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>notifications\/cancelled<\/td>\n<td>\u53cc\u5411<\/td>\n<td>\u53d6\u6d88\u6b63\u5728\u6267\u884c\u7684\u8bf7\u6c42<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>3.4 \u6807\u51c6\u9519\u8bef\u7801<\/h4>\n<p>MCP \u6cbf\u7528\u4e86 JSON-RPC 2.0 \u7684\u6807\u51c6\u9519\u8bef\u7801&#xff0c;\u5e76\u5728\u6b64\u57fa\u7840\u4e0a\u6269\u5c55\u4e86\u90e8\u5206 MCP \u4e13\u7528\u9519\u8bef\u7801&#xff1a;<\/p>\n<table>\n<tr>\u9519\u8bef\u7801\u542b\u4e49\u5e38\u89c1\u573a\u666f<\/tr>\n<tbody>\n<tr>\n<td>-32700<\/td>\n<td>Parse error<\/td>\n<td>JSON \u683c\u5f0f\u9519\u8bef&#xff0c;\u5982\u7f3a\u5c11\u5f15\u53f7\u3001\u62ec\u53f7\u4e0d\u5339\u914d<\/td>\n<\/tr>\n<tr>\n<td>-32600<\/td>\n<td>Invalid Request<\/td>\n<td>\u8bf7\u6c42\u683c\u5f0f\u4e0d\u7b26\u5408 MCP \u89c4\u8303<\/td>\n<\/tr>\n<tr>\n<td>-32601<\/td>\n<td>Method not found<\/td>\n<td>\u8c03\u7528\u4e86 Server \u4e0d\u652f\u6301\u7684\u65b9\u6cd5<\/td>\n<\/tr>\n<tr>\n<td>-32602<\/td>\n<td>Invalid params<\/td>\n<td>\u5de5\u5177\u53c2\u6570\u4e0d\u7b26\u5408 JSON Schema<\/td>\n<\/tr>\n<tr>\n<td>-32603<\/td>\n<td>Internal error<\/td>\n<td>Server \u5185\u90e8\u5f02\u5e38<\/td>\n<\/tr>\n<tr>\n<td>-32000 ~ -32099<\/td>\n<td>Server error&#xff08;\u4fdd\u7559\u6bb5&#xff09;<\/td>\n<td>Server \u81ea\u5b9a\u4e49\u9519\u8bef&#xff08;MCP \u9884\u7559&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8e29\u5751\u8bb0\u5f55&#xff1a;\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d&#xff0c;-32602&#xff08;Invalid params&#xff09;\u662f\u6700\u5e38\u89c1\u7684\u9519\u8bef\u3002\u539f\u56e0\u901a\u5e38\u662f LLM \u751f\u6210\u7684\u53c2\u6570\u7c7b\u578b\u4e0e JSON Schema \u5b9a\u4e49\u4e0d\u5339\u914d\u2014\u2014\u6bd4\u5982 Schema \u8981\u6c42 integer&#xff0c;LLM \u4f20\u4e86 &#034;5&#034;&#xff08;\u5b57\u7b26\u4e32&#xff09;\u3002\u5efa\u8bae\u5728 Server \u7aef\u505a\u5bbd\u677e\u7684\u7c7b\u578b\u8f6c\u6362&#xff0c;\u800c\u4e0d\u662f\u76f4\u63a5\u62d2\u7edd\u3002<\/p>\n<hr \/>\n<h3>\u56db\u3001\u4f20\u8f93\u5c42\u8bbe\u8ba1&#xff1a;stdio \/ SSE \/ Streamable HTTP<\/h3>\n<p>MCP \u534f\u8bae\u5c06\u300c\u6d88\u606f\u683c\u5f0f\u300d\u548c\u300c\u4f20\u8f93\u65b9\u5f0f\u300d\u89e3\u8026&#xff0c;\u652f\u6301\u591a\u79cd\u4f20\u8f93\u5c42\u3002\u4e0d\u540c\u7684\u4f20\u8f93\u65b9\u5f0f\u9002\u7528\u4e8e\u4e0d\u540c\u7684\u90e8\u7f72\u573a\u666f\u3002<\/p>\n<h4>4.1 stdio&#xff1a;\u672c\u5730\u8fdb\u7a0b\u901a\u4fe1<\/h4>\n<p>Client \u542f\u52a8 Server \u4f5c\u4e3a\u5b50\u8fdb\u7a0b&#xff0c;\u901a\u8fc7 stdin \u5199\u5165\u8bf7\u6c42\u3001\u901a\u8fc7 stdout \u8bfb\u53d6\u54cd\u5e94&#xff0c;\u6d88\u606f\u4ee5\u6362\u884c\u7b26\u5206\u9694\u3002<\/p>\n<p>Client                          Server (\u5b50\u8fdb\u7a0b)<br \/>\n  \u2502                               \u2502<br \/>\n  \u2502\u2500\u2500\u2500\u2500 stdin (JSON-RPC) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25ba\u2502<br \/>\n  \u2502                               \u2502<br \/>\n  \u2502\u25c4\u2500\u2500\u2500 stdout (JSON-RPC) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2502<br \/>\n  \u2502                               \u2502 <\/p>\n<p>\u914d\u7f6e\u793a\u4f8b&#xff08;Claude Desktop \u7684 mcp-servers-config.json&#xff09;&#xff1a;<\/p>\n<p>{<br \/>\n  &#034;mcpServers&#034;: {<br \/>\n    &#034;filesystem&#034;: {<br \/>\n      &#034;command&#034;: &#034;npx&#034;,<br \/>\n      &#034;args&#034;: [&#034;-y&#034;, &#034;&#064;modelcontextprotocol\/server-filesystem&#034;, &#034;\/path\/to\/dir&#034;]<br \/>\n    },<br \/>\n    &#034;code-review&#034;: {<br \/>\n      &#034;command&#034;: &#034;java&#034;,<br \/>\n      &#034;args&#034;: [&#034;-jar&#034;, &#034;\/opt\/mcp-servers\/code-review-server.jar&#034;],<br \/>\n      &#034;env&#034;: {<br \/>\n        &#034;JAVA_OPTS&#034;: &#034;-Xmx512m&#034;<br \/>\n      }<br \/>\n    }<br \/>\n  }<br \/>\n} <\/p>\n<p>\u4f18\u70b9&#xff1a;\u96f6\u7f51\u7edc\u5f00\u9500\u3001\u5929\u7136\u8fdb\u7a0b\u9694\u79bb\u3001\u65e0\u9700\u7aef\u53e3\u5206\u914d\u3002<\/p>\n<p>\u7f3a\u70b9&#xff1a;\u65e0\u6cd5\u8de8\u673a\u5668\u901a\u4fe1\u3001\u4e0d\u652f\u6301\u591a Client \u5171\u4eab\u3001Server \u5d29\u6e83\u9700\u8981 Client \u91cd\u65b0\u542f\u52a8\u8fdb\u7a0b\u3002<\/p>\n<p>\u5178\u578b\u573a\u666f&#xff1a;Claude Desktop \u7b49\u672c\u5730\u5e94\u7528\u901a\u8fc7 command: npx \u542f\u52a8\u672c\u5730 MCP Server\u3002<\/p>\n<p>\u8e29\u5751\u8bb0\u5f55&#xff1a;stdio \u6a21\u5f0f\u4e0b&#xff0c;Server \u8fdb\u7a0b\u7684 stderr \u8f93\u51fa\u4f1a\u88ab Host \u6355\u83b7\u5e76\u4f5c\u4e3a\u65e5\u5fd7\u8bb0\u5f55\u3002\u5982\u679c Server \u5728 stderr \u4e2d\u8f93\u51fa\u5927\u91cf\u8c03\u8bd5\u4fe1\u606f&#xff0c;\u53ef\u80fd\u5f71\u54cd Host \u7684\u6027\u80fd\u3002\u751f\u4ea7\u73af\u5883\u4e2d&#xff0c;\u5efa\u8bae\u5c06 Server \u7684\u65e5\u5fd7\u8f93\u51fa\u5230\u72ec\u7acb\u6587\u4ef6&#xff0c;\u800c\u975e stderr\u3002<\/p>\n<h4>4.2 SSE&#xff1a;HTTP \u957f\u8fde\u63a5\u6d41\u5f0f\u4f20\u8f93<\/h4>\n<p>Server \u4f5c\u4e3a HTTP \u670d\u52a1\u8fd0\u884c\u3002Client \u5148\u901a\u8fc7 GET \u8bf7\u6c42\u5efa\u7acb SSE \u957f\u8fde\u63a5&#xff0c;\u518d\u901a\u8fc7 POST \u8bf7\u6c42\u53d1\u9001 JSON-RPC \u6d88\u606f&#xff0c;\u54cd\u5e94\u901a\u8fc7 SSE \u6d41\u63a8\u9001\u56de\u6765&#xff1a;<\/p>\n<p>Client                          Server (HTTP \u670d\u52a1)<br \/>\n  \u2502                               \u2502<br \/>\n  \u2502\u2500\u2500\u2500\u2500 GET \/sse \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25ba\u2502<br \/>\n  \u2502\u25c4\u2500\u2500\u2500 SSE: event: endpoint \u2500\u2500\u2500\u2500\u2502  \u2190 \u8fd4\u56de\u6d88\u606f\u7aef\u70b9\u5730\u5740<br \/>\n  \u2502\u25c4\u2500\u2500\u2500 SSE: data: \/messages \u2500\u2500\u2500\u2500\u2502<br \/>\n  \u2502                               \u2502<br \/>\n  \u2502\u2500\u2500\u2500\u2500 POST \/messages \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25ba\u2502  \u2190 \u53d1\u9001 JSON-RPC \u8bf7\u6c42<br \/>\n  \u2502\u25c4\u2500\u2500\u2500 SSE: data: response \u2500\u2500\u2500\u2500\u2500\u2502  \u2190 \u901a\u8fc7 SSE \u6d41\u63a5\u6536\u54cd\u5e94 <\/p>\n<p>Nginx \u53cd\u5411\u4ee3\u7406\u914d\u7f6e&#xff08;\u751f\u4ea7\u73af\u5883\u5fc5\u505a&#xff09;&#xff1a;<\/p>\n<p>location \/mcp\/ {<br \/>\n    proxy_pass http:\/\/mcp-backend;<br \/>\n    proxy_http_version 1.1;<\/p>\n<p>    # \u5173\u952e&#xff1a;\u5173\u95ed\u5206\u5757\u4f20\u8f93\u7f16\u7801&#xff0c;SSE \u4e0d\u9700\u8981<br \/>\n    chunked_transfer_encoding off;<\/p>\n<p>    # \u5173\u952e&#xff1a;\u6e05\u9664 Connection \u5934&#xff0c;\u4fdd\u6301\u957f\u8fde\u63a5<br \/>\n    proxy_set_header Connection &#039;&#039;;<\/p>\n<p>    # \u5173\u952e&#xff1a;\u5c06\u8d85\u65f6\u8c03\u5927\u5230 3600 \u79d2\u4ee5\u4e0a<br \/>\n    # Nginx \u9ed8\u8ba4 60 \u79d2\u8d85\u65f6\u65ad\u5f00&#xff0c;\u4f1a\u5bfc\u81f4 SSE \u957f\u8fde\u63a5\u9891\u7e41\u4e2d\u65ad<br \/>\n    proxy_read_timeout 3600s;<br \/>\n    proxy_send_timeout 3600s;<\/p>\n<p>    # \u7f13\u51b2\u8bbe\u7f6e&#xff1a;\u5173\u95ed\u4ee3\u7406\u7f13\u51b2&#xff0c;\u786e\u4fdd\u5b9e\u65f6\u63a8\u9001<br \/>\n    proxy_buffering off;<br \/>\n    proxy_cache off;<\/p>\n<p>    # \u6807\u51c6\u4ee3\u7406\u5934<br \/>\n    proxy_set_header Host $host;<br \/>\n    proxy_set_header X-Real-IP $remote_addr;<br \/>\n    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;<br \/>\n} <\/p>\n<p>\u8e29\u5751\u8bb0\u5f55&#xff1a;SSE \u957f\u8fde\u63a5\u5728 Nginx \u53cd\u5411\u4ee3\u7406\u4e0b\u9ed8\u8ba4 60 \u79d2\u8d85\u65f6\u65ad\u5f00&#xff0c;\u8fd9\u662f\u751f\u4ea7\u73af\u5883\u4e2d\u6700\u5e38\u89c1\u7684\u6545\u969c\u4e4b\u4e00\u3002\u8868\u73b0\u4e3a\u5de5\u5177\u8c03\u7528\u5076\u5c14\u8d85\u65f6\u3001Client \u9891\u7e41\u91cd\u8fde\u3002\u89e3\u51b3\u65b9\u6848\u662f\u5c06 proxy_read_timeout \u8c03\u5927\u5230 3600 \u79d2\u4ee5\u4e0a\u3002\u540c\u65f6\u9700\u8981\u5173\u95ed proxy_buffering&#xff0c;\u5426\u5219 Nginx \u4f1a\u7f13\u51b2 SSE \u4e8b\u4ef6&#xff0c;\u5bfc\u81f4 Client \u6536\u4e0d\u5230\u5b9e\u65f6\u63a8\u9001\u3002<\/p>\n<h4>4.3 Streamable HTTP&#xff1a;\u65b0\u4e00\u4ee3\u63a8\u8350\u65b9\u5f0f<\/h4>\n<p>MCP \u534f\u8bae\u5728 2025 \u5e74\u521d\u5f15\u5165\u4e86 Streamable HTTP \u4f20\u8f93\u65b9\u5f0f&#xff0c;\u4f5c\u4e3a SSE \u7684\u66ff\u4ee3\u65b9\u6848\u3002\u5b83\u5c06\u6240\u6709\u901a\u4fe1\u7edf\u4e00\u5230\u6807\u51c6 HTTP \u8bf7\u6c42\/\u54cd\u5e94\u4e2d&#xff0c;\u652f\u6301\u670d\u52a1\u7aef\u6309\u9700\u5347\u7ea7\u4e3a SSE \u6d41\u3002<\/p>\n<p>\u6838\u5fc3\u8bbe\u8ba1\u601d\u8def&#xff1a;<\/p>\n<li>Client \u5411 Server \u7684\u5355\u4e00\u7aef\u70b9&#xff08;\u5982 \/mcp&#xff09;\u53d1\u9001 POST \u8bf7\u6c42&#xff0c;\u643a\u5e26 JSON-RPC \u6d88\u606f<\/li>\n<li>Server \u53ef\u4ee5\u9009\u62e9\u8fd4\u56de\u666e\u901a JSON \u54cd\u5e94&#xff08;\u9002\u7528\u4e8e\u7b80\u5355\u7684\u8bf7\u6c42-\u54cd\u5e94\u6a21\u5f0f&#xff09;<\/li>\n<li>\u6216\u8005\u901a\u8fc7 Content-Type: text\/event-stream \u5347\u7ea7\u4e3a SSE \u6d41&#xff08;\u9002\u7528\u4e8e\u9700\u8981\u6d41\u5f0f\u63a8\u9001\u7684\u573a\u666f&#xff09;<\/li>\n<li>\u65e0\u9700\u9884\u5148\u5efa\u7acb\u957f\u8fde\u63a5&#xff0c;\u4e5f\u4e0d\u9700\u8981\u50cf\u4f20\u7edf SSE \u90a3\u6837\u5148 GET \u518d POST<\/li>\n<p>\u8bf7\u6c42\u793a\u4f8b&#xff1a;<\/p>\n<p>POST \/mcp HTTP\/1.1<br \/>\nHost: mcp-server.example.com<br \/>\nContent-Type: application\/json<br \/>\nAccept: application\/json, text\/event-stream<\/p>\n<p>{<br \/>\n  &#034;jsonrpc&#034;: &#034;2.0&#034;,<br \/>\n  &#034;id&#034;: &#034;req-1&#034;,<br \/>\n  &#034;method&#034;: &#034;tools\/call&#034;,<br \/>\n  &#034;params&#034;: {<br \/>\n    &#034;name&#034;: &#034;searchDocs&#034;,<br \/>\n    &#034;arguments&#034;: { &#034;query&#034;: &#034;MCP \u534f\u8bae&#034; }<br \/>\n  }<br \/>\n} <\/p>\n<p>\u666e\u901a\u54cd\u5e94&#xff08;\u7b80\u5355\u8bf7\u6c42\u76f4\u63a5\u8fd4\u56de&#xff09;&#xff1a;<\/p>\n<p>HTTP\/1.1 200 OK<br \/>\nContent-Type: application\/json<\/p>\n<p>{<br \/>\n  &#034;jsonrpc&#034;: &#034;2.0&#034;,<br \/>\n  &#034;id&#034;: &#034;req-1&#034;,<br \/>\n  &#034;result&#034;: { &#034;content&#034;: [&#8230;] }<br \/>\n} <\/p>\n<p>\u6d41\u5f0f\u54cd\u5e94&#xff08;\u670d\u52a1\u7aef\u51b3\u5b9a\u5347\u7ea7\u4e3a SSE&#xff09;&#xff1a;<\/p>\n<p>HTTP\/1.1 200 OK<br \/>\nContent-Type: text\/event-stream<\/p>\n<p>event: message<br \/>\ndata: {&#034;jsonrpc&#034;:&#034;2.0&#034;,&#034;method&#034;:&#034;notifications\/progress&#034;,&#034;params&#034;:{&#034;progress&#034;:0.5}}<\/p>\n<p>event: message<br \/>\ndata: {&#034;jsonrpc&#034;:&#034;2.0&#034;,&#034;id&#034;:&#034;req-1&#034;,&#034;result&#034;:{&#034;content&#034;:[&#8230;]}} <\/p>\n<p>\u4f18\u70b9&#xff1a;\u65e0\u9700\u7ef4\u62a4\u957f\u8fde\u63a5&#xff0c;\u5bf9\u57fa\u7840\u8bbe\u65bd\u66f4\u53cb\u597d&#xff08;Nginx\u3001CDN\u3001API \u7f51\u5173\u65e0\u9700\u7279\u6b8a\u914d\u7f6e&#xff09;&#xff1b;\u652f\u6301\u65e0\u72b6\u6001\u90e8\u7f72&#xff08;Server \u53ef\u4ee5\u6a2a\u5411\u6269\u5c55&#xff09;&#xff1b;\u517c\u5bb9\u73b0\u6709\u7684 HTTP \u4e2d\u95f4\u4ef6&#xff08;\u8ba4\u8bc1\u3001\u9650\u6d41\u3001\u65e5\u5fd7&#xff09;\u3002<\/p>\n<p>Spring AI Streamable HTTP \u914d\u7f6e\u793a\u4f8b&#xff1a;<\/p>\n<p># Server \u7aef<br \/>\nspring:<br \/>\n  ai:<br \/>\n    mcp:<br \/>\n      server:<br \/>\n        enabled: true<br \/>\n        name: my-mcp-server<br \/>\n        version: 1.0.0<br \/>\n        type: SYNC<\/p>\n<p># Client \u7aef<br \/>\nspring:<br \/>\n  ai:<br \/>\n    mcp:<br \/>\n      client:<br \/>\n        enabled: true<br \/>\n        streamable-http:<br \/>\n          connections:<br \/>\n            my-server:<br \/>\n              url: http:\/\/mcp-server:8091<br \/>\n              endpoint: \/mcp<br \/>\n              timeout: 30000 <\/p>\n<p>Session \u7ba1\u7406\u673a\u5236&#xff1a;Streamable HTTP \u5f15\u5165\u4e86 Session \u6982\u5ff5\u3002Server \u5728\u9996\u6b21\u54cd\u5e94\u4e2d\u901a\u8fc7 Mcp-Session-Id \u54cd\u5e94\u5934\u8fd4\u56de\u4f1a\u8bdd ID&#xff0c;Client \u540e\u7eed\u8bf7\u6c42\u9700\u643a\u5e26\u8be5 ID&#xff1a;<\/p>\n<p># \u9996\u6b21\u8bf7\u6c42&#xff08;\u65e0 Session&#xff09;<br \/>\nPOST \/mcp HTTP\/1.1<br \/>\nContent-Type: application\/json<br \/>\n{&#034;jsonrpc&#034;:&#034;2.0&#034;,&#034;id&#034;:&#034;1&#034;,&#034;method&#034;:&#034;initialize&#034;,&#8230;}<\/p>\n<p># Server \u54cd\u5e94&#xff08;\u5206\u914d Session&#xff09;<br \/>\nHTTP\/1.1 200 OK<br \/>\nMcp-Session-Id: sess_abc123<br \/>\nContent-Type: application\/json<br \/>\n{&#034;jsonrpc&#034;:&#034;2.0&#034;,&#034;id&#034;:&#034;1&#034;,&#034;result&#034;:{&#8230;}}<\/p>\n<p># \u540e\u7eed\u8bf7\u6c42&#xff08;\u643a\u5e26 Session&#xff09;<br \/>\nPOST \/mcp HTTP\/1.1<br \/>\nMcp-Session-Id: sess_abc123<br \/>\nContent-Type: application\/json<br \/>\n{&#034;jsonrpc&#034;:&#034;2.0&#034;,&#034;id&#034;:&#034;2&#034;,&#034;method&#034;:&#034;tools\/list&#034;,&#8230;} <\/p>\n<p>\u8fd9\u79cd\u673a\u5236\u4f7f\u5f97 Server \u53ef\u4ee5\u5728\u9700\u8981\u65f6\u7ef4\u62a4\u4f1a\u8bdd\u72b6\u6001&#xff0c;\u540c\u65f6\u652f\u6301\u65e0\u72b6\u6001\u90e8\u7f72&#xff08;\u6b64\u65f6 Session ID \u4ec5\u7528\u4e8e\u8def\u7531&#xff09;\u3002<\/p>\n<h4>4.4 \u4e09\u79cd\u4f20\u8f93\u65b9\u5f0f\u5bf9\u6bd4<\/h4>\n<table>\n<tr>\u4f20\u8f93\u65b9\u5f0f\u901a\u4fe1\u6a21\u5f0f\u9002\u7528\u573a\u666f\u6ce8\u610f\u4e8b\u9879\u8fde\u63a5\u7ba1\u7406<\/tr>\n<tbody>\n<tr>\n<td>stdio<\/td>\n<td>\u672c\u5730\u7ba1\u9053<\/td>\n<td>\u672c\u5730 CLI \u5de5\u5177\u3001IDE \u63d2\u4ef6<\/td>\n<td>\u65e0\u6cd5\u8de8\u673a\u5668&#xff0c;\u4e0d\u652f\u6301\u591a Client<\/td>\n<td>Host \u7ba1\u7406\u8fdb\u7a0b\u751f\u547d\u5468\u671f<\/td>\n<\/tr>\n<tr>\n<td>SSE<\/td>\n<td>HTTP \u957f\u8fde\u63a5<\/td>\n<td>\u8fdc\u7a0b Web \u670d\u52a1\u3001\u5fae\u670d\u52a1<\/td>\n<td>\u9700\u914d\u7f6e Nginx \u8d85\u65f6&#xff0c;\u7ef4\u62a4\u957f\u8fde\u63a5<\/td>\n<td>Client \u7ef4\u62a4\u91cd\u8fde\u903b\u8f91<\/td>\n<\/tr>\n<tr>\n<td>Streamable HTTP<\/td>\n<td>\u6807\u51c6 HTTP&#xff08;\u53ef\u5347\u7ea7\u4e3a\u6d41&#xff09;<\/td>\n<td>\u63a8\u8350\u9ed8\u8ba4\u65b9\u5f0f<\/td>\n<td>\u65e0\u72b6\u6001\u53cb\u597d&#xff0c;\u57fa\u7840\u8bbe\u65bd\u517c\u5bb9\u597d<\/td>\n<td>\u65e0\u9700\u957f\u8fde\u63a5\u7ba1\u7406<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u9009\u578b\u5efa\u8bae&#xff1a;\u672c\u5730\u5f00\u53d1\u8c03\u8bd5\u7528 stdio&#xff0c;\u751f\u4ea7\u73af\u5883\u4f18\u5148\u9009\u62e9 Streamable HTTP\u3002\u5982\u679c Client SDK \u5c1a\u672a\u652f\u6301 Streamable HTTP&#xff0c;\u9000\u800c\u9009\u62e9 SSE&#xff0c;\u4f46\u52a1\u5fc5\u505a\u597d Nginx \u8d85\u65f6\u914d\u7f6e\u548c\u5fc3\u8df3\u4fdd\u6d3b\u3002<\/p>\n<hr \/>\n<h3>\u4e94\u3001\u534f\u8bae\u751f\u547d\u5468\u671f&#xff1a;\u4ece\u63e1\u624b\u5230\u8c03\u7528<\/h3>\n<p>Client \u4e0e Server \u5efa\u7acb\u8fde\u63a5\u540e&#xff0c;\u5fc5\u987b\u6309\u7167\u4e25\u683c\u7684\u65f6\u5e8f\u5b8c\u6210\u521d\u59cb\u5316\u63e1\u624b&#xff0c;\u624d\u80fd\u8fdb\u5165\u6b63\u5e38\u5de5\u4f5c\u72b6\u6001\u3002\u6574\u4e2a\u751f\u547d\u5468\u671f\u5206\u4e3a\u56db\u4e2a\u9636\u6bb5\u3002<\/p>\n<h4>5.1 \u9636\u6bb5\u4e00&#xff1a;\u521d\u59cb\u5316\u63e1\u624b<\/h4>\n<p>\u63e1\u624b\u662f Client \u548c Server \u5efa\u7acb\u4fe1\u4efb\u7684\u7b2c\u4e00\u6b65\u3002Client \u53d1\u9001 initialize \u8bf7\u6c42&#xff0c;\u643a\u5e26\u81ea\u8eab\u652f\u6301\u7684\u534f\u8bae\u7248\u672c\u548c\u80fd\u529b&#xff1a;<\/p>\n<p>\/\/ Client \u2192 Server&#xff1a;initialize \u8bf7\u6c42<br \/>\n{<br \/>\n  &#034;jsonrpc&#034;: &#034;2.0&#034;,<br \/>\n  &#034;id&#034;: &#034;init-1&#034;,<br \/>\n  &#034;method&#034;: &#034;initialize&#034;,<br \/>\n  &#034;params&#034;: {<br \/>\n    &#034;protocolVersion&#034;: &#034;2025-03-26&#034;,<br \/>\n    &#034;capabilities&#034;: {<br \/>\n      &#034;tools&#034;: {},<br \/>\n      &#034;resources&#034;: { &#034;subscribe&#034;: true }<br \/>\n    },<br \/>\n    &#034;clientInfo&#034;: {<br \/>\n      &#034;name&#034;: &#034;my-agent&#034;,<br \/>\n      &#034;version&#034;: &#034;1.0.0&#034;<br \/>\n    }<br \/>\n  }<br \/>\n} <\/p>\n<p>Server \u8fd4\u56de initialize \u54cd\u5e94&#xff0c;\u786e\u8ba4\u534f\u8bae\u7248\u672c\u3001\u58f0\u660e\u81ea\u8eab\u80fd\u529b&#xff1a;<\/p>\n<p>\/\/ Server \u2192 Client&#xff1a;initialize \u54cd\u5e94<br \/>\n{<br \/>\n  &#034;jsonrpc&#034;: &#034;2.0&#034;,<br \/>\n  &#034;id&#034;: &#034;init-1&#034;,<br \/>\n  &#034;result&#034;: {<br \/>\n    &#034;protocolVersion&#034;: &#034;2025-03-26&#034;,<br \/>\n    &#034;capabilities&#034;: {<br \/>\n      &#034;tools&#034;: { &#034;listChanged&#034;: true },<br \/>\n      &#034;resources&#034;: {},<br \/>\n      &#034;prompts&#034;: {}<br \/>\n    },<br \/>\n    &#034;serverInfo&#034;: {<br \/>\n      &#034;name&#034;: &#034;code-review-server&#034;,<br \/>\n      &#034;version&#034;: &#034;1.0.0&#034;<br \/>\n    }<br \/>\n  }<br \/>\n} <\/p>\n<p>\u968f\u540e&#xff0c;Client \u53d1\u9001 initialized \u901a\u77e5&#xff0c;\u786e\u8ba4\u63e1\u624b\u5b8c\u6210&#xff1a;<\/p>\n<p>\/\/ Client \u2192 Server&#xff1a;initialized \u901a\u77e5&#xff08;\u65e0\u9700\u54cd\u5e94&#xff09;<br \/>\n{<br \/>\n  &#034;jsonrpc&#034;: &#034;2.0&#034;,<br \/>\n  &#034;method&#034;: &#034;notifications\/initialized&#034;<br \/>\n} <\/p>\n<p>\u534f\u8bae\u7248\u672c\u534f\u5546\u89c4\u5219&#xff1a;protocolVersion \u91c7\u7528\u65e5\u671f\u683c\u5f0f&#xff08;\u5982 &#034;2025-03-26&#034;&#xff09;\u3002\u5982\u679c Client \u8bf7\u6c42\u7684\u7248\u672c Server \u4e0d\u652f\u6301&#xff0c;Server \u5e94\u8fd4\u56de\u9519\u8bef&#xff0c;Client \u964d\u7ea7\u91cd\u8bd5\u3002\u53cc\u65b9\u53d6\u90fd\u652f\u6301\u7684\u6700\u9ad8\u517c\u5bb9\u7248\u672c\u3002<\/p>\n<h4>5.2 \u9636\u6bb5\u4e8c&#xff1a;\u80fd\u529b\u534f\u5546<\/h4>\n<p>\u80fd\u529b\u534f\u5546\u662f MCP \u7684\u5173\u952e\u8bbe\u8ba1\u3002\u63e1\u624b\u54cd\u5e94\u4e2d\u7684 capabilities \u5b57\u6bb5\u662f Server \u7684&#034;\u80fd\u529b\u6e05\u5355&#034;&#xff1a;<\/p>\n<table>\n<tr>\u80fd\u529b\u58f0\u660e\u542b\u4e49Client \u884c\u4e3a<\/tr>\n<tbody>\n<tr>\n<td>tools: {}<\/td>\n<td>Server \u63d0\u4f9b\u53ef\u8c03\u7528\u7684\u5de5\u5177<\/td>\n<td>Client \u53ef\u4ee5\u8c03\u7528 tools\/list \u548c tools\/call<\/td>\n<\/tr>\n<tr>\n<td>tools.listChanged: true<\/td>\n<td>\u5de5\u5177\u5217\u8868\u53ef\u80fd\u52a8\u6001\u53d8\u5316<\/td>\n<td>Client \u76d1\u542c notifications\/tools\/list_changed<\/td>\n<\/tr>\n<tr>\n<td>resources: {}<\/td>\n<td>Server \u63d0\u4f9b\u53ea\u8bfb\u6570\u636e\u6e90<\/td>\n<td>Client \u53ef\u4ee5\u8c03\u7528 resources\/list \u548c resources\/read<\/td>\n<\/tr>\n<tr>\n<td>resources.subscribe: true<\/td>\n<td>\u652f\u6301\u8d44\u6e90\u53d8\u5316\u8ba2\u9605<\/td>\n<td>Client \u53ef\u4ee5\u8c03\u7528 resources\/subscribe<\/td>\n<\/tr>\n<tr>\n<td>prompts: {}<\/td>\n<td>\u63d0\u4f9b\u9884\u5b9a\u4e49 Prompt \u6a21\u677f<\/td>\n<td>Client \u53ef\u4ee5\u8c03\u7528 prompts\/list \u548c prompts\/get<\/td>\n<\/tr>\n<tr>\n<td>prompts.listChanged: true<\/td>\n<td>Prompt \u5217\u8868\u53ef\u80fd\u52a8\u6001\u53d8\u5316<\/td>\n<td>Client \u76d1\u542c notifications\/prompts\/list_changed<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Client \u6839\u636e Server \u7684\u80fd\u529b\u58f0\u660e\u51b3\u5b9a\u540e\u7eed\u4ea4\u4e92\u65b9\u5f0f\u2014\u2014\u5982\u679c Server \u4e0d\u58f0\u660e resources&#xff0c;Client \u5c31\u4e0d\u4f1a\u5c1d\u8bd5\u5217\u51fa\u8d44\u6e90\u3002\u8fd9\u79cd\u53cc\u5411\u58f0\u660e\u673a\u5236\u4f7f\u5f97\u534f\u8bae\u5177\u6709\u826f\u597d\u7684\u53ef\u6269\u5c55\u6027\u3002<\/p>\n<p>\u5b8c\u6574\u7684\u63e1\u624b &#043; \u80fd\u529b\u534f\u5546\u65f6\u5e8f\u56fe&#xff1a;<\/p>\n<p>Client                                          Server<br \/>\n  \u2502                                                \u2502<br \/>\n  \u2502\u2500\u2500\u2500\u2500 initialize \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25ba\u2502<br \/>\n  \u2502     {protocolVersion, capabilities, clientInfo} \u2502<br \/>\n  \u2502                                                \u2502<br \/>\n  \u2502\u25c4\u2500\u2500\u2500\u2500 initialize response \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2502<br \/>\n  \u2502     {protocolVersion, capabilities, serverInfo} \u2502<br \/>\n  \u2502                                                \u2502<br \/>\n  \u2502\u2500\u2500\u2500\u2500 notifications\/initialized \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25ba\u2502  &#xff08;\u63e1\u624b\u5b8c\u6210&#xff09;<br \/>\n  \u2502                                                \u2502<br \/>\n  \u2502     \u2190 \u6839\u636e capabilities \u51b3\u5b9a\u540e\u7eed\u884c\u4e3a \u2192          \u2502<br \/>\n  \u2502                                                \u2502<br \/>\n  \u2502\u2500\u2500\u2500\u2500 tools\/list \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25ba\u2502  &#xff08;\u4ec5\u5f53 Server \u58f0\u660e\u4e86 tools&#xff09;<br \/>\n  \u2502                                                \u2502<br \/>\n  \u2502\u25c4\u2500\u2500\u2500\u2500 tools\/list response \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2502<br \/>\n  \u2502     {tools: [&#8230;]}                              \u2502<br \/>\n  \u2502                                                \u2502<br \/>\n  \u2502\u2500\u2500\u2500\u2500 tools\/call \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u25ba\u2502  &#xff08;\u8c03\u7528\u5177\u4f53\u5de5\u5177&#xff09;<br \/>\n  \u2502     {name: &#034;searchDocs&#034;, arguments: {&#8230;}}      \u2502<br \/>\n  \u2502                                                \u2502<br \/>\n  \u2502\u25c4\u2500\u2500\u2500\u2500 tools\/call response \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2502<br \/>\n  \u2502     {content: [{type: &#034;text&#034;, text: &#034;&#8230;&#034;}]}    \u2502 <\/p>\n<p>\u80fd\u529b\u534f\u5546\u8fd8\u652f\u6301\u6e10\u8fdb\u5f0f\u589e\u5f3a&#xff1a;Client \u53ef\u4ee5\u53ea\u8bf7\u6c42\u81ea\u5df1\u9700\u8981\u7684\u80fd\u529b\u5b50\u96c6&#xff0c;Server \u4e5f\u53ef\u4ee5\u6839\u636e Client \u7684\u80fd\u529b\u58f0\u660e\u9009\u62e9\u6027\u5730\u66b4\u9732\u5de5\u5177\u3002\u4f8b\u5982&#xff0c;\u4e00\u4e2a\u9762\u5411\u7b80\u5355 Agent \u7684 Client \u53ef\u80fd\u53ea\u58f0\u660e tools \u80fd\u529b&#xff0c;Server \u5c31\u4e0d\u4f1a\u66b4\u9732\u590d\u6742\u7684 resources \u548c prompts\u3002<\/p>\n<h4>5.3 \u9636\u6bb5\u4e09&#xff1a;\u5de5\u5177\u53d1\u73b0<\/h4>\n<p>\u63e1\u624b\u5b8c\u6210\u540e&#xff0c;Client \u53d1\u9001 tools\/list \u8bf7\u6c42&#xff0c;\u83b7\u53d6 Server \u4e0a\u6240\u6709\u53ef\u7528\u5de5\u5177\u7684\u5217\u8868\u3002\u54cd\u5e94\u4e2d\u6bcf\u4e2a\u5de5\u5177\u5305\u542b\u540d\u79f0\u3001\u63cf\u8ff0\u548c\u53c2\u6570 Schema&#xff08;JSON Schema \u683c\u5f0f&#xff09;&#xff1a;<\/p>\n<p>\/\/ tools\/list \u54cd\u5e94\u793a\u4f8b<br \/>\n{<br \/>\n  &#034;jsonrpc&#034;: &#034;2.0&#034;,<br \/>\n  &#034;id&#034;: &#034;list-1&#034;,<br \/>\n  &#034;result&#034;: {<br \/>\n    &#034;tools&#034;: [<br \/>\n      {<br \/>\n        &#034;name&#034;: &#034;searchDocs&#034;,<br \/>\n        &#034;description&#034;: &#034;\u641c\u7d22\u9879\u76ee\u6587\u6863&#xff0c;\u8fd4\u56de\u6700\u5339\u914d\u7684\u6587\u6863\u7247\u6bb5&#034;,<br \/>\n        &#034;inputSchema&#034;: {<br \/>\n          &#034;type&#034;: &#034;object&#034;,<br \/>\n          &#034;properties&#034;: {<br \/>\n            &#034;query&#034;: {<br \/>\n              &#034;type&#034;: &#034;string&#034;,<br \/>\n              &#034;description&#034;: &#034;\u641c\u7d22\u5173\u952e\u8bcd&#034;<br \/>\n            },<br \/>\n            &#034;topK&#034;: {<br \/>\n              &#034;type&#034;: &#034;integer&#034;,<br \/>\n              &#034;description&#034;: &#034;\u8fd4\u56de\u7ed3\u679c\u6570\u91cf&#034;,<br \/>\n              &#034;default&#034;: 5<br \/>\n            }<br \/>\n          },<br \/>\n          &#034;required&#034;: [&#034;query&#034;]<br \/>\n        }<br \/>\n      },<br \/>\n      {<br \/>\n        &#034;name&#034;: &#034;executeQuery&#034;,<br \/>\n        &#034;description&#034;: &#034;\u6267\u884c\u53ea\u8bfb SQL \u67e5\u8be2&#xff0c;\u8fd4\u56de\u7ed3\u679c\u96c6&#034;,<br \/>\n        &#034;inputSchema&#034;: {<br \/>\n          &#034;type&#034;: &#034;object&#034;,<br \/>\n          &#034;properties&#034;: {<br \/>\n            &#034;sql&#034;: {<br \/>\n              &#034;type&#034;: &#034;string&#034;,<br \/>\n              &#034;description&#034;: &#034;SELECT \u8bed\u53e5&#xff08;\u4ec5\u652f\u6301\u53ea\u8bfb\u67e5\u8be2&#xff09;&#034;<br \/>\n            }<br \/>\n          },<br \/>\n          &#034;required&#034;: [&#034;sql&#034;]<br \/>\n        }<br \/>\n      }<br \/>\n    ]<br \/>\n  }<br \/>\n} <\/p>\n<p>\u8fd9\u4e2a\u5217\u8868\u5728\u8fd0\u884c\u65f6\u76f8\u5bf9\u7a33\u5b9a&#xff0c;Client \u4f1a\u7f13\u5b58\u7ed3\u679c\u4ee5\u907f\u514d\u6bcf\u6b21 LLM \u63a8\u7406\u90fd\u53d1\u8d77\u7f51\u7edc\u8bf7\u6c42\u3002\u5f53 Server \u58f0\u660e\u4e86 listChanged: true \u65f6&#xff0c;Client \u4f1a\u76d1\u542c notifications\/tools\/list_changed \u901a\u77e5&#xff0c;\u5728\u5de5\u5177\u53d8\u66f4\u65f6\u81ea\u52a8\u5237\u65b0\u7f13\u5b58\u3002<\/p>\n<p>\u6027\u80fd\u6570\u636e&#xff1a;\u5bf9\u4e8e\u6709 20&#043; \u5de5\u5177\u7684\u5927\u578b\u7cfb\u7edf&#xff0c;\u5de5\u5177\u5217\u8868\u7f13\u5b58\u53ef\u4ee5\u5c06\u9996\u6b21\u63a8\u7406\u5ef6\u8fdf\u964d\u4f4e 50-100ms\u3002Spring AI \u7684 McpSyncClient \u9ed8\u8ba4\u7f13\u5b58\u5de5\u5177\u5217\u8868&#xff0c;\u4ec5\u5728\u6536\u5230\u53d8\u66f4\u901a\u77e5\u65f6\u5237\u65b0\u3002<\/p>\n<h4>5.4 \u9636\u6bb5\u56db&#xff1a;\u5de5\u5177\u8c03\u7528<\/h4>\n<p>\u4e00\u5207\u5c31\u7eea\u540e&#xff0c;LLM \u51b3\u5b9a\u9700\u8981\u8c03\u7528\u67d0\u4e2a\u5de5\u5177\u65f6&#xff0c;Client \u53d1\u9001 tools\/call \u8bf7\u6c42&#xff0c;Server \u6267\u884c\u5de5\u5177\u903b\u8f91\u5e76\u8fd4\u56de\u7ed3\u679c&#xff1a;<\/p>\n<p>\/\/ tools\/call \u8bf7\u6c42<br \/>\n{<br \/>\n  &#034;jsonrpc&#034;: &#034;2.0&#034;,<br \/>\n  &#034;id&#034;: &#034;call-1&#034;,<br \/>\n  &#034;method&#034;: &#034;tools\/call&#034;,<br \/>\n  &#034;params&#034;: {<br \/>\n    &#034;name&#034;: &#034;searchDocs&#034;,<br \/>\n    &#034;arguments&#034;: {<br \/>\n      &#034;query&#034;: &#034;MCP \u534f\u8bae\u63e1\u624b\u6d41\u7a0b&#034;,<br \/>\n      &#034;topK&#034;: 3<br \/>\n    }<br \/>\n  }<br \/>\n}<\/p>\n<p>\/\/ tools\/call \u54cd\u5e94<br \/>\n{<br \/>\n  &#034;jsonrpc&#034;: &#034;2.0&#034;,<br \/>\n  &#034;id&#034;: &#034;call-1&#034;,<br \/>\n  &#034;result&#034;: {<br \/>\n    &#034;content&#034;: [<br \/>\n      {<br \/>\n        &#034;type&#034;: &#034;text&#034;,<br \/>\n        &#034;text&#034;: &#034;MCP \u63e1\u624b\u6d41\u7a0b\u5206\u4e3a\u56db\u6b65&#xff1a;1) Client \u53d1\u9001 initialize \u8bf7\u6c42&#8230;2) Server \u8fd4\u56de capabilities&#8230;&#034;<br \/>\n      },<br \/>\n      {<br \/>\n        &#034;type&#034;: &#034;text&#034;,<br \/>\n        &#034;text&#034;: &#034;\u80fd\u529b\u534f\u5546\u9636\u6bb5&#xff0c;Server \u901a\u8fc7 capabilities \u5b57\u6bb5\u58f0\u660e\u652f\u6301\u7684\u5de5\u5177\u7c7b\u578b&#8230;&#034;<br \/>\n      }<br \/>\n    ],<br \/>\n    &#034;isError&#034;: false<br \/>\n  }<br \/>\n} <\/p>\n<p>Client \u5c06\u7ed3\u679c\u6ce8\u5165 LLM \u4e0a\u4e0b\u6587&#xff0c;LLM \u57fa\u4e8e\u7ed3\u679c\u751f\u6210\u6700\u7ec8\u56de\u7b54\u3002\u8fd9\u5c31\u662f MCP \u7684\u5b8c\u6574\u5de5\u4f5c\u6d41&#xff1a;\u63e1\u624b \u2192 \u534f\u5546 \u2192 \u53d1\u73b0 \u2192 \u8c03\u7528&#xff0c;\u534f\u8bae\u5c42\u9762\u7684\u4e8b\u60c5\u5230\u6b64\u7ed3\u675f\u3002<\/p>\n<h4>5.5 \u9519\u8bef\u5904\u7406\u4e0e\u91cd\u8fde\u673a\u5236<\/h4>\n<p>\u9664\u4e86\u534f\u8bae\u5c42\u9519\u8bef&#xff0c;\u7f51\u7edc\u5c42\u9519\u8bef&#xff08;\u8fde\u63a5\u65ad\u5f00\u3001\u8d85\u65f6\u3001Server \u4e0d\u53ef\u8fbe&#xff09;\u9700\u8981 Client \u81ea\u884c\u5904\u7406\u3002\u751f\u4ea7\u73af\u5883\u4e2d&#xff0c;\u5065\u58ee\u7684\u91cd\u8fde\u673a\u5236\u662f\u4fdd\u969c\u53ef\u7528\u6027\u7684\u5173\u952e\u3002<\/p>\n<p>Spring AI MCP Client \u7684\u5185\u7f6e\u91cd\u8fde\u7b56\u7565&#xff1a;<\/p>\n<p>McpSyncClient client &#061; McpClient.sync(transport)<br \/>\n    .clientId(&#034;my-agent-client&#034;)<br \/>\n    .clientVersion(&#034;1.0.0&#034;)<br \/>\n    \/\/ \u91cd\u8fde\u914d\u7f6e<br \/>\n    .retryCount(3)                    \/\/ \u6700\u5927\u91cd\u8bd5\u6b21\u6570<br \/>\n    .retryInterval(Duration.ofSeconds(1))  \/\/ \u57fa\u7840\u91cd\u8bd5\u95f4\u9694<br \/>\n    .build();<\/p>\n<p>try {<br \/>\n    client.initialize();<br \/>\n} catch (McpConnectionException e) {<br \/>\n    \/\/ \u8fde\u63a5\u5931\u8d25&#xff0c;Client \u8fdb\u5165\u65ad\u5f00\u72b6\u6001<br \/>\n    \/\/ \u4e0b\u6b21\u8c03\u7528\u65f6\u4f1a\u81ea\u52a8\u5c1d\u8bd5\u91cd\u65b0\u8fde\u63a5<br \/>\n    log.error(&#034;MCP Server \u8fde\u63a5\u5931\u8d25: {}&#034;, e.getMessage());<br \/>\n} <\/p>\n<p>\u91cd\u8fde\u95f4\u9694\u91c7\u7528\u6307\u6570\u9000\u907f\u7b56\u7565&#xff08;1s \u2192 2s \u2192 4s&#xff09;&#xff0c;\u907f\u514d\u5728\u7f51\u7edc\u6545\u969c\u65f6\u5bf9 Server \u9020\u6210&#034;\u91cd\u8fde\u98ce\u66b4&#034;\u3002\u8d85\u8fc7\u6700\u5927\u91cd\u8bd5\u6b21\u6570\u540e&#xff0c;Client \u8fdb\u5165\u65ad\u5f00\u72b6\u6001&#xff0c;\u7b49\u5f85\u4e0b\u6b21\u8c03\u7528\u65f6\u91cd\u65b0\u5c1d\u8bd5\u8fde\u63a5\u3002<\/p>\n<p>\u751f\u4ea7\u73af\u5883\u5efa\u8bae&#xff1a;\u5728 Client \u524d\u52a0\u4e00\u5c42\u5065\u5eb7\u68c0\u67e5&#xff0c;\u5b9a\u671f\u53d1\u9001\u63a2\u6d3b\u8bf7\u6c42&#xff0c;\u8fde\u7eed\u5931\u8d25 3 \u6b21\u5219\u6807\u8bb0 Server \u4e3a\u4e0d\u53ef\u7528&#xff0c;\u544a\u8b66\u8fd0\u7ef4\u4eba\u5458&#xff1a;<\/p>\n<p>&#064;Component<br \/>\npublic class McpHealthIndicator implements HealthIndicator {<\/p>\n<p>    &#064;Autowired<br \/>\n    private McpSyncClient mcpClient;<\/p>\n<p>    &#064;Override<br \/>\n    public Health health() {<br \/>\n        try {<br \/>\n            \/\/ \u7528 listTools \u505a\u63a2\u6d3b&#xff08;\u8f7b\u91cf\u4e14\u5e42\u7b49&#xff09;<br \/>\n            mcpClient.listTools();<br \/>\n            return Health.up()<br \/>\n                .withDetail(&#034;server&#034;, &#034;mcp-server&#034;)<br \/>\n                .withDetail(&#034;tools&#034;, mcpClient.listTools().tools().size())<br \/>\n                .build();<br \/>\n        } catch (Exception e) {<br \/>\n            return Health.down()<br \/>\n                .withDetail(&#034;error&#034;, e.getMessage())<br \/>\n                .build();<br \/>\n        }<br \/>\n    }<br \/>\n} <\/p>\n<p>\u8fde\u63a5\u63a2\u6d4b\u7684\u9009\u578b\u7ec6\u8282&#xff1a;\u5bf9\u4e8e SSE \u4f20\u8f93&#xff0c;\u5065\u5eb7\u63a2\u6d4b\u5efa\u8bae\u4f7f\u7528 TCP \u7aef\u53e3\u63a2\u6d4b\u800c\u975e HTTP GET\u3002\u539f\u56e0\u662f GET \u8bf7\u6c42\u4f1a\u6253\u5f00 SSE \u957f\u8fde\u63a5\u5e76\u963b\u585e&#xff0c;\u5f71\u54cd\u6b63\u5e38\u7684\u8fde\u63a5\u7ba1\u7406\u3002TCP \u63a2\u6d4b\u53ea\u9a8c\u8bc1\u7aef\u53e3\u53ef\u8fbe\u6027&#xff0c;2 \u79d2\u8d85\u65f6\u5feb\u901f\u8fd4\u56de&#xff1a;<\/p>\n<p> \/\/ SSE \u7528 TCP \u63a2\u6d4b&#xff08;\u4e0d\u53d1 HTTP GET \u907f\u514d\u963b\u585e&#xff09;<br \/>\ntry (Socket socket &#061; new Socket()) {<br \/>\n    socket.connect(new InetSocketAddress(host, port), 2000);<br \/>\n    return ProbeResult.ok(id);<br \/>\n} catch (Exception e) {<br \/>\n    return ProbeResult.failed(id, e.getMessage());<br \/>\n} <\/p>\n<hr \/>\n<h3>\u516d\u3001\u4e09\u5927\u539f\u8bed&#xff1a;Tools \/ Resources \/ Prompts<\/h3>\n<p>MCP Server \u901a\u8fc7\u4e09\u79cd\u539f\u8bed&#xff08;Primitive&#xff09;\u5411\u5916\u66b4\u9732\u80fd\u529b\u3002\u7406\u89e3\u8fd9\u4e09\u8005\u7684\u5b9a\u4f4d\u548c\u533a\u522b&#xff0c;\u662f\u6b63\u786e\u4f7f\u7528 MCP \u7684\u524d\u63d0\u3002<\/p>\n<h4>6.1 Tools&#xff08;\u5de5\u5177&#xff09;&#xff1a;\u53ef\u88ab LLM \u8c03\u7528\u7684\u51fd\u6570<\/h4>\n<p>Tool \u662f MCP \u6700\u6838\u5fc3\u7684\u539f\u8bed\u3002\u6bcf\u4e2a Tool \u6709\u540d\u79f0\u3001\u63cf\u8ff0\u3001\u8f93\u5165\u53c2\u6570 Schema&#xff08;JSON Schema \u683c\u5f0f&#xff09;\u548c\u8f93\u51fa\u683c\u5f0f\u3002LLM \u901a\u8fc7 Tool \u4e0e\u5916\u90e8\u4e16\u754c\u4ea4\u4e92\u2014\u2014\u641c\u7d22\u6587\u6863\u3001\u67e5\u8be2\u6570\u636e\u5e93\u3001\u6267\u884c\u4ee3\u7801\u3001\u8c03\u7528 API\u3002Tool \u7684\u6838\u5fc3\u7279\u5f81\u662f\u6709\u526f\u4f5c\u7528&#xff1a;\u5b83\u4f1a\u6267\u884c\u64cd\u4f5c\u3001\u6539\u53d8\u72b6\u6001\u3001\u8fd4\u56de\u65b0\u6570\u636e\u3002<\/p>\n<p>\u63cf\u8ff0&#xff08;description&#xff09;\u5b57\u6bb5\u5bf9 Tool \u81f3\u5173\u91cd\u8981\u2014\u2014\u5b83\u662f LLM \u7406\u89e3\u5de5\u5177\u7528\u9014\u7684\u552f\u4e00\u4f9d\u636e\u3002\u6765\u770b\u4e00\u4e2a\u6b63\u53cd\u5bf9\u6bd4&#xff1a;<\/p>\n<table>\n<tr>\u63cf\u8ff0\u8d28\u91cf\u793a\u4f8bLLM \u8c03\u7528\u51c6\u786e\u7387<\/tr>\n<tbody>\n<tr>\n<td>\u274c \u592a\u6a21\u7cca<\/td>\n<td>&#034;\u5ba1\u67e5\u4ee3\u7801&#034;<\/td>\n<td>~60%&#xff08;LLM \u4e0d\u786e\u5b9a\u4f55\u65f6\u8c03\u7528&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u26a0\ufe0f \u4e00\u822c<\/td>\n<td>&#034;\u5bf9\u4ee3\u7801\u8fdb\u884c\u9759\u6001\u5206\u6790&#034;<\/td>\n<td>~75%<\/td>\n<\/tr>\n<tr>\n<td>\u2705 \u5177\u4f53\u6e05\u6670<\/td>\n<td>&#034;\u5bf9 Java \u4ee3\u7801\u4ed3\u5e93\u8fdb\u884c\u9759\u6001\u5206\u6790&#xff0c;\u8fd4\u56de\u6f5c\u5728\u7f3a\u9677\u5217\u8868\u548c\u4fee\u590d\u5efa\u8bae&#034;<\/td>\n<td>~95%<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u7ecf\u9a8c\u6cd5\u5219&#xff1a;\u63cf\u8ff0\u4e2d\u5e94\u5305\u542b\u300c\u505a\u4ec0\u4e48\u300d\u548c\u300c\u8fd4\u56de\u4ec0\u4e48\u300d\u4e24\u4e2a\u7ef4\u5ea6\u3002\u66f4\u597d\u7684\u505a\u6cd5\u662f\u52a0\u4e0a\u300c\u4f55\u65f6\u4f7f\u7528 \/ \u4f55\u65f6\u4e0d\u4f7f\u7528\u300d\u7684\u6307\u5f15&#xff1a;<\/p>\n<p>&#064;Tool(description &#061; &#034;&#034;&#034;<br \/>\n    \u5ba1\u67e5 Java \u4ee3\u7801\u5e76\u63d0\u4f9b\u6539\u8fdb\u5efa\u8bae\u3002<br \/>\n    \u5f53\u7528\u6237\u63d0\u4ea4\u4ee3\u7801\u7247\u6bb5\u8981\u6c42 review \u65f6\u4f7f\u7528\u6b64\u5de5\u5177\u3002<br \/>\n    \u4e0d\u8981\u7528\u4e8e&#xff1a;\u4ee3\u7801\u683c\u5f0f\u5316\u3001\u7f16\u8bd1\u68c0\u67e5\u7b49\u975e\u5ba1\u67e5\u573a\u666f\u3002<br \/>\n    &#034;&#034;&#034;) <\/p>\n<h4>6.2 Resources&#xff08;\u8d44\u6e90&#xff09;&#xff1a;\u53ef\u88ab\u8bfb\u53d6\u7684\u6570\u636e\u6e90<\/h4>\n<p>Resource \u63d0\u4f9b\u53ea\u8bfb\u6570\u636e&#xff0c;\u4f9b LLM \u83b7\u53d6\u4e0a\u4e0b\u6587\u4fe1\u606f\u3002\u4e0e Tool \u7684\u533a\u522b\u5728\u4e8e&#xff1a;Tool \u662f&#034;\u505a\u4e8b&#034;&#xff08;\u6709\u526f\u4f5c\u7528&#xff09;&#xff0c;Resource \u662f&#034;\u770b\u4e1c\u897f&#034;&#xff08;\u53ea\u8bfb&#xff09;\u3002<\/p>\n<p>\u4f8b\u5982&#xff0c;\u4e00\u4e2a\u6587\u4ef6\u7cfb\u7edf Server \u53ef\u4ee5\u66b4\u9732 file:\/\/\/path\/to\/config.yml \u683c\u5f0f\u7684 Resource&#xff0c;\u8ba9 LLM \u5728\u6267\u884c\u5de5\u5177\u8c03\u7528\u524d\u5148\u8bfb\u53d6\u9879\u76ee\u914d\u7f6e\u3002Resource \u652f\u6301 URI \u5bfb\u5740\u548c\u53ef\u9009\u7684\u8ba2\u9605\u673a\u5236\u2014\u2014\u5f53\u8d44\u6e90\u5185\u5bb9\u53d1\u751f\u53d8\u5316\u65f6&#xff0c;Server \u53ef\u4ee5\u4e3b\u52a8\u901a\u77e5 Client\u3002<\/p>\n<h4>6.3 Prompts&#xff08;\u63d0\u793a\u6a21\u677f&#xff09;&#xff1a;\u9884\u5b9a\u4e49\u7684\u8c03\u7528\u6a21\u677f<\/h4>\n<p>Prompt \u662f Server \u9884\u5b9a\u4e49\u7684 Prompt \u6a21\u677f\u3002Client \u83b7\u53d6\u6a21\u677f\u540e\u586b\u5145\u53c2\u6570&#xff0c;\u518d\u53d1\u9001\u7ed9 LLM\u3002\u4f8b\u5982&#xff0c;\u4e00\u4e2a\u4ee3\u7801\u5ba1\u67e5 Server \u53ef\u4ee5\u66b4\u9732\u4e00\u4e2a review-prompt \u6a21\u677f&#xff0c;\u81ea\u52a8\u586b\u5145\u4ed3\u5e93\u8def\u5f84\u548c\u5206\u652f\u4fe1\u606f&#xff0c;\u7701\u53bb Client \u62fc\u63a5\u590d\u6742 Prompt \u7684\u5de5\u4f5c\u3002<\/p>\n<h4>6.4 \u4e09\u8005\u5bf9\u6bd4<\/h4>\n<table>\n<tr>\u539f\u8bed\u5b9a\u4f4d\u662f\u5426\u5fc5\u9700\u6838\u5fc3\u7279\u5f81<\/tr>\n<tbody>\n<tr>\n<td>Tools<\/td>\n<td>\u53ef\u6267\u884c\u7684\u52a8\u4f5c<\/td>\n<td>\u662f<\/td>\n<td>\u6709\u526f\u4f5c\u7528&#xff0c;LLM \u4e3b\u52a8\u8c03\u7528&#xff0c;\u53c2\u6570\u9700 JSON Schema<\/td>\n<\/tr>\n<tr>\n<td>Resources<\/td>\n<td>\u53ea\u8bfb\u7684\u6570\u636e\u6e90<\/td>\n<td>\u5426<\/td>\n<td>\u65e0\u526f\u4f5c\u7528&#xff0c;\u63d0\u4f9b\u4e0a\u4e0b\u6587&#xff0c;\u652f\u6301 URI \u5bfb\u5740\u548c\u8ba2\u9605<\/td>\n<\/tr>\n<tr>\n<td>Prompts<\/td>\n<td>\u9884\u5b9a\u4e49\u7684\u6a21\u677f<\/td>\n<td>\u5426<\/td>\n<td>Server \u7aef\u5b9a\u4e49&#xff0c;Client \u586b\u5145\u53c2\u6570&#xff0c;\u964d\u4f4e\u62fc\u63a5\u6210\u672c<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5b9e\u9645\u5f00\u53d1\u4e2d&#xff0c;\u5927\u591a\u6570 MCP Server \u53ea\u66b4\u9732 Tools&#xff0c;\u8fd9\u662f MCP \u6700\u6838\u5fc3\u7684\u80fd\u529b\u3002Resources \u548c Prompts \u662f\u53ef\u9009\u589e\u5f3a\u2014\u2014\u5f53\u9700\u8981\u8ba9 LLM \u611f\u77e5\u7ed3\u6784\u5316\u6570\u636e\u6216\u590d\u7528\u590d\u6742 Prompt \u65f6&#xff0c;\u518d\u5f15\u5165\u8fd9\u4e24\u8005\u3002<\/p>\n<hr \/>\n<h3>\u4e03\u3001MCP \u4e0e A2A&#xff1a;\u4e24\u5957\u534f\u8bae&#xff0c;\u4e24\u4e2a\u5c42\u9762<\/h3>\n<p>2025 \u5e74 4 \u6708&#xff0c;Google \u53d1\u5e03\u4e86 A2A&#xff08;Agent-to-Agent&#xff09;\u534f\u8bae\u3002\u5f88\u591a\u4eba\u5bb9\u6613\u628a A2A \u548c MCP \u641e\u6df7&#xff0c;\u56e0\u4e3a\u5b83\u4eec\u90fd\u6d89\u53ca&#034;Agent \u8fde\u63a5&#034;\u3002\u4f46\u5b83\u4eec\u89e3\u51b3\u7684\u662f\u5b8c\u5168\u4e0d\u540c\u7684\u95ee\u9898\u3002<\/p>\n<p>\u6253\u4e00\u4e2a\u6bd4\u65b9&#xff1a;MCP \u5c31\u50cf\u4f60\u7528\u624b\u673a\u8c03\u7528\u5916\u5356 App\u2014\u2014\u4f60&#xff08;Agent&#xff09;\u544a\u8bc9 App&#xff08;Tool&#xff09;&#034;\u6211\u8981\u4e00\u4efd\u5bab\u4fdd\u9e21\u4e01&#034;&#xff0c;App \u8fd4\u56de\u7ed3\u679c\u3002\u6574\u4e2a\u8fc7\u7a0b App \u4e0d\u4f1a\u4e3b\u52a8\u7ed9\u4f60\u53d1\u6d88\u606f&#xff0c;\u4e5f\u4e0d\u4f1a\u62d2\u7edd\u4f60\u7684\u8bf7\u6c42\u3002\u800c A2A \u5c31\u50cf\u4f60\u548c\u540c\u4e8b\u534f\u4f5c\u5b8c\u6210\u4e00\u4e2a\u9879\u76ee\u2014\u2014\u4f60&#xff08;Agent&#xff09;\u544a\u8bc9\u540c\u4e8b&#xff08;Agent&#xff09;&#034;\u5e2e\u6211\u5ba1\u67e5\u4e00\u4e0b\u8fd9\u4e2a\u65b9\u6848&#034;&#xff0c;\u540c\u4e8b\u53ef\u80fd\u4f1a\u95ee\u4f60\u51e0\u4e2a\u95ee\u9898\u3001\u63d0\u51fa\u4fee\u6539\u5efa\u8bae\u3001\u751a\u81f3\u62d2\u7edd\u6267\u884c\u4e0d\u5408\u7406\u7684\u8981\u6c42\u3002<\/p>\n<table>\n<tr>\u7ef4\u5ea6MCPA2A<\/tr>\n<tbody>\n<tr>\n<td>\u901a\u4fe1\u5bf9\u8c61<\/td>\n<td>Agent \u2194 Tool&#xff08;\u65e0\u72b6\u6001\u51fd\u6570&#xff09;<\/td>\n<td>Agent \u2194 Agent&#xff08;\u6709\u72b6\u6001\u5b9e\u4f53&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u8c03\u7528\u8bed\u4e49<\/td>\n<td>\u51fd\u6570\u8c03\u7528&#xff0c;\u540c\u6b65\u8fd4\u56de<\/td>\n<td>\u4efb\u52a1\u59d4\u6258&#xff0c;\u6709\u751f\u547d\u5468\u671f\u548c\u72b6\u6001\u673a<\/td>\n<\/tr>\n<tr>\n<td>\u8c01\u53d1\u8d77<\/td>\n<td>Agent \u4e3b\u52a8\u8c03\u7528 Tool<\/td>\n<td>\u53cc\u65b9\u90fd\u53ef\u4ee5\u53d1\u8d77\u8bf7\u6c42<\/td>\n<\/tr>\n<tr>\n<td>\u80fd\u5426\u62d2\u7edd<\/td>\n<td>\u4e0d\u80fd&#xff0c;Tool \u53ea\u662f\u6267\u884c\u51fd\u6570<\/td>\n<td>\u53ef\u4ee5&#xff0c;Agent \u53ef\u4ee5\u62d2\u7edd\u4e0d\u5408\u7406\u8bf7\u6c42<\/td>\n<\/tr>\n<tr>\n<td>\u72b6\u6001\u7ba1\u7406<\/td>\n<td>\u65e0\u72b6\u6001<\/td>\n<td>\u6709\u72b6\u6001&#xff08;Task \u72b6\u6001\u673a&#xff0c;\u5f02\u6b65\u8f6e\u8be2&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u4f20\u8f93\u65b9\u5f0f<\/td>\n<td>stdio \/ SSE \/ Streamable HTTP<\/td>\n<td>HTTP &#043; JSON-RPC 2.0 \/ SSE \/ Webhook<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u7b80\u5355\u8bf4&#xff1a;MCP \u89e3\u51b3 Agent \u600e\u4e48\u4f7f\u7528\u5de5\u5177&#xff0c;A2A \u89e3\u51b3 Agent \u600e\u4e48\u4e0e Agent \u534f\u4f5c\u3002\u4e24\u8005\u4e0d\u662f\u7ade\u4e89\u5173\u7cfb&#xff0c;\u800c\u662f\u4e92\u8865\u5173\u7cfb\u3002<\/p>\n<p>\u4e00\u4e2a Agent \u53ef\u4ee5\u540c\u65f6\u662f MCP Client&#xff08;\u8c03\u7528\u5916\u90e8\u5de5\u5177&#xff09;\u548c A2A Endpoint&#xff08;\u88ab\u5176\u4ed6 Agent \u8c03\u7528&#xff09;\u3002\u6bd4\u5982\u4e00\u4e2a\u4ee3\u7801\u5ba1\u67e5 Agent&#xff1a;\u5b83\u4f5c\u4e3a MCP Client \u8c03\u7528\u5b89\u5168\u626b\u63cf\u5de5\u5177\u548c\u4ee3\u7801\u8d28\u91cf\u5de5\u5177&#xff0c;\u540c\u65f6\u4f5c\u4e3a A2A Endpoint \u63a5\u6536\u6765\u81ea\u5176\u4ed6 Agent \u7684\u5ba1\u67e5\u8bf7\u6c42\u3002<\/p>\n<p>\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510<br \/>\n\u2502            \u4ee3\u7801\u5ba1\u67e5 Agent                         \u2502<br \/>\n\u2502                                                  \u2502<br \/>\n\u2502  \u4f5c\u4e3a MCP Client&#xff08;\u8c03\u7528\u5de5\u5177&#xff09;&#xff1a;                     \u2502<br \/>\n\u2502    \u2192 \u5b89\u5168\u626b\u63cf\u5de5\u5177                                 \u2502<br \/>\n\u2502    \u2192 \u4ee3\u7801\u8d28\u91cf\u68c0\u67e5\u5de5\u5177                              \u2502<br \/>\n\u2502    \u2192 \u4f9d\u8d56\u5206\u6790\u5de5\u5177                                 \u2502<br \/>\n\u2502                                                  \u2502<br \/>\n\u2502  \u4f5c\u4e3a A2A Endpoint&#xff08;\u88ab\u8c03\u7528&#xff09;&#xff1a;                     \u2502<br \/>\n\u2502    \u2190 \u63a5\u6536\u6765\u81ea\u7f16\u6392 Agent \u7684\u5ba1\u67e5\u8bf7\u6c42                  \u2502<br \/>\n\u2502    \u2192 \u8fd4\u56de\u5ba1\u67e5\u7ed3\u679c &#043; \u8fdb\u5ea6\u901a\u77e5                       \u2502<br \/>\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 <\/p>\n<hr \/>\n<h3>\u516b\u3001\u5de5\u7a0b\u5b9e\u8df5\u4e2d\u7684\u5e38\u89c1\u95ee\u9898\u4e0e\u8e29\u5751\u8bb0\u5f55<\/h3>\n<h4>8.1 \u534f\u8bae\u7248\u672c\u4e0d\u517c\u5bb9<\/h4>\n<p>\u73b0\u8c61&#xff1a;Client \u548c Server \u63e1\u624b\u5931\u8d25&#xff0c;Server \u8fd4\u56de -32600 Invalid Request\u3002<\/p>\n<p>\u539f\u56e0&#xff1a;MCP \u534f\u8bae\u7248\u672c\u53f7\u91c7\u7528\u65e5\u671f\u683c\u5f0f&#xff08;\u5982 &#034;2024-11-05&#034;\u3001&#034;2025-03-26&#034;&#xff09;&#xff0c;\u4e0d\u540c\u7248\u672c\u7684 SDK \u53ef\u80fd\u652f\u6301\u4e0d\u540c\u7684\u534f\u8bae\u7248\u672c\u3002Spring AI 1.1.x \u4f7f\u7528 MCP SDK 0.18.x&#xff0c;\u4e0e 0.17.x \u5b58\u5728 breaking change\u3002<\/p>\n<p>\u89e3\u51b3\u65b9\u6848&#xff1a;\u5728 pom.xml \u4e2d\u663e\u5f0f\u9501\u5b9a MCP SDK \u7248\u672c&#xff1a;<\/p>\n<p>&lt;dependency&gt;<br \/>\n  &lt;groupId&gt;io.modelcontextprotocol&lt;\/groupId&gt;<br \/>\n  &lt;artifactId&gt;mcp-sdk-java-jackson&lt;\/artifactId&gt;<br \/>\n  &lt;version&gt;0.18.2&lt;\/version&gt;<br \/>\n&lt;\/dependency&gt; <\/p>\n<h4>8.2 SSE \u957f\u8fde\u63a5\u9891\u7e41\u65ad\u5f00<\/h4>\n<p>\u73b0\u8c61&#xff1a;\u5de5\u5177\u8c03\u7528\u5076\u5c14\u8d85\u65f6&#xff0c;Client \u65e5\u5fd7\u663e\u793a\u9891\u7e41\u91cd\u8fde\u3002<\/p>\n<p>\u539f\u56e0&#xff1a;Nginx \u9ed8\u8ba4\u7684 proxy_read_timeout \u4e3a 60 \u79d2&#xff0c;SSE \u957f\u8fde\u63a5\u5728 60 \u79d2\u65e0\u6570\u636e\u4f20\u8f93\u540e\u4f1a\u88ab Nginx \u4e3b\u52a8\u65ad\u5f00\u3002<\/p>\n<p>\u89e3\u51b3\u65b9\u6848&#xff1a;\u53c2\u8003\u672c\u6587 4.2 \u8282\u7684 Nginx \u914d\u7f6e&#xff0c;\u5c06\u8d85\u65f6\u8c03\u5927\u81f3 3600 \u79d2\u4ee5\u4e0a&#xff0c;\u540c\u65f6\u5173\u95ed proxy_buffering\u3002<\/p>\n<h4>8.3 \u5de5\u5177\u63cf\u8ff0\u4e0d\u591f\u7cbe\u51c6\u5bfc\u81f4 LLM \u8c03\u9519\u5de5\u5177<\/h4>\n<p>\u73b0\u8c61&#xff1a;LLM \u9891\u7e41\u8c03\u7528\u9519\u8bef\u7684\u5de5\u5177&#xff0c;\u6216\u8005\u5728\u4e0d\u9700\u8981\u5de5\u5177\u65f6\u5f3a\u884c\u8c03\u7528\u3002<\/p>\n<p>\u539f\u56e0&#xff1a;\u5de5\u5177\u7684 description \u592a\u6a21\u7cca&#xff0c;LLM \u65e0\u6cd5\u51c6\u786e\u5224\u65ad\u5de5\u5177\u7684\u9002\u7528\u573a\u666f\u3002<\/p>\n<p>\u89e3\u51b3\u65b9\u6848&#xff1a;<\/p>\n<li>\u63cf\u8ff0\u4e2d\u660e\u786e\u300c\u505a\u4ec0\u4e48\u300d&#043;\u300c\u8fd4\u56de\u4ec0\u4e48\u300d<\/li>\n<li>\u4f7f\u7528 &#034;When to Use \/ When NOT to Use&#034; \u6a21\u5f0f<\/li>\n<li>\u5982\u679c\u5de5\u5177\u6709 5 \u4e2a\u4ee5\u4e0a&#xff0c;\u7ed9\u6bcf\u4e2a\u5de5\u5177\u52a0\u4e0a\u9886\u57df\u524d\u7f00&#xff08;\u5982 db_query\u3001db_schema\u3001search_docs&#xff09;<\/li>\n<h4>8.4 \u591a Server \u573a\u666f\u4e0b\u7684\u5de5\u5177\u540d\u51b2\u7a81<\/h4>\n<p>\u73b0\u8c61&#xff1a;\u4e24\u4e2a Server \u66b4\u9732\u4e86\u540c\u540d\u5de5\u5177&#xff0c;Client \u8def\u7531\u5230\u9519\u8bef\u7684 Server\u3002<\/p>\n<p>\u89e3\u51b3\u65b9\u6848&#xff1a;Spring AI \u91c7\u7528\u547d\u540d\u7a7a\u95f4\u9694\u79bb\u7b56\u7565&#xff0c;\u6bcf\u4e2a\u5de5\u5177\u540d\u79f0\u524d\u7f00\u52a0\u4e0a Server \u540d\u79f0&#xff1a;<\/p>\n<p>code-review.reviewCode    \u2192 \u8def\u7531\u5230 code-review Server<br \/>\ndatabase.executeQuery     \u2192 \u8def\u7531\u5230 database Server <\/p>\n<p>\u5982\u679c\u4e24\u4e2a Server \u7684\u5de5\u5177\u540d\u5b8c\u5168\u76f8\u540c&#xff0c;\u524d\u7f00\u4e0d\u540c\u4e5f\u4e0d\u4f1a\u51b2\u7a81\u3002<\/p>\n<h4>8.5 \u8bca\u65ad\u89c2\u6d4b&#xff1a;\u5de5\u5177\u8c03\u7528\u7684\u5168\u94fe\u8def\u65e5\u5fd7<\/h4>\n<p>\u751f\u4ea7\u73af\u5883\u4e2d&#xff0c;\u5de5\u5177\u8c03\u7528\u7684\u53ef\u89c2\u6d4b\u6027\u81f3\u5173\u91cd\u8981\u3002\u5efa\u8bae\u901a\u8fc7\u88c5\u9970\u5668\u6a21\u5f0f\u4e3a\u6bcf\u4e2a\u5de5\u5177\u8c03\u7528\u6dfb\u52a0\u65e5\u5fd7\u8bb0\u5f55&#xff1a;<\/p>\n<p>public class LoggingToolCallback implements ToolCallback {<br \/>\n    private final ToolCallback delegate;<\/p>\n<p>    &#064;Override<br \/>\n    public String call(String args) {<br \/>\n        log.info(&#034;[MCP-TOOL] invoke: {} args&#061;{}&#034;,<br \/>\n            toolName, truncate(args, 200));<br \/>\n        long start &#061; System.currentTimeMillis();<br \/>\n        try {<br \/>\n            String result &#061; delegate.call(args);<br \/>\n            log.info(&#034;[MCP-TOOL] success: {} cost&#061;{}ms result&#061;{}&#034;,<br \/>\n                toolName, System.currentTimeMillis() &#8211; start,<br \/>\n                truncate(result, 200));<br \/>\n            return result;<br \/>\n        } catch (Exception e) {<br \/>\n            log.error(&#034;[MCP-TOOL] failed: {} cost&#061;{}ms error&#061;{}&#034;,<br \/>\n                toolName, System.currentTimeMillis() &#8211; start,<br \/>\n                e.getMessage());<br \/>\n            throw e;<br \/>\n        }<br \/>\n    }<br \/>\n} <\/p>\n<p>\u65e5\u5fd7\u5173\u952e\u5b57 [MCP-TOOL] \u65b9\u4fbf grep \u8fc7\u6ee4\u3002\u5efa\u8bae\u5728\u670d\u52a1\u542f\u52a8\u65f6\u6253\u5370\u5de5\u5177\u6c47\u603b\u62a5\u544a&#xff0c;\u5feb\u901f\u786e\u8ba4\u8fde\u63a5\u72b6\u6001&#xff1a;<\/p>\n<p>MCP \u8fde\u63a5\u72b6\u6001: 3 \u4e2a\u8fde\u63a5, 8 \u4e2a\u5de5\u5177<br \/>\n  code-review-local \u2192 ok (3 tools)<br \/>\n  zhipu-web-search  \u2192 ok (1 tool)<br \/>\n  amap-maps         \u2192 failed (timeout) <\/p>\n<h4>8.6 \u5e76\u53d1\u4e0e\u9650\u6d41<\/h4>\n<p>MCP Client&#xff08;\u5c24\u5176\u662f LLM \u9a71\u52a8\u7684 Agent&#xff09;\u53ef\u80fd\u9ad8\u9891\u5e76\u53d1\u8c03\u7528\u5de5\u5177\u3002\u5b9e\u6d4b\u4e2d\u66fe\u51fa\u73b0\u5355\u4e2a Agent \u5728 1 \u79d2\u5185\u53d1\u8d77 200&#043; \u6b21\u8bf7\u6c42&#xff0c;\u76f4\u63a5\u6253\u6ee1\u540e\u7aef\u670d\u52a1\u7ebf\u7a0b\u6c60\u3002<\/p>\n<p>\u5efa\u8bae\u5b9e\u65bd\u4e24\u7ea7\u9650\u6d41&#xff1a;<\/p>\n<table>\n<tr>\u9650\u6d41\u7ef4\u5ea6\u7b56\u7565\u63a8\u8350\u503c<\/tr>\n<tbody>\n<tr>\n<td>\u6bcf Client QPS<\/td>\n<td>\u4ee4\u724c\u6876&#xff08;\u5982 Guava RateLimiter&#xff09;<\/td>\n<td>\u5355 Agent \u2264 10 req\/s<\/td>\n<\/tr>\n<tr>\n<td>\u5168\u5c40\u5de5\u5177\u5e76\u53d1\u6570<\/td>\n<td>\u4fe1\u53f7\u91cf&#xff08;Semaphore&#xff09;<\/td>\n<td>\u5355\u5de5\u5177 \u2264 50 \u5e76\u53d1<\/td>\n<\/tr>\n<tr>\n<td>\u5355\u5de5\u5177\u8d85\u65f6<\/td>\n<td>\u72ec\u7acb\u8d85\u65f6\u914d\u7f6e<\/td>\n<td>\u6839\u636e\u5de5\u5177\u7279\u6027\u8bbe\u7f6e&#xff08;5s~60s&#xff09;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h3>\u603b\u7ed3<\/h3>\n<p>MCP \u534f\u8bae\u7684\u6838\u5fc3\u8bbe\u8ba1\u53ef\u4ee5\u6d53\u7f29\u4e3a\u51e0\u4e2a\u5173\u952e\u51b3\u7b56&#xff1a;<\/p>\n<ul>\n<li>\u7528 JSON-RPC 2.0 \u505a\u6d88\u606f\u683c\u5f0f\u2014\u2014\u6bd4 gRPC \u8f7b\u91cf&#xff0c;\u6bd4 REST \u66f4\u9002\u5408\u53cc\u5411\u901a\u4fe1<\/li>\n<li>\u4f20\u8f93\u5c42\u4e0e\u6d88\u606f\u683c\u5f0f\u89e3\u8026\u2014\u2014\u540c\u4e00\u6761\u6d88\u606f\u53ef\u4ee5\u8d70 stdio\u3001SSE \u6216 Streamable HTTP&#xff0c;\u90e8\u7f72\u65b9\u5f0f\u7075\u6d3b<\/li>\n<li>\u80fd\u529b\u534f\u5546\u673a\u5236\u2014\u2014Client \u548c Server \u53cc\u5411\u58f0\u660e\u80fd\u529b&#xff0c;\u907f\u514d\u65e0\u610f\u4e49\u7684\u8bf7\u6c42\u548c\u9519\u8bef<\/li>\n<li>\u4e09\u5927\u539f\u8bed\u5206\u5de5\u660e\u786e\u2014\u2014Tools \u505a\u4e8b\u3001Resources \u63d0\u4f9b\u6570\u636e\u3001Prompts \u63d0\u4f9b\u6a21\u677f<\/li>\n<li>Host\/Client\/Server \u4e09\u89d2\u67b6\u6784\u2014\u2014\u5de5\u5177\u751f\u6001\u4e0e\u5bbf\u4e3b\u5e94\u7528\u5b8c\u5168\u89e3\u8026<\/li>\n<\/ul>\n<p>\u7406\u89e3\u4e86\u8fd9\u4e9b\u8bbe\u8ba1\u51b3\u7b56&#xff0c;MCP \u5c31\u4e0d\u518d\u662f\u4e00\u4e2a\u9ed1\u76d2\u534f\u8bae&#xff0c;\u800c\u662f\u4e00\u5957\u6709\u6e05\u6670\u5de5\u7a0b\u903b\u8f91\u7684\u901a\u4fe1\u89c4\u8303\u3002\u534f\u8bae\u672c\u8eab\u5e76\u4e0d\u590d\u6742&#xff0c;\u771f\u6b63\u7684\u6311\u6218\u5728\u4e8e\u5982\u4f55\u57fa\u4e8e\u5b83\u6784\u5efa\u53ef\u9760\u7684\u5de5\u5177\u670d\u52a1\u2014\u2014\u8fd9\u5c31\u662f\u4e0b\u4e00\u7bc7\u8981\u89e3\u51b3\u7684\u95ee\u9898\u3002<\/p>\n<hr \/>\n<p>\u4e0b\u4e00\u7bc7\u9884\u544a&#xff1a;MCP-02\u300aMCP Server \u5f00\u53d1\u5b9e\u6218\u300b&#xff0c;\u5c06\u4ece\u4ee3\u7801\u5c42\u9762\u62c6\u89e3\u5982\u4f55\u7528 Spring AI \u6784\u5efa\u4e00\u4e2a\u751f\u4ea7\u7ea7\u7684 MCP Server\u2014\u2014\u4ece &#064;Tool \u6ce8\u89e3\u5b9a\u4e49\u5de5\u5177&#xff0c;\u5230 SSE \u4f20\u8f93\u914d\u7f6e&#xff0c;\u5230\u591a\u6a21\u5757\u5de5\u5177\u805a\u5408&#xff0c;\u5230\u751f\u4ea7\u73af\u5883\u7684\u8fde\u63a5\u7ba1\u7406\u548c\u5065\u5eb7\u68c0\u67e5\u3002<\/p>\n<p>\u2014 \u6df1\u5165\u7406\u89e3 AI Agent \u00b7 MCP \u5b50\u7cfb\u5217 \u00b7 \u7b2c 1 \u7bc7 \u2014<\/p>\n<p>\u6709\u95ee\u9898\u8bc4\u8bba\u533a\u89c1&#xff0c;\u6b22\u8fce\u4ea4\u6d41~<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5bfc\u8bfb&#xff1a;2024 \u5e74 11 \u6708&#xff0c;Anthropic \u53d1\u5e03\u4e86 MCP&#xff08;Model Context Protocol&#xff09;\u2014\u2014\u4e00\u4e2a\u7528\u4e8e\u6807\u51c6\u5316 LLM \u5e94\u7528\u4e0e\u5916\u90e8\u5de5\u5177\u3001\u6570\u636e\u6e90\u4e4b\u95f4\u901a\u4fe1\u7684\u5f00\u653e\u534f\u8bae\u3002\u534a\u5e74\u540e&#xff0c;MCP \u5df2\u7ecf\u6210\u4e3a AI Agent \u9886\u57df\u7684\u4e8b\u5b9e\u6807\u51c6&#xff1a;OpenAI\u3001Google\u3001LangChain\u3001Spring AI \u7b49\u4e3b\u6d41\u5e73\u53f0\u7eb7\u7eb7\u63a5\u5165\u3002MCP \u4e0d\u662f\u53c8\u4e00\u4e2a RPC \u6846\u67b6&#xff0c;\u800c\u662f\u4e13\u4e3a\u5927\u6a21\u578b\u4ea4\u4e92<\/p>\n","protected":false},"author":2,"featured_media":92247,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[10187,66,50],"topic":[],"class_list":["post-92248","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-codingplan","tag-ai","tag-50"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u6df1\u5165\u7406\u89e3 AI Agent \u00b7 MCP \u5b50\u7cfb\u5217 #01\uff1aMCP \u534f\u8bae\u5168\u89e3\u2014\u4ece\u6d88\u606f\u683c\u5f0f\u5230\u4f20\u8f93\u5c42\u7684\u5b8c\u6574\u62c6\u89e3 - \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\/92248.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u6df1\u5165\u7406\u89e3 AI Agent \u00b7 MCP \u5b50\u7cfb\u5217 #01\uff1aMCP \u534f\u8bae\u5168\u89e3\u2014\u4ece\u6d88\u606f\u683c\u5f0f\u5230\u4f20\u8f93\u5c42\u7684\u5b8c\u6574\u62c6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u5bfc\u8bfb&#xff1a;2024 \u5e74 11 \u6708&#xff0c;Anthropic \u53d1\u5e03\u4e86 MCP&#xff08;Model Context Protocol&#xff09;\u2014\u2014\u4e00\u4e2a\u7528\u4e8e\u6807\u51c6\u5316 LLM \u5e94\u7528\u4e0e\u5916\u90e8\u5de5\u5177\u3001\u6570\u636e\u6e90\u4e4b\u95f4\u901a\u4fe1\u7684\u5f00\u653e\u534f\u8bae\u3002\u534a\u5e74\u540e&#xff0c;MCP \u5df2\u7ecf\u6210\u4e3a AI Agent \u9886\u57df\u7684\u4e8b\u5b9e\u6807\u51c6&#xff1a;OpenAI\u3001Google\u3001LangChain\u3001Spring AI \u7b49\u4e3b\u6d41\u5e73\u53f0\u7eb7\u7eb7\u63a5\u5165\u3002MCP \u4e0d\u662f\u53c8\u4e00\u4e2a RPC \u6846\u67b6&#xff0c;\u800c\u662f\u4e13\u4e3a\u5927\u6a21\u578b\u4ea4\u4e92\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/92248.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-09T12:41:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260809124058-6a78755a07b23.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=\"11 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/92248.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/92248.html\",\"name\":\"\u6df1\u5165\u7406\u89e3 AI Agent \u00b7 MCP \u5b50\u7cfb\u5217 #01\uff1aMCP \u534f\u8bae\u5168\u89e3\u2014\u4ece\u6d88\u606f\u683c\u5f0f\u5230\u4f20\u8f93\u5c42\u7684\u5b8c\u6574\u62c6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-09T12:41:03+00:00\",\"dateModified\":\"2026-08-09T12:41:03+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/92248.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/92248.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/92248.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u6df1\u5165\u7406\u89e3 AI Agent \u00b7 MCP \u5b50\u7cfb\u5217 #01\uff1aMCP \u534f\u8bae\u5168\u89e3\u2014\u4ece\u6d88\u606f\u683c\u5f0f\u5230\u4f20\u8f93\u5c42\u7684\u5b8c\u6574\u62c6\u89e3\"}]},{\"@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":"\u6df1\u5165\u7406\u89e3 AI Agent \u00b7 MCP \u5b50\u7cfb\u5217 #01\uff1aMCP \u534f\u8bae\u5168\u89e3\u2014\u4ece\u6d88\u606f\u683c\u5f0f\u5230\u4f20\u8f93\u5c42\u7684\u5b8c\u6574\u62c6\u89e3 - \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\/92248.html","og_locale":"zh_CN","og_type":"article","og_title":"\u6df1\u5165\u7406\u89e3 AI Agent \u00b7 MCP \u5b50\u7cfb\u5217 #01\uff1aMCP \u534f\u8bae\u5168\u89e3\u2014\u4ece\u6d88\u606f\u683c\u5f0f\u5230\u4f20\u8f93\u5c42\u7684\u5b8c\u6574\u62c6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u5bfc\u8bfb&#xff1a;2024 \u5e74 11 \u6708&#xff0c;Anthropic \u53d1\u5e03\u4e86 MCP&#xff08;Model Context Protocol&#xff09;\u2014\u2014\u4e00\u4e2a\u7528\u4e8e\u6807\u51c6\u5316 LLM \u5e94\u7528\u4e0e\u5916\u90e8\u5de5\u5177\u3001\u6570\u636e\u6e90\u4e4b\u95f4\u901a\u4fe1\u7684\u5f00\u653e\u534f\u8bae\u3002\u534a\u5e74\u540e&#xff0c;MCP \u5df2\u7ecf\u6210\u4e3a AI Agent \u9886\u57df\u7684\u4e8b\u5b9e\u6807\u51c6&#xff1a;OpenAI\u3001Google\u3001LangChain\u3001Spring AI \u7b49\u4e3b\u6d41\u5e73\u53f0\u7eb7\u7eb7\u63a5\u5165\u3002MCP \u4e0d\u662f\u53c8\u4e00\u4e2a RPC \u6846\u67b6&#xff0c;\u800c\u662f\u4e13\u4e3a\u5927\u6a21\u578b\u4ea4\u4e92","og_url":"https:\/\/www.wsisp.com\/helps\/92248.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-09T12:41:03+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260809124058-6a78755a07b23.jpg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"11 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/92248.html","url":"https:\/\/www.wsisp.com\/helps\/92248.html","name":"\u6df1\u5165\u7406\u89e3 AI Agent \u00b7 MCP \u5b50\u7cfb\u5217 #01\uff1aMCP \u534f\u8bae\u5168\u89e3\u2014\u4ece\u6d88\u606f\u683c\u5f0f\u5230\u4f20\u8f93\u5c42\u7684\u5b8c\u6574\u62c6\u89e3 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-09T12:41:03+00:00","dateModified":"2026-08-09T12:41:03+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/92248.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/92248.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/92248.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u6df1\u5165\u7406\u89e3 AI Agent \u00b7 MCP \u5b50\u7cfb\u5217 #01\uff1aMCP \u534f\u8bae\u5168\u89e3\u2014\u4ece\u6d88\u606f\u683c\u5f0f\u5230\u4f20\u8f93\u5c42\u7684\u5b8c\u6574\u62c6\u89e3"}]},{"@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\/92248","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=92248"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/92248\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/92247"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=92248"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=92248"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=92248"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=92248"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}