---
title: "Discussion on \"Architecting Durable MCP Servers in Laravel for Long-Running AI Agents\" | Hashnode"
description: "Discussion on \"Architecting Durable MCP Servers in Laravel for Long-Running AI Agents\". The demo works flawlessly. You ask the AI agent to analyze a customer's billing history, query the internal documentation, and draft a personalized support response. The Large Language Model (LLM) thi"
url: "https://hashnode.com/posts/architecting-durable-mcp-servers-in-laravel-for-long-running-ai-agents/6ae5c0202b6f7d05044d6501"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Architecting Durable MCP Servers in Laravel for Long-Running AI Agents](https://hosseinhezami.hashnode.dev/architecting-durable-mcp-servers-in-laravel-for-long-running-ai-agents?utm_source=hashnode&utm_medium=feed)

The demo works flawlessly. You ask the AI agent to analyze a customer's billing history, query the internal documentation, and draft a personalized support response. The Large Language Model (LLM) thi

Oct 31 · 19 min read · hosseinhezami.hashnode.dev  
Read the article

-   [#ai](https://hashnode.com/tag/ai)
-   [#ai-agents](https://hashnode.com/tag/ai-agents)
-   [#laravel](https://hashnode.com/tag/laravel)
-   [#mcp](https://hashnode.com/tag/mcp)

## Written by

[Hossein Hezami](https://hashnode.com/@hosseinhezami)

@hosseinhezami · New York, USA

  
[View profile](https://hashnode.com/@hosseinhezami)

## Responses 2

Markdown supported · ⌘↵ to post

[Hayrullah Kar](https://hashnode.com/@magesheet)

[Nov 1](https://hashnode.com/posts/architecting-durable-mcp-servers-in-laravel-for-long-running-ai-agents/6ae5c0202b6f7d05044d6501/comment/6ae6f1c312b873a336d03c13)

One detail in section 1 is worth adjusting. MCP is not limited to a blocking request and response. The Streamable HTTP transport can answer a tool call with a Server-Sent Events stream, no WebSockets needed, and the spec has `notifications/progress` for long calls. Your ticket pattern still makes sense behind a proxy with a hard idle timeout.

[AI Developer](https://hashnode.com/@lycore)

[Oct 31](https://hashnode.com/posts/architecting-durable-mcp-servers-in-laravel-for-long-running-ai-agents/6ae5c0202b6f7d05044d6501/comment/6ae5da301c0d346354f43a50)

The ticket pattern is a good fit, and the HMAC plus allowlist section is the part I'd push hardest. One gap in the sample is that webhook\_url is still an input the model supplies. Even with an allowlist, it is safer to have the server resolve the callback from the authenticated client or session, so the model never chooses where results go. I'd also dedupe on a hash of (user\_id, tool\_name, normalized input) and return the existing ticket, since a retrying agent otherwise queues duplicate 500MB exports. In the job, catching \\Exception and writing 'failed' hides errors from the queue, so $tries and backoff never apply. Separating 'export failed' from 'webhook delivery failed' would let you retry delivery without redoing the four minute work.

How would you handle a ticket whose worker dies mid-run and leaves it in 'pending' forever, with a lease or heartbeat, or a sweeper job?
