Skip to content

Commit 0c0f003

Browse files
technigeelastic-renovate-prod[bot]bryangwjJoshMock
authored
Includes specific user-agent for MCP (#68)
* Includes specific user-agent for MCP * Simplified product name for user agent * chore(deps): update node.js to v22.16.0 (#58) Co-authored-by: elastic-renovate-prod[bot] <174716857+elastic-renovate-prod[bot]@users.noreply.github.com> * Add new configuration option for Elasticsearch path prefix (#72) * Update index.ts to accept path prefix in Elasticsearch URL * Update README.md to include information about path prefix --------- Co-authored-by: Josh Mock <[email protected]> * fix(deps): update dependency @elastic/elasticsearch to v9.0.2 (#74) Co-authored-by: elastic-renovate-prod[bot] <174716857+elastic-renovate-prod[bot]@users.noreply.github.com> * chore(deps): update buildkite plugin monorepo-diff to v1.4.0 (#75) Co-authored-by: elastic-renovate-prod[bot] <174716857+elastic-renovate-prod[bot]@users.noreply.github.com> * fix(deps): update dependency @modelcontextprotocol/sdk to v1.12.1 (#76) Co-authored-by: elastic-renovate-prod[bot] <174716857+elastic-renovate-prod[bot]@users.noreply.github.com> --------- Co-authored-by: elastic-renovate-prod[bot] <174716857+elastic-renovate-prod[bot]@users.noreply.github.com> Co-authored-by: Ang Wei Jun Bryan <[email protected]> Co-authored-by: Josh Mock <[email protected]>
1 parent 3f84d7c commit 0c0f003

File tree

2 files changed

+267
-248
lines changed

2 files changed

+267
-248
lines changed

index.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,13 @@ import {
1818
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
1919
import 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
2229
class 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(

0 commit comments

Comments
 (0)