File tree Expand file tree Collapse file tree 2 files changed +267
-248
lines changed Expand file tree Collapse file tree 2 files changed +267
-248
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,13 @@ import {
1818import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js" ;
1919import fs from "fs" ;
2020
21+ // Product metadata, used to generate the request User-Agent header and
22+ // passed to the McpServer constructor.
23+ const product = {
24+ name : "elasticsearch-mcp" ,
25+ version : "0.1.1" ,
26+ } ;
27+
2128// Prepend a path prefix to every request path
2229class CustomTransport extends Transport {
2330 private readonly pathPrefix : string ;
@@ -108,6 +115,9 @@ export async function createElasticsearchMcpServer(
108115
109116 const clientOptions : ClientOptions = {
110117 node : url ,
118+ headers : {
119+ "user-agent" : `${ product . name } /${ product . version } ` ,
120+ } ,
111121 } ;
112122
113123 if ( pathPrefix ) {
@@ -142,10 +152,7 @@ export async function createElasticsearchMcpServer(
142152
143153 const esClient = new Client ( clientOptions ) ;
144154
145- const server = new McpServer ( {
146- name : "elasticsearch-mcp-server" ,
147- version : "0.1.1" ,
148- } ) ;
155+ const server = new McpServer ( product ) ;
149156
150157 // Tool 1: List indices
151158 server . tool (
You can’t perform that action at this time.
0 commit comments