How the AWS Cloud Control API MCP Server Enforces Tool Order

An AI agent can choose which infrastructure tool to call next, but the AWS Cloud Control API (CCAPI) MCP server decides whether that call can proceed. To create a resource, the agent must present a valid token from an earlier security scan. If the agent skips the scan, the server rejects the creation request rather than relying on the model to follow instructions.

The distinction matters because the Model Context Protocol (MCP) exposes tools as independent operations. A tool description can tell a model which operation should come first, but MCP does not itself enforce that order. The CCAPI server adds that check for infrastructure workflows, where skipping a step can mean creating a resource from code that has not been scanned.

How the server checks each step

The server uses FastMCP’s mcp.tool() decorator to expose functions with schemas that describe their required inputs. Those descriptions tell the agent where to obtain each token. One example sequence starts with get_aws_session_info(), continues through generate_infrastructure_code() and run_checkov(), and ends with create_resource(). The schema guides the agent; the server’s token check enforces the dependency.

The server generates cryptographically secure tokens and keeps them with their associated data in an in-memory store called _workflow_store. The agent carries each token in its conversation context and passes it to the next tool. The receiving tool checks the token against the store before proceeding. A token that was never issued, has been altered or has already been consumed fails that check.

For example, the implementation description says explain() validates and consumes a properties_token, then issues an explained_properties_token for a later call.

Workflow diagram: The diagram labels the input and output of explain() as generated_code_token and explained_token. These labels differ from properties_token and explained_properties_token in the implementation description.

What happens when a session ends

The tokens are short-lived and tied to a particular workflow. Separate agent interactions start independently, and an unfinished workflow must start over if the agent session ends or refreshes. Stopping or restarting the server also clears any tokens still in memory. The author identifies database storage as an option for implementations that need to preserve state across restarts; it is not how the described server stores tokens.

A FastMCP proposal for explicit tool dependencies illustrates a different approach: a developer could declare a prerequisite with syntax such as @mcp.tool(depends_on=["run_checkov"]). That syntax is a proposal, not the mechanism the CCAPI server uses. In the implementation described here, the resource-creation tool checks for a server-issued token regardless of which call the model chooses to attempt next.