← cookbook/langchain-mesh-rag
6 min read·intermediate·updated just now

LangChain RAG over the Instadash mesh

Plug instamesh_search as a LangChain tool. Your agent retrieves from a corpus of public, structured grids — no vector DB, no embedding pipeline.

#llm#rag#langchain#python

What it builds

  • Two LangChain @tool functions: instamesh_search + fetch_grid_rows
  • A ReAct agent that picks the right grid and fetches rows
  • No Instadash key required — mesh search is open
  • Citations baked in via attribution metadata on every hit

The key step

@tool
def instamesh_search(query: str, k: int = 5) -> list[dict]:
    """Search the Instadash public mesh."""
    qs = urlencode({"q": query, "limit": min(k, 20)})
    with urlopen(f"https://instadash.io/api/mesh/search?{qs}") as r:
        return json.loads(r.read())["results"]
 
agent = create_react_agent(
    ChatAnthropic(model="claude-opus-4-7"),
    tools=[instamesh_search, fetch_grid_rows],
)
note
This is the core of the recipe. The full file (including setup, error handling, and the surrounding scaffolding) lives in the GitHub folder linked below — clone or copy it directly.

Run it

bash⎘ copy
git clone https://github.com/instadashio/instadash-recipes
cd instadash-recipes/langchain-mesh-rag
pip install -r requirements.txt
cp .env.example .env       # fill in your keys
python agent.py

Stack

langchainlanggraphpython
Full source on GitHub

README, runnable code, .env.example, dependencies — all in one folder.

↗ view on github
─ related recipesview all →