MCP Server Implementation in MULE 4

Glue4Enterprise · Intermediate ·🎯 Management & AI-Era Leadership ·9mo ago

About this lesson

These examples show you the process of creating an MCP server within your Mule app and defining multiple distinct tools that the MCP server will expose related with Salesforce Case management.

Full Transcript

Hello. So today we are going to see as part of this tutorial uh what is MCP connectors. Okay. Uh which is widely getting used or we are seeing this. Okay. So here in this tutorial we are going to see how we can use the MCP connectors which is the latest version. Okay. And the latest version if I'm not wrong it is 1.2.0. Okay. If you see I have already added what all activities or we can say the pallets which is provided by this MCP modules. Okay. So there are mostly broadly we can able to see it is two parts. One is the MCP client. Okay. Which is going to deal with the client as a client means invoking the third party MCP server. It's not only the third party. We can also invoke our the MCP server which has been designed and developed into the uh in mule 4. Okay. But we can also by using the MCP client we can able to see that uh to how we can invoke into the uh the this third party MCP server. But as part of this uh uh videos we are only going to concentrate on the MCP server. Okay. And we are not going to see these two things on new session listener or resource listener that I'm going to cover into the next video. Okay. But as part of this, we are only going to see how we can create our MCP server using the tools listener. Okay. So first of all, make sure we have this in our pom.xml this MCP connectors. Okay. Once it is going to there okay make sure we are going to use the MCP connect server as a global configuration element. Once you are going to edit it what you are able to see. Okay here we can able to see as a two types of connections. One is the estimable HTTP. Okay. One is the SSC. Okay. Estimable where we have to like synchronous processing is required and we can able to like uh if your payload is huge you can make it the streaming enabled so you can able to get into the chunk as well whenever you need like the asynchronous processings where the pushpull concept was required then we are going to see the SSC one okay as part of this videos we are going to focus on the estimable HTTP okay so each MCP server internally use one of the HTTP listeners. Okay, this is the reason if you see here I have nothing special treatment just our the normal HTTP. Okay, I'm not using any security or like TLS configurations. Okay, we need to make sure that this MCP endpoint is going to end with the MCP once we are going to use the estimable HTTP server. Suppose if you're going to change as SS SSC okay which is the uh this uh events okay so if you see this is going to by default change SSC endpoint as a SSC because that is required like whenever you are going to connect with your MCP server with LLM client okay or like the any MCP client okay so this is the end point through which we can able to identify whether the server which is deployed as a MCP is using one type of the connections either using estimable HTTP or using the SS. Okay, the response content type we have the two flavors one you can use the JSON and one you can the SSC which is the default one but here I have using the JSON one. Okay. If suppose you want to make sure that uh this as part of the response when it is coming from the MCP, it should hold certain type of the headers which is going to identify the results or like which is coming from actual MCP or maybe some kind of the constraint or dynamic. So we have this provision we can able to say this. Okay. And as part of this general we need to make sure that we are going to provide two important things. One is the server name that is the arbitrary you can put any like user friendly server name and what is your server versions. Okay. Apart from that I think these all are the configurations which is required as per the like uh requirements. Okay. But I kept it for as part of my demo as a default ones. Okay. You can like we have this privilege like we can able to increase request time out reconnection strategy. So all this but uh I'm keeping this all this default settings. Okay. So that's it. So just let me explain about my use case what I'm doing. So I wanted to present here one of the MCP server where I am like uh handling the case management kind of. Okay. So what is kind of case management means like we can able to create the case. Okay, I am exposing my MCP server or tools I will say like we can able to create the case. You can able to fetch the case against the case ID or case numbers or update. Okay. So let's first uh see this uh what are all the use case we are going to see. So here you can see I have given this mule MCP server phase case details. So we are going to uh fetching the case query from the Salesforce. Okay. So like a Salesforce connector is also required. Okay. If you see here like Salesforce connector is there. Okay. So nothing a special treatment whatever we used to do in our uh normal API to connect with the Salesforce. Similar kind of the treatment we are going to do here. Okay. And the second thing is how we can be able to create the case into the Salesforce. Okay. This is a small ping server test. Okay. This is the how uh we can able to fetch case by a status flow like suppose I think from that scenario like suppose fetch me all the new cases which are available. So in that way we can able to see this uh we can able to update the case like suppose once case is registered at a new okay I can able to like working escalated closed these kind of things. Okay, here the different flavor of the another flavor of the fetching the case by case ID. Okay. And here we like suppose if any analyst is going to add like think from that scenario whether you are going to uh connect this MCP server with LLM client like cursor and you want to update some things on the case we can able to do like the add case comment like suppose some analysis is going to provide some recommended solution from the uh cursor okay and or like any winds of cloudy okay so we have this privilege we can able to add this case command over there. Okay. Uh then after we can able to see the fage case resolutions like suppose if case has been resolved. Okay. What are the comments has been provided there we can able to fetch this case one. Okay. And one last I have kept uh although it should be part of the like we can club but uh as part of the demo I have club but ideally we should keep like the separate we should not uh do the like I think all the different system related MCP into the one okay but just as part of the demo I wanted to show what are the all the configurations is required to do for MCP okay so let's we will take the first phage case okay so here I will say As part of this MCP I have using this tool listeners because this has the features of the we can able to like exposing our endpoint you can say or as a tools okay which have this like the read and write operations okay and this like suppose just I'm telling uh theoretically this is the something the resource listeners okay where this is only going to provide the read only operations okay so this is tool nothing but as a kind of the end point okay which is into the natural language we are exposing in front of the like MCAP compatible like the client we can able to understand this tools okay and they can communicate it okay so once you are going to drag this MCP over here okay you can see what all configuration is required so first of all you need to put the uh connector configuration which is our MCP server this is the name is nothing but it is going to appear whenever you are going to use the MCP client or cursor anywhere. Okay. Uh I'm taking the cursor name because uh mostly I have done all this P uh or testing by using the cursor. Okay. So like suppose here is a name. So name is nothing but your tools name which is going to expose like whenever you are going to connect any MCP client or your LLM client is going to connect with the MCP server. So this must be a unique and purposefully. So we can able to understand what is the purpose of this. Uh we can provide the descriptions what is the purpose of this tool. Okay. And these are the parameters we can able to see this is the generic parameters. Okay. Where we can able to define the what is the request schema. Okay. Which is going to come as part of this. So if you see here this is the schema like uh uh by default this is the mandatory one where the name space kind of things we we need to provide we need to give the type what type of the request is uh this tool is uh uh is going to accept okay so here the object okay what are the different properties which is nothing but the fields out of these properties which are the required so in this flavor of this tools I have kept like the very generic so it is good to like uh accept any kind of the objects. Okay, you need to also configure make sure that what kind of response you are going to expect uh from this tools. Okay. So once you are going to see here different different uh response are there like suppose add text tool response content add image like suppose you have created one uh this MCP tool which is handling for the image. So you have the all option to add image tool response content. Okay. So you are going to get the image like which is the like in the bite code format. Okay. Here is the add text resource tool response content along with also the blob. So but here like as per requirement we are good to put here I have put as if you see this uh this is the first one this I have marked as a payload. Okay. So whatever the response is coming I'm good to like take it. Okay. And rest these all configurations are related with your normal API whatever like how we have developed. If you see here this fetch case details it is nothing but just a plain query which is fetching all the details and the relevant details from a case. Nothing else. Okay. This is our this logger just for the to make this informations and just whatever I'm fetching I'm converting into the JSON and I'm logging it. That's it. Okay. So this we have seen like the very uh uh generic one. Okay. Uh let me quickly show you like suppose create case. Okay. So in this create case if you see my name is different. Okay. And here I have defined this schema. Okay. So it's better to make it copy over here. Okay. Okay. Go to here and then I'm going to show it. Okay. See. So this is the mandatory one which we need to give it. Okay. Which tell us that the schema has been started. This is the type of the object. it is dealing with the properties is nothing but what all the fields which this tools is going to uh accept from the client. Okay. So here the subject name, description, so status, priority, account ID, contact ID and if you notice that I have put entire things into the required means it is required to accept this request otherwise it is going to fail. If any fields which you which are the optionals okay which is optional so you don't require we don't need to put into this section that's it okay so if you see here I have put it okay a similar way here the payload uh tools response content text payload I have mented okay rest everything is like whatever we have done okay let's see here like we have this privilege to like redely advance you can like the similar to others uh like our source connector So we can able to keep this. Okay. So similar way if you see here like uh H case details by case status similar way like here nothing is required. Okay I haven't put anything okay in response I have mark as a like uh payload. Okay. So that is also if you see update case status let's see here most of the things. Yeah, here if if you see update case status. So what I have posted it as a schema defining. So here I'm asking okay you need to define the case ID along with the status. Okay and both are mandatory. So in that case it is going to update the case status against the case ID. So it is validating for the case ID this. Okay. So this is the similar way for the fage case details ID this. Okay. similar way to uh like add case comment okay and these are the some query okay okay how we can able to so maybe here I have put the query or maybe I'm putting some sending directly content and it is updating this directly putting into the case content as a payload so that is doing okay and what is the schemas I have there okay so if you see here a schema against what it is going to Okay. So here you can say I need to send this parent ID is published. These three things I need to send it and comment body then it is going to uh add this case comment into there. Okay. Similar to face case resolution. Okay. So for face case resolution we need to give the case ID. Okay. And case ID is required. And what are the query? So okay. So I'm fetching current ID create from case comments. Okay. Where are the parent ID case? Okay. So I'm getting this case comment like suppose once it is closed or case. So we can able to get it this case ID against the case ID. What is the comment similar way? Okay. So this email one is the interesting one. Although I have clubbed here but I should not. But so email one if you also see the schema I have what I have mentioned. I need the subject. Okay. I need the body. I need the two. These all are required. Okay. To whom I need to send, what is the body? What is the subject? And this is the my email configurations. Okay. Which basically I have put uh some default value. And if you see here what the body and this is the some pillow do subject pillow.body which is coming I'm sending it as a text. PL. So this is the how we can able to do this MCP configurations. Okay. And it is uh pretty much simple like uh how we are going to deploy it locally. Okay. And how we are going to like deploy it into the any point platforms. Okay. So that is the similar case you can able to deploy over there. Okay. And whenever it is going to let me show you how we are going to deployed it. Okay. Yeah. So here the I think on the any point platforms you can able to see. Okay. I have already deployed. Okay. So nothing a special treatment while you are going to deploy similar to so here I have taken as a cloud hub to deploy these things. Okay. And if you see this has been like running few of the test cases I have executed. So here is the response. Okay. So like all the tools how we can able to see like whenever my MCP server has been deployed where all the tools are available what all tools are. Okay. So to quick check suppose I have already configured this deployed version of the MCP server okay into the cursor okay once I'm going to add it into if you see here the prel okay once I'm going to see this so if you compare this this fetch case details create case record fetch case details by status update case these all are nothing but all the naming convention which we have already mentioned in our like was fetch case details. Okay, this is the create case details. Okay, so this name is uh very important. Okay, it is going to map each and individual your tools which you have defined. Okay, as part of your MCP client whether it is you are using any like uh mule client, any third party client or your LLM client. Okay. So this through uh this way we can able to Okay. Just quickly demo here like suppose if I'm going to add the context. Okay. And I'm giving the prompt. Okay. Show me all open cases. Let's see. I'm giving show me all open cases. So let me see whether it is able to f details not delayed. Okay. sometimes happened because long times. Okay, let me see. Okay, so it is fetching this case details. Okay, so it is saying let me try fetch keys. Okay, f key. Okay, so suppose it tried first fetch case details and something like happened wrong not sure. So now it's trying another way fetch case details by status. So it's quite intelligent like whenever we are going to connect with the MCP server with LLM client it's quite intelligent like it has the capability to like internally redirect whether the context bit or content based okay so you can able to see like it it's try with the fage case details maybe internally some problem either it uh with your MCP server or with the LLM client we're not sure okay but it also find Okay. Okay. Let's move from this way. Okay. Let's I can see like the we have the another fields like tools which are available f details by status and it is trying to fetch from this. Okay. So this is the output which is coming from the JSON and now how smartly it's converted the JSON into the this natural language. Okay. And it's giving here. So that's it. uh hope you are going to like uh follow this uh MCP server con concept and you can able to implement and like uh understand how this MCP server into the MU4 is going to work. Thank you.

Original Description

These examples show you the process of creating an MCP server within your Mule app and defining multiple distinct tools that the MCP server will expose related with Salesforce Case management.
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Related Reads

Up next
How to Track Time in ProjectManager
ProjectManager
Watch →