{"id":94336,"date":"2026-08-14T10:18:32","date_gmt":"2026-08-14T02:18:32","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/94336.html"},"modified":"2026-08-14T10:18:32","modified_gmt":"2026-08-14T02:18:32","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-03%ef%bc%9a%e5%a4%9a-server-%e7%bc%96%e6%8e%92%e3%80%81%e8%b0%83%e7%94%a8%e9%93%be%e5%8f%af%e8%a7%82%e6%b5%8b","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/94336.html","title":{"rendered":"\u6df1\u5165\u7406\u89e3 AI Agent \u00b7 MCP \u5b50\u7cfb\u5217 #03\uff1a\u591a Server \u7f16\u6392\u3001\u8c03\u7528\u94fe\u53ef\u89c2\u6d4b\u4e0e\u8fde\u63a5\u751f\u547d\u5468\u671f\u7ba1\u7406"},"content":{"rendered":"<h2 style=\"text-align:center\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260814021825-6a7e7af19f586.jpg\" \/><\/h2>\n<p>\u534f\u8bae\u89e3\u51b3\u7684\u662f&#034;\u600e\u4e48\u5bf9\u8bdd&#034;&#xff0c;\u5de5\u7a0b\u5316\u89e3\u51b3\u7684\u662f&#034;\u600e\u4e48\u5728\u751f\u4ea7\u73af\u5883\u7a33\u5b9a\u5730\u5bf9\u8bdd&#034;\u3002<\/p>\n<hr \/>\n<p>\u524d\u4e00\u7bc7\u6211\u4eec\u7528 Spring AI \u642d\u5efa\u4e86\u4e00\u4e2a\u529f\u80fd\u5b8c\u6574\u7684 MCP Server&#xff0c;\/mcp\/sse \u7aef\u70b9\u80fd\u6b63\u5e38\u54cd\u5e94&#xff0c;\u5de5\u5177\u80fd\u88ab Client \u53d1\u73b0\u548c\u8c03\u7528\u3002\u4f46\u5f53\u4f60\u8bd5\u56fe\u628a\u8fd9\u4e2a\u7cfb\u7edf\u90e8\u7f72\u5230\u751f\u4ea7\u73af\u5883\u65f6&#xff0c;\u95ee\u9898\u4f1a\u4e00\u4e2a\u63a5\u4e00\u4e2a\u5192\u51fa\u6765&#xff1a;\u8fde\u63a5\u54ea\u4e9b Server&#xff1f;\u914d\u7f6e\u6563\u843d\u5728\u54ea\u91cc&#xff1f;\u4e00\u6b21\u8bf7\u6c42\u7ecf\u8fc7\u4e86\u51e0\u6b21 tool call&#xff1f;\u8017\u65f6\u591a\u5c11&#xff1f;SSE \u957f\u8fde\u63a5\u65ad\u4e86\u600e\u4e48\u529e&#xff1f;\u8fdc\u7aef\u8d85\u65f6\u4e86\u600e\u4e48\u964d\u7ea7&#xff1f;<\/p>\n<p>\u5728 Dream-SaaS \u5e73\u53f0\u4e2d&#xff0c;MCP Client \u8fd0\u884c\u5728 8090 \u7aef\u53e3&#xff0c;\u9700\u8981\u540c\u65f6\u8fde\u63a5\u672c\u5730 8095 \u7684 code-review-agent Server\u3001\u667a\u8c31\u8fdc\u7a0b web_search MCP\u3001\u9ad8\u5fb7\u8fdc\u7a0b maps MCP\u2014\u2014\u4e09\u4e2a\u4f20\u8f93\u534f\u8bae\u4e0d\u540c\u7684\u8fdc\u7aef\u670d\u52a1&#xff0c;\u4e24\u5957\u9274\u6743\u673a\u5236&#xff0c;\u4e09\u79cd\u8fde\u63a5\u751f\u547d\u5468\u671f\u3002\u672c\u6587\u4ee5 Dream-SaaS \u7684\u771f\u5b9e\u4ee3\u7801\u4e3a\u4e3b\u7ebf&#xff0c;\u62c6\u89e3\u591a Server \u7f16\u6392\u3001\u8c03\u7528\u94fe\u8def\u53ef\u89c2\u6d4b\u3001\u8fde\u63a5\u751f\u547d\u5468\u671f\u7ba1\u7406\u8fd9\u4e09\u4e2a\u5de5\u7a0b\u5316\u6838\u5fc3\u95ee\u9898\u3002<\/p>\n<h3>\u4e00\u3001\u4ece\u5f00\u53d1\u5230\u751f\u4ea7&#xff1a;MCP \u5de5\u7a0b\u5316\u7684\u4e09\u9053\u574e<\/h3>\n<h4>1.1 \u90e8\u7f72\u62d3\u6251&#xff1a;\u4e09\u6761\u94fe\u8def\u3001\u4e09\u79cd\u8fde\u63a5\u65b9\u5f0f<\/h4>\n<p>Dream-SaaS \u7684\u5b9e\u9645\u90e8\u7f72\u62d3\u6251\u5982\u4e0b&#xff1a;<\/p>\n<ul>\n<li>8090 \u7aef\u53e3&#xff1a;dream-ai-app&#xff08;MCP Client&#xff09;&#xff0c;\u9762\u5411\u7528\u6237\u7684\u95ee\u7b54\u5165\u53e3<\/li>\n<li>8095 \u7aef\u53e3&#xff1a;code-review-agent&#xff08;MCP Server&#xff09;&#xff0c;\u63d0\u4f9b review_code \u7b49\u4ee3\u7801\u5ba1\u67e5\u5de5\u5177<\/li>\n<li>\u8fdc\u7a0b&#xff1a;\u667a\u8c31 web_search&#xff08;SSE \u534f\u8bae&#xff09;\u3001\u9ad8\u5fb7 maps&#xff08;streamable-http \u534f\u8bae&#xff09;<\/li>\n<\/ul>\n<p>\u4e09\u6761\u94fe\u8def&#xff0c;\u4e09\u79cd\u8fde\u63a5\u65b9\u5f0f&#xff0c;\u4e24\u5957 API Key\u3002\u8fd9\u4e0d\u662f\u5047\u8bbe\u573a\u666f&#xff0c;\u800c\u662f\u65e5\u5e38\u5f00\u53d1\u4e2d\u771f\u5b9e\u9762\u5bf9\u7684\u5de5\u7a0b\u6311\u6218\u3002<\/p>\n<h4>1.2 \u4e09\u9053\u574e&#xff1a;\u7f16\u6392\u3001\u89c2\u6d4b\u3001\u751f\u547d\u5468\u671f<\/h4>\n<p>\u8fd9\u5f15\u51fa\u4e86\u5de5\u7a0b\u5316\u843d\u5730\u65f6\u5fc5\u987b\u76f4\u9762\u7684\u4e09\u9053\u574e&#xff1a;<\/p>\n<p>\u7b2c\u4e00\u9053\u574e&#xff1a;\u591a Server \u7684\u8fde\u63a5\u7ba1\u7406\u4e0e\u7f16\u6392\u3002 \u8fde\u63a5\u54ea\u4e9b Server\u3001\u8c01\u8fde\u4e86\u8c01\u3001\u914d\u7f6e\u6563\u843d\u5728\u54ea\u91cc&#xff1f;\u5f53 Client \u53ea\u8fde\u4e00\u4e2a Server \u65f6&#xff0c;\u4e00\u884c URL \u5c31\u5b8c\u4e8b\u3002\u4f46\u5f53 Client \u9700\u8981\u540c\u65f6\u7ba1\u7406\u4e09\u4e2a\u5f02\u6784\u8fdc\u7aef\u65f6&#xff0c;\u914d\u7f6e\u5c31\u4f1a\u6563\u843d\u5728 application.yml \u7684\u5404\u4e2a\u89d2\u843d&#xff0c;\u7f3a\u4e4f\u7edf\u4e00\u7684&#034;\u8c01\u8fde\u63a5\u8c01&#034;\u7684\u89c6\u56fe\u3002<\/p>\n<p>\u7b2c\u4e8c\u9053\u574e&#xff1a;\u5de5\u5177\u8c03\u7528\u7684\u53ef\u89c2\u6d4b\u6027\u3002 \u4e00\u6b21 \/mcp\/ask \u8bf7\u6c42\u53ef\u80fd\u89e6\u53d1\u591a\u6b21 tool call\u2014\u2014LLM \u53ef\u80fd\u5148\u8c03 webSearch \u641c\u7d22\u6587\u6863&#xff0c;\u518d\u8c03 review_code \u5ba1\u67e5\u4ee3\u7801\u3002\u5982\u679c\u6bcf\u6b21\u8c03\u7528\u90fd\u662f&#034;\u9ed1\u76d2&#034;&#xff0c;\u51fa\u4e86\u95ee\u9898\u6839\u672c\u65e0\u4ece\u6392\u67e5\u3002<\/p>\n<p>\u7b2c\u4e09\u9053\u574e&#xff1a;\u8fde\u63a5\u7684\u751f\u547d\u5468\u671f\u7ba1\u7406\u3002 \u542f\u52a8\u65f6\u8fdc\u7aef Server \u6ca1\u6d3b\u600e\u4e48\u529e&#xff1f;SSE \u957f\u8fde\u63a5\u65ad\u4e86\u600e\u4e48\u529e&#xff1f;\u8fdc\u7aef\u8d85\u65f6\u4e86\u600e\u4e48\u964d\u7ea7&#xff1f;\u5f00\u53d1\u4eba\u5458\u5fd8\u8bb0\u8bbe\u7f6e ZHIPU_API_KEY \u73af\u5883\u53d8\u91cf&#xff0c;\u542f\u52a8\u540e\u5927\u91cf 401 \u9519\u8bef\u5237\u5c4f\u2014\u2014\u8fd9\u4e9b\u60c5\u51b5\u5982\u679c\u4e0d\u5728\u4ee3\u7801\u5c42\u9762\u5904\u7406&#xff0c;\u6700\u7ec8\u4f53\u73b0\u4e3a\u7528\u6237\u4fa7\u7684&#034;AI \u56de\u7b54\u8d85\u65f6&#034;\u6216&#034;\u5de5\u5177\u8c03\u7528\u5f02\u5e38&#034;\u3002<\/p>\n<h4>1.3 \u65b9\u6848\u9009\u578b&#xff1a;Client \u4fa7\u5185\u5efa vs \u72ec\u7acb\u7f51\u5173<\/h4>\n<p>\u5728\u884c\u4e1a\u91cc&#xff0c;\u6709\u4e9b\u56e2\u961f\u9009\u62e9\u5f15\u5165\u72ec\u7acb\u7684 MCP \u7f51\u5173\u5c42\u6765\u505a\u7edf\u4e00\u4ee3\u7406&#xff1b;\u6709\u4e9b\u56e2\u961f\u9009\u62e9\u5728 Client \u4fa7\u5185\u5efa Registry \u548c\u89c2\u6d4b\u80fd\u529b\u3002Dream-SaaS \u9009\u62e9\u4e86\u540e\u8005\u2014\u2014\u4e0d\u5f15\u5165\u989d\u5916\u57fa\u7840\u8bbe\u65bd&#xff0c;\u5728 Java \u5e94\u7528\u5185\u90e8\u7528\u6a21\u5757\u5316\u7684\u65b9\u5f0f\u89e3\u51b3\u3002\u8fd9\u79cd\u65b9\u6848\u66f4\u8f7b\u91cf&#xff0c;\u4e5f\u66f4\u9002\u5408 Spring Boot \u6280\u672f\u6808\u7684\u56e2\u961f\u3002<\/p>\n<h3>\u4e8c\u3001\u591a Server \u7f16\u6392&#xff1a;Dream-SaaS \u7684 Registry \u540d\u518c\u65b9\u6848<\/h3>\n<h4>2.1 \u4e94\u6a21\u5757\u62c6\u5206&#xff1a;\u5404\u53f8\u5176\u804c<\/h4>\n<p>\u5f53 Client \u9700\u8981\u540c\u65f6\u8fde\u63a5 code-review&#xff08;\u672c\u5730 SSE&#xff09;\u3001\u667a\u8c31&#xff08;\u8fdc\u7a0b SSE &#043; Authorization&#xff09;\u3001\u9ad8\u5fb7&#xff08;\u8fdc\u7a0b streamable-http &#043; API Key&#xff09;\u65f6&#xff0c;\u914d\u7f6e\u6563\u843d\u5728 application.yml \u5404\u5904\u662f\u5fc5\u7136\u7684\u3002Dream-SaaS \u7684\u89e3\u6cd5\u662f\u62c6\u5206\u4e3a 5 \u4e2a Maven \u5b50\u6a21\u5757&#xff0c;\u7528\u4e00\u4efd Registry YAML \u4f5c\u4e3a\u8fde\u63a5\u5173\u7cfb\u7684&#034;\u5355\u4e00\u6765\u6e90&#034;&#xff1a;<\/p>\n<table>\n<tr>\u5b50\u6a21\u5757\u804c\u8d23<\/tr>\n<tbody>\n<tr>\n<td>dream-saas-mcp-common<\/td>\n<td>\u6a21\u5757 ID\u3001\u8fde\u63a5 ID \u7b49\u516c\u5171\u5e38\u91cf&#xff08;McpModuleIds&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>dream-saas-mcp-spi<\/td>\n<td>McpToolContributor SPI \u63a5\u53e3&#xff08;\u8be6\u89c1 MCP-02&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>dream-saas-mcp-registry<\/td>\n<td>\u540d\u518c YAML &#043; McpRegistryProperties \u914d\u7f6e\u7ed1\u5b9a<\/td>\n<\/tr>\n<tr>\n<td>dream-saas-mcp-server<\/td>\n<td>\u805a\u5408 Contributor \u2192 SyncToolSpecification&#xff0c;\u66b4\u9732\u7ed9 Spring AI MCP Server<\/td>\n<\/tr>\n<tr>\n<td>dream-saas-mcp-client<\/td>\n<td>ChatClient \u88c5\u914d\u3001REST \u8bca\u65ad\u7aef\u70b9\u3001\u8c03\u7528\u89c2\u6d4b\u3001\u8fde\u63a5\u8bca\u65ad<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>Server \u4fa7\u7684\u5de5\u5177\u6ce8\u518c\u673a\u5236&#xff08;McpToolContributor SPI\u3001McpToolContributorAggregator \u805a\u5408\u5668&#xff09;\u5df2\u5728 MCP-02 \u4e2d\u8be6\u7ec6\u62c6\u89e3&#xff0c;\u8fd9\u91cc\u805a\u7126 Client \u4fa7\u7684\u7f16\u6392\u3002<\/p>\n<p>\u6a21\u5757\u5e38\u91cf\u7684\u5b9a\u4e49\u503c\u5f97\u5355\u72ec\u770b\u4e00\u4e0b\u3002McpModuleIds \u7528\u7f16\u8bd1\u671f\u5e38\u91cf\u786e\u4fdd moduleId \u5168\u5c40\u552f\u4e00&#xff0c;\u907f\u514d&#034;\u5b57\u7b26\u4e32\u6563\u843d&#034;\u5e26\u6765\u7684\u62fc\u5199\u9519\u8bef&#xff1a;<\/p>\n<p>public final class McpModuleIds {<br \/>\n    public static final String CODE_REVIEW &#061; &#034;code-review&#034;;<br \/>\n    public static final String GRAPH &#061; &#034;graph&#034;;<br \/>\n    public static final String REPO_ANALYSIS &#061; &#034;repo-analysis&#034;;<br \/>\n    private McpModuleIds() {}<br \/>\n} <\/p>\n<h4>2.2 McpRegistryProperties&#xff1a;\u914d\u7f6e\u7ed1\u5b9a\u7684\u5b8c\u6574\u5b9e\u73b0<\/h4>\n<p>McpRegistryProperties \u662f Registry YAML \u5230 Java \u5bf9\u8c61\u7684\u6865\u6881&#xff0c;\u4f7f\u7528 Spring Boot \u7684 &#064;ConfigurationProperties \u81ea\u52a8\u7ed1\u5b9a\u3002\u4ee5\u4e0b\u662f\u5b8c\u6574\u6e90\u7801&#xff1a;<\/p>\n<p>&#064;ConfigurationProperties(prefix &#061; &#034;dream-saas.mcp.registry&#034;)<br \/>\npublic class McpRegistryProperties {<\/p>\n<p>    \/** \u903b\u8f91 Server \u767b\u8bb0&#xff08;module-id \u5bf9\u5e94\u54ea\u4e2a\u4e1a\u52a1 Contributor&#xff09; *\/<br \/>\n    private Map&lt;String, ServerEntry&gt; servers &#061; new LinkedHashMap&lt;&gt;();<\/p>\n<p>    \/** Client \u5b9e\u9645\u8fde\u63a5\u53c2\u6570&#xff08;\u4e0e spring.ai.mcp.client.sse.connections \u952e\u4e00\u81f4&#xff09; *\/<br \/>\n    private Map&lt;String, ConnectionEntry&gt; connections &#061; new LinkedHashMap&lt;&gt;();<\/p>\n<p>    \/** \u67d0\u5e94\u7528\u5e94\u542f\u7528\u54ea\u4e9b connection-id&#xff08;\u5982 dream-ai-app \u2192 8095 &#043; \u667a\u8c31&#xff09; *\/<br \/>\n    private Map&lt;String, ClientProfileEntry&gt; clientProfiles &#061; new LinkedHashMap&lt;&gt;();<\/p>\n<p>    public List&lt;String&gt; connectionIdsForProfile(String profileId) {<br \/>\n        ClientProfileEntry profile &#061; clientProfiles.get(profileId);<br \/>\n        if (profile &#061;&#061; null || profile.getConnectionIds() &#061;&#061; null) {<br \/>\n            return List.of();<br \/>\n        }<br \/>\n        return new ArrayList&lt;&gt;(profile.getConnectionIds());<br \/>\n    }<\/p>\n<p>    public static class ServerEntry {<br \/>\n        private String moduleId;<br \/>\n        private String url;<br \/>\n        private String sseEndpoint &#061; &#034;\/mcp\/sse&#034;;<br \/>\n        private boolean enabled &#061; true;<br \/>\n        \/\/ getters\/setters \u7701\u7565<br \/>\n    }<\/p>\n<p>    public static class ConnectionEntry {<br \/>\n        private String transport &#061; &#034;sse&#034;;<br \/>\n        private String url;<br \/>\n        private String sseEndpoint;<br \/>\n        \/** streamable-http \u8def\u5f84&#xff08;\u4e0e spring.ai.mcp.client.streamable-http.connections.*.endpoint \u4e00\u81f4&#xff09; *\/<br \/>\n        private String endpoint;<br \/>\n        \/\/ getters\/setters \u7701\u7565<br \/>\n    }<\/p>\n<p>    public static class ClientProfileEntry {<br \/>\n        private List&lt;String&gt; connectionIds &#061; new ArrayList&lt;&gt;();<br \/>\n        \/\/ getters\/setters \u7701\u7565<br \/>\n    }<br \/>\n} <\/p>\n<p>\u4e09\u4e2a\u6838\u5fc3\u5b57\u6bb5\u5bf9\u5e94 YAML \u7684\u4e09\u4e2a\u6bb5\u843d&#xff1a;<\/p>\n<ul>\n<li>servers&#xff1a;\u903b\u8f91 Server \u767b\u8bb0&#xff0c;\u8bb0\u5f55 module-id\u3001URL\u3001SSE \u7aef\u70b9\u8def\u5f84<\/li>\n<li>connections&#xff1a;\u8fde\u63a5\u5143\u6570\u636e&#xff0c;\u8bb0\u5f55\u4f20\u8f93\u534f\u8bae&#xff08;sse\/streamable-http&#xff09;\u548c\u76ee\u6807 URL<\/li>\n<li>clientProfiles&#xff1a;Client Profile&#xff0c;\u58f0\u660e\u67d0\u4e2a\u5e94\u7528\u5e94\u8be5\u8fde\u63a5\u54ea\u4e9b connection-id<\/li>\n<\/ul>\n<p>connectionIdsForProfile() \u65b9\u6cd5\u662f Client Profile \u673a\u5236\u7684\u6838\u5fc3\u5165\u53e3\u2014\u2014\u4e0d\u540c\u5e94\u7528\u901a\u8fc7\u4f20\u5165\u4e0d\u540c\u7684 profileId&#xff0c;\u83b7\u53d6\u81ea\u5df1\u5e94\u8be5\u5efa\u7acb\u7684\u8fde\u63a5\u5217\u8868&#xff0c;\u5b9e\u73b0\u6309\u9700\u88c1\u526a\u8fde\u63a5\u8303\u56f4\u3002<\/p>\n<h4>2.3 Registry YAML&#xff1a;\u8fde\u63a5\u5173\u7cfb\u7684\u5355\u4e00\u6765\u6e90<\/h4>\n<p>Client \u4fa7\u91c7\u7528**&#034;\u53cc\u8f68\u914d\u7f6e&#034;**\u7b56\u7565&#xff1a;\u4e00\u4efd Registry YAML \u8bb0\u5f55&#034;\u903b\u8f91\u4e0a\u6709\u54ea\u4e9b Server\u3001\u54ea\u4e9b Connection&#034;&#xff0c;\u53e6\u4e00\u4efd Spring AI \u914d\u7f6e\u63a7\u5236&#034;\u5b9e\u9645\u53d1\u8d77\u54ea\u4e9b\u8fde\u63a5&#034;\u3002<\/p>\n<p>dream-saas:<br \/>\n  mcp:<br \/>\n    registry:<br \/>\n      # \u903b\u8f91 Server \u5b9a\u4e49<br \/>\n      servers:<br \/>\n        code-review-local:<br \/>\n          module-id: code-review<br \/>\n          url: ${MCP_CODE_REVIEW_SERVER_URL:http:\/\/127.0.0.1:8095}<br \/>\n          sse-endpoint: \/mcp\/sse<br \/>\n          enabled: true<\/p>\n<p>      # Client Profile&#xff1a;\u54ea\u4e2a\u5e94\u7528\u8fde\u54ea\u4e9b Connection<br \/>\n      client-profiles:<br \/>\n        dream-ai-gateway:<br \/>\n          connection-ids:<br \/>\n            &#8211; code-review-local<br \/>\n            &#8211; zhipu-web-search<br \/>\n            &#8211; amap-maps<\/p>\n<p>      # Connection \u5143\u6570\u636e<br \/>\n      connections:<br \/>\n        code-review-local:<br \/>\n          transport: sse<br \/>\n          url: http:\/\/127.0.0.1:8095<br \/>\n        zhipu-web-search:<br \/>\n          transport: sse<br \/>\n          url: https:\/\/open.bigmodel.cn<br \/>\n        amap-maps:<br \/>\n          transport: streamable-http<br \/>\n          url: https:\/\/mcp.amap.com<\/p>\n<p># Spring AI \u5b9e\u9645\u5efa\u8fde&#xff08;\u952e\u540d\u5fc5\u987b\u4e0e registry.connections \u4e00\u81f4&#xff09;<br \/>\nspring:<br \/>\n  ai:<br \/>\n    mcp:<br \/>\n      client:<br \/>\n        sse:<br \/>\n          connections:<br \/>\n            code-review-local:<br \/>\n              url: ${MCP_CODE_REVIEW_SERVER_URL:http:\/\/127.0.0.1:8095}<br \/>\n              sse-endpoint: \/mcp\/sse<br \/>\n            zhipu-web-search:<br \/>\n              url: https:\/\/open.bigmodel.cn<br \/>\n              sse-endpoint: \/api\/mcp\/web_search\/sse?Authorization&#061;${ZHIPU_API_KEY:}<br \/>\n        streamable-http:<br \/>\n          connections:<br \/>\n            amap-maps:<br \/>\n              url: https:\/\/mcp.amap.com<br \/>\n              endpoint: \/mcp?key&#061;${AMAP_MAPS_API_KEY:} <\/p>\n<p>\u8fd9\u5957\u8bbe\u8ba1\u7684\u6838\u5fc3\u4ef7\u503c\u5728\u4e8e Client Profile&#xff1a;dream-ai-gateway \u7684 profile \u58f0\u660e\u4e86\u5b83\u9700\u8981\u8fde\u63a5\u4e09\u4e2a Server&#xff0c;\u800c\u53e6\u4e00\u4e2a\u5e94\u7528\u53ef\u4ee5\u58f0\u660e\u53ea\u8fde\u63a5 code-review-local\u3002\u4e0d\u540c\u5e94\u7528\u6309\u9700\u88c1\u526a\u8fde\u63a5\u8303\u56f4&#xff0c;\u907f\u514d\u542f\u52a8\u65f6\u5efa\u4e00\u5806\u7528\u4e0d\u5230\u7684\u8fdc\u7aef\u8fde\u63a5\u3002<\/p>\n<h4>2.4 \u53cc\u8f68\u914d\u7f6e\u7684\u4e00\u81f4\u6027\u4fdd\u969c<\/h4>\n<p>\u4e24\u5957\u914d\u7f6e\u7684\u952e\u540d\u5fc5\u987b\u4e00\u81f4\u2014\u2014code-review-local\u3001zhipu-web-search\u3001amap-maps \u5728 dream-saas.mcp.registry.connections \u548c spring.ai.mcp.client.sse.connections \u4e2d\u540c\u65f6\u51fa\u73b0\u3002Registry \u8d1f\u8d23&#034;\u6587\u6863\u5316 &#043; \u8bca\u65ad&#034;&#xff0c;Spring AI \u914d\u7f6e\u8d1f\u8d23&#034;\u5b9e\u9645\u5efa\u8fde&#034;\u3002<\/p>\n<p>\u8fd9\u79cd&#034;\u53cc\u8f68&#034;\u8bbe\u8ba1\u770b\u4f3c\u5197\u4f59&#xff0c;\u5b9e\u5219\u6709\u660e\u786e\u7684\u5de5\u7a0b\u610f\u4e49&#xff1a;Registry YAML \u662f\u7ed9\u4eba\u548c\u8bca\u65ad\u5de5\u5177\u770b\u7684&#034;\u58f0\u660e\u5f0f\u5143\u6570\u636e&#034;&#xff0c;Spring AI \u914d\u7f6e\u662f\u7ed9\u6846\u67b6\u6d88\u8d39\u7684\u6267\u884c\u914d\u7f6e\u3002\u4e24\u8005\u952e\u540d\u5bf9\u9f50\u540e&#xff0c;McpClientManager \u53ef\u4ee5\u5728\u542f\u52a8\u65f6\u81ea\u52a8\u6bd4\u5bf9\u4e00\u81f4\u6027\u3002<\/p>\n<h4>2.5 McpClientManager.logRegistryAlignment()&#xff1a;\u542f\u52a8\u65f6\u7684\u914d\u7f6e\u5bf9\u9f50\u6821\u9a8c<\/h4>\n<p>McpClientManager \u5728\u542f\u52a8\u9636\u6bb5\u6267\u884c\u540d\u518c\u5bf9\u9f50\u68c0\u67e5&#xff0c;\u6838\u5fc3\u4ee3\u7801\u5982\u4e0b&#xff1a;<\/p>\n<p>public class McpClientManager {<\/p>\n<p>    private final McpRegistryProperties registryProperties;<br \/>\n    private final Environment environment;<br \/>\n    private final String clientProfileId;<\/p>\n<p>    public void logRegistryAlignment() {<br \/>\n        List&lt;String&gt; expected &#061; registryProperties.connectionIdsForProfile(clientProfileId);<br \/>\n        log.warn(<br \/>\n                &#034;[MCP-CLIENT] registry profile&#061;{} expectedConnections&#061;{} registryConnections&#061;{}&#034;,<br \/>\n                clientProfileId,<br \/>\n                expected,<br \/>\n                registryProperties.getConnections().keySet());<br \/>\n        McpConnectionDiagnostics.logProbeResultsAsync(log, environment);<br \/>\n    }<\/p>\n<p>    public Map&lt;String, Object&gt; snapshot() {<br \/>\n        Map&lt;String, Object&gt; body &#061; new LinkedHashMap&lt;&gt;();<br \/>\n        body.put(&#034;clientProfileId&#034;, clientProfileId);<br \/>\n        body.put(&#034;expectedConnectionIds&#034;,<br \/>\n                registryProperties.connectionIdsForProfile(clientProfileId));<br \/>\n        body.put(&#034;connections&#034;, registryProperties.getConnections());<br \/>\n        body.put(&#034;servers&#034;, registryProperties.getServers());<br \/>\n        return body;<br \/>\n    }<br \/>\n} <\/p>\n<p>\u542f\u52a8\u65f6\u4f1a\u8f93\u51fa\u7c7b\u4f3c [MCP-CLIENT] registry profile&#061;dream-ai-gateway expectedConnections&#061;[code-review-local, zhipu-web-search, amap-maps] \u7684\u5bf9\u9f50\u65e5\u5fd7\u3002\u8fd0\u7ef4\u4eba\u5458\u4e00\u773c\u5c31\u80fd\u786e\u8ba4&#034;\u8c01\u8be5\u8fde\u3001\u8c01\u5b9e\u9645\u8fde\u4e86&#034;\u3002\u5982\u679c expectedConnections \u548c registryConnections \u4e0d\u4e00\u81f4&#xff0c;\u8bf4\u660e\u53cc\u8f68\u914d\u7f6e\u51fa\u73b0\u4e86\u504f\u5dee&#xff0c;\u9700\u8981\u7acb\u5373\u6392\u67e5\u3002<\/p>\n<p>\u6ce8\u610f logRegistryAlignment() \u7684\u6700\u540e\u4e00\u6b65\u8c03\u7528\u4e86 McpConnectionDiagnostics.logProbeResultsAsync()\u2014\u2014\u914d\u7f6e\u5bf9\u9f50\u68c0\u67e5\u5b8c\u6210\u540e&#xff0c;\u7d27\u63a5\u7740\u5c31\u662f\u8fde\u63a5\u53ef\u8fbe\u6027\u63a2\u6d4b&#xff0c;\u4e24\u8005\u6784\u6210\u4e86\u542f\u52a8\u9636\u6bb5\u7684\u5b8c\u6574\u8bca\u65ad\u94fe\u3002<\/p>\n<h4>2.6 default vs prod&#xff1a;\u751f\u4ea7\u914d\u7f6e\u7626\u8eab\u7b56\u7565<\/h4>\n<p>\u5f00\u53d1\u73af\u5883\u548c\u751f\u4ea7\u73af\u5883\u7684\u914d\u7f6e\u5dee\u5f02\u662f\u5de5\u7a0b\u5316\u843d\u5730\u7684\u5173\u952e\u73af\u8282\u3002\u4ee5\u4e0b\u662f dream-saas-mcp-registry-default.yml&#xff08;\u5f00\u53d1\u73af\u5883&#xff09;\u7684\u5173\u952e\u7247\u6bb5&#xff1a;<\/p>\n<p># \u5f00\u53d1\u73af\u5883&#xff1a;\u8fde\u63a5\u6240\u6709 Server<br \/>\ndream-saas:<br \/>\n  mcp:<br \/>\n    registry:<br \/>\n      client-profiles:<br \/>\n        dream-ai-gateway:<br \/>\n          connection-ids:<br \/>\n            &#8211; code-review-local<br \/>\n            &#8211; zhipu-web-search<br \/>\n            &#8211; amap-maps<br \/>\n      connections:<br \/>\n        code-review-local:<br \/>\n          transport: sse<br \/>\n          url: ${MCP_CODE_REVIEW_SERVER_URL:http:\/\/127.0.0.1:8095}<br \/>\n        zhipu-web-search:<br \/>\n          transport: sse<br \/>\n          url: https:\/\/open.bigmodel.cn<br \/>\n          sse-endpoint: \/api\/mcp\/web_search\/sse?Authorization&#061;${ZHIPU_API_KEY:}<br \/>\n        amap-maps:<br \/>\n          transport: streamable-http<br \/>\n          url: https:\/\/mcp.amap.com<br \/>\n          endpoint: \/mcp?key&#061;${AMAP_MAPS_API_KEY:}<\/p>\n<p>spring:<br \/>\n  ai:<br \/>\n    mcp:<br \/>\n      client:<br \/>\n        sse:<br \/>\n          connections:<br \/>\n            code-review-local:<br \/>\n              url: ${MCP_CODE_REVIEW_SERVER_URL:http:\/\/127.0.0.1:8095}<br \/>\n            zhipu-web-search:<br \/>\n              url: https:\/\/open.bigmodel.cn<br \/>\n              sse-endpoint: \/api\/mcp\/web_search\/sse?Authorization&#061;${ZHIPU_API_KEY:}<br \/>\n        streamable-http:<br \/>\n          connections:<br \/>\n            amap-maps:<br \/>\n              url: https:\/\/mcp.amap.com<br \/>\n              endpoint: \/mcp?key&#061;${AMAP_MAPS_API_KEY:} <\/p>\n<p>\u751f\u4ea7\u73af\u5883 dream-saas-mcp-registry-prod.yml \u505a\u4e86\u5927\u5e45\u7626\u8eab&#xff1a;<\/p>\n<p># \u73b0\u7f51 MCP \u540d\u518c&#xff1a;\u4ec5\u672c\u673a code-review&#xff0c;\u907f\u514d\u65e0 Key \u7684\u5916\u90e8\u8fde\u63a5\u62d6\u57ae\u542f\u52a8<br \/>\ndream-saas:<br \/>\n  mcp:<br \/>\n    registry:<br \/>\n      servers:<br \/>\n        code-review-local:<br \/>\n          module-id: code-review<br \/>\n          url: ${MCP_CODE_REVIEW_SERVER_URL:http:\/\/127.0.0.1:8095}<br \/>\n          sse-endpoint: ${MCP_CODE_REVIEW_SSE_PATH:\/mcp\/sse}<br \/>\n          enabled: true<br \/>\n      client-profiles:<br \/>\n        dream-ai-gateway:<br \/>\n          connection-ids:<br \/>\n            &#8211; code-review-local    # \u53ea\u8fde\u672c\u5730 Server<br \/>\n      connections:<br \/>\n        code-review-local:<br \/>\n          transport: sse<br \/>\n          url: ${MCP_CODE_REVIEW_SERVER_URL:http:\/\/127.0.0.1:8095}<\/p>\n<p>spring:<br \/>\n  ai:<br \/>\n    mcp:<br \/>\n      client:<br \/>\n        sse:<br \/>\n          connections:<br \/>\n            code-review-local:<br \/>\n              url: ${MCP_CODE_REVIEW_SERVER_URL:http:\/\/127.0.0.1:8095}<br \/>\n        streamable-http:<br \/>\n          connections: {}    # \u663e\u5f0f\u6e05\u7a7a\u5916\u90e8\u8fde\u63a5 <\/p>\n<p>\u5bf9\u6bd4\u4e24\u4e2a\u914d\u7f6e&#xff0c;\u5dee\u5f02\u4e00\u76ee\u4e86\u7136&#xff1a;<\/p>\n<table>\n<tr>\u914d\u7f6e\u9879default&#xff08;\u5f00\u53d1&#xff09;prod&#xff08;\u751f\u4ea7&#xff09;<\/tr>\n<tbody>\n<tr>\n<td>client-profiles connection-ids<\/td>\n<td>3 \u4e2a&#xff08;code-review &#043; \u667a\u8c31 &#043; \u9ad8\u5fb7&#xff09;<\/td>\n<td>1 \u4e2a&#xff08;code-review&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>SSE \u8fde\u63a5\u6570<\/td>\n<td>2<\/td>\n<td>1<\/td>\n<\/tr>\n<tr>\n<td>streamable-http \u8fde\u63a5\u6570<\/td>\n<td>1<\/td>\n<td>0&#xff08;connections: {}&#xff09;<\/td>\n<\/tr>\n<tr>\n<td>\u9700\u8981\u7684\u73af\u5883\u53d8\u91cf<\/td>\n<td>ZHIPU_API_KEY\u3001AMAP_MAPS_API_KEY\u3001MCP_CODE_REVIEW_SERVER_URL<\/td>\n<td>\u4ec5 MCP_CODE_REVIEW_SERVER_URL<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u8fd9\u4e0d\u662f&#034;\u5077\u5de5\u51cf\u6599&#034;&#xff0c;\u800c\u662f\u52a1\u5b9e\u7684\u5de5\u7a0b\u51b3\u7b56\u3002\u751f\u4ea7\u73af\u5883\u6ca1\u6709\u914d\u7f6e\u667a\u8c31\u548c\u9ad8\u5fb7\u7684 API Key&#xff0c;\u5982\u679c\u4ecd\u7136\u5c1d\u8bd5\u5efa\u8fde&#xff0c;SSE \u957f\u8fde\u63a5\u4f1a\u53cd\u590d\u5931\u8d25&#xff0c;\u4ea7\u751f\u5927\u91cf SSE stream observed an error \u8b66\u544a&#xff0c;\u751a\u81f3\u62d6\u57ae\u5e94\u7528\u542f\u52a8\u3002<\/p>\n<p>\u503c\u5f97\u6ce8\u610f\u7684\u6280\u672f\u7ec6\u8282&#xff1a;streamable-http.connections: {} \u4e0d\u662f&#034;\u6ca1\u5199&#034;&#xff0c;\u800c\u662f\u663e\u5f0f\u6e05\u7a7a\u3002\u5728 YAML \u4e2d\u5982\u679c\u53ea\u662f\u4e0d\u5199\u5185\u5bb9&#xff0c;Spring Boot \u7684 relaxed binding \u53ef\u80fd\u4f1a\u4ece default profile \u7ee7\u627f\u9ed8\u8ba4\u503c\u3002\u7528 connections: {} \u663e\u5f0f\u8bbe\u4e3a\u7a7a Map&#xff0c;\u624d\u80fd\u771f\u6b63\u8986\u76d6 default \u914d\u7f6e\u3002<\/p>\n<h3>\u4e09\u3001\u53ef\u89c2\u6d4b\u6027&#xff1a;\u8ba9\u6bcf\u6b21 MCP \u8c03\u7528\u90fd\u6709\u8ff9\u53ef\u5faa<\/h3>\n<p>\u5f53 Client \u540c\u65f6\u8fde\u63a5\u591a\u4e2a MCP Server \u65f6&#xff0c;\u4e00\u6b21 \/mcp\/ask \u8bf7\u6c42\u53ef\u80fd\u89e6\u53d1\u591a\u6b21 tool call\u3002\u5982\u679c\u6bcf\u6b21\u8c03\u7528\u90fd\u662f&#034;\u9ed1\u76d2&#034;&#xff0c;\u51fa\u4e86\u95ee\u9898\u6839\u672c\u65e0\u4ece\u6392\u67e5\u3002Dream-SaaS \u7684\u89c2\u6d4b\u65b9\u6848\u5206\u4e09\u5c42&#xff1a;\u8c03\u7528\u7ea7\u65e5\u5fd7\u3001\u542f\u52a8\u7ea7\u8bca\u65ad\u548c\u5168\u94fe\u8def\u8ffd\u8e2a\u3002<\/p>\n<h4>3.1 LoggingToolCallback&#xff1a;\u88c5\u9970\u5668\u6a21\u5f0f\u7684\u8c03\u7528\u65e5\u5fd7<\/h4>\n<p>LoggingToolCallback \u7528\u88c5\u9970\u5668\u6a21\u5f0f\u5305\u88c5\u539f\u59cb ToolCallback&#xff0c;\u5728\u6bcf\u6b21\u5de5\u5177\u8c03\u7528\u524d\u540e\u63d2\u5165\u65e5\u5fd7\u3002\u8fd9\u662f\u6574\u4e2a\u89c2\u6d4b\u4f53\u7cfb\u7684\u57fa\u7840&#xff1a;<\/p>\n<p>public final class LoggingToolCallback implements ToolCallback {<\/p>\n<p>    private static final Logger log &#061; LoggerFactory.getLogger(<br \/>\n            McpClientObservability.LOGGER_NAME);<\/p>\n<p>    private final ToolCallback delegate;<\/p>\n<p>    private LoggingToolCallback(ToolCallback delegate) {<br \/>\n        this.delegate &#061; delegate;<br \/>\n    }<\/p>\n<p>    public static ToolCallback wrap(ToolCallback delegate) {<br \/>\n        if (delegate &#061;&#061; null) return null;<br \/>\n        return new LoggingToolCallback(delegate);<br \/>\n    }<\/p>\n<p>    &#064;Override<br \/>\n    public String call(String toolInput) {<br \/>\n        String toolName &#061; toolName();<br \/>\n        String connection &#061; resolveConnection(toolName);<br \/>\n        int inputLen &#061; toolInput &#061;&#061; null ? 0 : toolInput.length();<br \/>\n        long startMs &#061; System.currentTimeMillis();<\/p>\n<p>        log.info(&#034;[MCP-TOOL] invoke | connection&#061;{} | tool&#061;{} | inputChars&#061;{}&#034;,<br \/>\n                connection, toolName, inputLen);<br \/>\n        try {<br \/>\n            String result &#061; delegate.call(toolInput);<br \/>\n            long endMs &#061; System.currentTimeMillis();<br \/>\n            int resultLen &#061; result &#061;&#061; null ? 0 : result.length();<br \/>\n            log.info(&#034;[MCP-TOOL] success | connection&#061;{} | elapsedMs&#061;{} | resultChars&#061;{}&#034;,<br \/>\n                    connection, endMs &#8211; startMs, resultLen);<br \/>\n            appendToolSpan(toolName, connection, true, startMs, endMs, inputLen, resultLen, null);<br \/>\n            return result;<br \/>\n        } catch (RuntimeException ex) {<br \/>\n            long endMs &#061; System.currentTimeMillis();<br \/>\n            log.info(&#034;[MCP-TOOL] failed | connection&#061;{} | elapsedMs&#061;{} | error&#061;{}&#034;,<br \/>\n                    connection, endMs &#8211; startMs, ex.getMessage());<br \/>\n            appendToolSpan(toolName, connection, false, startMs, endMs, inputLen, 0, ex.getMessage());<br \/>\n            throw ex;<br \/>\n        }<br \/>\n    }<br \/>\n} <\/p>\n<p>\u88c5\u9970\u5668\u6a21\u5f0f\u7684\u8bbe\u8ba1\u8003\u91cf&#xff1a;\u8fd9\u91cc\u9009\u62e9\u88c5\u9970\u5668\u800c\u975e AOP \u6216 Filter&#xff0c;\u539f\u56e0\u6709\u4e09\u2014\u2014\u7b2c\u4e00&#xff0c;ToolCallback \u662f Spring AI \u7684\u63a5\u53e3&#xff0c;\u88c5\u9970\u5668\u662f\u6700\u81ea\u7136\u7684\u6269\u5c55\u65b9\u5f0f&#xff1b;\u7b2c\u4e8c&#xff0c;\u88c5\u9970\u5668\u53ef\u4ee5\u62ff\u5230 toolName() \u548c resolveConnection() \u7684\u4e0a\u4e0b\u6587\u4fe1\u606f&#xff0c;\u8fd9\u4e9b\u5728 AOP \u7684 JoinPoint \u4e2d\u4e0d\u5bb9\u6613\u83b7\u53d6&#xff1b;\u7b2c\u4e09&#xff0c;\u88c5\u9970\u5668\u7684\u5305\u88c5\u987a\u5e8f\u53ef\u63a7&#xff0c;\u907f\u514d\u88ab\u5176\u4ed6 AOP \u5207\u9762\u5e72\u6270\u3002<\/p>\n<p>resolveConnection() \u901a\u8fc7\u5de5\u5177\u540d\u524d\u7f00\u63a8\u65ad\u8fde\u63a5\u5f52\u5c5e&#xff1a;<\/p>\n<p>private static String resolveConnection(String toolName) {<br \/>\n    if (toolName &#061;&#061; null || toolName.isBlank()) return &#034;unknown&#034;;<br \/>\n    if (toolName.startsWith(&#034;maps_&#034;))       return &#034;amap-maps&#034;;<br \/>\n    if (toolName.startsWith(&#034;webSearch&#034;))   return &#034;zhipu-web-search&#034;;<br \/>\n    if (toolName.startsWith(&#034;review_&#034;) ||<br \/>\n        toolName.startsWith(&#034;list_&#034;) ||<br \/>\n        toolName.startsWith(&#034;get_&#034;))        return &#034;code-review-local&#034;;<br \/>\n    if (toolName.startsWith(&#034;graph_&#034;))      return &#034;dream-ai-graph&#034;;<br \/>\n    return &#034;unknown&#034;;<br \/>\n} <\/p>\n<p>\u5305\u88c5\u53d1\u751f\u5728 McpConfig \u7684 ChatClient \u88c5\u914d\u9636\u6bb5&#xff1a;<\/p>\n<p>&#064;Bean(&#034;mcpChatClient&#034;)<br \/>\npublic ChatClient mcpChatClient(ChatModel chatModel,<br \/>\n        ObjectProvider&lt;SyncMcpToolCallbackProvider&gt; provider) {<br \/>\n    ChatClient.Builder builder &#061; ChatClient.builder(chatModel);<br \/>\n    provider.ifAvailable(p -&gt; {<br \/>\n        ToolCallback[] wrapped &#061; Arrays.stream(p.getToolCallbacks())<br \/>\n                .map(LoggingToolCallback::wrap)  \/\/ \u9010\u4e2a\u5305\u88c5<br \/>\n                .toArray(ToolCallback[]::new);<br \/>\n        builder.defaultToolCallbacks(wrapped);<br \/>\n    });<br \/>\n    return builder.build();<br \/>\n} <\/p>\n<p>\u8fd9\u91cc\u4f7f\u7528 ObjectProvider&lt;SyncMcpToolCallbackProvider&gt; \u800c\u975e\u76f4\u63a5\u6ce8\u5165&#xff0c;\u662f\u5173\u952e\u7684\u8bbe\u8ba1\u9009\u62e9\u3002ObjectProvider \u662f Spring \u7684\u5ef6\u8fdf\u67e5\u627e\u673a\u5236&#xff0c;\u5982\u679c SyncMcpToolCallbackProvider \u4e0d\u5b58\u5728&#xff08;\u6bd4\u5982 spring.ai.mcp.client.enabled&#061;false&#xff09;&#xff0c;ifAvailable() \u4f1a\u9759\u9ed8\u8df3\u8fc7&#xff0c;\u4e0d\u4f1a\u5bfc\u81f4 Bean \u521b\u5efa\u5931\u8d25\u3002<\/p>\n<h4>3.2 McpClientObservability&#xff1a;\u89c2\u6d4b\u5de5\u5177\u65b9\u6cd5\u96c6<\/h4>\n<p>McpClientObservability \u662f\u89c2\u6d4b\u4f53\u7cfb\u7684\u5de5\u5177\u7c7b&#xff0c;\u63d0\u4f9b\u4e86\u5de5\u5177\u6e05\u5355\u63d0\u53d6\u3001\u8fde\u63a5\u5206\u7ec4\u3001\u54cd\u5e94\u6458\u8981\u7b49\u8f85\u52a9\u65b9\u6cd5\u3002\u4ee5\u4e0b\u662f\u6838\u5fc3\u5b9e\u73b0&#xff1a;<\/p>\n<p>public final class McpClientObservability {<\/p>\n<p>    public static final String LOGGER_NAME &#061; &#034;com.zhu.dream.ai.mcp.client.observability&#034;;<\/p>\n<p>    \/** \u63d0\u53d6 provider \u4e2d\u6240\u6709\u5de5\u5177\u540d&#xff08;\u6392\u5e8f\u540e\u8fd4\u56de&#xff09; *\/<br \/>\n    public static List&lt;String&gt; toolNames(SyncMcpToolCallbackProvider provider) {<br \/>\n        if (provider &#061;&#061; null) return List.of();<br \/>\n        return Arrays.stream(provider.getToolCallbacks())<br \/>\n                .map(ToolCallback::getToolDefinition)<br \/>\n                .map(def -&gt; def !&#061; null ? def.name() : &#034;?&#034;)<br \/>\n                .sorted()<br \/>\n                .toList();<br \/>\n    }<\/p>\n<p>    \/** \u6309 connection \u5206\u7ec4\u5de5\u5177\u540d&#xff08;\u57fa\u4e8e\u547d\u540d\u7ea6\u5b9a&#xff09; *\/<br \/>\n    public static Map&lt;String, List&lt;String&gt;&gt; groupToolsByConnection(<br \/>\n            List&lt;String&gt; toolNames, List&lt;String&gt; configuredConnections) {<br \/>\n        Map&lt;String, List&lt;String&gt;&gt; groups &#061; new LinkedHashMap&lt;&gt;();<br \/>\n        for (String connection : configuredConnections) {<br \/>\n            groups.put(connection, new ArrayList&lt;&gt;());<br \/>\n        }<br \/>\n        groups.put(&#034;unclassified&#034;, new ArrayList&lt;&gt;());<\/p>\n<p>        for (String name : toolNames) {<br \/>\n            String group &#061; classifyToolConnection(name, configuredConnections);<br \/>\n            groups.computeIfAbsent(group, k -&gt; new ArrayList&lt;&gt;()).add(name);<br \/>\n        }<br \/>\n        groups.entrySet().removeIf(e -&gt; e.getValue().isEmpty());<br \/>\n        return groups;<br \/>\n    }<\/p>\n<p>    \/** \u6587\u672c\u622a\u65ad&#xff08;\u65e5\u5fd7\u5b89\u5168&#xff09; *\/<br \/>\n    public static String truncate(String text, int maxChars) {<br \/>\n        if (text &#061;&#061; null) return &#034;&#034;;<br \/>\n        if (text.length() &lt;&#061; maxChars) return text;<br \/>\n        return text.substring(0, maxChars) &#043; &#034;\u2026&#034;;<br \/>\n    }<br \/>\n} <\/p>\n<p>groupToolsByConnection() \u7684\u8bbe\u8ba1\u610f\u56fe\u662f&#xff1a;\u542f\u52a8\u65f6\u8ba9\u8fd0\u7ef4\u4eba\u5458\u4e00\u773c\u770b\u6e05&#034;\u6bcf\u4e2a connection \u4e0b\u9762\u6302\u4e86\u54ea\u4e9b tool&#034;\u3002\u5206\u7ec4\u7684\u4f9d\u636e\u662f\u5de5\u5177\u540d\u524d\u7f00\u4e0e resolveConnection() \u76f8\u540c\u7684\u547d\u540d\u7ea6\u5b9a\u3002unclassified \u5206\u7ec4\u7528\u6765\u6536\u96c6\u65e0\u6cd5\u5f52\u7c7b\u7684\u5de5\u5177&#xff0c;\u65b9\u4fbf\u6392\u67e5\u662f\u5426\u6709\u5de5\u5177\u540d\u4e0d\u7b26\u5408\u7ea6\u5b9a\u3002<\/p>\n<p>truncate() \u65b9\u6cd5\u770b\u4f3c\u7b80\u5355&#xff0c;\u4f46\u5728\u65e5\u5fd7\u573a\u666f\u4e0b\u975e\u5e38\u91cd\u8981\u2014\u2014\u7528\u6237\u95ee\u9898\u53ef\u80fd\u5f88\u957f&#xff0c;\u76f4\u63a5\u6253\u5230\u65e5\u5fd7\u91cc\u4f1a\u5bfc\u81f4\u65e5\u5fd7\u884c\u81a8\u80c0&#xff0c;\u5f71\u54cd\u65e5\u5fd7\u91c7\u96c6\u548c\u68c0\u7d22\u3002\u7edf\u4e00\u622a\u65ad\u5230 120 \u5b57\u7b26&#xff08;\/mcp\/ask \u4e2d\u7684\u7528\u6cd5&#xff09;&#xff0c;\u65e2\u4fdd\u7559\u4e86\u8db3\u591f\u7684\u4e0a\u4e0b\u6587\u4fe1\u606f&#xff0c;\u53c8\u907f\u514d\u65e5\u5fd7\u7206\u70b8\u3002<\/p>\n<h4>3.3 McpClientStartupReporter&#xff1a;\u542f\u52a8\u7ea7\u8bca\u65ad<\/h4>\n<p>\u8c03\u7528\u7ea7\u65e5\u5fd7\u89e3\u51b3\u7684\u662f&#034;\u8fd0\u884c\u65f6\u53ef\u89c2\u6d4b&#034;&#xff0c;\u4f46\u5f88\u591a MCP \u8fde\u63a5\u95ee\u9898\u53d1\u751f\u5728\u542f\u52a8\u9636\u6bb5\u3002McpClientStartupReporter \u5728\u542f\u52a8\u5b8c\u6210\u540e\u6253\u5370\u4e00\u4efd&#034;\u5de5\u5177\u6e05\u5355&#034;&#xff1a;<\/p>\n<p>public void report() {<br \/>\n    boolean mcpClientEnabled &#061; environment.getProperty(<br \/>\n            &#034;spring.ai.mcp.client.enabled&#034;, Boolean.class, false);<br \/>\n    List&lt;String&gt; configuredConnections &#061;<br \/>\n            McpClientObservability.configuredConnectionNames(environment);<br \/>\n    SyncMcpToolCallbackProvider provider &#061;<br \/>\n            syncMcpToolCallbackProvider.getIfAvailable();<br \/>\n    if (provider &#061;&#061; null) {<br \/>\n        log.info(&#034;[MCP-CLIENT] startup | enabled&#061;{} | &#034;<br \/>\n                &#043; &#034;provider&#061;missing | configuredConnections&#061;{}&#034;,<br \/>\n                mcpClientEnabled, configuredConnections);<br \/>\n        return;<br \/>\n    }<br \/>\n    List&lt;String&gt; toolNames &#061; McpClientObservability.toolNames(provider);<br \/>\n    Map&lt;String, List&lt;String&gt;&gt; groups &#061;<br \/>\n            McpClientObservability.groupToolsByConnection(<br \/>\n                    toolNames, configuredConnections);<br \/>\n    log.info(&#034;[MCP-CLIENT] startup | enabled&#061;{} | &#034;<br \/>\n            &#043; &#034;toolCount&#061;{} | toolGroups&#061;{}&#034;,<br \/>\n            mcpClientEnabled, toolNames.size(), groups);<br \/>\n} <\/p>\n<p>\u542f\u52a8\u540e\u4f60\u4f1a\u770b\u5230\u8fd9\u6837\u7684\u65e5\u5fd7&#xff1a;<\/p>\n<p>[MCP-CLIENT] startup | enabled&#061;true | toolCount&#061;5 | toolGroups&#061;{<br \/>\n  code-review-local&#061;[review_code, suggest_fix, analyze_complexity],<br \/>\n  zhipu-web-search&#061;[webSearch],<br \/>\n  amap-maps&#061;[maps_direction_driving, maps_geo]<br \/>\n} <\/p>\n<p>\u6bcf\u4e2a connection \u4e0b\u9762\u6302\u4e86\u54ea\u4e9b tool&#xff0c;\u4e00\u76ee\u4e86\u7136\u3002\u5982\u679c provider&#061;missing&#xff0c;\u8bf4\u660e Spring AI \u7684 MCP Client \u6ca1\u6709\u6b63\u786e\u521d\u59cb\u5316\u3002\u5982\u679c\u67d0\u4e2a connection \u4e0b tool \u6570\u91cf\u4e3a 0&#xff0c;\u8bf4\u660e\u5bf9\u5e94 Server \u7684\u5de5\u5177\u5217\u8868\u672a\u6210\u529f\u62c9\u53d6\u3002<\/p>\n<h4>3.4 \u4e00\u6b21 \/mcp\/ask \u7684\u5b8c\u6574\u94fe\u8def<\/h4>\n<p>McpAskController \u662f Dream-SaaS \u7684 MCP \u95ee\u7b54\u5165\u53e3&#xff0c;\u5b83\u5c55\u793a\u4e86\u4e00\u6761\u5b8c\u6574\u7684\u8c03\u7528\u94fe\u8def\u3002\u4ee5\u4e0b\u662f executeAsk() \u7684\u5173\u952e\u7247\u6bb5&#xff1a;<\/p>\n<p>private AskResult executeAsk(String question, String userId) {<br \/>\n    String q &#061; question &#061;&#061; null ? &#034;&#034; : question;<br \/>\n    String traceId &#061; &#034;mcp-&#034; &#043; UUID.randomUUID().toString()<br \/>\n            .replace(&#034;-&#034;, &#034;&#034;).substring(0, 16);<br \/>\n    SyncMcpToolCallbackProvider provider &#061; syncMcpToolCallbackProvider.getIfAvailable();<br \/>\n    int toolCount &#061; provider &#061;&#061; null ? 0 : provider.getToolCallbacks().length;<\/p>\n<p>    log.info(&#034;[MCP-CLIENT] ask start | traceId&#061;{} | toolCount&#061;{} | question&#061;{}&#034;,<br \/>\n            traceId, toolCount, McpClientObservability.truncate(q, 120));<\/p>\n<p>    long startMs &#061; System.currentTimeMillis();<br \/>\n    ObserveCallerContext.set(userId);<br \/>\n    ObserveCallerContext.setRunId(traceId);<br \/>\n    try {<br \/>\n        ChatResponse chatResponse &#061; chatClient.prompt().user(q).call().chatResponse();<br \/>\n        AskSummary summary &#061; McpClientObservability.summarizeAskResponse(chatResponse);<br \/>\n        String content &#061; McpClientObservability.extractAnswerText(chatResponse);<br \/>\n        long durationMs &#061; System.currentTimeMillis() &#8211; startMs;<\/p>\n<p>        \/\/ \u8865\u4e00\u6761 chat span&#xff0c;\u5de5\u5177\u7531 LoggingToolCallback \u5199\u5165<br \/>\n        RunObserveBuffer.append(traceId,<br \/>\n                RunObserveBuffer.chatSpan(&#034;mcp-chat-&#034; &#043; shortId(), null,<br \/>\n                        &#034;mcp-ask&#034;, true, startMs, System.currentTimeMillis(),<br \/>\n                        Map.of(&#034;dreamsaas.source&#034;, &#034;mcp&#034;,<br \/>\n                               &#034;gen_ai.operation.name&#034;, &#034;chat&#034;,<br \/>\n                               &#034;mcp.registryToolCount&#034;, toolCount)));<\/p>\n<p>        log.info(&#034;[MCP-CLIENT] ask done | traceId&#061;{} | durationMs&#061;{} | &#034;<br \/>\n                &#043; &#034;answerChars&#061;{} | modelToolCalls&#061;{}&#034;,<br \/>\n                traceId, durationMs, summary.answerChars(), summary.toolCallsSummary());<br \/>\n        return new AskResult(content, toolCalls, durationMs, traceId);<br \/>\n    } finally {<br \/>\n        List&lt;AgentSpanSnapshot&gt; live &#061; RunObserveBuffer.drain(traceId);<br \/>\n        AgentTraceCapture cap &#061; traceCapture.getIfAvailable();<br \/>\n        if (cap !&#061; null) {<br \/>\n            cap.capture(toSnapshot(traceId, userId, q, content, ok,<br \/>\n                    startMs, endMs, live, toolCalls, toolCount));<br \/>\n        }<br \/>\n        ObserveCallerContext.clear();<br \/>\n    }<br \/>\n} <\/p>\n<p>\u4e00\u6b21\u5b8c\u6574\u7684\u8bf7\u6c42\u94fe\u8def\u5982\u4e0b&#xff1a;<\/p>\n<ul>\n<li>\u8bf7\u6c42\u5230\u8fbe&#xff1a;\u751f\u6210\u552f\u4e00 traceId&#xff0c;\u8bb0\u5f55\u5f53\u524d\u53ef\u7528\u5de5\u5177\u6570<\/li>\n<li>LLM \u51b3\u7b56&#xff1a;ChatClient.prompt().user(q).call() \u5c06\u95ee\u9898\u53d1\u7ed9\u5927\u6a21\u578b&#xff0c;\u6a21\u578b\u51b3\u5b9a\u8c03\u7528\u54ea\u4e9b MCP \u5de5\u5177<\/li>\n<li>\u5de5\u5177\u6267\u884c&#xff1a;\u6bcf\u4e2a MCP \u5de5\u5177\u8c03\u7528\u7ecf\u8fc7 LoggingToolCallback&#xff0c;\u4ea7\u751f [MCP-TOOL] invoke \/ success \/ failed \u65e5\u5fd7<\/li>\n<li>Trace \u91c7\u96c6&#xff1a;\u901a\u8fc7 RunObserveBuffer \u6536\u96c6\u6240\u6709 span&#xff08;chat span &#043; tool spans&#xff09;&#xff0c;finally \u5757\u4e2d\u901a\u8fc7 AgentTraceCapture \u6301\u4e45\u5316<\/li>\n<li>\u7ed3\u679c\u6c47\u603b&#xff1a;\u54cd\u5e94\u4f53\u5305\u542b answer\u3001toolCalls\u3001durationMs\u3001traceId \u56db\u4e2a\u5173\u952e\u5b57\u6bb5<\/li>\n<\/ul>\n<p>\u5bf9\u5e94\u65e5\u5fd7\u94fe\u8def&#xff1a;<\/p>\n<p>[MCP-CLIENT] ask start | traceId&#061;mcp-a1b2c3d4e5f67890 | toolCount&#061;5 | question&#061;\u5e2e\u6211\u5ba1\u67e5\u8fd9\u6bb5\u4ee3\u7801&#8230;<br \/>\n[MCP-TOOL] invoke  | connection&#061;code-review-local | tool&#061;review_code | inputChars&#061;256<br \/>\n[MCP-TOOL] success | connection&#061;code-review-local | elapsedMs&#061;1823 | resultChars&#061;1024<br \/>\n[MCP-TOOL] invoke  | connection&#061;code-review-local | tool&#061;suggest_fix | inputChars&#061;1024<br \/>\n[MCP-TOOL] success | connection&#061;code-review-local | elapsedMs&#061;982 | resultChars&#061;512<br \/>\n[MCP-CLIENT] ask done | traceId&#061;mcp-a1b2c3d4e5f67890 | durationMs&#061;3842 | answerChars&#061;386 <\/p>\n<p>\u4ece ask start \u5230 ask done&#xff0c;\u4e2d\u95f4\u5939\u7740\u6bcf\u6b21\u5de5\u5177\u8c03\u7528\u7684 invoke \/ success\u2014\u2014\u8fd9\u5c31\u662f MCP \u5de5\u7a0b\u5316\u4e2d\u6700\u6734\u7d20\u7684&#034;\u5168\u94fe\u8def\u8ffd\u8e2a&#034;\u3002\u4e0d\u9700\u8981\u5f15\u5165 OpenTelemetry \u4e4b\u7c7b\u7684\u91cd\u578b\u6846\u67b6&#xff0c;\u7528\u88c5\u9970\u5668\u6a21\u5f0f &#043; \u7ed3\u6784\u5316\u65e5\u5fd7\u5c31\u80fd\u8986\u76d6\u6838\u5fc3\u573a\u666f\u3002<\/p>\n<h3>\u56db\u3001\u8fde\u63a5\u751f\u547d\u5468\u671f\u7ba1\u7406&#xff1a;\u63a2\u6d4b\u3001\u91cd\u8bd5\u4e0e\u4f18\u96c5\u964d\u7ea7<\/h3>\n<p>\u524d\u4e09\u8282\u89e3\u51b3\u4e86&#034;\u8fde\u54ea\u4e9b Server&#034;\u3001&#034;\u8c03\u7528\u8fc7\u7a0b\u600e\u4e48\u770b&#034;\u7684\u95ee\u9898\u3002\u4f46\u8fd8\u6709\u4e00\u4e2a\u5173\u952e\u573a\u666f\u6ca1\u6709\u8986\u76d6&#xff1a;\u8fde\u63a5\u7684\u751f\u547d\u5468\u671f\u3002\u4e00\u4e2a MCP Server \u4e0d\u662f\u6c38\u8fdc\u5728\u7ebf\u7684&#xff0c;SSE \u957f\u8fde\u63a5\u53ef\u80fd\u56e0\u4e3a\u7f51\u7edc\u6296\u52a8\u65ad\u5f00&#xff0c;\u8fdc\u7aef\u670d\u52a1\u53ef\u80fd\u8d85\u65f6\u3002Dream-SaaS \u7684 McpConnectionDiagnostics \u63d0\u4f9b\u4e86\u4e00\u5957\u5b8c\u6574\u7684\u8fde\u63a5\u751f\u547d\u5468\u671f\u7ba1\u7406\u65b9\u6848\u3002<\/p>\n<h4>4.1 \u542f\u52a8\u65f6\u7684\u5f02\u6b65\u63a2\u6d4b<\/h4>\n<p>\u5e94\u7528\u542f\u52a8\u5b8c\u6210\u540e&#xff0c;McpClientManager.logRegistryAlignment() \u5728\u5b8c\u6210\u540d\u518c\u5bf9\u9f50\u6821\u9a8c\u4e4b\u540e&#xff0c;\u8c03\u7528 McpConnectionDiagnostics.logProbeResultsAsync() \u5bf9\u6240\u6709\u5df2\u914d\u7f6e\u7684\u8fde\u63a5\u6267\u884c\u5f02\u6b65\u63a2\u6d4b\u3002\u6838\u5fc3\u63a2\u6d4b\u5165\u53e3&#xff1a;<\/p>\n<p>public static void logProbeResultsAsync(Logger log, Environment env) {<br \/>\n    List&lt;ConnectionTarget&gt; targets &#061; resolveConnectionTargets(env);<br \/>\n    if (targets.isEmpty()) {<br \/>\n        log.warn(&#034;[MCP-CLIENT] connection probe | no connections found&#034;);<br \/>\n        return;<br \/>\n    }<br \/>\n    \/\/ \u5148\u540c\u6b65\u6253\u5370\u914d\u7f6e\u4fe1\u606f<br \/>\n    for (ConnectionTarget target : targets) {<br \/>\n        String cred &#061; credentialHint(target);<br \/>\n        log.warn(&#034;[MCP-CLIENT] connection config | id&#061;{} | transport&#061;{} | &#034;<br \/>\n                &#043; &#034;target&#061;{} | credentialHint&#061;{}&#034;,<br \/>\n                target.id(), target.transport(),<br \/>\n                maskSecrets(target.fullUrl()),<br \/>\n                cred !&#061; null ? cred : &#034;none&#034;);<br \/>\n    }<br \/>\n    \/\/ \u518d\u5f02\u6b65\u6267\u884c\u63a2\u6d4b<br \/>\n    CompletableFuture.runAsync(() -&gt; logProbeResults(log, env))<br \/>\n            .exceptionally(ex -&gt; {<br \/>\n                log.warn(&#034;[MCP-CLIENT] connection probe | async error&#061;{}&#034;, ex.toString());<br \/>\n                return null;<br \/>\n            });<br \/>\n} <\/p>\n<p>\u5f02\u6b65\u63a2\u6d4b\u7684 CompletableFuture \u7528\u6cd5\u503c\u5f97\u5c55\u5f00\u8ba8\u8bba\u3002\u8fd9\u91cc\u7684\u8bbe\u8ba1\u610f\u56fe\u662f&#xff1a;\u542f\u52a8\u9636\u6bb5\u7684\u4e3b\u7ebf\u7a0b\u4e0d\u5e94\u8be5\u88ab\u7f51\u7edc\u63a2\u6d4b\u963b\u585e\u3002\u5982\u679c 3 \u4e2a\u8fde\u63a5\u4e2d\u6709 1 \u4e2a\u8fdc\u7aef\u65e0\u54cd\u5e94&#xff0c;\u540c\u6b65\u63a2\u6d4b\u4f1a\u5bfc\u81f4\u5e94\u7528\u542f\u52a8\u591a\u7b49 2 \u79d2&#xff08;TCP \u8d85\u65f6&#xff09;&#xff0c;\u8fd9\u5728 CI\/CD \u73af\u5883\u4e2d\u7d2f\u79ef\u8d77\u6765\u5f88\u53ef\u89c2\u3002CompletableFuture.runAsync() \u5c06\u63a2\u6d4b\u4efb\u52a1\u63d0\u4ea4\u5230 ForkJoinPool&#xff0c;\u4e3b\u7ebf\u7a0b\u53ef\u4ee5\u7acb\u5373\u7ee7\u7eed\u6267\u884c\u540e\u7eed\u7684 Bean \u521d\u59cb\u5316\u3002<\/p>\n<p>\u63a2\u6d4b\u7b56\u7565\u6309\u4f20\u8f93\u534f\u8bae\u5dee\u5f02\u5316&#xff1a;<\/p>\n<ul>\n<li>SSE \u8fde\u63a5&#xff1a;\u7528 TCP probe \u68c0\u6d4b\u76ee\u6807\u7aef\u53e3\u662f\u5426\u53ef\u8fbe&#xff08;\u4e0d\u5bf9 SSE \u53d1 GET \u8bf7\u6c42&#xff0c;\u907f\u514d\u957f\u8fde\u63a5\u963b\u585e\u542f\u52a8&#xff09;<\/li>\n<li>streamable-http \u8fde\u63a5&#xff1a;\u7528 HTTP HEAD \u8bf7\u6c42\u68c0\u6d4b\u7aef\u70b9\u662f\u5426\u5b58\u6d3b<\/li>\n<li>\u8d85\u65f6\u63a7\u5236&#xff1a;TCP \u63a2\u6d4b\u8d85\u65f6 2 \u79d2&#xff0c;HTTP \u63a2\u6d4b\u8d85\u65f6 2 \u79d2&#xff0c;\u6240\u6709\u8fde\u63a5\u7684\u63a2\u6d4b\u603b\u8d85\u65f6 8 \u79d2<\/li>\n<\/ul>\n<p>TCP probe \u7684\u5b9e\u73b0&#xff1a;<\/p>\n<p>private static ProbeResult probeTcp(ConnectionTarget target) {<br \/>\n    try {<br \/>\n        URI uri &#061; URI.create(target.fullUrl());<br \/>\n        String host &#061; uri.getHost();<br \/>\n        int port &#061; uri.getPort();<br \/>\n        if (port &lt;&#061; 0) {<br \/>\n            port &#061; &#034;https&#034;.equalsIgnoreCase(uri.getScheme()) ? 443 : 80;<br \/>\n        }<br \/>\n        try (Socket socket &#061; new Socket()) {<br \/>\n            socket.connect(new InetSocketAddress(host, port),<br \/>\n                    (int) TCP_TIMEOUT.toMillis());<br \/>\n        }<br \/>\n        return new ProbeResult(target.id(), target.transport(),<br \/>\n                maskSecrets(target.fullUrl()), true, null, null,<br \/>\n                &#034;TCP \u53ef\u8fbe&#xff08;SSE \u4e0d\u5bf9 GET \u505a probe&#xff0c;\u907f\u514d\u957f\u8fde\u63a5\u963b\u585e&#xff09;&#034;);<br \/>\n    } catch (Exception e) {<br \/>\n        Throwable root &#061; rootCause(e);<br \/>\n        return failed(target, root.getClass().getSimpleName(), null, root);<br \/>\n    }<br \/>\n} <\/p>\n<p>\u8fd9\u662f\u4e00\u4e2a\u5bb9\u6613\u8e29\u5751\u7684\u8bbe\u8ba1\u51b3\u7b56&#xff1a;SSE \u7aef\u70b9\u54cd\u5e94 GET \u8bf7\u6c42\u540e\u4f1a\u4fdd\u6301\u957f\u8fde\u63a5\u4e0d\u5173\u95ed\u3002\u5982\u679c\u5bf9 SSE \u7aef\u70b9\u53d1 HTTP GET \u505a\u5065\u5eb7\u68c0\u67e5&#xff0c;\u8fd9\u4e2a\u8fde\u63a5\u4f1a\u4e00\u76f4\u6302\u7740&#xff0c;\u963b\u585e\u63a2\u6d4b\u7ebf\u7a0b\u3002\u6240\u4ee5\u53ea\u505a TCP \u5c42\u7684\u7aef\u53e3\u53ef\u8fbe\u6027\u68c0\u6d4b\u2014\u2014\u77e5\u9053\u7aef\u53e3\u901a\u4e86\u5c31\u591f\u4e86\u3002<\/p>\n<h4>4.2 \u9519\u8bef\u5206\u7c7b\u4e0e\u667a\u80fd\u63d0\u793a<\/h4>\n<p>McpConnectionDiagnostics \u5bf9\u63a2\u6d4b\u5931\u8d25\u7684\u60c5\u51b5\u8fdb\u884c\u5206\u7c7b&#xff0c;\u7ed9\u51fa\u53ef\u76f4\u63a5\u6267\u884c\u7684\u6392\u67e5\u5efa\u8bae&#xff1a;<\/p>\n<table>\n<tr>\u9519\u8bef\u7c7b\u578b\u89e6\u53d1\u6761\u4ef6\u8bca\u65ad\u63d0\u793a<\/tr>\n<tbody>\n<tr>\n<td>CREDENTIAL<\/td>\n<td>URL \u4e2d\u7684 ${ZHIPU_API_KEY:} \u89e3\u6790\u4e3a\u7a7a<\/td>\n<td>\u73af\u5883\u53d8\u91cf ZHIPU_API_KEY \u672a\u8bbe\u7f6e<\/td>\n<\/tr>\n<tr>\n<td>ConnectException<\/td>\n<td>TCP probe \u629b\u51fa Connection refused<\/td>\n<td>\u76ee\u6807 Server \u672a\u542f\u52a8\u6216\u7aef\u53e3\u4e0d\u53ef\u8fbe<\/td>\n<\/tr>\n<tr>\n<td>HTTP 401\/403<\/td>\n<td>HTTP HEAD \u8fd4\u56de 401 \u6216 403<\/td>\n<td>API Key \u65e0\u6548\u6216\u5df2\u8fc7\u671f<\/td>\n<\/tr>\n<tr>\n<td>ProbeTimeout<\/td>\n<td>\u63a2\u6d4b\u8d85\u8fc7\u603b\u8d85\u65f6&#xff08;8s&#xff09;<\/td>\n<td>\u63a2\u6d4b\u8d85\u65f6&#xff1a;\u4e0d\u5bf9 SSE \u53d1 GET&#xff0c;\u907f\u514d\u957f\u8fde\u63a5\u963b\u585e\u542f\u52a8<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>credentialHint() \u65b9\u6cd5\u4e13\u95e8\u5904\u7406\u51ed\u636e\u7f3a\u5931\u7684\u60c5\u51b5&#xff1a;<\/p>\n<p>public static String credentialHint(ConnectionTarget target) {<br \/>\n    String fullUrl &#061; target.fullUrl();<br \/>\n    if (containsEmptyQueryParam(fullUrl, &#034;Authorization&#034;)) {<br \/>\n        return &#034;\u73af\u5883\u53d8\u91cf ZHIPU_API_KEY \u672a\u8bbe\u7f6e&#xff08;sse-endpoint \u4e2d Authorization&#061; \u4e3a\u7a7a&#xff09;&#034;;<br \/>\n    }<br \/>\n    if (containsEmptyQueryParam(fullUrl, &#034;key&#034;)) {<br \/>\n        return &#034;\u73af\u5883\u53d8\u91cf AMAP_MAPS_API_KEY \u672a\u8bbe\u7f6e&#xff08;endpoint \u4e2d key&#061; \u4e3a\u7a7a&#xff09;&#034;;<br \/>\n    }<br \/>\n    if (&#034;code-review-local&#034;.equals(target.id())<br \/>\n            &amp;&amp; (fullUrl &#061;&#061; null || fullUrl.isBlank())) {<br \/>\n        return &#034;code-review-local \u7684 url \u672a\u914d\u7f6e&#xff0c;\u68c0\u67e5 MCP_CODE_REVIEW_SERVER_URL&#034;;<br \/>\n    }<br \/>\n    return null;<br \/>\n} <\/p>\n<p>probeFailureHint() \u5219\u6839\u636e\u5f02\u5e38\u7c7b\u578b\u548c HTTP \u72b6\u6001\u7801\u5339\u914d\u6392\u67e5\u5efa\u8bae&#xff1a;<\/p>\n<p>public static String probeFailureHint(ConnectionTarget target,<br \/>\n        Throwable error, Integer httpStatus) {<br \/>\n    String credentialHint &#061; credentialHint(target);<br \/>\n    if (credentialHint !&#061; null) return credentialHint;<br \/>\n    if (error instanceof ConnectException) {<br \/>\n        if (&#034;code-review-local&#034;.equals(target.id())) {<br \/>\n            return &#034;TCP \u8fde\u63a5\u88ab\u62d2\u7edd&#xff1a;8095 \u672a\u76d1\u542c\u3002\u5148\u542f\u52a8 code-review-agent&#034;;<br \/>\n        }<br \/>\n        return &#034;TCP\/\u7f51\u7edc\u4e0d\u53ef\u8fbe&#xff1a;\u68c0\u67e5 url \u662f\u5426\u6b63\u786e\u3001\u8fdc\u7aef\u670d\u52a1\u662f\u5426\u542f\u52a8&#034;;<br \/>\n    }<br \/>\n    if (httpStatus !&#061; null) {<br \/>\n        if (httpStatus &#061;&#061; 401 || httpStatus &#061;&#061; 403) {<br \/>\n            return &#034;\u8ba4\u8bc1\u5931\u8d25&#xff1a;\u68c0\u67e5 API Key \u662f\u5426\u6709\u6548\u3001\u662f\u5426\u8fc7\u671f&#034;;<br \/>\n        }<br \/>\n    }<br \/>\n    if (error instanceof HttpTimeoutException || error instanceof TimeoutException) {<br \/>\n        return &#034;\u63a2\u6d4b\u8d85\u65f6&#xff1a;\u8fdc\u7aef\u65e0\u54cd\u5e94\u6216\u7f51\u7edc\u6162&#034;;<br \/>\n    }<br \/>\n    return &#034;SDK \u5c42 WARN\u300cSSE stream observed an error\u300d\u8bf7\u5bf9\u7167 connectionId \u4e0e target&#034;;<br \/>\n} <\/p>\n<p>\u8fd9\u79cd&#034;\u4e0d\u53ea\u544a\u8bc9\u4f60\u9519\u4e86&#xff0c;\u8fd8\u544a\u8bc9\u4f60\u600e\u4e48\u6539&#034;\u7684\u8bbe\u8ba1&#xff0c;\u5927\u5e45\u964d\u4f4e\u4e86\u65b0\u4eba\u7684\u6392\u67e5\u6210\u672c\u3002<\/p>\n<p>maskSecrets() \u65b9\u6cd5\u786e\u4fdd URL \u5728\u65e5\u5fd7\u4e2d\u8131\u654f&#xff1a;<\/p>\n<p>public static String maskSecrets(String url) {<br \/>\n    if (url &#061;&#061; null || url.isBlank()) return &#034;&#034;;<br \/>\n    return url.replaceAll(&#034;(?i)(Authorization&#061;)[^&amp;]*&#034;, &#034;$1***&#034;)<br \/>\n              .replaceAll(&#034;(?i)([?&amp;]key&#061;)[^&amp;]*&#034;, &#034;$1***&#034;)<br \/>\n              .replaceAll(&#034;(?i)([?&amp;]token&#061;)[^&amp;]*&#034;, &#034;$1***&#034;);<br \/>\n} <\/p>\n<p>\u6b63\u5219\u5339\u914d\u8986\u76d6\u4e86\u4e09\u79cd\u5e38\u89c1\u7684\u51ed\u636e\u53c2\u6570\u540d&#xff1a;Authorization\u3001key\u3001token\u3002\u65e0\u8bba URL \u4e2d\u643a\u5e26\u54ea\u79cd\u51ed\u636e&#xff0c;\u65e5\u5fd7\u4e2d\u90fd\u4f1a\u663e\u793a\u4e3a ***\u3002<\/p>\n<h4>4.3 SSE \u957f\u8fde\u63a5\u65ad\u5f00\u4e0e\u81ea\u52a8\u91cd\u8fde<\/h4>\n<p>SSE \u662f\u4e00\u79cd\u957f\u8fde\u63a5\u534f\u8bae\u3002\u7f51\u7edc\u6296\u52a8\u3001Server \u91cd\u542f\u3001\u8d1f\u8f7d\u5747\u8861\u5668\u8d85\u65f6\u7b49\u60c5\u51b5\u90fd\u53ef\u80fd\u5bfc\u81f4 SSE \u8fde\u63a5\u65ad\u5f00\u3002Spring AI \u7684 MCP Client \u5185\u7f6e\u4e86 SSE \u91cd\u8fde\u673a\u5236\u2014\u2014\u5f53 SSE \u8fde\u63a5\u65ad\u5f00\u65f6&#xff0c;Client \u4f1a\u81ea\u52a8\u5c1d\u8bd5\u91cd\u65b0\u5efa\u7acb\u8fde\u63a5&#xff0c;\u65e5\u5fd7\u4e2d\u4f1a\u51fa\u73b0 SSE stream observed an error \u540e\u8ddf\u91cd\u65b0\u8fde\u63a5\u7684\u5c1d\u8bd5\u3002\u8fd9\u79cd\u91cd\u8fde\u662f\u900f\u660e\u7684&#xff0c;\u5e94\u7528\u4ee3\u7801\u65e0\u9700\u5173\u5fc3\u3002<\/p>\n<p>\u4f46\u8981\u6ce8\u610f&#xff1a;\u91cd\u8fde\u671f\u95f4\u53d1\u8d77\u7684\u5de5\u5177\u8c03\u7528\u4f1a\u5931\u8d25\u3002\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48 LoggingToolCallback \u7684 failed \u65e5\u5fd7\u975e\u5e38\u5173\u952e\u2014\u2014\u901a\u8fc7 error&#061; \u5b57\u6bb5\u53ef\u4ee5\u5feb\u901f\u5224\u65ad\u662f&#034;\u8fde\u63a5\u65ad\u5f00\u5bfc\u81f4\u8c03\u7528\u5931\u8d25&#034;\u8fd8\u662f&#034;\u5de5\u5177\u6267\u884c\u672c\u8eab\u51fa\u9519&#034;\u3002<\/p>\n<p>streamable-http \u7684\u5904\u7406\u65b9\u5f0f\u4e0d\u540c\u3002streamable-http \u672c\u8d28\u4e0a\u662f\u4e00\u6b21\u6027\u7684 HTTP \u8bf7\u6c42&#xff0c;\u6bcf\u6b21\u5de5\u5177\u8c03\u7528\u53d1\u8d77\u72ec\u7acb\u7684\u8bf7\u6c42-\u54cd\u5e94&#xff0c;\u4e0d\u5b58\u5728&#034;\u957f\u8fde\u63a5\u65ad\u5f00&#034;\u7684\u95ee\u9898\u3002\u8fd9\u4e5f\u662f MCP 2026-07-28 \u65b0\u89c4\u8303\u5c06 streamable-http \u63d0\u5347\u4e3a\u63a8\u8350\u4f20\u8f93\u7684\u539f\u56e0\u4e4b\u4e00\u2014\u2014\u5b83\u5929\u7136\u66f4\u9002\u5408\u751f\u4ea7\u73af\u5883\u4e2d\u7684\u8d1f\u8f7d\u5747\u8861\u548c\u65e0\u72b6\u6001\u90e8\u7f72\u3002<\/p>\n<h4>4.4 \u8fdc\u7a0b MCP \u8d85\u65f6\u7684\u964d\u7ea7\u7b56\u7565<\/h4>\n<p>\u8fdc\u7a0b MCP Server&#xff08;\u667a\u8c31\u3001\u9ad8\u5fb7&#xff09;\u7684\u54cd\u5e94\u65f6\u95f4\u4e0d\u53ef\u63a7\u3002Dream-SaaS \u7684\u964d\u7ea7\u7b56\u7565\u5206\u4e24\u5c42&#xff1a;<\/p>\n<ul>\n<li>\u8fde\u63a5\u7ea7\u8d85\u65f6&#xff1a;Spring AI \u7684 SSE\/streamable-http \u4f20\u8f93\u5c42\u914d\u7f6e\u4e86\u8fde\u63a5\u8d85\u65f6\u548c\u8bfb\u53d6\u8d85\u65f6\u3002\u8d85\u65f6\u540e\u5e95\u5c42\u629b\u51fa\u5f02\u5e38&#xff0c;LoggingToolCallback \u6355\u83b7\u5e76\u8bb0\u5f55 [MCP-TOOL] failed \u65e5\u5fd7<\/li>\n<li>\u5e94\u7528\u7ea7\u964d\u7ea7&#xff1a;\/mcp\/ask \u7aef\u70b9\u5728\u5de5\u5177\u8c03\u7528\u5931\u8d25\u65f6&#xff0c;\u8fd4\u56de\u7ed3\u6784\u5316\u7684\u9519\u8bef\u4fe1\u606f\u2014\u2014\u5305\u542b\u5931\u8d25\u7684 connection\u3001tool \u540d\u79f0\u548c\u9519\u8bef\u7c7b\u578b&#xff0c;\u800c\u4e0d\u662f\u76f4\u63a5\u629b 500\u3002LLM \u53ef\u4ee5\u636e\u6b64\u51b3\u5b9a&#034;\u4e0d\u4f9d\u8d56\u8be5\u5de5\u5177&#xff0c;\u7528\u5df2\u6709\u4fe1\u606f\u7ee7\u7eed\u56de\u7b54&#034;<\/li>\n<\/ul>\n<p>\u4ece\u65e5\u5fd7\u5173\u952e\u5b57\u53ef\u4ee5\u8ffd\u8e2a\u964d\u7ea7\u7684\u5b8c\u6574\u94fe\u8def&#xff1a;[MCP-TOOL] invoke \u2192 [MCP-TOOL] failed | elapsedMs&#061;2003&#xff08;\u8d85\u65f6&#xff09;\u2192 \u5e94\u7528\u5c42\u8fd4\u56de\u7ed3\u6784\u5316\u9519\u8bef\u7ed9 LLM\u3002elapsedMs \u5b57\u6bb5\u662f\u5224\u65ad&#034;\u662f\u8d85\u65f6\u8fd8\u662f\u6267\u884c\u6162&#034;\u7684\u5173\u952e\u4f9d\u636e\u3002<\/p>\n<h4>4.5 \/mcp\/status&#xff1a;\u7efc\u5408\u8bca\u65ad\u7aef\u70b9<\/h4>\n<p>\u8bca\u65ad\u548c\u63a2\u6d4b\u7684\u6700\u7ec8\u4ea7\u51fa&#xff0c;\u901a\u8fc7 \/mcp\/status \u7aef\u70b9\u66b4\u9732\u7ed9\u8fd0\u7ef4\u548c\u5f00\u53d1\u4eba\u5458\u3002McpClientStatusController \u6574\u5408\u4e86\u6240\u6709\u89c2\u6d4b\u4fe1\u606f&#xff1a;<\/p>\n<p>&#064;RestController<br \/>\n&#064;RequestMapping(&#034;\/mcp&#034;)<br \/>\npublic class McpClientStatusController {<\/p>\n<p>    &#064;GetMapping(&#034;\/status&#034;)<br \/>\n    public Map&lt;String, Object&gt; status() {<br \/>\n        Map&lt;String, Object&gt; body &#061; new LinkedHashMap&lt;&gt;();<br \/>\n        body.put(&#034;mcpClientEnabled&#034;, mcpClientEnabled);<br \/>\n        body.put(&#034;askEnabled&#034;, askEnabled);<br \/>\n        body.put(&#034;observabilityLogger&#034;, McpClientObservability.LOGGER_NAME);<br \/>\n        body.put(&#034;platform&#034;, &#034;dream-ai-mcp&#034;);<\/p>\n<p>        \/\/ Registry \u540d\u518c\u5feb\u7167<br \/>\n        McpClientManager manager &#061; mcpClientManager.getIfAvailable();<br \/>\n        if (manager !&#061; null) {<br \/>\n            body.put(&#034;registry&#034;, manager.snapshot());<br \/>\n        }<\/p>\n<p>        \/\/ \u8fde\u63a5\u63a2\u6d4b\u7ed3\u679c<br \/>\n        body.put(&#034;configuredConnections&#034;,<br \/>\n                McpClientObservability.configuredConnectionNames(environment));<br \/>\n        body.put(&#034;connectionProbes&#034;,<br \/>\n                McpConnectionDiagnostics.probeAll(environment).stream()<br \/>\n                        .map(McpConnectionDiagnostics::toStatusMap).toList());<\/p>\n<p>        \/\/ Provider \u72b6\u6001\u548c\u5de5\u5177\u6e05\u5355<br \/>\n        SyncMcpToolCallbackProvider provider &#061;<br \/>\n                syncMcpToolCallbackProvider.getIfAvailable();<br \/>\n        if (provider &#061;&#061; null) {<br \/>\n            body.put(&#034;providerReady&#034;, false);<br \/>\n            body.put(&#034;toolCount&#034;, 0);<br \/>\n            body.put(&#034;hint&#034;, &#034;spring.ai.mcp.client.enabled&#061;true \u4e14 MCP Server \u5c31\u7eea&#8230;&#034;);<br \/>\n            return body;<br \/>\n        }<\/p>\n<p>        List&lt;String&gt; toolNames &#061; McpClientObservability.toolNames(provider);<br \/>\n        body.put(&#034;providerReady&#034;, true);<br \/>\n        body.put(&#034;toolCount&#034;, toolNames.size());<br \/>\n        body.put(&#034;tools&#034;, toolNames);<br \/>\n        body.put(&#034;toolGroups&#034;,<br \/>\n                McpClientObservability.groupToolsByConnection(<br \/>\n                        toolNames, configuredConnections));<br \/>\n        return body;<br \/>\n    }<br \/>\n} <\/p>\n<p>\u8fd9\u4e2a\u7aef\u70b9\u8fd4\u56de\u7684\u4fe1\u606f\u5305\u62ec&#xff1a;<\/p>\n<ul>\n<li>mcpClientEnabled \/ askEnabled&#xff1a;\u529f\u80fd\u5f00\u5173\u72b6\u6001<\/li>\n<li>registry&#xff1a;\u540d\u518c\u5feb\u7167&#xff08;profile\u3001expectedConnections\u3001connections\u3001servers&#xff09;<\/li>\n<li>connectionProbes&#xff1a;\u6bcf\u4e2a\u8fde\u63a5\u7684\u63a2\u6d4b\u7ed3\u679c&#xff08;reachable\u3001errorType\u3001hint&#xff09;<\/li>\n<li>toolGroups&#xff1a;\u5de5\u5177\u6309 connection \u5206\u7ec4\u7684\u6e05\u5355<\/li>\n<\/ul>\n<p>\u90e8\u7f72\u540e\u7684\u6807\u51c6\u9a8c\u6536\u6d41\u7a0b\u662f&#xff1a;\u542f\u52a8\u5e94\u7528 \u2192 \u67e5\u770b\u542f\u52a8\u65e5\u5fd7\u4e2d\u7684 [MCP-CLIENT] startup \u548c [MCP-CLIENT] connection probe \u2192 \u8bbf\u95ee \/mcp\/status \u786e\u8ba4\u6240\u6709 connection \u72b6\u6001 \u2192 \u901a\u8fc7 \/mcp\/ask \u53d1\u9001\u6d4b\u8bd5\u8bf7\u6c42\u9a8c\u8bc1\u7aef\u5230\u7aef\u94fe\u8def\u3002\u8fd9\u5957\u6d41\u7a0b\u8ba9 MCP \u7684\u90e8\u7f72\u9a8c\u6536\u4ece&#034;\u51ed\u611f\u89c9&#034;\u53d8\u6210\u4e86&#034;\u770b\u6570\u636e&#034;\u3002<\/p>\n<h3>\u603b\u7ed3<\/h3>\n<p>MCP \u5de5\u7a0b\u5316\u7684\u4e09\u9053\u574e\u2014\u2014\u591a Server \u7f16\u6392\u3001\u8c03\u7528\u53ef\u89c2\u6d4b\u3001\u8fde\u63a5\u751f\u547d\u5468\u671f\u7ba1\u7406\u2014\u2014\u4e0d\u662f\u7406\u8bba\u95ee\u9898&#xff0c;\u800c\u662f\u6bcf\u4e2a\u843d\u5730 MCP \u7684\u56e2\u961f\u90fd\u4f1a\u9047\u5230\u7684\u5b9e\u9645\u6311\u6218\u3002Dream-SaaS \u7684\u9009\u62e9\u662f&#xff1a;\u4e0d\u5f15\u5165\u989d\u5916\u57fa\u7840\u8bbe\u65bd&#xff0c;\u7528\u6a21\u5757\u5316\u7684 Registry \u540d\u518c\u3001\u88c5\u9970\u5668\u6a21\u5f0f\u7684\u89c2\u6d4b\u65e5\u5fd7\u3001\u5f02\u6b65\u63a2\u6d4b\u4e0e\u9519\u8bef\u5206\u7c7b\u673a\u5236\u6765\u89e3\u51b3\u3002\u8fd9\u5957\u65b9\u6848\u8f7b\u91cf\u3001\u53ef\u63a7\u3001\u53ef\u6f14\u8fdb\u3002<\/p>\n<p>\u56de\u987e\u6574\u4e2a MCP \u5b50\u7cfb\u5217\u7684\u4e09\u7bc7\u6587\u7ae0&#xff1a;<\/p>\n<ul>\n<li>MCP-01 \u534f\u8bae\u5168\u89e3&#xff1a;\u62c6\u89e3\u4e86 MCP \u7684\u534f\u8bae\u8bbe\u8ba1\u2014\u2014JSON-RPC \u6d88\u606f\u683c\u5f0f\u3001Host\/Client\/Server \u4e09\u89d2\u67b6\u6784\u3001\u4f20\u8f93\u5c42\u89e3\u8026<\/li>\n<li>MCP-02 Server \u5f00\u53d1\u5b9e\u6218&#xff1a;\u4ece\u4ee3\u7801\u5c42\u9762\u6784\u5efa\u4e86 MCP Server\u2014\u2014McpToolContributor SPI\u3001&#064;Tool \u6ce8\u89e3\u3001SSE \u4f20\u8f93\u914d\u7f6e\u30012026-07-28 \u65e0\u72b6\u6001\u65b0\u89c4\u8303<\/li>\n<li>MCP-03 \u5de5\u7a0b\u5316\u5b9e\u6218&#xff1a;\u4ee5 Dream-SaaS \u771f\u5b9e\u4ee3\u7801\u4e3a\u4e3b\u7ebf&#xff0c;\u89e3\u51b3\u4e86\u591a Server \u7f16\u6392\u3001\u53ef\u89c2\u6d4b\u6027\u3001\u8fde\u63a5\u751f\u547d\u5468\u671f\u7ba1\u7406\u4e09\u5927\u751f\u4ea7\u7ea7\u95ee\u9898<\/li>\n<\/ul>\n<p>\u4e0b\u4e00\u7bc7\u6211\u4eec\u5c06\u8df3\u51fa MCP \u7684\u5de5\u5177\u8c03\u7528\u8303\u7574&#xff0c;\u8fdb\u5165 Agent \u8bb0\u5fc6\u7cfb\u7edf&#xff08;#05&#xff09;\u2014\u2014Agent \u600e\u4e48\u8bb0\u4f4f\u4e0a\u4e0b\u6587\u3001\u600e\u4e48\u79ef\u7d2f\u957f\u671f\u77e5\u8bc6\u3001\u600e\u4e48\u5728\u5bf9\u8bdd\u4e2d\u5b9e\u73b0&#034;\u771f\u6b63\u7684\u7406\u89e3&#034;\u800c\u975e\u6bcf\u6b21\u90fd\u4ece\u96f6\u5f00\u59cb\u3002<\/p>\n<p>\u2014 \u6df1\u5165\u7406\u89e3 AI Agent \u00b7 MCP \u5b50\u7cfb\u5217 \u00b7 \u7b2c 3 \u7bc7 \u2014<\/p>\n<p>\u6709\u95ee\u9898\u8bc4\u8bba\u533a\u89c1&#xff0c;\u6b22\u8fce\u4ea4\u6d41~<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u534f\u8bae\u89e3\u51b3\u7684\u662f\\&#8221;\u600e\u4e48\u5bf9\u8bdd\\&#8221;&#xff0c;\u5de5\u7a0b\u5316\u89e3\u51b3\u7684\u662f\\&#8221;\u600e\u4e48\u5728\u751f\u4ea7\u73af\u5883\u7a33\u5b9a\u5730\u5bf9\u8bdd\\&#8221;\u3002 \u524d\u4e00\u7bc7\u6211\u4eec\u7528 Spring AI \u642d\u5efa\u4e86\u4e00\u4e2a\u529f\u80fd\u5b8c\u6574\u7684 MCP Server&#xff0c;\/mcp\/sse \u7aef\u70b9\u80fd\u6b63\u5e38\u54cd\u5e94&#xff0c;\u5de5\u5177\u80fd\u88ab Client \u53d1\u73b0\u548c\u8c03\u7528\u3002\u4f46\u5f53\u4f60\u8bd5\u56fe\u628a\u8fd9\u4e2a\u7cfb\u7edf\u90e8\u7f72\u5230\u751f\u4ea7\u73af\u5883\u65f6&#xff0c;\u95ee\u9898\u4f1a\u4e00\u4e2a\u63a5\u4e00\u4e2a\u5192\u51fa\u6765&#xff1a;\u8fde\u63a5\u54ea\u4e9b Server&#xff1f;\u914d\u7f6e\u6563\u843d\u5728\u54ea\u91cc&#xff1f;\u4e00\u6b21\u8bf7\u6c42\u7ecf\u8fc7\u4e86\u51e0\u6b21 tool call&#xff1f;\u8017\u65f6\u591a<\/p>\n","protected":false},"author":2,"featured_media":94335,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[10187,50],"topic":[],"class_list":["post-94336","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-codingplan","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 #03\uff1a\u591a Server \u7f16\u6392\u3001\u8c03\u7528\u94fe\u53ef\u89c2\u6d4b\u4e0e\u8fde\u63a5\u751f\u547d\u5468\u671f\u7ba1\u7406 - \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\/94336.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 #03\uff1a\u591a Server \u7f16\u6392\u3001\u8c03\u7528\u94fe\u53ef\u89c2\u6d4b\u4e0e\u8fde\u63a5\u751f\u547d\u5468\u671f\u7ba1\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u534f\u8bae\u89e3\u51b3\u7684\u662f&quot;\u600e\u4e48\u5bf9\u8bdd&quot;&#xff0c;\u5de5\u7a0b\u5316\u89e3\u51b3\u7684\u662f&quot;\u600e\u4e48\u5728\u751f\u4ea7\u73af\u5883\u7a33\u5b9a\u5730\u5bf9\u8bdd&quot;\u3002 \u524d\u4e00\u7bc7\u6211\u4eec\u7528 Spring AI \u642d\u5efa\u4e86\u4e00\u4e2a\u529f\u80fd\u5b8c\u6574\u7684 MCP Server&#xff0c;\/mcp\/sse \u7aef\u70b9\u80fd\u6b63\u5e38\u54cd\u5e94&#xff0c;\u5de5\u5177\u80fd\u88ab Client \u53d1\u73b0\u548c\u8c03\u7528\u3002\u4f46\u5f53\u4f60\u8bd5\u56fe\u628a\u8fd9\u4e2a\u7cfb\u7edf\u90e8\u7f72\u5230\u751f\u4ea7\u73af\u5883\u65f6&#xff0c;\u95ee\u9898\u4f1a\u4e00\u4e2a\u63a5\u4e00\u4e2a\u5192\u51fa\u6765&#xff1a;\u8fde\u63a5\u54ea\u4e9b Server&#xff1f;\u914d\u7f6e\u6563\u843d\u5728\u54ea\u91cc&#xff1f;\u4e00\u6b21\u8bf7\u6c42\u7ecf\u8fc7\u4e86\u51e0\u6b21 tool call&#xff1f;\u8017\u65f6\u591a\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/94336.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-14T02:18:32+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260814021825-6a7e7af19f586.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=\"14 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/94336.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/94336.html\",\"name\":\"\u6df1\u5165\u7406\u89e3 AI Agent \u00b7 MCP \u5b50\u7cfb\u5217 #03\uff1a\u591a Server \u7f16\u6392\u3001\u8c03\u7528\u94fe\u53ef\u89c2\u6d4b\u4e0e\u8fde\u63a5\u751f\u547d\u5468\u671f\u7ba1\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-14T02:18:32+00:00\",\"dateModified\":\"2026-08-14T02:18:32+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/94336.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/94336.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/94336.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 #03\uff1a\u591a Server \u7f16\u6392\u3001\u8c03\u7528\u94fe\u53ef\u89c2\u6d4b\u4e0e\u8fde\u63a5\u751f\u547d\u5468\u671f\u7ba1\u7406\"}]},{\"@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 #03\uff1a\u591a Server \u7f16\u6392\u3001\u8c03\u7528\u94fe\u53ef\u89c2\u6d4b\u4e0e\u8fde\u63a5\u751f\u547d\u5468\u671f\u7ba1\u7406 - \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\/94336.html","og_locale":"zh_CN","og_type":"article","og_title":"\u6df1\u5165\u7406\u89e3 AI Agent \u00b7 MCP \u5b50\u7cfb\u5217 #03\uff1a\u591a Server \u7f16\u6392\u3001\u8c03\u7528\u94fe\u53ef\u89c2\u6d4b\u4e0e\u8fde\u63a5\u751f\u547d\u5468\u671f\u7ba1\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u534f\u8bae\u89e3\u51b3\u7684\u662f\"\u600e\u4e48\u5bf9\u8bdd\"&#xff0c;\u5de5\u7a0b\u5316\u89e3\u51b3\u7684\u662f\"\u600e\u4e48\u5728\u751f\u4ea7\u73af\u5883\u7a33\u5b9a\u5730\u5bf9\u8bdd\"\u3002 \u524d\u4e00\u7bc7\u6211\u4eec\u7528 Spring AI \u642d\u5efa\u4e86\u4e00\u4e2a\u529f\u80fd\u5b8c\u6574\u7684 MCP Server&#xff0c;\/mcp\/sse \u7aef\u70b9\u80fd\u6b63\u5e38\u54cd\u5e94&#xff0c;\u5de5\u5177\u80fd\u88ab Client \u53d1\u73b0\u548c\u8c03\u7528\u3002\u4f46\u5f53\u4f60\u8bd5\u56fe\u628a\u8fd9\u4e2a\u7cfb\u7edf\u90e8\u7f72\u5230\u751f\u4ea7\u73af\u5883\u65f6&#xff0c;\u95ee\u9898\u4f1a\u4e00\u4e2a\u63a5\u4e00\u4e2a\u5192\u51fa\u6765&#xff1a;\u8fde\u63a5\u54ea\u4e9b Server&#xff1f;\u914d\u7f6e\u6563\u843d\u5728\u54ea\u91cc&#xff1f;\u4e00\u6b21\u8bf7\u6c42\u7ecf\u8fc7\u4e86\u51e0\u6b21 tool call&#xff1f;\u8017\u65f6\u591a","og_url":"https:\/\/www.wsisp.com\/helps\/94336.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-14T02:18:32+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260814021825-6a7e7af19f586.jpg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"14 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/94336.html","url":"https:\/\/www.wsisp.com\/helps\/94336.html","name":"\u6df1\u5165\u7406\u89e3 AI Agent \u00b7 MCP \u5b50\u7cfb\u5217 #03\uff1a\u591a Server \u7f16\u6392\u3001\u8c03\u7528\u94fe\u53ef\u89c2\u6d4b\u4e0e\u8fde\u63a5\u751f\u547d\u5468\u671f\u7ba1\u7406 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-14T02:18:32+00:00","dateModified":"2026-08-14T02:18:32+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/94336.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/94336.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/94336.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 #03\uff1a\u591a Server \u7f16\u6392\u3001\u8c03\u7528\u94fe\u53ef\u89c2\u6d4b\u4e0e\u8fde\u63a5\u751f\u547d\u5468\u671f\u7ba1\u7406"}]},{"@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\/94336","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=94336"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/94336\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/94335"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=94336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=94336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=94336"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=94336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}