Skip to content

Commit 8264dae

Browse files
susan-shu-cjedrazb
andauthored
Add index pattern arg for list indices tool (#44)
Co-authored-by: Jedr Blaszyk <[email protected]>
1 parent a19ad2e commit 8264dae

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

index.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,19 @@ export async function createElasticsearchMcpServer(
112112
server.tool(
113113
"list_indices",
114114
"List all available Elasticsearch indices",
115-
{},
116-
async () => {
115+
{
116+
indexPattern: z
117+
.string()
118+
.trim()
119+
.min(1, "Index pattern is required")
120+
.describe("Index pattern of Elasticsearch indices to list"),
121+
},
122+
async ( {indexPattern} ) => {
117123
try {
118-
const response = await esClient.cat.indices({ format: "json" });
124+
const response = await esClient.cat.indices({
125+
index: indexPattern,
126+
format: "json"
127+
});
119128

120129
const indicesInfo = response.map((index) => ({
121130
index: index.index,

0 commit comments

Comments
 (0)