MCP Tasks (async): Why Aren't Any Agents Supporting Them? — Cornelia Davis, Temporal
AI Engineer · 23 min · 269 sentences · from YouTube's caption track
Each timecode opens YouTube at the start of that sentence. Line anchors (#s42) are the cue ids in the WebVTT, and every line carries its start and end seconds. All transcripts has every talk, and the whole corpus as one file.
- 00:01[music]
- 00:12I know it's 1 minute ahead, but these 20-minute sessions are really short, so I'm going to get started.
- 00:18So, title of my talk you all have seen cuz you're all here, which is why the heck aren't any agents supporting MCP tasks.
- 00:25If you don't know what tasks are, don't worry, you will know in just a moment.
- 00:30But, the first answer to that question is, well, cuz they're smart.
- 00:34The people who are building those clients are smart.
- 00:37What I mean by that is that the MCP tasks specification that came out in November was marked as experimental.
- 00:44And so, well, you might shrug and say, well, gosh, those clients and servers, they're all supporting a whole bunch of experimental things.
- 00:52Why not MCP tasks?
- 00:54Well, again, you'll see the answer to that as we move forward.
- 00:58Um the next answer to that question is, well, they're pretty involved.
- 01:03Um there's a lot of complexity in here, and that's what I want to do over the next 20 minutes is teach you some of that complexity.
- 01:11Quick intro, my name is Cornelia Davis.
- 01:14I'm a technologist at uh Temporal.
- 01:16Uh we're distributed systems stuff.
- 01:19I have a long history in distributed systems, did a whole bunch of stuff in the microservices era, um including Cloud Foundry, Kubernetes, GitOps, Weave Works, all of that stuff, and I even wrote a book about that.
- 01:31That's who I am.
- 01:32Today's agenda in the next 19 minutes is that rather than just talking about things in the abstract, I'm going to ground us in a very concrete example.
- 01:42So, I'm going to give you the lay of the land of that concrete example.
- 01:45Then, I'm going to give you an overview of MCP tasks.
- 01:48Quick question, who here is wants to do things with tasks?
- 01:53Async MCP tools.
- 01:55Okay.
- 01:56So, I'm going to give you a little bit of an overview.
- 01:58Um then we're going to talk about it MCP tasks V1.
- 02:01That's the spec that came out in November and spoiler alert, there's a new one coming out in July.
- 02:07So, that comment that I made about them being smart about not implementing it yet.
- 02:11Well, there's some pretty radical changes.
- 02:14So, I'm going to show you um what's happening with V2 and I actually have some live demos to show all this working and then we'll have some takeaways at the end.
- 02:23So, the use case that we're going to talk about here is a simple purchase order use case.
- 02:29So, the use case is you're going to get in a purchase order and then it's going to go through a number of steps.
- 02:35It's going to record the fact that the goods were received and then it's going to do in parallel, it's going to do some back office stuff updating inventory, sending out notifications
- 02:46and then in parallel to that it's going to pay some invoices.
- 02:51Now, the invoicing is going to happen via an MCP tool.
- 02:55Now, that MCP tool is has itself a number of steps.
- 03:01So, it's going to validate against an ERP, then it's going to have a little human in the loop to request approval, maybe.
- 03:08Um then it's going to reconcile against the ERP again, do a little bit more human in the loop and so on.
- 03:14So, you can see that on the right hand side that MCP server that's going to be it's a tool that's going to be doing the invoice processing for us.
- 03:23It is long running.
- 03:25It's not going to work in a request response style and that's what MCP tasks are all about.
- 03:31And what we're going to do and I'm today's talk is not about temporal, but really what I did here was just showed you a couple of snippets of the code and yes, I will be sharing all the code for what I'm showing today.
- 03:44Couple of snippets here and the real point that I want you to look at is that reject or approve.
- 03:50That is showing you that there is a mechanism for signaling into a long-running process.
- 03:56And that's really the point.
- 03:58And that's what we need is that this is all about asynchronous.
- 04:02So, you understand what MCP tasks are now?
- 04:04MCP tasks are allowing you to have an MCP tool that you can invoke and then it is long-running in the background, and then eventually you can get back some response.
- 04:17So, let's talk about that MCP tasks overview.
- 04:21This is a very simple sequence diagram.
- 04:24It's exactly what you all would expect when I tell you that MCP tasks are long-running tasks.
- 04:30You're going to invoke a tool, and instead of getting back a response, you're going to get a handle.
- 04:36And you can interact with that handle, right?
- 04:39Obvious, right?
- 04:40This is This isn't rocket science.
- 04:42Looks easy enough, right?
- 04:44Well, it turns out that if you actually want this to work over long horizons, it gets a little bit more complicated than that.
- 04:53So, what are some of those complications?
- 04:55Well, you can have all sorts of the longer something runs, the more likely there's going to be some kind of infrastructure blip that's going to cause a problem in that long-running task.
- 05:07So, you could have network blips, you could have network challenges, you could have humans that you're waiting for their in-a-loop part, and they go away on vacation like I'm about to, yay,
- 05:20um day after tomorrow.
- 05:22Um or processes can crash.
- 05:25So, your agent can go down.
- 05:26The agent that's processing the purchase order can go down, or your MCP server can go down as well.
- 05:32So, all of those problems you need to deal with, and those are the things that makes it a little bit more difficult.
- 05:39Now, in addition to what I've told you about MCP tasks so far that you're going to get back a handle that you can interact with by the specification those MCP
- 05:52tasks can't disappear.
- 05:55This is verbage from the spec itself that says once you've locked launched a task it has to be durable.
- 06:03What that means is all of these things that I just showed you on the previous screen clients humans going away on vacation servers going down clients going down connections
- 06:15disconnecting the task needs to survive that and you need to be able to interact with that task when the infrastructure comes back.
- 06:25And I'm going to show you how all of that is done.
- 06:28Now on there's elements there's server side elements that talk about how you make the server side durable and I did a talk at the MCP Dev Summit in March
- 06:40and this is the QR code that it will take you to that YouTube video and that's where I go into a lot of detail about the server side and what you need to do with the server side.
- 06:49Today as you saw is an extension of that work where I'm talking about the client side.
- 06:57So without further ado let me go into a demo.
- 07:00I for those of you who know me I'm always doing demos.
- 07:03So what we have here is we have a dashboard.
- 07:06Um I am not doing this through a chat interface because it frankly it's more efficient for me to click a couple of buttons here to show you this rather than trying to type things in.
- 07:16So I have a user interface here that's showing you the number of purchase orders that have been submitted.
- 07:21I'm going to submit a simple purchase order so that's just a button that is kicking things off and in a moment if the dam demo gods are with me it says submitted we should see the purchase order pop up here and it should show some
- 07:35Ah here's why it's not working because I haven't started my servers.
- 07:40So remember I said it has to work even when the servers aren't running.
- 07:44I forgot to show you here that what I'm doing in this these two windows is in the upper window, I'm starting the back end.
- 07:51This is the MCP server.
- 07:54And in the um lower window, I am starting the MCP client.
- 07:59And you'll see what that client is in a moment.
- 08:01You can see in the splash screen there that I am using fast MCP on the client side.
- 08:06So, let's go back here and notice that even though I submitted that, even though my servers weren't running, that submission did go through.
- 08:15So, it's captured that.
- 08:17So, what you can see here, and you didn't see it cycle through, but on the far right-hand side, the invoice task is it initially showed you that it was work submitted,
- 08:27then it showed you that it was working, and now it's asking for input required.
- 08:33I can come over here.
- 08:34Let me show you what's going on at the back end and at the front end.
- 08:37What I have here are some dashboards that are showing those running processes.
- 08:43On the right-hand side, you have the back end.
- 08:46That's where the invoice processing is, and you can see the name here.
- 08:49Let me increase the font size there a little bit.
- 08:53So, you can see that this is running the invoice, and on the left-hand side, you can see that it's running the PO.
- 08:58I'll explain that task tracker thing in just a moment.
- 09:03So, if we go into the invoice, we can see that it has the process that we talked about earlier.
- 09:08It validated against the ERP, and now it's waiting for human input.
- 09:12It's waiting for that approval.
- 09:14Over on the PO side, we can also see the process that I showed you earlier, which is to say, let's go back here.
- 09:22It is So, ah, yes.
- 09:25So, it did that record recorded that the goods were received.
- 09:29Then, in parallel, it's invoking the invoice processor MCP task.
- 09:35And notice that there's this line item here that says task tracker workflow.
- 09:40Yes, indeed.
- 09:41That is my MCP client implementation.
- 09:43Remember I said nobody's implemented this on the client side?
- 09:47Well, I created my own implementation here.
- 09:49But in parallel with doing the invoice processing, we also had this back office stuff that was happening.
- 09:56So if I come back over here and I click on input required, I can approve this.
- 10:02And I'll hit submit.
- 10:04And we come over here and you'll see in just a moment that the signal is going to come into the back end.
- 10:10Uh need to refresh.
- 10:11Oh, there it goes.
- 10:13So the approval came into the back end and now the back end is going ahead with its additional process paying the invoice.
- 10:20And you'll see a number of line items there.
- 10:22There's some um some uh re- uh retries that are have been programmed in here, but you can see here that it took a few tries before the the ERP went through.
- 10:31We paid the line item and now you can see that the task completed.
- 10:36So everything's completed.
- 10:38If I go back to the dashboard that you saw at the top, you can see that all of those processes completed.
- 10:48Okay?
- 10:49So that's the basic stuff.
- 10:51And I can run that again, but in the in I already gave you inadvertently gave you the example of the infrastructure was down.
- 11:00I could have killed that server halfway through and it would have continued exactly exactly as you saw here.
- 11:07Okay?
- 11:07So you saw it at the very beginning.
- 11:09All right, let's go back to slides.
- 11:11So that's the first demo.
- 11:13So let's talk about um tasks version one.
- 11:18So in tasks version one, there were a number of tool semantics.
- 11:22And again, I go over these tool semantics in a lot more detail in that MCP Dev Summit talk.
- 11:28But there's one really interesting thing that I want to draw your attention to, which is that tasks come with it One of the things that the specification defines is a life cycle for tasks.
- 11:40And that's what you see here on the screen.
- 11:43It has working.
- 11:44It can go into an input required.
- 11:46From input required, it can go back to working, and then eventually it'll complete or be canceled or fail.
- 11:53So, that's one of the things that's super interesting about the task specification is that it's about the life cycle of the task.
- 12:03There's a whole bunch of other semantics there as well around obtaining inputs and delivering results.
- 12:09And I'm going to go through this fairly quickly because I already mentioned some of this is going away.
- 12:15So, this is what the tool semantics were before the task semantics.
- 12:20Notice that tools/call is exactly the same.
- 12:24There's some metadata that you pass in when you want it to be async.
- 12:28And then there's task get cancel list, as well as task result.
- 12:35And so, the top four are request-response in style.
- 12:39The bottom one keeps a connection open.
- 12:41It keeps a connection alive.
- 12:43And the sequence diagram that you can see here is kind of the basic stuff.
- 12:47Now, there's two hiccups with this um uh two major challenges with this particular version of the protocol.
- 12:56The first one is right here.
- 12:58Task list.
- 13:00This is a stateful protocol.
- 13:02So, what that means is that the Remember I said that the server was responsible for durability?
- 13:09Well, this particular endpoint allows me to go to the server and say, "Hey, what tasks do you have?"
- 13:17So, if I have had if the client has gone away, if the user took too long to respond, if my network dropped out and I had to reconnect, I can use this task list to go back to the server and say, "What have you got?"
- 13:32And then you can continue on with that.
- 13:35That works fine if you have one task or two tasks, or maybe it it even works if you have 10 tasks, but what happens if you've got a whole slew of agents out there and you've got a million tasks at the back end.
- 13:52Spoiler alert, there is no filter on that endpoint.
- 13:56So, you would have to go through a million tasks to find the one that you're looking for that you want to interact with.
- 14:02This is going away.
- 14:03You'll see in just a moment, but that's one of the challenges.
- 14:06Just because you can doesn't mean you should.
- 14:08The other one is the task result because that is where we were tunneling the input required.
- 14:15So, in the case of task result, this sequence diagram is really simple.
- 14:20It doesn't have the the interactivity.
- 14:23What we have as soon as you do task as soon as you have input required is the top and bottom are just fine, but this middle section has this weird protocol where you open a long-running connection
- 14:35and then the server elicits a response from the client.
- 14:40That gets super tricky.
- 14:42And I'm running short on time, so I'm not actually going to show you this demo.
- 14:47Happy to show it to you.
- 14:48I'll be around all day tomorrow, too.
- 14:51So, I can happy to show it to you, but I want to show you instead Here's basically the architecture of what you need to build on the server side.
- 14:59This is Notice that this is using fast MCP.
- 15:02So, fast MCP already has support for server side and some client side stuff as well.
- 15:08But, the interesting thing is notice that little box in the on the left-hand side that on the on the lower part where it says MCP client protocol handler?
- 15:18That protocol handler with the ugliness that I just showed you or results actually looks like this.
- 15:25And I can show this to you running and it has all sorts of complexity in it.
- 15:30I got to have the long-running connection.
- 15:32Well, what happens if my connection dies in the middle of that?
- 15:35How do I pick up where I left off when I come back?
- 15:38You'll see that a big part of what the task specification does is it talks about durability.
- 15:44So, back to the question of why the heck aren't there any clients that are supporting this protocol?
- 15:51Yeah.
- 15:52That's why.
- 15:53Super involved.
- 15:55It's still involved with V2, but it gets better.
- 15:58So, let me tell you about that.
- 16:00So, in May, Angie Jones, who's responsible for developer experience at the Agoric AI Foundation, which is where MCP now lives, posted this blog.
- 16:12And one of the things that made me jump up and celebrate a little bit is that the protocol is going stateless.
- 16:21So, as somebody who's been working in the microservices world for a long time, stateful protocols are the absolute worst thing in large-scale distributed systems.
- 16:32So, the protocol is going stateless.
- 16:34It's also doing a number of other things.
- 16:37So, the first bullet is a stateless core.
- 16:39The second bullet is interesting cuz it's they also have structured MCP so that there's a core and there's extensions.
- 16:46If some of you were in the room for the previous two talks, they talked about MCPUI two talks ago, they mentioned extension.
- 16:54Well, that's what's happening here in the V2 MCP protocol is that they have extensions and tasks have become an extension.
- 17:04So, let me tell you a little bit about how tasks changed from V1 to V2 and I do want to give you one more demo.
- 17:12So, on the left-hand side, you can see what the protocol was before.
- 17:16These are the RPC requests that you were doing over the wire.
- 17:19On the right-hand side, you can see a couple of things.
- 17:23Task list has gone away.
- 17:27Good.
- 17:28Wasn't particularly useful anyway, especially at large scale.
- 17:32And instead of having this input required going over a long-running session, you now have an endpoint that allows you from the client side to say, "Here's an update."
- 17:45So, if you remember a while ago, I showed you that screenshot that said Temporal has this notion of a signal.
- 17:52That's effectively what this is.
- 17:53It's a way of signaling into this long-running task.
- 17:57The task result stays, but it changes because it no longer has this long session-based protocol.
- 18:04But, I put the picture on the right-hand side here to emphasize the fact that the life cycle management of these tasks is unchanged.
- 18:15That's actually sound.
- 18:17Now, I go into this a lot into more detail in the talk that I keep referring to.
- 18:23Um on the server side, in invoice processing, I have my own state machine that the invoice is going through.
- 18:30And so, part of what you're doing when you implement these server-side these tasks is you're mapping from the life cycle states of the task over to the domain state machine that's running the the application that the the MCP server in the back end or the tool.
- 18:48So, list again goes away.
- 18:51Now, remember I said that the MCP tasks specification has durability all over it?
- 18:57With this change, given that lists are gone, you now are required on the client side, well, kind of required.
- 19:07There's a little an a little uh parenthetical remark here.
- 19:10The The spec right now says that clients should persist task IDs, but it also points out that if you don't persist task IDs, there is no way to get it back.
- 19:22So, I'm not quite sure why this doesn't have a an all caps must.
- 19:28The other thing that I want to point out is that I already mentioned it is that you're going to have potentially a lot of agents that are processing POs
- 19:37or a lot of agents that are doing a lot of things.
- 19:40And so, having multiple things running, I think is really um crucial as well.
- 19:46So, with that um I'm going to go to the the second demo.
- 19:53And I'm going to go back to my purchase order here.
- 19:58So, what I'm going to do now is I'm going to submit a number of things.
- 20:02And I'm actually still demoing here because I have 13 seconds left.
- 20:07I'm not going to switch over to my V2.
- 20:09You'll see that from the high level, it actually looks exactly the same.
- 20:15I am going to show you what the client proto- client server protocol looks like in the V1 case.
- 20:20It's really quite ugly.
- 20:21But, you'll notice here that we have um I've submitted a bunch of different ones.
- 20:27I can tell you with the V1 protocol, the reference implementation, if you had input required on multiple even though you can see that there's many of them in flight, on the client side they were FIFO.
- 20:40So, you could only respond to the first one.
- 20:43And part of the protocol that I implemented was to get around that gap.
- 20:47So, let's come over here.
- 20:49We can refresh both of these and you can see that there's going to be a bunch of POs in flight.
- 20:55And now I want to show you the task tracker.
- 20:59So, if we go into the task tracker, that's the MCP client.
- 21:03And now let me just expand this so we can see it in a little bit more detail.
- 21:07What you can see here is that remember that that protocol, I showed you that big long sequence diagram?
- 21:14There's a lot of steps involved in that.
- 21:16And what I've done here is I've implemented it as a workflow.
- 21:20And you can see here that there's some elicitation handling that's going from the server side back to the client.
- 21:27So, I won't go into any more details cuz I'm literally out of time now, but I want to share two more things.
- 21:33And that is Um so, going from V1, remember this ugly picture, to V2 in the client server protocol, much much cleaner.
- 21:45Much easier to implement.
- 21:47So, speaking of implementing, here's a summary of all the things that you need to do if you want to implement tasks.
- 21:53Still relatively involved.
- 21:55Here's a picture.
- 21:56I'm going to make these slides available in the Git repo that I'm about to show you.
- 22:01And here's the Git repo that I'm going about to show you.
- 22:04And while you're getting that screenshot, I'm going to tell you about two pieces of work that I'm continuing with.
- 22:10Number one, even though this is better, it still doesn't scale to the millions.
- 22:18Why?
- 22:19Because if I've got a million tasks running, I've got a million clients that are doing gets against each and every one of those tasks.
- 22:27That does not scale.
- 22:29There is a part of the MCPC task specification that is a notifications protocol, which I haven't gotten far enough yet, but it's showing promise, which is going to allow you to, instead of having a million clients
- 22:45uh uh to uh pulling their tasks, it's going to have a single endpoint where they can say, "Has something changed?"
- 22:53And if it has, tell me which one, and now I'll go pull that task.
- 22:58So, it's definitely from a scale perspective.
- 23:01The other thing that we're doing is in the very near future in the next month or so or two, we're going to have a an implementation of all of this where it's going to be much simpler for you.
- 23:13My goal is to actually implement it in in fast MCP so
- 23:17[snorts]
- 23:17that you can use the same protocol the same framework that you're using probably for your MCP servers today.
- 23:24So without further ado, that is it.
- 23:26Thank you to the next speaker for letting me go a few minutes long and I'll be around.
- 23:30I'll step out if you have any questions find me in the hallway.
- 23:34[applause]