← All AI Engineer talks

AI Engineer World's Fair 2025

Exposing Agents as MCP Servers with mcp-agent: Sarmad Qadri

About this talk

Sarmad Qadri, identified in the recording as CEO of LastMile AI, explains how mcp-agent exposes AI agents as Model Context Protocol servers that compatible clients can invoke and compose. Drawing parallels with Language Server Protocol, he describes standardized access to tools and data, simpler architectures based on stronger models and Anthropic's Building Effective Agents patterns, orchestrator-based multi-agent systems, and durable asynchronous workflows that can pause, resume, retry, and incorporate human input.

Chapters

  1. 0:00Why expose agents as MCP servers?
  2. 1:03From Language Server Protocol to Model Context Protocol
  3. 3:38Better models, MCP, and simpler agent architectures
  4. 5:50Effective agent patterns and multi-agent orchestration
  5. 8:08Introducing mcp-agent and durable asynchronous workflows
  6. 13:14MCP-enabled file and web access example
  7. 17:37Run agents from any MCP-compatible environment

Talk transcript

  1. 0:00

    My name is Sarmad, and today I want to talk about building effective agents with Model Context Protocol or MCP. So a lot has changed in the last year, um, especially as far as agent development is concerned.

  2. 0:14

    I think 2025 is the year of agents and, uh, things like MCP make agent design simpler and more robust than ever before. So I want to talk about what the agent tech stack looks like in 2025.

  3. 0:27

    The second thing is a lot of, uh, MCP servers today are just, you know, one-to-one mappings of existing REST API, uh, uh, services to MCP tools. Uh, but MCP servers can be a lot more than that.

  4. 0:41

    They could even be agents. And so I want to show how, uh, agents can be represented as MCP servers. And the last thing is, uh, a little bit of a look into, uh, agent architecture and modeling agents as asynchronous workflows with workflow orchestration, uh, infrastructure like Airflow, Temporal, et cetera.

  5. 1:03

    So a little bit about me. I'm the CEO of LastMile AI, and I've in the past, uh, been working on developer tools, uh, f-for a while, for many years, and back in 2016 to 2018, I was working on, uh, Language Server Protocol and language servers at, at Microsoft.

  6. 1:21

    Uh, LSP revolutionized IDEs. Here on the right, you can kind of see, uh, the list of hundreds and hundreds of language servers that are now available. But before this, uh, every IDE had to-- had a, a unique API surface, and so every language server had to implement, uh, you know, VS Code specific way of doing things or

  7. 1:42

    an Eclipse specific way, and it was very fragmented as an ecosystem. And LSP completely, you know, changed that, uh, by standardizing a single interface, API interface for how language services should be exposed in IDEs.

  8. 1:58

    And so when, uh, you know, LLMs took off, even before tool calling was a thing, I've been thinking about what it would take to make a LSP style protocol for LLMs.

  9. 2:08

    And I've been thinking about this for a long time. Here you have this like scratchpad from 2023 where, uh, this is the era of, you know, ChatGPT plugins. And, uh, I was thinking of how, you know, uh, agent authentication should work or how LLM should be connected to tools, resources, data in some way.

  10. 2:30

    Uh, and so Model Context Protocol, which Anthropic created a few months ago, has been a godsend, and I think it incorporates a lot of the things that, uh, are really necessary to, to get, um, you know, agents into production, and we'll talk a little bit about that.

  11. 2:46

    Like I stated before, I think 2025 is the year that agents hit production, uh, en masse. Uh, until now, there have been a lot of, uh, high, uh, impact use cases that, uh, our customers see that have been stalled in proof of concept stage.

  12. 3:01

    Things like, you know, people want to work, uh, do workflow automation, they want to, uh, deal with unstructured data, uh, and process it in interesting ways. Uh, they want to do information retrieval.

  13. 3:13

    And you're starting to see agents appear in each of these categories already, and I think that pattern will accelerate, uh, in the coming months.

  14. 3:23

    So what does this tech stack look like for agents in 2025? There are three big, uh, kind of updates or changes that are happening, um, which I think, uh, allow you to build effective agents, uh, much more easily than ever before.

  15. 3:38

    So the first thing is better models. We have, uh, reasoning models and LLMs that are pretty reliable for a lot of use cases. And with test-time compute, uh, a lot of the complexity, things like, you know, chain-of-thought reasoning, uh, or ReAct or other kind of patterns that had been implemented at the framework layer are actually now shifting

  16. 4:01

    left into the inference layer. And all that, uh, allows is for less complexity and less burden for app developers because they can get a lot more done by just invoking a model API than ever before.

  17. 4:17

    The second thing is Model Context Protocol, uh, or MCP. For folks who are not familiar, MCP is basically a standardized interface for connecting LLMs to tools, to data, to resources, to the world around them.

  18. 4:30

    Uh, and so the really re-- the revolutionary thing about it is that it is a single way, it provides a single interface to connect and give context to LLMs.

  19. 4:42

    Uh, whereas in the past, there used to be, uh, you know, a multitude of data connectors that were platform specific that you would have to integrate with.

  20. 4:53

    And MCP has taken off. You know, Google, OpenAI, Microsoft, many other companies, potentially competitors, uh, have all kind of coalesced around MCP. Uh, and so it is gonna become the de facto standard for how LLMs connect to the world around them.

  21. 5:14

    And the last part that's really, uh, changed in the last few months is there are simpler architectures for, uh, how agent applications should look. Agents today, unlike the past, are now simply, you know, orchestrators of better models and MCP, uh, and connecting a, a-- LLMs to these tools and resources using these standard protocols, uh,

  22. 5:38

    in some well-defined patterns. There's no longer a need for monolithic AI frameworks that did a lot of heavy lifting at the framework layer in the past. Uh, now you can have simple agent patterns.

  23. 5:50

    You implement them with, uh, standard protocols, with good LLMs, and you can get a long way. And just to show you, uh, Anthropic at the, uh, uh, end of last year, beginning of this year, released this very influential blog post called Building Effective Agents.

  24. 6:07

    And in it, they highlighted a couple of agent patterns that work well in production from their experience with, uh, you know, deploying agents, uh, into enterprises. And so the simplest example of this pattern is this thing called an augmented LLM, which is basically an LLM that has access to tools and resources or data.

  25. 6:28

    Uh, and you basically, you know, it's the base building block. You run this LLM in a loop, it gets an input, it may call tools, it may retrieve data in order to do its job, and it runs, you know, several, uh, iterations and returns a response at the end.

  26. 6:45

    And then you can build more um, interesting patterns on top of that. So then you can have an augmented LLM, which is the optimizer, uh, that generates a response, and you can connect it to another augmented LLM, uh, which is the evaluator that evaluates the quality of the generated response and gives feedback to the, to the generator

  27. 7:04

    LLM, uh, to see what it could do better. And this process happens over, like, a set of, uh, iterations until the evaluator LLM is happy with the res-- quality of the response and then it, you know, returns the final response to the user.

  28. 7:20

    You could have, you know, distributed systems practices like fanning out to multiple, uh, sub-agents and then fanning back in, uh, to aggregate the results. And perhaps the most sophisticated one, which we're starting to see in, uh, tools like Claude Code and other, uh, you know, agentic systems, is this idea of an orchestrator, where you have one LLM

  29. 7:43

    that does-- that generates a plan and, uh, assigns tasks to sub-agents, uh, dynamically, and then synthesizes the results, uh, before res-responding back to the user. And this process can also run in a loop, but really the idea is that there is a planner that is reasoning and deciding, uh, what to do next, kind of dynamically.

  30. 8:08

    So, uh, what I did towards the end of last year, uh, as part of my Christmas break was, uh, I wanted to build an agent of, of library that implemented all of the patterns that this Building Effective Agents blog post, uh, had, uh, and basically was very opinionated about the world being MCP native in the very near

  31. 8:28

    future. And so that's what I built. It's called mcp-agent. Uh, it's on GitHub, you can check it out. Uh, and it is basically making a few very key opinionated choices.

  32. 8:40

    One is that MCP is gonna be everywhere. So every line of business application, uh, think like, you know, Notion, Google Docs, Cursor or Claude, is soon gonna be an MCP compatible client.

  33. 8:52

    Uh, so that means that it could connect to MCP servers. And on the flip side, I think every service, uh, this is already starting to happen, is gonna have an MCP server equivalent, uh, for it.

  34. 9:03

    And so you're gonna see things like, you know, a Linear MCP server, a GitHub MCP server, and any kind of like SaaS product that needs to expose itself to LLMs will have an MCP server.

  35. 9:15

    The second thing that I'm gonna show in a little bit is that agents should be thought of as, uh, microservices, and they can be deployed as MCP servers themselves.

  36. 9:25

    And as we'll talk about in a little bit, that actually gives a lot of benefits on how multi-agent interactions can work.

  37. 9:34

    And the last part is agents are async workflows, and they should be modeled as such because they can be paused, resumed, retried. You may have a human in the loop, uh, and that's really a workflow orchestration that's asynchronous instead of something that's, uh, you know, happening in your chat session, uh, in proc.

  38. 9:54

    You know, if you think of, um, agentic behavior in the MCP world today, it all happens on the client side. So you use Claude or Cursor, and they in turn use MCP servers to solve your-- the tasks you give them.

  39. 10:07

    But what if a-agents themselves were exposed as MCP servers? In that case, if, if you connect an agent as an MCP server to an MCP client, then that client, uh, can invoke that agent, it could coordinate, uh, across multiple agents, it could orchestrate similar to the patterns I showed you, the same as it does today with any

  40. 10:26

    other MCP server. Also, you could do multi-agent communication also over MCP, so agents can then invoke other agents. In this diagram, you kind of see an MCP client that's connected to MCP s-- regular MCP servers like GitHub, Slack, Linear, et cetera, but it's also connected to agent servers.

  41. 10:48

    Uh, and these agent servers in turn can connect to other MCP servers, uh, just over the base MCP protocol. Uh, and so then you can kind of get multi-agent collaboration and coordination for free.

  42. 11:01

    The MCP client can invoke, in this case, MCP agent server A, which in turn may invoke other MCP servers, or it may even invoke other agents. Uh, and as a result, you basically have this network of agents that, uh, may get activated from a single command that a user sends through Claude, Cursor or some other MCP client.

  43. 11:25

    So what are the benefits of this? If you expose agents as MCP servers, the first thing you get is composable agents. Like I mentioned, you have complex multi-agent systems that can operate over the same base protocol that everybody's adopting.

  44. 11:39

    We know MCP is gonna be a common standard, and so we can, uh, safely build on top of it. The second thing is you get platform agnostic agents. You can build these agents once, and then you can reuse them anywhere that is MCP compatible.

  45. 11:55

    And finally, you get scalable agents. Um, if you run agent workflows on dedicated infrastructure, then you can kind of separate the, where the agent is, uh, uh, where the agent compute is happening from, uh, the client that is being used to invoke the agent.

  46. 12:10

    Uh, and that gives enormous benefits in terms of, you know, scalability, uh, performance and, uh, durability as well.

  47. 12:19

    So I've talked about agents as async workflows. What I mean by that is that agents can be paused and resumed. Uh, they need to await on human feedback in some cases.

  48. 12:28

    Uh, they may fail and then they need to be retried. Uh, agents could be triggered or scheduled. It's not just a chat application that, uh, is agentic. You could have a webhook that triggers an agent or a cron job that, you know, triggers an agent every, every day or every week or something.

  49. 12:45

    Uh, and so right way to model all of this is as asynchronous workflows. And so that's what we do in mcp-agent as well. We use Temporal, uh, as the durable execution backend to the compute or the orchestration of agent execution.

  50. 13:01

    So let's do a quick demo to show what all of this looks like, just to make it more real. So, uh, the first thing you'll see here is I have, uh, this task that I wanna build an agent for.

  51. 13:14

    Uh, in this case, it's a fairly complex task. I'm asking an agent to load the student's short story from a markdown file, which is this, but we assume this is a student's short story.

  52. 13:24

    Uh, and then I wanna generate a report, uh, basically grade this short story across proofreading, uh, factual and logical consistency, as well as style adherence. And by the way, for the style adherence, uh, I wanna use the APA style guide from this URL.

  53. 13:40

    Uh, and finally, I wanna write that graded report, uh, to the markdown file, graded_report.md. So the agent that I've created here is actually, um, gonna do a couple of things, but first I connect it to a couple of MCP servers.

  54. 13:54

    I have the fetch MCP server, which, uh, can connect to URLs and get fetch data from the internet, and I have the file system, uh, MCP server to interact with the file system.

  55. 14:06

    So right off the bat, because, uh, of MCP, I don't need to interact with the file system or, uh, interact with the internet and, and fetch URLs in a, in a unique way.

  56. 14:18

    It's all over the same base protocol, and it's all exposed as tools from these MCP servers. Uh, and then I define a couple of these agents where I have a finder agent that can fetch content from the internet or from disk.

  57. 14:31

    I have a writer agent that can write stuff to disk. Uh, I have a proofreader, a fact checker, a style enforcer, and then I have an orchestrator. Recall from, you know, those, uh, agent patterns I showed you.

  58. 14:43

    Uh, this one will basically generate a plan given the task, and it will use-- uh, it will orchestrate these agents that I've defined, uh, in a, a way that it sees fit.

  59. 14:53

    So this workflow, uh, is about like a hundred lines of code, uh, and that it's still doing something fairly sophisticated. So if we run this,

  60. 15:05

    uh, we're gonna use Temporal to run this. And so

  61. 15:09

    I'll kick this off, and you'll see that the worker job has triggered, and it's gonna start executing, uh, workflow UI. You see that there is a workflow that's been triggered, and the first thing you'll see that the agent does is it actually generates a plan.

  62. 15:25

    So over here you see that it's broken down the task I gave it, the fairly complex multi-step task, uh, into a series of steps that it's gonna do. First, it's gonna load the student's short story, uh, and it's gonna use the finder agent for that.

  63. 15:41

    In turn, the finder agent is gonna use the file system MCP server. Then it's gonna analyze, uh, the short story using the proofreader, uh, the fact checker, the style enforcer, and finally, it's gonna, uh, generate the graded_report.markdown file and write with the writer agent.

  64. 15:59

    And so then you see that the agent is executing. Uh, there's a whole workflow graph. This can fail at any step and can be retried. It can be terminated.

  65. 16:10

    It can await for human feedback. And here you see that it already completed, so we should have a graded_report.markdown file that's generated for us. Um, and if we see what's in it, you can kind of see that it did what I asked it to.

  66. 16:27

    Uh, factual consistency, APA style guide. Um, it was able to do all this correctly.

  67. 16:35

    Lastly, you can actually do the same thing now by exposing this agent as an MCP server. You can connect it to an MCP client like Claude Desktop. Here I have the agent exposed as an MCP server, and you see that it exposes itself as workflows.

  68. 16:51

    Uh, and so I gave it the same short story here, um, and I asked it to grade it us- with this basic agent. And so what it does is it runs the in- the, the, the workflow, it gives the input of the story, and then it polls for the status of that workflow job, because note that the

  69. 17:09

    agent is executing in a different, uh, execution environment. I could close my Claude Desktop and come back and I can check the status of that workflow and get me the results at a later date.

  70. 17:21

    And so the asynchronous nature of this work-- of this agent, uh, helps me, uh, kinda, you know, kick off agent tasks from anywhere. And then it, like, once the agent, uh, completes, it presents me the report over here.

  71. 17:37

    And so I can still use this agent in a chatbot environment. I can run this agent anywhere that is MCP compatible. Thank you all for listening to this. There's a lot more that you can do, uh, with agents because of the revolution that MCP is causing.

  72. 17:54

    I'd love to chat more, uh, in general about, uh, the future of agents. Uh, so you can come find me over email, Twitter, or GitHub. Thank you.