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
Stack
langchainlanggraphpython
Full source on GitHub
README, runnable code, .env.example, dependencies — all in one folder.