Loading video player...
H, what do I want to order today?
A barista can only make the perfect
coffee, but only if someone orders. And
that's the client's role. They ask and
the server responds. Hi, I'm Ian and I'm
a cloud advocate here at Microsoft. And
I really love this part because once you
grasp the client side, you see how
developers, not just systems, drive the
interaction. Clients are where user
needs get translated into actual
requests. And that's what makes client
server architectures so powerful.
Joining me today are Sandra and Bruno,
who are a powerful team. They're going
to be showing us how MCP clients work,
how they make the requests that bring
everything to life. Guys, take it away.
>> Thanks, Aan. Welcome. So, Bruno, last
episode we just created an MCP server.
Now, I would love to see how I can use
this MCP server as a developer using for
instance VS Code with its GitHub copilot
integration. And then afterwards, why
don't we also create an client? As a
Java developer, I would love to see this
using lang chain forj.
>> Yeah, absolutely. So, we we did
implement a server that lists uh species
of monkeys and we can we can access this
tool in different ways. We can use uh
we can use the
inspector for MCP which is this project
here model context protocol/insspector
in npm. This gives us a very easy way to
test. This is an MCP client at the end
of the day and it's good for testing an
MCP server. So I put the URL here of my
MCP server. I hit connect. I can list
the MCP tools available on this server
and I can trigger them. So here I'm
going to trigger the list monkey species
and I can run this tool. I got a list of
11 total species. I can make other calls
like get uh random species. It just
returns one and all the data. But this
is just an inspector tool. I I what I
really want is to get this MCP server
available in a in an environment that is
actually useful as part of my flow when
interacting with AI. So what we're going
to do is configure this MCP server u on
Visual Studio Code and then we're going
to implement an actual Java application
that uses this MCP client as part of an
agentic flow. If you are curious about
how to do these things, it's all part of
the repo let's learn MCP Java on on
GitHub um on the Microsoft organization.
So let's look into Visual Studio Code
first. When I when I ask Visual Studio
Code, let's use the ask mode. And we're
gonna
we're gonna use the ask mode for give me
uh uh three species
of monkeys.
And right now it doesn't have the that
MCP server configured as a as an MCP
server on on this environment. So it
came up with these options here uh resus
capu chain and how
these are probably coming from the
training model of uh son 4 which is the
model that I used for this interaction.
So, let's add the actual MCP server that
you created for species. And let's go to
here. Add a server. And we're going to
do localhost
8080 MCP SSE.
>> Yes.
>> Yes. Is that correct?
>> Yeah, that was correct.
>> All right. monkey species
MCP server
and um let's available on this workspace
only
>> and let's trust this MCP server.
All right. So now we have in this
workspace in this project here which is
the which is the MCP client project. I'm
also configuring the the server as an
MCP server for these Visual Studio Code
environment and it already found four
tools as we can see here. So we can show
the output. Let's see if the output
shows something. Uh this is the login of
the Visual Studio Code client connecting
to that server. Okay. So now let's go
here and
let's ask
so nay
MCP resource. Oh, not MCP resources.
Let's let's just ask the question again.
Give me
uh three species of monkey. Let's see if
it let's see if it will connect to the
MCP server. It did not. It did not
because it's not in aentic mode. Let's
put in aentic mode.
And let's make sure it's using
the MCP server for monkeys. And let's
click okay. Now I I did select I mean
all of the MCP servers in my environment
were selected. I I deselect all of them
and I only selected this one because I
don't want the LLM go trigger all the
other MCP servers.
Cool. So now I'll get you three monkey
species using the available tools to
provide you with accurate information.
Let's say it's a it's an MCP server with
accurate data, not just random training
models. Um, and then let's allow the
execution. So it did run uh it did run
list monkey species and it found one
species here, Spidey monkey. And let's
get the details for these species. And
let's get the details for this one and
for this one. So it got details for
three species. There you go. So, we have
the spider monkey, we have the Japanese
macac, and we have pro probosi's monkey.
Great. These are actually coming from
the MCP server that we implemented
before uh as we can see uh in the source
code, which oh, we'll skip that part.
You can go back to the video and watch
again. Now, what if I want to implement
an application that actually uh uh
integrates with the MCP server as well.
So we have this code here that we
already wrote and it's a it's a an
application using lang J forj
and it has a chat model uh it has a
system message you have this chat
interaction with with the uh um with the
application we have an open AI key but
we're going to actually use the local
large language model for this example we
have up and running to have an e-memory
chat memory store And we're going to
have tools. So for the tools, we're
going to use the MCP server that we
configured that we implemented. It's up
and running. And here's the MCP.json
file configured. We're going to use this
MCPJSON file for this Java application.
So when we run this application,
what we are doing here is combining
implementation of a chat service with a
provider and with a model. the chat
service.
Here we add in this AI services builder.
We have a bot which is a chatbot. We're
going to use a chat model which is going
to be a llama and we're going to use a
tool provider. This tool provider is the
MCP tool provider that has the MCP
server we configured. So let's just run
this code and see how it works. So let's
create a new terminal
and call java minus jar. And you see I
passed the argument here chat. So now
I'm in chat mode in this Java terminal
application. And I can say something how
like what monkey species do you know
or give me three species of monkey the
same prompt that we gave visual studio
code. Let's go with that. All right. So
it returned spider monkey, howler monkey
and Japanese macak. So three species
different than two uh in a different
order than the one give me fake tissues
species.
And these ones are fake coming from the
server. Volcanic amber monkey. Uh give
me all species
you have.
Let's see if it will list all of them.
There you go. 11 v instases as we saw in
the beginning. All of them coming from
the MCP serve. So it's not using its
large language model training data set
behind the scenes. It's just using the
information coming from the MCP server.
So this client we have Visual Studio
Code as a client and we have a Java
application as a client as an MCP client
for that MCP server. And you can
configure other tools like cloud desktop
or GitHub copilot CLI that just got
released um and um um cloud codecs all
these agent AI CLIs can now can also
connect to MCP servers as long as you
have this configuration. So go have fun.
Sandra is that is I I know monkey
species is not the best example but I
mean it
>> that's the best example with you can
totally run it locally but when you also
want pictures because I would love to
see pictures here we can just switch to
Azure OpenAI and with Lchain forj it's a
quick win. It's going to be the same
code just you as Bono pointed out you
just give it the secrets and the key and
then it will work.
>> Awesome. So, thank you Sandra. Thank you
for folks watching and uh have a great
day.
>> Thank you so much Bruno and Sandra for
this amazing session.
The only thing better than one cloud
advocate is two and we had both of you
today to lead us on this amazing
journey. For those of you who followed
along or would like to learn more, you
can find resources at aka.ms/java
andai for beginners. Link is also in the
description of this video. We hope you
stick around and we'll see you in the
next episode.
In this episode, Ayan Gupta is joined again by Bruno Borges and Sandra Ahlgrimm, who show you the other side of MCP (Model Context Protocol): building clients! If the server is the barista, the client is the customer placing the order. This is where user needs get translated into actual requests, making client-server architectures so powerful. Building directly on the last session where you created an MCP server, this session demonstrates how to consume that server from multiple client applications. You'll learn three distinct approaches to working with MCP: testing with the MCP Inspector tool, integrating into Visual Studio Code with GitHub Copilot, and building a Java application using LangChain4j. Bruno and Sandra first show you how to configure VS Code to use your MCP server, allowing GitHub Copilot to access your custom tools during development. You'll see how the AI can automatically call your server's functions to retrieve accurate, domain-specific data rather than relying solely on its training data. This creates a powerful workflow where your development environment becomes aware of your business logic and APIs. Next, they build a complete Java chat application using LangChain4j that integrates with the MCP server. You'll see how to configure chat models (including local models like Llama), set up chat memory, and register MCP tools as providers. The application demonstrates real-time interaction, with the AI model calling your MCP tools to answer questions about monkey species, but the same patterns work for any domain. 0:00 - Introduction: Clients Drive the Interaction 0:57 - Recap: The MCP Server We Built 1:36 - Testing with MCP Inspector Tool 2:21 - Configuring MCP in Visual Studio Code 3:00 - Using MCP Resources in Copilot 3:42 - Enabling Agent Mode for MCP 4:42 - Querying the MCP Server via VS Code 5:40 - Getting Accurate Data from MCP Tools 6:23 - Building a Java Client Application 7:01 - Integrating LangChain4j with MCP 7:42 - Running the Chat Application 8:27 - Querying for Monkey Species 8:51 - Testing with Fictional Species 9:29 - Using Other AI CLI Tools with MCP 10:05 - Session Recap and Wrap-Up Resources: aka.ms/JavaAndAIForBeginners #MCP #ModelContextProtocol #JavaClient #LangChain4j #GitHubCopilot #AIIntegration #JavaDevelopment #ChatApplications #VSCode #LocalLLM #AITools #LlamaAI