Okay, so we've now covered the three ways to use MCP with Nan.
The one that we're going to use most of the time that will be most useful for you, which is an MCP
client node like a backup, a backup in cases where there isn't a tool readily available in Nan.
And you can use the wonderful standard MCP to connect to anyone that's made an MCP server that suits
your needs.
That's the blue one.
The yellow one is if you're trying to make your own MCP server that other people might want to reuse.
And then the purple one is if you want all of your workflows to be MCP servers, so that that Claude
say, could run any one of them.
These are the three ways to use MCP.
And now after all of this, I have I have some bad news.
So the bad news is that MCP actually isn't as useful in Nan as it is in some other contexts.
And I say that for a couple of reasons.
The first of them is that Ann doesn't support one of those three transport mechanisms that I told you
about the three different architectures.
The first of them is called stdio standard input output, and that approach is not supported, at least
as of now.
With connecting to N810, you have to use one of the other two, and that rules out a bunch of different
MCP servers that are designed for that particular way of working.
So that's just one of those things.
It just means that you've got a slightly smaller pool of MCP servers than than the rest of the world.
That's one thing.
And what's the other thing?
Well, the other thing is kind of funny is to say that that actually, Nan is so good that you've already
got a ton of tools to choose from.
And remember, I just said to you that if there isn't already an existing tool that that covers your
needs, then you should use that.
That means that that the Nan team or the community have worked to package something into tools.
For Nan, that's the first choice.
Well, that first choice is available a lot of the time.
It's actually quite hard to find something that doesn't have an Nan node.
And so when there is an n node, you should use that.
So the times when you need to fall back to like an MCP is actually quite rare because there's so many
tools already in Nan.
It's almost like saying Nan is so good that there's less need for this kind of generic MCP client MCP
server setup, so that's worth worth recognizing.
So when it came to, to me building some interesting projects with MCP, I struggled to start with because
every time I thought of a good idea, there was already an end node for that.
And that kept happening to me.
It's like, ah, and it ends too good.
So you may you may find you have that problem.
You're determined to use MCP because it's all the rage.
And and everyone wants to use MCP.
But it turns out Nan already got you covered.
You've already got so many tools.
It's not like there's such a need for it.
But still, I found a couple of needs.
And that's what we're gonna do in today's practical.
But first, there's one more thing I want to mention that's got nothing to do with MCP, but it's something
important to mention.
It's something that we touched on during the lab yesterday, which I sort of introduced in a bit of
a rush, and I it deserves it warrants a little bit more time.
I told you that tools are the major innovation that stands behind a genetic AI.
Well, in addition to tools, there is a kind of secret weapon the the the the dark secret.
That's not so much of a of a secret, uh, of agents and of using llms generally is this fabulous thing
called structured outputs that we did in the lab yesterday.
And I just want to reinforce it.
Structured outputs is when you have an AI agent or really any NLM call and you say, you know what,
I don't want you just to generate any tokens.
I want you to output JSON, and I want you to output JSON that conforms to a particular spec.
And as you may remember, the way you do it in Nan is by setting a flag.
And that flag is right there.
When you're editing the agent, there is like a switch, require specific output format, and you turn
that switch on, and then this new little, uh, sub node appears in your node cluster AI agent that
says output parser.
And you can attach that to like a structured output parser as, as I've done in this diagram.
And then within that you get to specify the kind of JSON that you want it to produce, and that that
is the magic.
That is where you say, I want to constrain the output of this AI agent to conform to this JSON, and
it's super powerful, and it allows you to build a more bulletproof approach around your your AI.
And I use it all the time and so should you.
And as a pro point, it's worth mentioning that for many llms, the way this works is that it's actually
implemented using tools itself.
It is a tool to produce structured outputs, and you can see that behind the scenes when you when you
look at the, uh, the actual information exchanged with the AI.
Okay.
So with all of that, we have the bits and pieces now to go and do today's lab to go and actually put
this MCP thing into practice.
We're going to use someone else's tools.
We're going to use an MCP client to connect to an MCP server and use their tools.
And we're also going to take a complete workflow and make it an MCP server so that someone else can
call into it.
We're going to do both of those things, recognizing that the first one is the more relevant one for
for for you and me day to day.
Okay.
Let's go and do this.
Okay.
Here we are back in.
And and we're going to start with some housekeeping.
Let's go to projects.
My project right here.
And from here let's go over to Project Settings on the right.
And let's change the name of this.
Let's make the name of this amplify, which is going to be the name of our project Save Project amplify.
Save successfully.
That's satisfying.
And over on the left here, it becomes amplify.
And I'm going to change this this folder name.
Let's let's rename this folder from my first folder.
Let's let's take this make this uh testing.
Oh let's make it prototyping.
That feels better.
Prototyping rename.
And then we're going to make a new folder in here.
And we're going to have the new folder be uh to to.
So right click here create folder.
It's going to be um MCP.
That's what we're going to call it.
It's where we're going to build out our MCP workflows right now okay.
So here we go I'm going into MCP our new folder.
We're going to create a workflow.
Nothing there yet.
Let's change it.
Uh okay.
First step we are going to do the usual on chat message.
Click escape to come back here again.
Let's hide the chat.
Nice and clean screen okay.
Next up I wonder what noble add here.
Let's make it an AI agent.
That's what it's all about.
And now here is the usual AI agent screen, and we're normally pressing escape right away.
But no, I want to add one option that becomes increasingly important as we get a little bit more in
depth.
I'm going to click here and Max iterations.
This is how many total parts of the loop, how many times it will run the loop before it says, okay,
that's enough.
I've done too many iterations as a sort of way to avoid it going on forever.
We're going to bump that up from 10 to 30, because ten just isn't enough when it gets to hardcore stuff
like we're going to be doing today and, uh, there we go.
I'm also going to turn on require specific output formats because we're all about structured outputs.
So there we have our AI agent.
And just to keep it simple, we will have a chat model that I'm going to use open AI.
You can of course use whichever one you're now comfortable with.
Um but I'm going to make it a strong one this time because I want to mess around with doing some hefty
stuff, but you for sure can try with a smaller one if you'd prefer, if you'd prefer the, uh, the
price point or whatever, I'm going to go with GPT 5.2, the very latest one.
Uh, but I am I'm going to I'm going to say the reasoning effort, which is how long, how much time
does it spend to think things through before coming to the the outcome?
I'm going to say low so that we're we're a little bit faster and more economical.
We don't need it to be on on slow, uh, long thinking times.
So this is a nice combo, most powerful model on the planet for me and with a low reasoning effort.
I like this setup.
Okay, so here is our agent.
Let's just have some simple memory for now and we are almost ready to get started.
Okay, just before we start with our MCP, I want to set this structured outputs this output parser,
and I should explain that what we're going to be building here is kind of taking things we've done in
the past a step further.
I want to build an engine that's able to find sales prospects from the internet, so it's able to find
people that we could sell our product to by being like an intelligent salesperson.
Okay.
Which means that what I want it to output is ultimately going to be leads leads for me or sales prospects.
So let's see how can we how can we how can we do that with structured outputs.
Well, we start by clicking the plus here and selecting Structured Output parser.
And you'll remember that what goes here is the JSON that we want our model to produce.
So what should that look like.
Okay let's delete whatever's there already.
And let's have our best shot at this.
So what we want is something that's going to respond with sales prospects.
So we want a JSON object.
So open and close curly braces.
It's going to have a field called prospects prospects like so.
And this is going to be a list of prospects.
So a list you remember in JSON is surrounded in square brackets like that.
And each each element of this list is going to be another object.
So we need more curly braces like this.
And that's going to have some fields.
Okay.
This is each of the prospects in the list.
So let's let's come up with each of them.
Each field it's going to have a first name perhaps.
The uh prospect.
First name here.
Last name perhaps.
Sounds sensible.
Uh.
Last name?
Uh, then we could have their company.
Where they work, we could have their role, what they do.
And I'm just putting in here in the values, just English language that describes to the LM what we
really want in there.
There's no hard and fast rules to this.
It's just something that will be read in by the LM as it figures out what do we want it to generate.
So that's the role.
What else do we want?
How about, uh, email?
Predicted email address for this prospect.
And then finally, rationale.
Why this prospect is, uh, qualified, uh, uh, as a potential client.
Oh, okay.
Uh, so those are sensible fields that we might want our LLM to generate.
And this is why Structured Outputs is such a powerful technique, because this gives us an opportunity
to constrain what the LLM generates and to make sure that it generates something consistent with our
business objective generating prospects that conform to this schema.
That's that's why it's so powerful.
And that's why I love to use it.