on-internet
← Community

Enforce a tool call order in an MCP server

Stack Overflow ·

I have a question regarding tools that relates to each other. For instance, LangChain DeepAgent has a "read" (read_file) and a "list" (ls) tool for files. It mentions that "list" must be called before you call "read" or "edit", so that the LLM doesn't try to read a file that doesn't exist for instance. But the constraint is only loosely enforced via the list tool description. My goal is to enforce this constraint more strictly, with code, in the context of tools served distantly from an MCP server and supposing no control over the agent loop. Illustration from a trace: How to enforce this tool

Comments

Sign in or sign up to comment and upvote.

No comments yet.