MCP server for my elastic search which is on cloud

I am trying to setup MCP server for my elastic database which is on cloud. I want to connect to it using langchain. Is there any best for example for it

Hi @ravitejavemula333,

Welcome back! To confirm, are you using mcp-server-elasticsearch? Are you using LangChain JS or Python?

Generally to connect to any MCP server using LangChain MCP adapters.

Hope that helps!

Hi,
Yes i am using GitHub - elastic/mcp-server-elasticsearch
i am able to connect to mcp server, but not getting expected results, it is failing to extract the query and failing to get correct fields.
i think i need to write a prompt.
do you have any examples?

Hey @ravitejavemula333 ,
Happy to hear that you were able to to connect to the Elasticsearch MCP server, that's a good starting point. Two things to consider if you are not getting the results you want.

  1. Model choice is super important: Which LLM are you using? Some models are much better at following instructions and calling tools than others especially lightweight ones. Consider testing different models to see if your output improves. If possible, start with the larger models like GPT or Claude to pinpoint whether the model choice is the main blocker.

  2. You need a better system prompt: Like you mentioned, you probably want to tweak your system prompt and be explicit in the instructions you give it. I would start with trying out different models first as this will also affect how effective your system prompt is. This also makes it hard to provide examples as you need to tune them to each model.

Some general tips when building a system prompt:

  • Define the role and objective
  • Be explicit when defining capabilities like which tools to call for which actions and what to expect in terms of the output of the tool
  • Set boundaries like, "only use this index" or "only use this tool for this action" or "Don't make up any information"
  • Give it a list of step by step instructions of the workflow you expect it to follow
  • Provide a sample final output

Hope this helps, let us know how it goes!

1 Like

Hi thank for the reply.

  1. right now i am testing with mistral and llama, mistral is better i feel
  2. Yes, i have added system prompt, then somehow i am getting expected results, but still needs to tuned.
  3. Major concern is i have some fields which are keyword types, so i want to get the enum values from the field and i should be able to match those values with the user query. so that it helps a lot, It would be good if we have such tool which can give all enum values.

Hi Ravi, Could you please share what is the label value for mcp server. I am specifying localhost:8080/mcp as server but when initializing the MCPTool, its asking for label.

could you please elaborate your query ?

1 Like

I was following this link learn.microsoft. com/en-us/azure/ai-foundry/agents/how-to/tools/model-context-protocol-samples?pivots=python to access a MCP server exists locally but couldn’t find what value should give for label. But lately found that it could be anything that client can provide.