Ai-Agents
MCP tools on Cloudflare, Part 1: Stateless
The problem this solves
Most MCP tools are request-response. A client asks a question, the server hits an upstream, returns an answer, done. Domain lookups, API queries, calculations — none of these need session state, none need server-initiated notifications, nothing needs to live between calls. Treat them that way and the failure modes shrink. State is something to opt into when a tool genuinely demands it.
Cloudflare Workers reward this discipline. A request-response Worker scales to zero, deploys in seconds, and bills only for the milliseconds it ran. The moment you reach for Durable Objects or persistent state, you’ve moved into a different operational and cost class. The bare transport pattern below keeps you on the cheap side until something specific demands otherwise.
Why Go for AI agents
When we started building agent infrastructure at Aktagon, we evaluated several languages. The decision came down to what matters most in production: reliability, observability, and deployment simplicity.
Concurrency without complexity
Go’s goroutines and channels map naturally to agent workflows. Each agent step runs as a goroutine. Communication between steps uses typed channels. No thread pools to tune, no async/await coloring, no callback hell.
func (a *Agent) Run(ctx context.Context, task Task) (Result, error) {
results := make(chan StepResult, len(a.steps))
for _, step := range a.steps {
go step.Execute(ctx, task, results)
}
return a.collect(ctx, results)
}
Single binary deployment
go build produces a single static binary. No runtime, no dependencies, no container layers beyond scratch. This matters when deploying to edge locations or air-gapped healthcare environments.