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