Dev.to AI 🤖 Ai 👁 0 📖 1 min read

MCP Has No Concept of Tool Order — Here's How to Enforce It Anyway

session_state = {} # session_id -> {"step_a_done": False} def tool_b(session_id, **kwargs): state = session_state.setdefault(session_id, {"step_a_done": False}) if not state["step_a_done"]: # a normal t

Ramdai Bista
Ramdai Bista

Posted on Nov 25 • Originally published at agentkitworks.com

MCP Has No Concept of Tool Order — Here's How to Enforce It Anyway

session_state = {} # session_id -> {"step_a_done": False}

def tool_b(session_id, **kwargs):
state = session_state.setdefault(session_id, {"step_a_done": False})
if not state["step_a_done"]:
# a normal tool error, not an exception that kills the connection
return {
"isError": True,
"content": [{"type": "text", "text": "call tool_a first — tool_b requires its output"}],
}
# ... do the real work

DEV Community

We're a place where coders share, stay up-to-date and grow their careers.

📰 Read the original article on Dev.to AI

Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.