BlockEdge

Technology and digital life

How the AWS Cloud Control API MCP Server Enforces Tool Order

An AI agent can ask to create a cloud resource before it has scanned the infrastructure code. The AWS Cloud Control API MCP server is designed to reject that request: the creation tool requires a valid token from the scan step. The agent chooses which tool to call, but the server decides whether the call can proceed.

That distinction matters because the Model Context Protocol (MCP) exposes tools as independent operations. It lets a server describe the inputs a tool requires, but does not itself enforce a sequence across calls. The Cloud Control API server uses tool descriptions to guide the agent and server-side validation to enforce the dependencies.

How a tool checks its prerequisites

The server uses FastMCP’s mcp.tool() decorator to expose functions and describe their required inputs. When the agent discovers the tools, the parameter descriptions tell it which earlier call supplies each token. One sequence starts with get_aws_session_info(), proceeds to generate_infrastructure_code() and run_checkov(), and ends with create_resource(). Knowing that sequence helps the model plan; it does not give the model permission to skip a step.

The server generates cryptographically secure tokens and keeps them, along with their associated data, in an in-memory store called _workflow_store. The agent carries the tokens between calls in its conversation context. Each receiving tool checks the submitted token against the store. If the token is missing, invalid or already consumed, the operation fails.

The implementation description gives a specific example: explain() validates and consumes a properties_token, then issues an explained_properties_token. The workflow illustration uses different labels for that same call: generated_code_token as its input and explained_token as its output. Those labels do not match the written example. The mechanism described in both is that the server checks evidence of the preceding step before issuing a token for the next one.

How the AWS Cloud Control API MCP Server Enforces Tool Order

What happens when a session ends

Tokens are short-lived and removed after use. If the server process stops or restarts, any remaining tokens disappear. Agent sessions also run independently: if a session ends or is refreshed, an unfinished workflow must start again. This isolates concurrent infrastructure operations, at the cost of making interrupted work non-resumable under the in-memory design. The author identifies database storage as an option for deployments that need state to survive a restart, not as part of the default implementation.

A FastMCP proposal discusses declaring a dependency directly, for example with @mcp.tool(depends_on=["run_checkov"]). That syntax is a proposal, not the mechanism the Cloud Control API server relies on. In the implementation described here, a resource creation call succeeds only if the server can validate its required tokens.