MCP Client Implementation in MULE 4

Glue4Enterprise · Intermediate ·📰 AI News & Updates ·9mo ago

About this lesson

These examples show you the process of creating an MCP Client within your Mule app and calling multiple distinct tools that has already exposed using Mule 4 as MCP server will expose related with Salesforce Case management. OpenAI has been used to analyze the Case and provide next suggested actions.

Full Transcript

Hello. So in last video we have seen like how we can able to uh create MCP server and we connected this MCP server with the cursor. Okay. So we all like went through all the like uh uh different different tools which we have created. So just like the overview I wanted to just quick recap kind of you okay like suppose different different tools we have created like which uh generic case details create case details okay case details by status update case status okay case details by case ID okay and add case comment so these are the different different tools which I have created as part of the MCP servers okay and this MCP server is already deployed into the inpoint platforms. Let me show you which is up and running. Okay. Now as part of this video we are going to see how we can able to create the MCP clients. Okay. Means when I'm talking about the MCP clients means by using the MCP connectors which okay uh it has the uh mostly this all activities are separated by the two categories. We can say one is for the client, one is for the server. So this MCP server tools listener we have used to create the MCP server. Now how by using the MCP client okay we can able to call this tools. So that we are going to see this. Okay. Along with that we are also going to see uh one of the Mulesoft AI chain connector where I have used the agent defined prompt template. Okay. So we'll see like what is the purpose of this. Okay. So let me first go here. So I have created few uh plain our HTTP based endpoints. Okay. And that I'm going to use as a postman to call this. Okay. And so a request is going to hit our HTTP. Okay. And from this request okay how we are going to call this our MCP. Okay. So let's quickly see what are all the configurations for this MCP server. Okay is required. First of all we are going to open this MCP client. Okay. So here you can see as part of the global element properties we are supposed to give the server URL. Okay. And this server URL is nothing but if you see here MCP server this URL where your our MCP server is deployed. Okay. So that we have given okay we are putting uh MCP endpoint path as a MCP. So it is going to give like the uh the user friendly name. Okay. This is the required like we are giving this mute MCP client and this is the client version. Okay. And if you see like uh if you remember in our uh uh this MCP server we have chosen this estimable HTTP client. So same we have chosen here I as part of this authentication process if you see I have used the username and password which is nothing but our this client ID and client secret so that we need to pass. So if you see here I have used the basic authentication so in spite of the username or password I have used client ID and client secret. Okay as part of advance I haven't used any like if you need any default request header we are good to proceed. You can set the recon uh uh reconnection est but I haven't selected I put it. Okay, let's connect it test it the connections whether the connection is getting successful or not. So if you see notice uh this connection is successful. Okay. So we are good to proceed here. Now we'll see what is the Musoft AI chain how we can able to configure. Okay. So once you know this uh this there is a global element properties as part of this connector called the Musoft AI chain. Okay. Where we have this privilege like we can able to select this open AI. Okay. So as a LLM type I have chosen this uh open AI. There are lots of the others LLM types are there. We are good to choose like see here like an enthropic Azure okay huggin mistra okay so lots of the element types okay I have used it is asking this configuration JSON files so I have given the path where my configuration JSON file and this is going to hold nothing but just the open API key okay which is the secret key so that I cannot disclose here okay once you are going to choose the LLM type it has the different different models which are availables. Okay, we are good to choose any models. Okay, what is the temperature of date? Okay, what is the LLM time out? What is the LLM time out? And what is the max token? We can say as part of the request response. Okay, because we all know this LLM type uh any LLM is going to like work on the tokens. Okay. Like suppose if I was sending the any uh sentence like suppose uh anything like uh uh I love mute soft something. Okay. So if you see here like uh basically it is going to break each and every word. Okay. As a token. So it is like for each different model or LLM it has the own like way to like break it like suppose some models can break it into the like three words for three token and one for the SPS so total four okay sometimes like suppose if you seen the now like this is unbelievable unbelievable okay so suppose or this is impossible so these kind of things if you are going to give okay so it quite possible like impossible can be they they can uh like uh broke or they can uh generate this token as a I am possible okay so these kind of things so it's totally depend on the how they have uh like uh designed their or train their LLM type okay so these all configuration we can able to set I haven't set any advanced node or this okay so we don't have any like options to test the connection. So keep it there. Okay. Now we are quickly going to see what all endpoints and what I have and how I have used the MCP uh this uh MCP client to call the tools. So suppose the first is for the fetch case details. So this is my simple endpoint like we used to do our why we create the API. Okay. These are the some variables for my logging purpose. Okay. or for my like suppose case numbers. Okay, just wait. I think it's hanging corresponding. Okay. So here see the case number. So few of Okay. Let's quickly move into the how we can able to configure this particular tools. Okay. So here if you need it is looking for the connector configuration. So you are good to put as a MCF MCP client. Once you are going to connect with this MCP client which is uh like connecting to the MCP server we are good to see all the availables tools. Okay. And these tools are nothing but in different uh terminology we can say these are my end points of the MCP server which we use to say the tools. Okay. we can pass the argument. Okay. Apart from that, if you are supposed to pass any additional par properties, we are good to pass here. Okay. So that's it I'm doing here. Okay. If you see here, uh the response which is we are going to get from the MCP this client call tool mostly we are going to get as a in a string format. Okay. Mostly we are going to get into the a string format. So what I'm doing I'm reading it as a application.json JSONs okay and suppose this is the generic to fetch case details on the basis of that like suppose once I'm going to get the response so it's going to fetch all the case details okay and on basis of that I'm going to fetch the specific case numbers okay which we uh has been passed and that I have store here just the mapping so this is the just our normal technique how we are going to fetch it but uh this is the how the configuration we are supposed to do okay to get this value okay now coming to this open AI okay so what I'm going to do okay when I'm going to fetch the particular case details okay I am sending this payload okay to the open AI okay although this is not the correct way to send the entire payload to open AAI Okay. Uh but while I'm sending it, I'm ensuring these all are the paid version. These all are the true and my payload is not containing doesn't contain any sensitive informations like your credit card, your PAN number something. So we need to make sure that the the security governance should be proper use. But as part of the demo, we maybe ignore this. So what I'm doing whatever I have placed the case details I'm just passing those case details to the LLM okay which is our this open AI and what instruction I'm saying that this open AI like you are an AI agent okay now I'm asking summarize case details along all fields of the case record suggest and next action towards resolution of this case okay so I'm asking asking to provide the potential resolution of this case. Okay, which I'm going to fetch. Okay, so this is I'm going to get it through this agent defined prompt templates as part of the mulesoft AI chains. Okay, and this is the response I'm writing to make it more understanding. Okay, I have used the EML here. Okay, so this is for the fage case details. Similar way I have I'm using the update case status. Okay. So here if you see here I'm using the updatus case status. So this is the tool name which I'm getting. Okay. I'm passing the payload and this is the once it is going to update. I'm again passing the fage case details by case ID to get to check uh validate whether case has been updated or not. Okay. Or similar to like fetch case details by case ID. If you see here, so this is going to like face case details by case ID. Okay, this is one quite interesting one whether we can discuss a little bit more. Suppose uh some case has been going to create like we used to say the new case. Okay. So here is the new case is going to create. Okay. And once it is going to create what I am doing against the case ID okay I'm calling the open AI okay so how I'm getting the case ID once the case is going to create by using the another tools like uh MCP client call to the fage case details by case ID I'm going to get the case ID of it okay and what I'm doing I'm sending this uh this payload informations okay whatever the case details has been created to the open AI okay and I'm saying the same things okay summarize case details along all fields of the case record suggest action towards resolution of this case suppose a customer has raised the case which is the new okay so once the analyst is going to take a look into it why not I can like at least give a kickoff kind of things okay so we will have this much of details what are the all total work around okay which could be possible to execute at the customer end. Okay. Or maybe analyst can take the reference of before going to uh deep dive into that. Okay. So because of that I will show you like how this is going to work. Okay. So uh in that case I'm just sending this whatever the case details if to the open AI to get it. Okay. And along with that if you see I'm also adding the case comment. Okay. So whatever the template I'm going to get it okay from this open AI this uh summarization of case and the uh suggested potential uh resolution of that case okay that I'm going to update into the case itself by adding the case comment so that anyone who is going to assign and look into case can able to see it okay so we'll see this all okay and now this is for the health checkup. Okay. So, it also MCP client ping. If you see here, we have the MCP client B. We can able to check the status. Okay. Here we can also we have privilege to get all the tools which are available into this MCP server. So that we can able to see here if we have defined any resource. So we can also able to get this resource here since as part of our previous video where we have done the MCP server we haven't defined any resource listeners. So that's why it will be like although it has created and we are hitting we are going to get the null value of that. Okay. So hope like this is clear about okay so what I did I deployed this MCP client as well okay into our any point. Okay. Here. Okay. I have deployed here. Okay. So, let's see how this is going to like work. Okay. So, let me open this first uh this postman. Okay. And suppose if I'm saying the fetch all tools. Okay. Which means all the tools which are see this is nothing but my client. Okay. So this is the MCP client which I'm hitting and this MCP client is calling the MCP server. Okay. So here I'm trying to fetch all the tools which are available into the MCP server. So if you see here, so here you can see this is the uh name of the fetch case details, create case record, fetch case details, status, update case status. So all the tools which are available into the MCP server. Okay. It is giving me list of it. Okay. So the purpose of that maybe we can expose this uh API. Sorry. So we can expose this API to the third party the caller one. Okay. And through this our client okay they can able to interact with our MCP server through if any orchestrations or choreography is required we can able to perform along with that we can also able to like we are not going to expose the MCP server directly to the outer world. So maybe we can give this uh as a kind of the experience API and they are going to hit it and maybe the all the governance security orchestrations we can able to control into this API. Okay. So they can be able to like uh know like what all the EMCP tools are available along with the descriptions and what are the input schema is required to make sure that we are going to get the response. So we can able to so let us go step by step how we can able to create a case record. Okay. So let me see. So let's see like I have one already I have preconfigured this value. Okay, I'm hitting this MCP client as a create case record. So let's see how this is going to treat it. See, so if you see here into this MCP client, there must be some activity should happen. Okay. So here you can say it received the request body means it is going through this client only. Okay. And if you see here how like this uh response is coming. Okay. So to make it more understanding, okay, uh easily readable I have used the ML. So here you can say it is giving the case summary. Okay. So if you see it is giving the very enrich informations like account okay what is the account ID industry owner owner ID along with this contact contact ID emails okay along with that if you see here it is giving the suggested next action okay so this is coming from the open AI so it's saying that investigate the error okay engage technical support communicate with the user monitor progress document resolution blah blah Okay. So the case has been created. Okay. Let's verify how we can be able to verify this case. So here the case number is uh 1 190. Okay. Okay. So we can able to see like uh this case number has been generated here. Okay. So let's validate this into the Salesforce. Okay. So let me go here and uh all open cases. So there must be a case 1 190. Okay. Once I'm going to open this. Okay. Here you can see the case is new. Okay. Case has been uh created. And here you can see like as part of this add comment which I'm doing into okay it has put this details over case as well. Okay. because I'm like whatever I'm getting from the open AI I wanted to put into this case comment okay so that it has been put here okay let's uh validate in another way okay so suppose if I'm going here fage case details by case ID okay so let me pass this case ID as part of the URI parameters let me send it okay so here you can see it is giving is case details. Okay. And uh let me try with the update case details. So suppose so update case details is looking for the case ID and let me pass this working. Let's see how this is going to behave. Okay. So here see it is like giving the 200. Okay. Okay. The status is working. Let's verify from the back end as well. So just maybe refresh this. Okay. So the status of this case number which is ending on 90 must be in the working. So here you can see it is the working and here you can see also updated case status new to working. Okay. So here we can able to see what else we had a so page course update. Okay. So this is the pretty much okay how we can able to see it okay through this MCP client uh to call tools we can able to invoke the uh this MCP server. So here uh we can also able to like uh invoke the third party okay uh but here I have used the M MCP uh server which is built in the mule. Okay. So uh through as part of this uh the escope of this video. Okay. So hope uh you are going to explore from your side and try to implement this. One thing which is very important to know like whenever you are going to use this agent defined prompt template in the survey it is not going to work on a trial versions you are supposed to at least add uh minimum $5. Okay. as part of the if you are using the open AI then only this is going to work from your client side otherwise with the trial version it's not going to work okay so hope you are going to uh uh explore this and you like this video okay thank you thanks for your

Original Description

These examples show you the process of creating an MCP Client within your Mule app and calling multiple distinct tools that has already exposed using Mule 4 as MCP server will expose related with Salesforce Case management. OpenAI has been used to analyze the Case and provide next suggested actions.
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Related Reads

📰
HEMN Technologies
Learn how HEMN Technologies is redefining the approach to AI adoption in businesses, focusing on a more proactive and innovative strategy rather than just adapting to AI.
Medium · AI
📰
Google and Ford are funding a push into the trades, the jobs their AI can’t do
Google and Ford are funding a push into trades jobs that AI can't do, highlighting the need for skilled workers in areas like electrician and technician roles
The Next Web AI
📰
$130 Billion In AI Data Centers Stalled. The Bottleneck Is Consent
$130 billion in AI data center projects are stalled due to local opposition, highlighting the need for developers to prioritize community consent
Forbes Innovation
📰
Global Trade Dynamics Q3 2026 — Geopolitical & Macroeconomic Analysis
Analyze global trade dynamics using AI and data analysis to understand geopolitical and macroeconomic trends
Dev.to AI
Up next
The Most Important Conversation in AI Right Now
Matthew Berman
Watch →