{"id":85968,"date":"2026-07-28T01:34:53","date_gmt":"2026-07-27T17:34:53","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/85968.html"},"modified":"2026-07-28T01:34:53","modified_gmt":"2026-07-27T17:34:53","slug":"%e4%bd%bf%e7%94%a8-typescript-%e5%88%9b%e5%bb%ba-elasticsearch-mcp-%e6%9c%8d%e5%8a%a1%e5%99%a8","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/85968.html","title":{"rendered":"\u4f7f\u7528 TypeScript \u521b\u5efa Elasticsearch MCP \u670d\u52a1\u5668"},"content":{"rendered":"<p>\u4ece\u4e1a\u52a1\u80cc\u666f\u3001\u6838\u5fc3\u534f\u8bae\u539f\u7406\u3001\u4ee3\u7801\u5b9e\u73b0\u3001\u96c6\u6210\u6d4b\u8bd5\u5168\u7ef4\u5ea6\u8bb2\u89e3\u5982\u4f55\u7528 TypeScript \u642d\u5efa Elasticsearch MCP \u670d\u52a1\u5668&#xff0c;\u5b9e\u73b0 LLM \u4e0e Elasticsearch \u77e5\u8bc6\u5e93\u7684\u6807\u51c6\u5316\u8054\u52a8\u3002<\/p>\n<h3>\u4e00\u3001\u4e1a\u52a1\u80cc\u666f&#xff1a;Elasticsearch&#043;LLM \u7684\u75db\u70b9\u4e0e MCP \u7684\u4ef7\u503c<\/h3>\n<p>\u5728\u5904\u7406\u8d85\u5927\u578b\u4f01\u4e1a\u5185\u90e8\u77e5\u8bc6\u5e93&#xff08;\u5982\u6280\u672f\u6587\u6863\u3001\u8fd0\u7ef4\u89c4\u8303\u3001\u7814\u53d1\u6807\u51c6&#xff09;\u65f6&#xff0c;Elasticsearch \u51ed\u501f\u5f3a\u5927\u7684\u5168\u6587\u68c0\u7d22\u80fd\u529b&#xff0c;\u80fd\u5feb\u901f\u5b9a\u4f4d\u76f8\u5173\u6587\u6863&#xff0c;\u4f46\u8fd9\u53ea\u662f\u4fe1\u606f\u5904\u7406\u7684\u7b2c\u4e00\u6b65\u3002\u5de5\u7a0b\u5e08\u7684\u6838\u5fc3\u9700\u6c42\u8fdc\u4e0d\u6b62\u300c\u627e\u5230\u6587\u6863\u300d&#xff0c;\u800c\u662f\u8ba9\u5927\u8bed\u8a00\u6a21\u578b&#xff08;LLM&#xff09;\u7efc\u5408\u591a\u7bc7\u6587\u6863\u5185\u5bb9\u3001\u751f\u6210\u7cbe\u7b80\u6458\u8981\u3001\u5e76\u628a\u7b54\u6848\u6eaf\u6e90\u5230\u539f\u59cb\u6587\u6863&#xff0c;\u907f\u514d LLM \u751f\u6210\u5185\u5bb9\u51fa\u73b0\u300c\u5e7b\u89c9\u300d&#xff0c;\u540c\u65f6\u4fdd\u8bc1\u7b54\u6848\u53ef\u8ffd\u6eaf\u3002<\/p>\n<p>\u4f46 LLM \u4e0e\u5916\u90e8\u7cfb\u7edf&#xff08;Elasticsearch&#xff09;\u7684\u8fde\u63a5\u957f\u671f\u5b58\u5728\u788e\u7247\u5316\u95ee\u9898&#xff1a;\u81ea\u5b9a\u4e49 API \u5bf9\u63a5\u3001\u63d2\u4ef6\u5f00\u53d1\u65e0\u7edf\u4e00\u6807\u51c6&#xff0c;\u4e0d\u540c\u5ba2\u6237\u7aef\u9002\u914d\u6210\u672c\u6781\u9ad8\u3002\u800c\u6a21\u578b\u4e0a\u4e0b\u6587\u534f\u8bae&#xff08;MCP&#xff0c;Model Context Protocol&#xff09; \u6b63\u662f\u4e3a\u89e3\u51b3\u8fd9\u4e00\u95ee\u9898\u8bde\u751f\u7684\u5f00\u653e\u6807\u51c6&#xff0c;\u5b83\u4e3a LLM \u4e0e\u5916\u90e8\u7cfb\u7edf\u63d0\u4f9b\u4e86\u6807\u51c6\u5316\u3001\u5b89\u5168\u7684\u53cc\u5411\u901a\u4fe1\u89c4\u8303&#xff0c;\u8ba9 Elasticsearch \u8fd9\u7c7b\u68c0\u7d22\u7cfb\u7edf\u80fd\u65e0\u7f1d\u63a5\u5165 LLM \u5e94\u7528\u3002<\/p>\n<p>Elastic \u5b98\u65b9\u867d\u63d0\u4f9b\u4e86\u73b0\u6210\u7684 MCP \u89e3\u51b3\u65b9\u6848&#xff0c;\u4f46\u81ea\u5b9a\u4e49 MCP \u670d\u52a1\u5668\u80fd\u8ba9\u5f00\u53d1\u8005\u5b8c\u5168\u638c\u63a7\u641c\u7d22\u903b\u8f91\u3001\u7ed3\u679c\u683c\u5f0f\u3001\u540e\u5904\u7406\u6d41\u7a0b&#xff08;\u5982\u6458\u8981\u751f\u6210\u3001\u5f15\u7528\u6eaf\u6e90&#xff09;&#xff0c;\u8fd9\u4e5f\u662f\u672c\u6587\u642d\u5efa\u81ea\u5b9a\u4e49\u670d\u52a1\u5668\u7684\u6838\u5fc3\u521d\u8877\u3002<\/p>\n<h3>\u4e8c\u3001\u6838\u5fc3\u6982\u5ff5&#xff1a;\u5148\u641e\u61c2\u300c\u662f\u4ec0\u4e48\u300d&#xff0c;\u518d\u8c08\u300c\u600e\u4e48\u505a\u300d<\/h3>\n<h4>1. \u4ec0\u4e48\u662f MCP&#xff08;\u6a21\u578b\u4e0a\u4e0b\u6587\u534f\u8bae&#xff09;&#xff1f;<\/h4>\n<p>MCP \u662fAnthropic \u516c\u53f8\u5f00\u6e90\u7684\u5f00\u653e\u901a\u4fe1\u6807\u51c6&#xff0c;\u6838\u5fc3\u4f5c\u7528\u662f\u5efa\u7acbLLM \u5e94\u7528 \u2194 \u5916\u90e8\u7cfb\u7edf&#xff08;Elasticsearch\u3001\u6570\u636e\u5e93\u3001\u6587\u4ef6\u7cfb\u7edf\u7b49&#xff09; \u7684\u5b89\u5168\u53cc\u5411\u8fde\u63a5&#xff0c;\u66ff\u4ee3\u4f20\u7edf\u81ea\u5b9a\u4e49\u63a5\u53e3\u3001\u4e13\u5c5e\u63d2\u4ef6\u7684\u788e\u7247\u5316\u5bf9\u63a5\u65b9\u5f0f\u3002<\/p>\n<ul>\n<li>\n<p>\u6838\u5fc3\u7279\u6027&#xff1a;\u6807\u51c6\u5316\u5de5\u5177\u6ce8\u518c\u3001\u7ed3\u6784\u5316\u6570\u636e\u4f20\u8f93\u3001\u591a\u5ba2\u6237\u7aef\u517c\u5bb9\u3001\u8f7b\u91cf\u901a\u4fe1&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u901a\u4fe1\u539f\u7406&#xff1a;MCP \u670d\u52a1\u5668\u5bf9\u5916\u66b4\u9732\u300c\u5de5\u5177\u300d&#xff0c;MCP \u5ba2\u6237\u7aef\u4e3b\u52a8\u53d1\u73b0\u5e76\u8c03\u7528\u8fd9\u4e9b\u5de5\u5177&#xff0c;\u5b9e\u73b0\u6570\u636e\u4e92\u901a&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u4f20\u8f93\u65b9\u5f0f&#xff1a;\u672c\u6587\u91c7\u7528Stdio&#xff08;\u6807\u51c6\u8f93\u5165\u8f93\u51fa\u6d41&#xff09; \u4f20\u8f93&#xff0c;\u5ba2\u6237\u7aef\u4ee5\u5b50\u8fdb\u7a0b\u5f62\u5f0f\u542f\u52a8\u670d\u52a1\u5668&#xff0c;\u65e0\u9700\u989d\u5916\u7aef\u53e3&#xff0c;\u662f\u672c\u5730 MCP \u670d\u52a1\u7684\u6700\u4f18\u8f7b\u91cf\u65b9\u6848\u3002<\/p>\n<\/li>\n<\/ul>\n<h4>2. \u5b98\u65b9 MCP \u65b9\u6848 vs \u81ea\u5b9a\u4e49 TypeScript MCP \u670d\u52a1\u5668<\/h4>\n<table>\n<tr>\u7ef4\u5ea6\u5b98\u65b9\u65b9\u6848 (Elastic Agent Builder \/ Python)\u81ea\u5b9a\u4e49 TypeScript MCP \u670d\u52a1\u5668<\/tr>\n<tbody>\n<tr>\n<td align=\"left\">\u67e5\u8be2\u80fd\u529b<\/td>\n<td align=\"left\">\u53d7\u9650&#xff1a;\u4ec5\u652f\u6301 ES|QL \u6216\u9002\u914d\u4f4e\u7248\u672c ES&#xff0c;\u65e0\u6cd5\u4f7f\u7528\u5b8c\u6574 DSL \u8fdb\u884c\u590d\u6742\u68c0\u7d22\u3002<\/td>\n<td align=\"left\">\u5b8c\u6574&#xff1a;\u652f\u6301 Elasticsearch \u5b8c\u6574\u67e5\u8be2 DSL&#xff0c;\u5b9e\u73b0\u7cbe\u51c6\u3001\u590d\u6742\u7684\u5168\u6587\u68c0\u7d22\u3002<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u7ed3\u679c\u5904\u7406<\/td>\n<td align=\"left\">\u5355\u4e00&#xff1a;\u65e0\u81ea\u5b9a\u4e49\u6458\u8981\u6216\u5f15\u7528\u751f\u6210\u903b\u8f91&#xff0c;\u4ec5\u8fd4\u56de\u539f\u59cb\u6570\u636e\u3002<\/td>\n<td align=\"left\">\u667a\u80fd&#xff1a;\u53ef\u96c6\u6210 OpenAI \u7b49\u5927\u6a21\u578b&#xff0c;\u81ea\u5b9a\u4e49\u6458\u8981\u751f\u6210\u3001\u5f15\u7528\u6807\u6ce8\u53ca\u683c\u5f0f\u5316\u903b\u8f91\u3002<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u5f00\u53d1\u4f53\u9a8c<\/td>\n<td align=\"left\">\u4e00\u822c&#xff1a;Python \u751f\u6001\u5bf9\u524d\u7aef\/Node \u5de5\u7a0b\u5e08\u4e0d\u591f\u53cb\u597d&#xff0c;\u6216\u53d7\u9650\u4e8e\u7279\u5b9a\u7248\u672c\u3002<\/td>\n<td align=\"left\">\u9ad8\u6548&#xff1a;\u57fa\u4e8e Node.js &#043; TypeScript&#xff0c;\u7c7b\u578b\u5b89\u5168&#xff0c;\u5b8c\u7f8e\u9002\u914d\u73b0\u4ee3\u524d\u7aef\/\u670d\u52a1\u7aef\u751f\u6001\u3002<\/td>\n<\/tr>\n<tr>\n<td align=\"left\">\u6269\u5c55\u6027<\/td>\n<td align=\"left\">\u5c01\u95ed&#xff1a;\u903b\u8f91\u56fa\u5316&#xff0c;\u96be\u4ee5\u6dfb\u52a0\u989d\u5916\u7684\u4e1a\u52a1\u5904\u7406\u6d41\u7a0b\u3002<\/td>\n<td align=\"left\">\u5b8c\u5168\u53ef\u63a7&#xff1a;\u652f\u6301\u6309\u9700\u6dfb\u52a0\u6570\u636e\u6e05\u6d17\u3001\u6743\u9650\u6821\u9a8c\u3001\u591a\u6e90\u878d\u5408\u7b49\u540e\u5904\u7406\u903b\u8f91\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>3. \u6838\u5fc3\u6280\u672f\u6808\u4e0e\u4f5c\u7528\u539f\u7406<\/h4>\n<table>\n<tr>\u4f9d\u8d56\u5305\u6838\u5fc3\u4f5c\u7528\u5e95\u5c42\u539f\u7406<\/tr>\n<tbody>\n<tr>\n<td>&#064;elastic\/elasticsearch<\/td>\n<td>Elasticsearch Node.js \u5b98\u65b9\u5ba2\u6237\u7aef<\/td>\n<td>\u5c01\u88c5 ES RESTful API&#xff0c;\u5b9e\u73b0 DSL \u67e5\u8be2\u3001\u7d22\u5f15\u64cd\u4f5c\u3001\u7ed3\u679c\u89e3\u6790<\/td>\n<\/tr>\n<tr>\n<td>&#064;modelcontextprotocol\/sdk<\/td>\n<td>MCP \u670d\u52a1\u5668\u6838\u5fc3 SDK<\/td>\n<td>\u5c01\u88c5 MCP \u534f\u8bae\u89c4\u8303&#xff0c;\u63d0\u4f9b\u670d\u52a1\u5668\u521d\u59cb\u5316\u3001\u5de5\u5177\u6ce8\u518c\u3001\u4f20\u8f93\u901a\u4fe1\u80fd\u529b<\/td>\n<\/tr>\n<tr>\n<td>openai<\/td>\n<td>OpenAI \u5b98\u65b9 SDK<\/td>\n<td>\u8c03\u7528 gpt-4o-mini \u6a21\u578b&#xff0c;\u5b9e\u73b0\u68c0\u7d22\u540e\u6587\u6863\u7684\u6458\u8981\u751f\u6210\u4e0e\u7b54\u6848\u7efc\u5408<\/td>\n<\/tr>\n<tr>\n<td>zod<\/td>\n<td>\u8fd0\u884c\u65f6\u7c7b\u578b\u6821\u9a8c\u5e93<\/td>\n<td>\u5f25\u8865 TypeScript \u7f16\u8bd1\u671f\u7c7b\u578b\u6821\u9a8c\u7684\u4e0d\u8db3&#xff0c;\u5bf9\u5de5\u5177\u5165\u53c2\/\u51fa\u53c2\u505a\u5b9e\u65f6\u6821\u9a8c&#xff0c;\u4fdd\u8bc1\u6570\u636e\u5408\u6cd5\u6027<\/td>\n<\/tr>\n<tr>\n<td>ts-node\/typescript<\/td>\n<td>TypeScript \u8fd0\u884c\/\u7f16\u8bd1\u5de5\u5177<\/td>\n<td>\u5c06 TS \u4ee3\u7801\u7f16\u8bd1\u4e3a Node.js \u53ef\u6267\u884c\u7684 JS \u4ee3\u7801&#xff0c;\u652f\u6301\u5f00\u53d1\u65f6\u70ed\u8fd0\u884c<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h4>4. MCP \u5ba2\u6237\u7aef&#xff1a;Claude Desktop<\/h4>\n<p>MCP \u5ba2\u6237\u7aef\u662f\u8c03\u7528 MCP \u670d\u52a1\u5668\u5de5\u5177\u7684\u7ec8\u7aef\u8f7d\u4f53&#xff0c;\u5e02\u9762\u4e0a\u6709\u591a\u79cd\u5ba2\u6237\u7aef\u53ef\u9009&#xff0c;\u672c\u6587\u9009\u62e9 Claude Desktop \u6838\u5fc3\u539f\u56e0&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u5f00\u7bb1\u5373\u7528&#xff0c;\u65e0\u9700\u989d\u5916\u5f00\u53d1\u5ba2\u6237\u7aef\u754c\u9762&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u5185\u7f6e LLM \u610f\u56fe\u89e3\u6790\u80fd\u529b&#xff0c;\u53ef\u81ea\u52a8\u4e32\u8054\u591a\u4e2a MCP \u5de5\u5177&#xff08;\u5148\u68c0\u7d22\u518d\u603b\u7ed3&#xff09;&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u652f\u6301\u81ea\u7136\u8bed\u8a00\u4ea4\u4e92&#xff0c;\u7528\u6237\u76f4\u63a5\u63d0\u95ee\u5373\u53ef\u89e6\u53d1 MCP \u5de5\u5177\u8c03\u7528&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u652f\u6301\u5de5\u5177\u8c03\u7528\u6743\u9650\u6388\u6743&#xff0c;\u4fdd\u8bc1\u672c\u5730\u670d\u52a1\u5b89\u5168\u3002<\/p>\n<\/li>\n<\/ul>\n<h3>\u4e09\u3001\u5148\u4fee\u6761\u4ef6<\/h3>\n<p>\u642d\u5efa\u524d\u9700\u51c6\u5907\u597d\u4ee5\u4e0b\u73af\u5883\u4e0e\u5bc6\u94a5&#xff0c;\u7f3a\u4e00\u4e0d\u53ef&#xff1a;<\/p>\n<li>\n<p>Node.js 20 \u53ca\u4ee5\u4e0a\u7248\u672c&#xff08;\u4fdd\u8bc1 MCP SDK \u4e0e ES \u5ba2\u6237\u7aef\u517c\u5bb9&#xff09;&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u53ef\u7528\u7684 Elasticsearch \u670d\u52a1&#xff08;\u672c\u5730\/Elastic Cloud \u5747\u53ef&#xff09;&#xff1b;<\/p>\n<\/li>\n<li>\n<p>OpenAI API \u5bc6\u94a5&#xff08;\u7528\u4e8e\u8c03\u7528 gpt-4o-mini \u751f\u6210\u6458\u8981&#xff09;&#xff1b;<\/p>\n<\/li>\n<li>\n<p>Claude Desktop \u5ba2\u6237\u7aef&#xff08;MCP \u4ea4\u4e92\u754c\u9762&#xff09;\u3002<\/p>\n<\/li>\n<h3>\u56db\u3001\u5168\u6d41\u7a0b\u5b9e\u73b0&#xff1a;\u4ece\u9879\u76ee\u521d\u59cb\u5316\u5230\u670d\u52a1\u4e0a\u7ebf<\/h3>\n<h4>\u7b2c\u4e00\u6b65&#xff1a;\u521d\u59cb\u5316 Node.js \u9879\u76ee\u5e76\u5b89\u88c5\u4f9d\u8d56<\/h4>\n<p>\u9996\u5148\u521b\u5efa\u7a7a\u9879\u76ee&#xff0c;\u521d\u59cb\u5316 package.json \u7ba1\u7406\u4f9d\u8d56&#xff1a;<\/p>\n<p>npm init -y<\/p>\n<p>\u518d\u5b89\u88c5\u6838\u5fc3\u4f9d\u8d56\u4e0e\u5f00\u53d1\u4f9d\u8d56&#xff1a;<\/p>\n<p>npm install &#064;elastic\/elasticsearch &#064;modelcontextprotocol\/sdk openai zod &amp;&amp; npm install &#8211;save-dev ts-node &#064;types\/node typescript<\/p>\n<p>\u4f9d\u8d56\u4f5c\u7528\u8865\u5145&#xff1a;<\/p>\n<ul>\n<li>\n<p>&#064;elastic\/elasticsearch&#xff1a;\u63d0\u4f9b ES \u8fde\u63a5\u3001\u67e5\u8be2\u3001\u6570\u636e\u8bfb\u5199\u80fd\u529b&#xff1b;<\/p>\n<\/li>\n<li>\n<p>&#064;modelcontextprotocol\/sdk&#xff1a;MCP \u670d\u52a1\u5668\u7684\u6838\u5fc3\u9aa8\u67b6&#xff0c;\u8d1f\u8d23\u5de5\u5177\u6ce8\u518c\u3001\u5ba2\u6237\u7aef\u901a\u4fe1&#xff1b;<\/p>\n<\/li>\n<li>\n<p>openai&#xff1a;\u5bf9\u63a5 OpenAI \u5927\u6a21\u578b&#xff0c;\u5b9e\u73b0 RAG \u4e2d\u7684\u300c\u751f\u6210\u300d\u73af\u8282&#xff1b;<\/p>\n<\/li>\n<li>\n<p>zod&#xff1a;\u5b9a\u4e49\u5de5\u5177\u5165\u53c2\/\u51fa\u53c2\u7684\u7ed3\u6784\u5316\u6a21\u5f0f&#xff0c;\u8fd0\u884c\u65f6\u6821\u9a8c\u6570\u636e&#xff0c;\u907f\u514d\u975e\u6cd5\u53c2\u6570\u5bfc\u81f4\u670d\u52a1\u5d29\u6e83&#xff1b;<\/p>\n<\/li>\n<li>\n<p>ts-node\/&#064;types\/node\/typescript&#xff1a;TS \u4ee3\u7801\u7684\u8fd0\u884c\u3001\u7c7b\u578b\u5b9a\u4e49\u3001\u7f16\u8bd1\u5de5\u5177&#xff0c;\u4fdd\u8bc1 TypeScript \u53ef\u5728 Node \u73af\u5883\u6267\u884c\u3002<\/p>\n<\/li>\n<\/ul>\n<h4>\u7b2c\u4e8c\u6b65&#xff1a;\u51c6\u5907 Elasticsearch \u77e5\u8bc6\u5e93\u6570\u636e\u96c6<\/h4>\n<p>\u4e3a\u4e86\u8ba9 MCP \u670d\u52a1\u5668\u6709\u53ef\u68c0\u7d22\u7684\u6570\u636e&#xff0c;\u9700\u6784\u5efa\u6a21\u62df\u4f01\u4e1a\u5185\u90e8\u6280\u672f\u77e5\u8bc6\u5e93&#xff0c;\u6587\u6863\u683c\u5f0f\u7edf\u4e00\u5982\u4e0b&#xff1a;<\/p>\n<p>{<br \/>\n    &#034;id&#034;: 5,<br \/>\n    &#034;title&#034;: &#034;Logging Standards for Microservices&#034;,<br \/>\n    &#034;content&#034;: &#034;Consistent logging across microservices helps with debugging and tracing. Use structured JSON logs and include request IDs and timestamps. Avoid logging sensitive information. Centralize logs in Elasticsearch or a similar system. Configure log rotation to prevent storage issues and ensure logs are searchable for at least 30 days.&#034;,<br \/>\n    &#034;tags&#034;: [&#034;logging&#034;, &#034;microservices&#034;, &#034;standards&#034;]<br \/>\n}<\/p>\n<p>\u8865\u5145\u5b9e\u73b0\u7ec6\u8282&#xff1a;\u9700\u7f16\u5199\u811a\u672c\u5b8c\u6210Elasticsearch \u7d22\u5f15\u521b\u5efa &#043; \u6279\u91cf\u6570\u636e\u5bfc\u5165&#xff0c;\u6838\u5fc3\u903b\u8f91\u4e3a&#xff1a;<\/p>\n<li>\n<p>\u8fde\u63a5 ES \u670d\u52a1&#xff0c;\u521b\u5efa\u540d\u4e3a documents \u7684\u7d22\u5f15&#xff08;\u8bbe\u7f6e\u5b57\u6bb5\u6620\u5c04&#xff1a;title\/text\u3001content\/text\u3001tags\/keyword&#xff09;&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u8bfb\u53d6\u672c\u5730\u77e5\u8bc6\u5e93 JSON \u6570\u636e&#xff0c;\u901a\u8fc7 ES bulk API \u6279\u91cf\u5bfc\u5165\u6587\u6863&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u6821\u9a8c\u7d22\u5f15\u6570\u636e\u662f\u5426\u5199\u5165\u6210\u529f&#xff0c;\u4fdd\u8bc1\u68c0\u7d22\u53ef\u7528\u3002<\/p>\n<\/li>\n<h4>\u7b2c\u4e09\u6b65&#xff1a;\u7f16\u5199 TypeScript MCP \u670d\u52a1\u5668\u6838\u5fc3\u4ee3\u7801<\/h4>\n<p>\u521b\u5efa\u9879\u76ee\u5165\u53e3\u6587\u4ef6 index.ts&#xff0c;\u9010\u6a21\u5757\u5b9e\u73b0\u903b\u8f91&#xff0c;\u6bcf\u6bb5\u4ee3\u7801\u5747\u9644\u5e26\u539f\u7406\u89e3\u6790&#xff1a;<\/p>\n<h5>1. \u5bfc\u5165\u4f9d\u8d56\u4e0e\u73af\u5883\u53d8\u91cf\u914d\u7f6e<\/h5>\n<p>\/\/ index.ts<br \/>\nimport { z } from &#034;zod&#034;;<br \/>\nimport { Client } from &#034;&#064;elastic\/elasticsearch&#034;;<br \/>\nimport { McpServer } from &#034;&#064;modelcontextprotocol\/sdk\/server\/mcp.js&#034;;<br \/>\nimport { StdioServerTransport } from &#034;&#064;modelcontextprotocol\/sdk\/server\/stdio.js&#034;;<br \/>\nimport OpenAI from &#034;openai&#034;;<\/p>\n<p>\/\/ \u73af\u5883\u53d8\u91cf\u914d\u7f6e&#xff1a;\u652f\u6301\u4ece\u7cfb\u7edf\u73af\u5883\u53d8\u91cf\u8bfb\u53d6&#xff0c;\u672c\u5730\u5f00\u53d1\u9ed8\u8ba4\u672c\u5730 ES \u5730\u5740<br \/>\nconst ELASTICSEARCH_ENDPOINT &#061; process.env.ELASTICSEARCH_ENDPOINT ?? &#034;http:\/\/localhost:9200&#034;;<br \/>\nconst ELASTICSEARCH_API_KEY &#061; process.env.ELASTICSEARCH_API_KEY ?? &#034;&#034;;<br \/>\nconst OPENAI_API_KEY &#061; process.env.OPENAI_API_KEY ?? &#034;&#034;;<br \/>\nconst INDEX &#061; &#034;documents&#034;; \/\/ \u56fa\u5b9a\u68c0\u7d22\u7684 ES \u7d22\u5f15\u540d<\/p>\n<p>\u8bf4\u660e&#xff1a;\u901a\u8fc7\u73af\u5883\u53d8\u91cf\u89e3\u8026\u914d\u7f6e&#xff0c;\u907f\u514d\u5bc6\u94a5\u786c\u7f16\u7801&#xff1b;\u9ed8\u8ba4\u672c\u5730 ES \u5730\u5740\u9002\u914d\u5f00\u53d1\u73af\u5883&#xff0c;\u751f\u4ea7\u73af\u5883\u53ef\u901a\u8fc7\u73af\u5883\u53d8\u91cf\u6ce8\u5165\u4e91\u670d\u52a1\u5730\u5740\u3002<\/p>\n<h5>2. \u521d\u59cb\u5316 ES \u4e0e OpenAI \u5ba2\u6237\u7aef<\/h5>\n<p>\/\/ \u521d\u59cb\u5316 OpenAI \u5ba2\u6237\u7aef<br \/>\nconst openai &#061; new OpenAI({<br \/>\n  apiKey: OPENAI_API_KEY,<br \/>\n});<\/p>\n<p>\/\/ \u521d\u59cb\u5316 Elasticsearch \u5ba2\u6237\u7aef<br \/>\nconst _client &#061; new Client({<br \/>\n  node: ELASTICSEARCH_ENDPOINT,<br \/>\n  auth: {<br \/>\n    apiKey: ELASTICSEARCH_API_KEY, \/\/ \u4e91 ES \u7528 API Key&#xff0c;\u672c\u5730\u53ef\u7701\u7565<br \/>\n  },<br \/>\n});<\/p>\n<p>\u8bf4\u660e&#xff1a;ES \u5ba2\u6237\u7aef\u57fa\u4e8e HTTP\/HTTPS \u4e0e ES \u96c6\u7fa4\u901a\u4fe1&#xff0c;\u652f\u6301 API Key \u8ba4\u8bc1&#xff08;Elastic Cloud \u5f3a\u5236\u8981\u6c42&#xff09;&#xff1b;OpenAI \u5ba2\u6237\u7aef\u901a\u8fc7 API Key \u9274\u6743&#xff0c;\u8c03\u7528\u6a21\u578b\u63a5\u53e3\u3002<\/p>\n<h5>3. Zod \u7ed3\u6784\u5316\u6a21\u5f0f\u5b9a\u4e49&#xff08;\u6838\u5fc3&#xff1a;\u8fd0\u884c\u65f6\u7c7b\u578b\u5b89\u5168&#xff09;<\/h5>\n<p>\/\/ \u539f\u59cb\u6587\u6863\u7ed3\u6784\u6821\u9a8c<br \/>\nconst DocumentSchema &#061; z.object({<br \/>\n  id: z.number(),<br \/>\n  title: z.string(),<br \/>\n  content: z.string(),<br \/>\n  tags: z.array(z.string()),<br \/>\n});<\/p>\n<p>\/\/ \u68c0\u7d22\u7ed3\u679c\u7ed3\u6784&#xff08;\u65b0\u589e\u76f8\u5173\u6027\u5f97\u5206&#xff09;<br \/>\nconst SearchResultSchema &#061; z.object({<br \/>\n  id: z.number(),<br \/>\n  title: z.string(),<br \/>\n  content: z.string(),<br \/>\n  tags: z.array(z.string()),<br \/>\n  score: z.number(),<br \/>\n});<\/p>\n<p>\/\/ TypeScript \u7c7b\u578b\u63a8\u5bfc&#xff1a;Zod Schema \u81ea\u52a8\u751f\u6210 TS \u7c7b\u578b<br \/>\ntype Document &#061; z.infer&lt;typeof DocumentSchema&gt;;<br \/>\ntype SearchResult &#061; z.infer&lt;typeof SearchResultSchema&gt;;<\/p>\n<p>\u8865\u5145&#xff1a;TypeScript \u4ec5\u505a\u7f16\u8bd1\u671f\u7c7b\u578b\u6821\u9a8c&#xff0c;\u8fd0\u884c\u65f6\u65e0\u6cd5\u6821\u9a8c\u63a5\u53e3\u8fd4\u56de\/\u7528\u6237\u8f93\u5165\u6570\u636e&#xff1b;Zod \u5b9e\u73b0\u8fd0\u884c\u65f6\u5f3a\u6821\u9a8c&#xff0c;\u540c\u65f6\u81ea\u52a8\u63a8\u5bfc TS \u7c7b\u578b&#xff0c;\u517c\u987e\u7c7b\u578b\u5b89\u5168\u4e0e\u8fd0\u884c\u65f6\u7a33\u5b9a\u6027&#xff0c;\u662f MCP \u5de5\u5177\u7ed3\u6784\u5316\u4ea4\u4e92\u7684\u6838\u5fc3\u3002<\/p>\n<h5>4. \u521d\u59cb\u5316 MCP \u670d\u52a1\u5668<\/h5>\n<p>const server &#061; new McpServer({<br \/>\n  name: &#034;Elasticsearch RAG MCP&#034;,<br \/>\n  description: &#034;A RAG server using Elasticsearch. Provides tools for document search, result summarization, and source citation.&#034;,<br \/>\n  version: &#034;1.0.0&#034;,<br \/>\n});<\/p>\n<p>\u8bf4\u660e&#xff1a;McpServer \u662f MCP SDK \u7684\u6838\u5fc3\u5b9e\u4f8b&#xff0c;\u5b9a\u4e49\u670d\u52a1\u5668\u7684\u57fa\u7840\u4fe1\u606f&#xff08;\u540d\u79f0\u3001\u63cf\u8ff0\u3001\u7248\u672c&#xff09;&#xff0c;\u7528\u4e8e\u5ba2\u6237\u7aef\u53d1\u73b0\u4e0e\u8bc6\u522b\u670d\u52a1\u3002<\/p>\n<h4>\u7b2c\u56db\u6b65&#xff1a;\u6ce8\u518c MCP \u6838\u5fc3\u5de5\u5177&#xff08;RAG \u5de5\u4f5c\u6d41\u5b9e\u73b0&#xff09;<\/h4>\n<p>MCP \u670d\u52a1\u5668\u7684\u6838\u5fc3\u662f\u5bf9\u5916\u66b4\u9732\u5de5\u5177&#xff0c;\u672c\u6587\u5b9e\u73b0\u68c0\u7d22&#043;\u603b\u7ed3\u7684\u5b8c\u6574 RAG \u5de5\u4f5c\u6d41&#xff0c;\u5171\u4e24\u4e2a\u5de5\u5177&#xff1a;<\/p>\n<li>\n<p>search_docs&#xff1a;Elasticsearch \u5168\u6587\u68c0\u7d22&#xff0c;\u62c9\u53d6\u76f8\u5173\u6587\u6863&#xff1b;<\/p>\n<\/li>\n<li>\n<p>summarize_and_cite&#xff1a;\u57fa\u4e8e\u68c0\u7d22\u7ed3\u679c&#xff0c;\u8c03\u7528 OpenAI \u751f\u6210\u6458\u8981&#043;\u6587\u6863\u5f15\u7528\u3002<\/p>\n<\/li>\n<h5>\u5de5\u5177 1&#xff1a;search_docs&#xff08;Elasticsearch \u68c0\u7d22\u5de5\u5177&#xff09;<\/h5>\n<p>server.registerTool(<br \/>\n  &#034;search_docs&#034;,<br \/>\n  {<br \/>\n    title: &#034;Search Documents&#034;,<br \/>\n    description: &#034;Search for documents in Elasticsearch using full-text search. Returns the most relevant documents with their content, title, tags, and relevance score.&#034;,<br \/>\n    \/\/ \u5165\u53c2\u6a21\u5f0f&#xff1a;\u67e5\u8be2\u5173\u952e\u8bcd&#043;\u6700\u5927\u8fd4\u56de\u7ed3\u679c\u6570<br \/>\n    inputSchema: {<br \/>\n      query: z.string().describe(&#034;The search query terms to find relevant documents&#034;),<br \/>\n      max_results: z.number().optional().default(5).describe(&#034;Maximum number of results to return&#034;),<br \/>\n    },<br \/>\n    \/\/ \u51fa\u53c2\u6a21\u5f0f&#xff1a;\u68c0\u7d22\u7ed3\u679c\u6570\u7ec4&#043;\u603b\u547d\u4e2d\u6570<br \/>\n    outputSchema: {<br \/>\n      results: z.array(SearchResultSchema),<br \/>\n      total: z.number(),<br \/>\n    },<br \/>\n  },<br \/>\n  \/\/ \u5de5\u5177\u6267\u884c\u903b\u8f91<br \/>\n  async ({ query, max_results }) &#061;&gt; {<br \/>\n    \/\/ \u5165\u53c2\u6821\u9a8c<br \/>\n    if (!query) {<br \/>\n      return {<br \/>\n        content: [{ type: &#034;text&#034;, text: &#034;Query parameter is required&#034; }],<br \/>\n        isError: true,<br \/>\n      };<br \/>\n    }<\/p>\n<p>    try {<br \/>\n      \/\/ Elasticsearch DSL \u590d\u6742\u67e5\u8be2<br \/>\n      const response &#061; await _client.search({<br \/>\n        index: INDEX,<br \/>\n        size: max_results,<br \/>\n        query: {<br \/>\n          bool: {<br \/>\n            \/\/ \u5fc5\u987b\u5339\u914d&#xff1a;\u591a\u5b57\u6bb5\u6a21\u7cca\u68c0\u7d22<br \/>\n            must: [<br \/>\n              {<br \/>\n                multi_match: {<br \/>\n                  query: query,<br \/>\n                  fields: [&#034;title^2&#034;, &#034;content&#034;, &#034;tags&#034;], \/\/ title \u6743\u91cd\u63d0\u5347 2 \u500d<br \/>\n                  fuzziness: &#034;AUTO&#034;, \/\/ \u81ea\u52a8\u5bb9\u9519\u62fc\u5199\u9519\u8bef<br \/>\n                },<br \/>\n              },<br \/>\n            ],<br \/>\n            \/\/ \u53ef\u9009\u5339\u914d&#xff1a;\u77ed\u8bed\u7cbe\u786e\u5339\u914d&#xff0c;\u989d\u5916\u52a0\u5206<br \/>\n            should: [<br \/>\n              {<br \/>\n                match_phrase: {<br \/>\n                  title: { query: query, boost: 2 },<br \/>\n                },<br \/>\n              },<br \/>\n            ],<br \/>\n          },<br \/>\n        },<br \/>\n        \/\/ \u9ad8\u4eae\u5173\u952e\u8bcd&#xff1a;\u6807\u8bb0\u68c0\u7d22\u547d\u4e2d\u7684\u5b57\u6bb5<br \/>\n        highlight: { fields: { title: {}, content: {} } },<br \/>\n      });<\/p>\n<p>      \/\/ \u89e3\u6790 ES \u68c0\u7d22\u7ed3\u679c<br \/>\n      const results: SearchResult[] &#061; response.hits.hits.map((hit: any) &#061;&gt; {<br \/>\n        const source &#061; hit._source as Document;<br \/>\n        return {<br \/>\n          id: source.id,<br \/>\n          title: source.title,<br \/>\n          content: source.content,<br \/>\n          tags: source.tags,<br \/>\n          score: hit._score ?? 0, \/\/ \u76f8\u5173\u6027\u5f97\u5206<br \/>\n        };<br \/>\n      });<\/p>\n<p>      \/\/ \u683c\u5f0f\u5316\u975e\u7ed3\u6784\u5316\u6587\u672c\u54cd\u5e94&#xff08;\u4f9b Claude \u5c55\u793a&#xff09;<br \/>\n      const contentText &#061; results<br \/>\n        .map((r, i) &#061;&gt; &#096;[${i &#043; 1}] ${r.title} (score: ${r.score.toFixed(2)})\\\\n${r.content.substring(0, 200)}&#8230;&#096;)<br \/>\n        .join(&#034;\\\\n\\\\n&#034;);<\/p>\n<p>      \/\/ \u603b\u547d\u4e2d\u6570\u5904\u7406&#xff08;\u517c\u5bb9 ES \u4e0d\u540c\u7248\u672c\u8fd4\u56de\u683c\u5f0f&#xff09;<br \/>\n      const totalHits &#061; typeof response.hits.total &#061;&#061;&#061; &#034;number&#034;<br \/>\n        ? response.hits.total<br \/>\n        : (response.hits.total?.value ?? 0);<\/p>\n<p>      \/\/ \u8fd4\u56de MCP \u6807\u51c6\u54cd\u5e94&#xff1a;content&#xff08;\u6587\u672c&#xff09;&#043; structuredContent&#xff08;\u7ed3\u6784\u5316\u6570\u636e&#xff09;<br \/>\n      return {<br \/>\n        content: [{ type: &#034;text&#034;, text: &#096;Found ${results.length} relevant documents:\\\\n\\\\n${contentText}&#096; }],<br \/>\n        structuredContent: { results: results, total: totalHits },<br \/>\n      };<br \/>\n    } catch (error: any) {<br \/>\n      console.log(&#034;Error during search:&#034;, error);<br \/>\n      return {<br \/>\n        content: [{ type: &#034;text&#034;, text: &#096;Error searching documents: ${error.message}&#096; }],<br \/>\n        isError: true,<br \/>\n      };<br \/>\n    }<br \/>\n  }<br \/>\n);<\/p>\n<p>\u6838\u5fc3\u539f\u7406\u6df1\u5ea6\u89e3\u6790&#xff1a;<\/p>\n<li>\n<p>Elasticsearch \u67e5\u8be2 DSL \u8bbe\u8ba1&#xff1a;<\/p>\n<ul>\n<li>\n<p>bool\/must&#xff1a;\u5f3a\u5236\u591a\u5b57\u6bb5\u5339\u914d&#xff0c;\u8986\u76d6\u6807\u9898\u3001\u5185\u5bb9\u3001\u6807\u7b7e&#xff1b;<\/p>\n<\/li>\n<li>\n<p>title^2&#xff1a;\u6743\u91cd\u63d0\u5347&#xff0c;\u6807\u9898\u542b\u5173\u952e\u8bcd\u7684\u6587\u6863\u76f8\u5173\u6027\u5f97\u5206\u7ffb\u500d&#xff0c;\u6392\u5e8f\u66f4\u9760\u524d&#xff1b;<\/p>\n<\/li>\n<li>\n<p>fuzziness: &#034;AUTO&#034;&#xff1a;\u81ea\u52a8\u62fc\u5199\u5bb9\u9519&#xff0c;\u77ed\u8bcd\u5141\u8bb81\u4e2a\u5b57\u7b26\u9519\u8bef&#xff0c;\u957f\u8bcd\u5141\u8bb82\u4e2a&#xff0c;\u63d0\u5347\u68c0\u7d22\u5bb9\u9519\u6027&#xff1b;<\/p>\n<\/li>\n<li>\n<p>should\/match_phrase&#xff1a;\u77ed\u8bed\u7cbe\u786e\u5339\u914d\u989d\u5916\u52a0\u5206&#xff0c;\u5f3a\u5316\u7cbe\u51c6\u68c0\u7d22\u6548\u679c&#xff1b;<\/p>\n<\/li>\n<li>\n<p>highlight&#xff1a;\u9ad8\u4eae\u547d\u4e2d\u5173\u952e\u8bcd&#xff0c;\u4fbf\u4e8e\u5feb\u901f\u5b9a\u4f4d\u6838\u5fc3\u5185\u5bb9\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>MCP \u54cd\u5e94\u89c4\u8303&#xff1a;\u5fc5\u987b\u8fd4\u56de content&#xff08;\u975e\u7ed3\u6784\u5316\u6587\u672c&#xff0c;\u4f9b\u5ba2\u6237\u7aef\u5c55\u793a&#xff09;&#043; \u53ef\u9009 structuredContent&#xff08;\u7ed3\u6784\u5316\u6570\u636e&#xff0c;\u4f9b\u7a0b\u5e8f\u4e8c\u6b21\u5904\u7406&#xff09;\u3002<\/p>\n<\/li>\n<h5>\u5de5\u5177 2&#xff1a;summarize_and_cite&#xff08;\u6458\u8981&#043;\u5f15\u7528\u751f\u6210\u5de5\u5177&#xff09;<\/h5>\n<p>server.registerTool(<br \/>\n  &#034;summarize_and_cite&#034;,<br \/>\n  {<br \/>\n    title: &#034;Summarize and Cite&#034;,<br \/>\n    description: &#034;Summarize the provided search results to answer a question and return citation metadata for the sources used.&#034;,<br \/>\n    \/\/ \u5165\u53c2&#xff1a;\u68c0\u7d22\u7ed3\u679c&#043;\u7528\u6237\u95ee\u9898&#043;\u6458\u8981\u957f\u5ea6&#043;\u6700\u5927\u53c2\u8003\u6587\u6863\u6570<br \/>\n    inputSchema: {<br \/>\n      results: z.array(SearchResultSchema).describe(&#034;Array of search results from search_docs&#034;),<br \/>\n      question: z.string().describe(&#034;The question to answer&#034;),<br \/>\n      max_length: z.number().optional().default(500).describe(&#034;Maximum length of the summary in characters&#034;),<br \/>\n      max_docs: z.number().optional().default(5).describe(&#034;Maximum number of documents to include in the context&#034;),<br \/>\n    },<br \/>\n    \/\/ \u51fa\u53c2&#xff1a;\u6458\u8981&#043;\u5f15\u7528\u6e90\u6570\u91cf&#043;\u5f15\u7528\u8be6\u60c5<br \/>\n    outputSchema: {<br \/>\n      summary: z.string(),<br \/>\n      sources_used: z.number(),<br \/>\n      citations: z.array(<br \/>\n        z.object({<br \/>\n          id: z.number(),<br \/>\n          title: z.string(),<br \/>\n          tags: z.array(z.string()),<br \/>\n          relevance_score: z.number(),<br \/>\n        })<br \/>\n      ),<br \/>\n    },<br \/>\n  },<br \/>\n  async ({ results, question, max_length, max_docs }) &#061;&gt; {<br \/>\n    \/\/ \u5165\u53c2\u6821\u9a8c<br \/>\n    if (!results || results.length &#061;&#061;&#061; 0 || !question) {<br \/>\n      return {<br \/>\n        content: [{ type: &#034;text&#034;, text: &#034;Both results and question parameters are required, and results must not be empty&#034; }],<br \/>\n        isError: true,<br \/>\n      };<br \/>\n    }<\/p>\n<p>    try {<br \/>\n      \/\/ \u622a\u53d6\u524dN\u7bc7\u6587\u6863\u4f5c\u4e3a\u4e0a\u4e0b\u6587<br \/>\n      const used &#061; results.slice(0, max_docs);<br \/>\n      \/\/ \u62fc\u63a5\u4e0a\u4e0b\u6587\u6587\u672c&#xff1a;\u683c\u5f0f\u5316\u6587\u6863\u5185\u5bb9\u4f9b LLM \u9605\u8bfb<br \/>\n      const context &#061; used<br \/>\n        .map((r: SearchResult, i: number) &#061;&gt; &#096;[Document ${i &#043; 1}: ${r.title}]\\\\n${r.content}&#096;)<br \/>\n        .join(&#034;\\\\n\\\\n&#8212;\\\\n\\\\n&#034;);<\/p>\n<p>      \/\/ \u8c03\u7528 OpenAI gpt-4o-mini \u751f\u6210\u6458\u8981<br \/>\n      const completion &#061; await openai.chat.completions.create({<br \/>\n        model: &#034;gpt-4o-mini&#034;,<br \/>\n        messages: [<br \/>\n          {<br \/>\n            role: &#034;system&#034;,<br \/>\n            content: &#034;You are a helpful assistant that answers questions based on provided documents. Synthesize information from the documents to answer the user&#039;s question accurately and concisely. If the documents don&#039;t contain relevant information, say so.&#034;,<br \/>\n          },<br \/>\n          { role: &#034;user&#034;, content: &#096;Question: ${question}\\\\n\\\\nRelevant Documents:\\\\n${context}&#096; },<br \/>\n        ],<br \/>\n        \/\/ Token \u8ba1\u7b97&#xff1a;\u4e2d\u6587\u5b57\u7b26\u22481token&#061;4\u5b57\u7b26&#xff0c;\u6700\u5927\u9650\u52361000token\u9632\u6b62\u6ea2\u51fa<br \/>\n        max_tokens: Math.min(Math.ceil(max_length \/ 4), 1000),<br \/>\n        temperature: 0.3, \/\/ \u4f4e\u6e29\u5ea6&#xff0c;\u51cf\u5c11\u751f\u6210\u968f\u673a\u6027&#xff0c;\u4fdd\u8bc1\u7b54\u6848\u7cbe\u51c6<br \/>\n      });<\/p>\n<p>      \/\/ \u89e3\u6790 LLM \u8fd4\u56de\u7684\u6458\u8981<br \/>\n      const summaryText &#061; completion.choices[0]?.message?.content ?? &#034;No summary generated.&#034;;<br \/>\n      \/\/ \u751f\u6210\u5f15\u7528\u5143\u6570\u636e<br \/>\n      const citations &#061; used.map((r: SearchResult) &#061;&gt; ({<br \/>\n        id: r.id,<br \/>\n        title: r.title,<br \/>\n        tags: r.tags,<br \/>\n        relevance_score: r.score,<br \/>\n      }));<\/p>\n<p>      \/\/ \u683c\u5f0f\u5316\u6700\u7ec8\u54cd\u5e94\u6587\u672c<br \/>\n      const citationText &#061; citations<br \/>\n        .map((c: any, i: number) &#061;&gt; &#096;[${i &#043; 1}] ID: ${c.id}, Title: &#034;${c.title}&#034;, Tags: ${c.tags.join(&#034;, &#034;)}, Score: ${c.relevance_score.toFixed(2)}&#096;)<br \/>\n        .join(&#034;\\\\n&#034;);<br \/>\n      const combinedText &#061; &#096;Summary:\\\\n\\\\n${summaryText}\\\\n\\\\nSources used (${citations.length}):\\\\n\\\\n${citationText}&#096;;<\/p>\n<p>      \/\/ \u8fd4\u56de MCP \u6807\u51c6\u54cd\u5e94<br \/>\n      return {<br \/>\n        content: [{ type: &#034;text&#034;, text: combinedText }],<br \/>\n        structuredContent: { summary: summaryText, sources_used: citations.length, citations: citations },<br \/>\n      };<br \/>\n    } catch (error: any) {<br \/>\n      return {<br \/>\n        content: [{ type: &#034;text&#034;, text: &#096;Error generating summary and citations: ${error.message}&#096; }],<br \/>\n        isError: true,<br \/>\n      };<br \/>\n    }<br \/>\n  }<br \/>\n);<\/p>\n<p>\u6838\u5fc3\u539f\u7406\u6df1\u5ea6\u89e3\u6790&#xff1a;<\/p>\n<li>\n<p>RAG \u4e0a\u4e0b\u6587\u62fc\u63a5&#xff1a;\u5c06\u68c0\u7d22\u5230\u7684\u6587\u6863\u683c\u5f0f\u5316\u7f16\u53f7&#xff0c;\u8ba9 LLM \u6e05\u6670\u533a\u5206\u4e0d\u540c\u6765\u6e90&#xff0c;\u907f\u514d\u5185\u5bb9\u6df7\u6dc6&#xff1b;<\/p>\n<\/li>\n<li>\n<p>OpenAI \u8c03\u7528\u53c2\u6570\u8bbe\u8ba1&#xff1a;<\/p>\n<ul>\n<li>\n<p>temperature: 0.3&#xff1a;\u964d\u4f4e\u751f\u6210\u968f\u673a\u6027&#xff0c;\u4fdd\u8bc1\u6458\u8981\u4e25\u683c\u57fa\u4e8e\u68c0\u7d22\u6587\u6863&#xff0c;\u51cf\u5c11\u5e7b\u89c9&#xff1b;<\/p>\n<\/li>\n<li>\n<p>max_tokens&#xff1a;\u6309\u5b57\u7b26\u6570\u6362\u7b97 token&#xff0c;\u63a7\u5236\u6458\u8981\u957f\u5ea6&#xff0c;\u540c\u65f6\u8bbe\u7f6e\u4e0a\u9650\u9632\u6b62\u63a5\u53e3\u62a5\u9519&#xff1b;<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u5f15\u7528\u6eaf\u6e90&#xff1a;\u63d0\u53d6\u68c0\u7d22\u7ed3\u679c\u7684\u5143\u6570\u636e&#xff08;ID\u3001\u6807\u9898\u3001\u6807\u7b7e\u3001\u5f97\u5206&#xff09;&#xff0c;\u5b9e\u73b0\u7b54\u6848\u53ef\u8ffd\u6eaf&#xff0c;\u6ee1\u8db3\u4f01\u4e1a\u77e5\u8bc6\u5e93\u7684\u5408\u89c4\u6027\u8981\u6c42\u3002<\/p>\n<\/li>\n<h5>5. \u542f\u52a8 MCP \u670d\u52a1\u5668&#xff08;Stdio \u4f20\u8f93&#xff09;<\/h5>\n<p>\/\/ \u521b\u5efa Stdio \u4f20\u8f93\u5b9e\u4f8b&#xff1a;\u6807\u51c6\u8f93\u5165\u8f93\u51fa\u6d41\u901a\u4fe1<br \/>\nconst transport &#061; new StdioServerTransport();<br \/>\n\/\/ \u670d\u52a1\u5668\u8fde\u63a5\u4f20\u8f93\u5c42&#xff0c;\u5f00\u59cb\u76d1\u542c\u5ba2\u6237\u7aef\u8c03\u7528<br \/>\nserver.connect(transport);<\/p>\n<p>\u8bf4\u660e&#xff1a;StdioServerTransport \u662f MCP \u6700\u8f7b\u91cf\u5316\u7684\u4f20\u8f93\u65b9\u5f0f&#xff0c;Claude Desktop \u4f5c\u4e3a\u7236\u8fdb\u7a0b&#xff0c;\u901a\u8fc7\u6807\u51c6\u8f93\u5165&#xff08;stdin&#xff09;\u53d1\u9001\u8c03\u7528\u6307\u4ee4&#xff0c;\u670d\u52a1\u5668\u901a\u8fc7\u6807\u51c6\u8f93\u51fa&#xff08;stdout&#xff09;\u8fd4\u56de\u7ed3\u679c&#xff0c;\u65e0\u9700\u5360\u7528\u7f51\u7edc\u7aef\u53e3&#xff0c;\u672c\u5730\u90e8\u7f72\u5b89\u5168\u9ad8\u6548\u3002<\/p>\n<h4>\u7b2c\u4e94\u6b65&#xff1a;\u7f16\u8bd1 TypeScript \u4ee3\u7801<\/h4>\n<p>\u5c06 TS \u4ee3\u7801\u7f16\u8bd1\u4e3a Node.js \u53ef\u6267\u884c\u7684 JS \u4ee3\u7801&#xff0c;\u6267\u884c\u7f16\u8bd1\u547d\u4ee4&#xff1a;<\/p>\n<p>npx tsc index.ts &#8211;target ES2022 &#8211;module node16 &#8211;moduleResolution node16 &#8211;outDir .\/dist &#8211;strict &#8211;esModuleInterop<\/p>\n<p>\u7f16\u8bd1\u53c2\u6570\u89e3\u6790&#xff1a;<\/p>\n<ul>\n<li>\n<p>&#8211;target ES2022&#xff1a;\u7f16\u8bd1\u4e3a ES2022 \u8bed\u6cd5&#xff0c;\u517c\u5bb9 Node.js 20&#043;&#xff1b;<\/p>\n<\/li>\n<li>\n<p>&#8211;module node16&#xff1a;\u9002\u914d Node.js \u6a21\u5757\u5316\u89c4\u8303&#xff1b;<\/p>\n<\/li>\n<li>\n<p>&#8211;outDir .\/dist&#xff1a;\u8f93\u51fa\u7f16\u8bd1\u540e\u7684 JS \u6587\u4ef6\u5230 dist \u76ee\u5f55&#xff1b;<\/p>\n<\/li>\n<li>\n<p>&#8211;strict&#xff1a;\u5f00\u542f TS \u4e25\u683c\u6a21\u5f0f&#xff0c;\u4fdd\u8bc1\u7c7b\u578b\u5b89\u5168&#xff1b;<\/p>\n<\/li>\n<li>\n<p>&#8211;esModuleInterop&#xff1a;\u517c\u5bb9 CommonJS \u4e0e ES \u6a21\u5757\u3002<\/p>\n<\/li>\n<\/ul>\n<p>\u7f16\u8bd1\u5b8c\u6210\u540e&#xff0c;dist\/index.js \u5373\u4e3a MCP \u670d\u52a1\u5668\u7684\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n<h4>\u7b2c\u516d\u6b65&#xff1a;\u96c6\u6210 MCP \u670d\u52a1\u5668\u5230 Claude Desktop<\/h4>\n<p>Claude Desktop \u901a\u8fc7\u914d\u7f6e\u6587\u4ef6\u52a0\u8f7d\u672c\u5730 MCP \u670d\u52a1\u5668&#xff0c;\u9700\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u5185\u5bb9&#xff1a;<\/p>\n<p>{<br \/>\n  &#034;mcpServers&#034;: {<br \/>\n    &#034;elasticsearch-rag-mcp&#034;: {<br \/>\n      &#034;command&#034;: &#034;node&#034;,<br \/>\n      &#034;args&#034;: [&#034;\/Users\/user-name\/app-dir\/dist\/index.js&#034;], \/\/ \u7f16\u8bd1\u540e JS \u6587\u4ef6\u7684\u7edd\u5bf9\u8def\u5f84<br \/>\n      &#034;env&#034;: {<br \/>\n        &#034;ELASTICSEARCH_ENDPOINT&#034;: &#034;your-endpoint-here&#034;, \/\/ ES \u670d\u52a1\u5730\u5740<br \/>\n        &#034;ELASTICSEARCH_API_KEY&#034;: &#034;your-api-key-here&#034;,    \/\/ ES \u8ba4\u8bc1\u5bc6\u94a5<br \/>\n        &#034;OPENAI_API_KEY&#034;: &#034;your-openai-key-here&#034;         \/\/ OpenAI \u5bc6\u94a5<br \/>\n      }<br \/>\n    }<br \/>\n  }<br \/>\n}<\/p>\n<p>\u8865\u5145\u7ec6\u8282&#xff1a;<\/p>\n<ul>\n<li>\n<p>\u914d\u7f6e\u6587\u4ef6\u8def\u5f84&#xff1a;macOS \u4e3a ~\/.claude\/config.json&#xff0c;Windows \u4e3a %APPDATA%\/Claude\/config.json&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u73af\u5883\u53d8\u91cf\u9700\u4e0e\u4ee3\u7801\u4e2d\u5b9a\u4e49\u7684\u53d8\u91cf\u540d\u5b8c\u5168\u4e00\u81f4&#xff0c;\u4fdd\u8bc1\u670d\u52a1\u80fd\u8bfb\u53d6\u5bc6\u94a5\u4e0e\u5730\u5740&#xff1b;<\/p>\n<\/li>\n<li>\n<p>args \u5fc5\u987b\u4e3a\u7edd\u5bf9\u8def\u5f84&#xff0c;\u907f\u514d Claude \u627e\u4e0d\u5230\u53ef\u6267\u884c\u6587\u4ef6\u3002<\/p>\n<\/li>\n<\/ul>\n<h3>\u4e94\u3001\u529f\u80fd\u6d4b\u8bd5&#xff1a;\u9a8c\u8bc1 MCP \u670d\u52a1\u5668\u5168\u6d41\u7a0b<\/h3>\n<h4>1. \u542f\u7528 MCP \u5de5\u5177<\/h4>\n<p>\u6253\u5f00 Claude Desktop&#xff0c;\u70b9\u51fb\u300c\u641c\u7d22\u548c\u5de5\u5177\u300d&#xff0c;\u786e\u8ba4 elasticsearch-rag-mcp \u4e0b\u7684\u4e24\u4e2a\u5de5\u5177\u5df2\u542f\u7528&#xff0c;\u53ef\u6309\u9700\u5f00\u542f\/\u5173\u95ed\u3002<\/p>\n<h4>2. \u5355\u5de5\u5177\u6d4b\u8bd5&#xff1a;\u68c0\u7d22\u6587\u6863<\/h4>\n<p>\u76f4\u63a5\u63d0\u95ee&#xff1a;\u641c\u7d22\u5173\u4e8e\u8ba4\u8bc1\u65b9\u6cd5\u548c\u57fa\u4e8e\u89d2\u8272\u8bbf\u95ee\u63a7\u5236\u7684\u6587\u6863<\/p>\n<p>Claude \u4f1a\u81ea\u52a8\u8c03\u7528 search_docs \u5de5\u5177&#xff0c;Elasticsearch \u68c0\u7d22\u540e\u8fd4\u56de 5 \u7bc7\u76f8\u5173\u6587\u6863&#xff0c;\u5c55\u793a\u6807\u9898\u3001\u76f8\u5173\u6027\u5f97\u5206\u3001\u5185\u5bb9\u6458\u8981&#xff0c;\u6548\u679c\u5982\u4e0b&#xff1a;<\/p>\n<p>Most Relevant Documents:<br \/>\nAccess Control and Role Management (highest relevance) &#8211; This document covers role-based access control (RBAC) principles&#8230;<br \/>\nUser Authentication with OAuth 2.0 &#8211; This document explains OAuth 2.0 authentication&#8230;<br \/>\n&#8230;<\/p>\n<h4>3. \u5de5\u5177\u4e32\u8054\u6d4b\u8bd5&#xff1a;\u68c0\u7d22&#043;\u603b\u7ed3&#043;\u5f15\u7528<\/h4>\n<p>\u63d0\u95ee&#xff1a;\u6539\u8fdb\u6211\u4eec\u7cfb\u7edf\u8ba4\u8bc1\u548c\u8bbf\u95ee\u63a7\u5236\u7684\u4e3b\u8981\u5efa\u8bae\u662f\u4ec0\u4e48&#xff1f;\u8bf7\u9644\u4e0a\u53c2\u8003\u6587\u732e\u3002<\/p>\n<p>\u6838\u5fc3\u903b\u8f91&#xff1a;Claude Desktop \u5185\u7f6e LLM \u81ea\u52a8\u89e3\u6790\u610f\u56fe&#xff0c;\u5148\u8c03\u7528 search_docs \u68c0\u7d22\u6587\u6863&#xff0c;\u518d\u5c06\u7ed3\u679c\u81ea\u52a8\u4f20\u9012\u7ed9 summarize_and_cite \u5de5\u5177&#xff0c;\u6700\u7ec8\u8fd4\u56de\u7cbe\u7b80\u6458\u8981&#043;\u5e26\u6807\u7b7e\u7684\u5f15\u7528\u6765\u6e90&#xff0c;\u793a\u4f8b\u7ed3\u679c&#xff1a;<\/p>\n<p>Based on the documentation, here are the main recommendations to improve authentication and access control across your systems:<\/p>\n<p>Key Recommendations<br \/>\n1. Implement Role-Based Access Control (RBAC) [1]<br \/>\n2. Regular Access Audits [1]<br \/>\n3. Just-in-Time (JIT) Access [1]<br \/>\n4. OAuth 2.0 for Secure Authentication [2]<br \/>\n5. Token Security and Management [2]<\/p>\n<p>References<br \/>\nAccess Control and Role Management (Tags: security, access-control)<br \/>\nUser Authentication with OAuth 2.0 (Tags: authentication, oauth)<\/p>\n<h4>4. \u6743\u9650\u6388\u6743<\/h4>\n<p>\u9996\u6b21\u8c03\u7528\u5de5\u5177\u65f6&#xff0c;Claude \u4f1a\u5f39\u51fa\u6388\u6743\u63d0\u793a&#xff0c;\u9009\u62e9\u300c\u59cb\u7ec8\u5141\u8bb8\u300d\u6216\u300c\u5141\u8bb8\u4e00\u6b21\u300d&#xff0c;\u5373\u53ef\u6b63\u5e38\u4f7f\u7528 MCP \u670d\u52a1\u3002<\/p>\n<h3>\u516d\u3001\u7ed3\u8bba\u4e0e\u540e\u7eed\u62d3\u5c55<\/h3>\n<h4>1. \u6838\u5fc3\u603b\u7ed3<\/h4>\n<p>\u672c\u6587\u5b8c\u6574\u5b9e\u73b0\u4e86\u57fa\u4e8e TypeScript \u7684 Elasticsearch MCP \u670d\u52a1\u5668&#xff0c;\u6253\u901a\u4e86\u300cElasticsearch \u68c0\u7d22 \u2192 OpenAI \u6458\u8981\u751f\u6210 \u2192 Claude Desktop \u4ea4\u4e92\u300d\u7684\u5b8c\u6574 RAG \u94fe\u8def&#xff0c;\u89e3\u51b3\u4e86\u4f01\u4e1a\u77e5\u8bc6\u5e93 LLM \u5e94\u7528\u7684\u68c0\u7d22\u7cbe\u51c6\u6027\u3001\u7b54\u6848\u53ef\u8ffd\u6eaf\u3001\u5de5\u5177\u6807\u51c6\u5316\u4e09\u5927\u6838\u5fc3\u95ee\u9898\u3002<\/p>\n<p>\u76f8\u8f83\u4e8e Elastic \u5b98\u65b9 MCP \u65b9\u6848&#xff0c;\u81ea\u5b9a\u4e49\u670d\u52a1\u5668\u5177\u5907\u5b8c\u6574 DSL \u68c0\u7d22\u3001\u81ea\u5b9a\u4e49\u540e\u5904\u7406\u3001\u7c7b\u578b\u5b89\u5168\u3001\u751f\u6001\u9002\u914d\u7b49\u6838\u5fc3\u4f18\u52bf&#xff0c;\u5b8c\u5168\u9002\u914d\u4f01\u4e1a\u5185\u90e8\u77e5\u8bc6\u5e93\u7684\u4e2a\u6027\u5316\u9700\u6c42\u3002<\/p>\n<h4>2. \u540e\u7eed\u62d3\u5c55\u65b9\u5411<\/h4>\n<ul>\n<li>\n<p>\u4e3a MCP \u670d\u52a1\u5668\u6dfb\u52a0\u641c\u7d22\u6a21\u677f&#xff0c;\u53c2\u6570\u5316\u67e5\u8be2\u63d0\u5347\u68c0\u7d22\u51c6\u786e\u6027\u4e0e\u7075\u6d3b\u6027&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u6269\u5c55\u66f4\u591a MCP \u5de5\u5177&#xff1a;\u5982\u6587\u6863\u65b0\u589e\u3001\u7d22\u5f15\u7ba1\u7406\u3001\u6743\u9650\u8fc7\u6ee4\u7b49&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u9002\u914d\u5176\u4ed6 MCP \u5ba2\u6237\u7aef&#xff08;\u5982 VS Code\u3001Web \u5ba2\u6237\u7aef&#xff09;&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u4f18\u5316 LLM \u63d0\u793a\u8bcd\u5de5\u7a0b&#xff0c;\u63d0\u5347\u6458\u8981\u8d28\u91cf\u4e0e\u5f15\u7528\u7cbe\u51c6\u5ea6&#xff1b;<\/p>\n<\/li>\n<li>\n<p>\u6dfb\u52a0\u65e5\u5fd7\u3001\u76d1\u63a7\u3001\u5f02\u5e38\u544a\u8b66&#xff0c;\u5b8c\u5584\u751f\u4ea7\u7ea7\u670d\u52a1\u80fd\u529b\u3002<\/p>\n<\/li>\n<\/ul>\n<p>MCP \u4f5c\u4e3a LLM \u5916\u90e8\u5de5\u5177\u6807\u51c6\u5316\u7684\u6838\u5fc3\u534f\u8bae&#xff0c;\u672a\u6765\u517c\u5bb9\u6027\u4e0e\u751f\u6001\u4f1a\u6301\u7eed\u5b8c\u5584&#xff0c;\u81ea\u5b9a\u4e49 MCP \u670d\u52a1\u5668\u6216\u5c06\u6210\u4e3a LLM \u5bf9\u63a5\u4f01\u4e1a\u5185\u90e8\u7cfb\u7edf\u7684\u4e3b\u6d41\u65b9\u6848\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ece\u4e1a\u52a1\u80cc\u666f\u3001\u6838\u5fc3\u534f\u8bae\u539f\u7406\u3001\u4ee3\u7801\u5b9e\u73b0\u3001\u96c6\u6210\u6d4b\u8bd5\u5168\u7ef4\u5ea6\u8bb2\u89e3\u5982\u4f55\u7528 TypeScript \u642d\u5efa Elasticsearch MCP \u670d\u52a1\u5668&#xff0c;\u5b9e\u73b0 LLM \u4e0e Elasticsearch \u77e5\u8bc6\u5e93\u7684\u6807\u51c6\u5316\u8054\u52a8\u3002<br \/>\n\u4e00\u3001\u4e1a\u52a1\u80cc\u666f&#xff1a;ElasticsearchLLM \u7684\u75db\u70b9\u4e0e MCP \u7684\u4ef7\u503c<br \/>\n\u5728\u5904\u7406\u8d85\u5927\u578b\u4f01\u4e1a\u5185\u90e8\u77e5\u8bc6\u5e93&#xff08;\u5982\u6280\u672f\u6587\u6863\u3001\u8fd0\u7ef4\u89c4\u8303\u3001\u7814\u53d1\u6807\u51c6&#xff09;\u65f6&#xff0c;Elasticsearch \u51ed\u501f\u5f3a\u5927\u7684\u5168\u6587\u68c0\u7d22\u80fd\u529b&#xff0c;\u80fd\u5feb<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[1299,73,568,43],"topic":[],"class_list":["post-85968","post","type-post","status-publish","format-standard","hentry","category-server","tag-elasticsearch","tag-mcp","tag-typescript","tag-43"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u4f7f\u7528 TypeScript \u521b\u5efa Elasticsearch MCP \u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/85968.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u4f7f\u7528 TypeScript \u521b\u5efa Elasticsearch MCP \u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u4ece\u4e1a\u52a1\u80cc\u666f\u3001\u6838\u5fc3\u534f\u8bae\u539f\u7406\u3001\u4ee3\u7801\u5b9e\u73b0\u3001\u96c6\u6210\u6d4b\u8bd5\u5168\u7ef4\u5ea6\u8bb2\u89e3\u5982\u4f55\u7528 TypeScript \u642d\u5efa Elasticsearch MCP \u670d\u52a1\u5668&#xff0c;\u5b9e\u73b0 LLM \u4e0e Elasticsearch \u77e5\u8bc6\u5e93\u7684\u6807\u51c6\u5316\u8054\u52a8\u3002 \u4e00\u3001\u4e1a\u52a1\u80cc\u666f&#xff1a;ElasticsearchLLM \u7684\u75db\u70b9\u4e0e MCP \u7684\u4ef7\u503c \u5728\u5904\u7406\u8d85\u5927\u578b\u4f01\u4e1a\u5185\u90e8\u77e5\u8bc6\u5e93&#xff08;\u5982\u6280\u672f\u6587\u6863\u3001\u8fd0\u7ef4\u89c4\u8303\u3001\u7814\u53d1\u6807\u51c6&#xff09;\u65f6&#xff0c;Elasticsearch \u51ed\u501f\u5f3a\u5927\u7684\u5168\u6587\u68c0\u7d22\u80fd\u529b&#xff0c;\u80fd\u5feb\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/85968.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-07-27T17:34:53+00:00\" \/>\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=\"9 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/85968.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/85968.html\",\"name\":\"\u4f7f\u7528 TypeScript \u521b\u5efa Elasticsearch MCP \u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-07-27T17:34:53+00:00\",\"dateModified\":\"2026-07-27T17:34:53+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/85968.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/85968.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/85968.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u4f7f\u7528 TypeScript \u521b\u5efa Elasticsearch MCP \u670d\u52a1\u5668\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u4f7f\u7528 TypeScript \u521b\u5efa Elasticsearch MCP \u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/85968.html","og_locale":"zh_CN","og_type":"article","og_title":"\u4f7f\u7528 TypeScript \u521b\u5efa Elasticsearch MCP \u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u4ece\u4e1a\u52a1\u80cc\u666f\u3001\u6838\u5fc3\u534f\u8bae\u539f\u7406\u3001\u4ee3\u7801\u5b9e\u73b0\u3001\u96c6\u6210\u6d4b\u8bd5\u5168\u7ef4\u5ea6\u8bb2\u89e3\u5982\u4f55\u7528 TypeScript \u642d\u5efa Elasticsearch MCP \u670d\u52a1\u5668&#xff0c;\u5b9e\u73b0 LLM \u4e0e Elasticsearch \u77e5\u8bc6\u5e93\u7684\u6807\u51c6\u5316\u8054\u52a8\u3002 \u4e00\u3001\u4e1a\u52a1\u80cc\u666f&#xff1a;ElasticsearchLLM \u7684\u75db\u70b9\u4e0e MCP \u7684\u4ef7\u503c \u5728\u5904\u7406\u8d85\u5927\u578b\u4f01\u4e1a\u5185\u90e8\u77e5\u8bc6\u5e93&#xff08;\u5982\u6280\u672f\u6587\u6863\u3001\u8fd0\u7ef4\u89c4\u8303\u3001\u7814\u53d1\u6807\u51c6&#xff09;\u65f6&#xff0c;Elasticsearch \u51ed\u501f\u5f3a\u5927\u7684\u5168\u6587\u68c0\u7d22\u80fd\u529b&#xff0c;\u80fd\u5feb","og_url":"https:\/\/www.wsisp.com\/helps\/85968.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-07-27T17:34:53+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"9 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/85968.html","url":"https:\/\/www.wsisp.com\/helps\/85968.html","name":"\u4f7f\u7528 TypeScript \u521b\u5efa Elasticsearch MCP \u670d\u52a1\u5668 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-07-27T17:34:53+00:00","dateModified":"2026-07-27T17:34:53+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/85968.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/85968.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/85968.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u4f7f\u7528 TypeScript \u521b\u5efa Elasticsearch MCP \u670d\u52a1\u5668"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/85968","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=85968"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/85968\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=85968"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=85968"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=85968"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=85968"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}