YouTubevideo· Dec 18, 2025· 30:58

Unlock AI Agent Access: Adding a WorkOS-Powered MCP Server to Laravel

Watch on YouTube ↗

transcript

75 moments
  1. So, you might be tired of hearing about MCPs. MCP this, MCP that. But let's just take a step back for a moment because in reality, you can kind of picture what the future of MCP looks like. Imagine \[music\] that there's these agents that for the applications that you regularly use, they can step in, log in, do the things that you normally would do and click around and type in, but it can be done in a more natural language and probably in the flow of other stuff that you're naturally doing within AI.

  2. But the big question that I think everyone has, it's not really about the future. As developers, it's more like, okay, that sounds \[music\] cool, but how does this actually fit into the app I already have? How would I even start thinking \[music\] about adding MCP to something that exists right now? \[music\] And so, that's what we're going to walk through today. I have this fully built out Laravel app. I call it bookmark it.

  3. It's pretty simple. It's just a place where I can save links that I find. I can organize them into collections, maybe ones that are packages that I want to watch or specific uh things that I want to keep in mind if I'm making a video. Those are lists that then can add specific links to them. And there's some fun little AI stuff. So, when I add a link, let's say I want to check out this new uh Mago PHP thing, I can of course add my own tags that I might have or create a new one.

  4. Uh, but I also can just have it pull things for me so that I can search and find it later. And this is great. And again, there's nothing incredibly fancy with this. It's just a Laravel application that does Laravel CRUD type things. But let's imagine I want to take this application and maybe you have an application that is even further along than this one. Maybe it's not just a personal tool.

  5. Maybe it's a full SAS application, but you want to give your users the ability to add uh AI integration work within the confines of the AI tools that they might be using like clawed desktop, chat GPT, clawed code depending on your particular audience. And instead of rebuilding everything that we have or creating a separate AI version of the application or a separate API that we might use for this, we're just going to take the code that's already there and then we're going to start bringing MCP into it.

  6. We're going to just take little pieces just enough to show what it looks like when an agent connects to your application and can authenticate as a real user. whoever has the authority to authenticate to that application, it can start doing actual work inside the product, pretending like it's clicking around or actually using the functionality of your application that you have already built. So, if you've been wondering how to add MCP to your own app without blowing everything up or starting from scratch, this will hopefully give you a super clear picture of what that first step looks like. So, let's jump in.

  7. This video is sponsored by Work OS, making your app enterprise ready. More on them later. All right, I kind of gave you a little tour of what this application does. You have the ability to have specific lists. These lists can either be private, people can't see them, they're only available to the user. They can be public, visible on a profile and searchable, or they can be unlisted. People with the link can actually view them.

  8. Of course, there's a lot of RBAC, RO based ass access control happening here, but the good thing is is that everything that we're doing can then just be turned into available functions for our uh AI applications to use through the MCP connection protocol.

  9. I guess MCP connection protocol is a little redundant. So, let me give you a step back. What is MCP? MCP is model context protocol. It's an open standard that connects AI assistance to systems where data actually lives, content repositories, business tool development environments and more.

  10. So you can think of this as the way for your AI tool, whether that be something like a cloud desktop or cloud code or chatbt. it can use your application or any application and have a more standardized way to actually talk and do things within that application.

  11. So if we have a public list of specific links that I have, I can take that link and then people can actually see that it's visible to everyone or any lists that are available for my particular profile. And so all of this is happening within this application. And uh the stack is it's using Laravel on the back end. It's using Livewire specifically with the Livewire starter kit with work OS.

  12. And that's really what we're going to be using for the MCP authentication functionality because we're already using work OS. I'm just going to change my username here as well, but we're already using work OS to be able to authenticate into our application. So we can also use work OS to be able to authenticate for our MCP as well. Let's think about what we want AI to do.

  13. Uh because the only thing that's really AI powered on this application is just the functionality to scrape that link and then just add some description and some tags for me so I don't have to type all that out to remember what that link was about and why I saved it in the first place. But let's say I am in cloud code and I'm starting to build out I don't know maybe a demo application.

  14. I start to remember there was a link that I saved that I want to have available to me. Well, so there's some things that we would want AI to do within our application. We want to maybe create new collections, new lists. We want to add links to those lists.

  15. We want to be able to have AI uh maybe clean up those lists, change the description, change the tags and then maybe we want to AI have be able the ability to search through those lists to find the ones that might be relevant to the specific task at hand. And so this is where work OS can come into play. Of course, Laravel has the starter kit with work OS already initialized. So that authentication of going into the web application works just like we would expect.

  16. But then MCP while it exposes our app action as tools work OS it provides that secure identity for the MCP client. So when the client the AI client expects to receive a particular authorization well it's going to get that through work OS work OS is going to return that token and then the MCP tools that we have set up and we're going to be using Laravel MCP to walk through what that looks like.

  17. Those MCP tools now have the ability to run as that real user that's already been authenticated into our application. Now, I'm not going to be walking through every single bit of code of Laravel MCP, but I do want to point out the parts that fit for this particular application, the parts that you do start to have to build and think through and create and then how it all wires together within your authorization. So, this isn't necessarily a code along with me, but it is a let's look at the highlights.

  18. So, first up is adding the Laravel MCP package. And I go a little bit more in depth in this within this video that you can find up here. Put simply, the Laravel MCP package enables you to create these servers that have a specific uh MCP web route to them. And those servers, if I was to click into this, enables you to then have each individual tools that the server might be able to have. And there's some prompts as well, but we're not going to be using them.

  19. So, what I've created here within my application is taking the things that I would want to do within the application. In this case, anything that I can click through. I want to create a tool. If I want to maybe create a bookmark, well, Laravel's MC MCP package enables you to say, okay, what does this tool do? And then what do you actually do with it? In this case, this is how you would create a bookmark.

  20. And I've had PHP Stan and Laravel Recctor help create and make this a little bit cleaner in terms of type safety because that just makes it a lot easier for the AI to know what to do with it as well.

  21. While this is standard Laravel code, it's just specifically formatted for the AI to use within the Laravel MCP package. So this lift for taking an application that doesn't have MCP enabled to enabling MCP is probably the bigger one. Uh authentication is going to be a lot easier that we'll see in a little bit. But saying, okay, what does the AI allow to do or what is it allowed to do is probably the bigger lift.

  22. You can think of each one of these tools and I have them listed between bookmarks, lists, uh the ability to search and then tags. You can think of this as just CRUD operations or just individual maybe actions that you would like the AI to do. You don't necessarily want to have them all stored in one piece together.

  23. Uh for search, for example, you can see here that this little annotation tells Laravel's MCP tool and the AI what this actually does. So is readon. It's means it's not going to change anything. If I was to create a list, this attribute to mark a tool as idmpotent. I might be saying that wrong. It just means that you can call this tool multiple times without worrying that it's going to break anything on the back end. So, this is just letting AI know what this tool does and how it might want to use it.

  24. Each tool has a description to specifically say to the AI uh if the user says anything that they want to do that maybe matches this description, that's when that specific tool might be best used. Then the server gives instructions to the AI. Basically, here's the specific operations that you have available and any tips or a server prompt if you will specifically for your applications MCP server and then the list of tools that are available as well.

  25. And you'll see here when we add this MCP server into our clawed web application or even chat GPT, we'll see all of these lists of tools available.

  26. So this is being uh exported to be publicly available to those who have authenticated. Next up, authenticating our MCP server. Now, since we're using work OS and since this video is sponsored by work OS, we can keep everything in that kind of ecosystem.

  27. Now, uh there's ways I'm going to show you how you can use Laravel Passport to still authenticate for your MCP and attach them or associate them to your users who are being authenticated within work OS on your front end. But I also just wanted to show you what this would look like if you called a custom configuration for your Laravel MCP package to authenticate within works offkit. So that AI.php routes, uh, well, we have a specific middleware that I've created. That's work OS.jwt.

  28. And we'll go ahead and dive into what this looks like. But if I was using Passport, again, this is a completely different package that you're not necessarily using. If you're using work OS, you're not necessarily using for your applications web platform, but it does make things a little simple if you do want to use that specifically for your Laravel MCP package otheication.

  29. But it does raise some tendencies of having the separation of concerns where you're having these tokens in your database uh and they're just associated to your users. It's as simple as calling these OOTH routes that point to everything that you would need within MCP o authentication and then saying that this is the particular uh middleware that you need and for O API requests. So this is going to check to make sure that the user is logged in before it authenticates them for this MCP package.

  30. So you're still using work OS to do that logging in piece. But what would it look like if we took work OS and just enabled that? So we were just getting all those tokens from OGIT rather than having to store them in our database. All of it boils down to this verify work OSJWT middleware that I've created which essentially just takes our initial requests and instead of routing it through something like passport, we're just sending it to directly to work OS.

  31. So it expects a particular token JWT and so we're going to grab that from work OS. First we're getting the specific user based off that work OS user ID and then we're grabbing that actual token and this is spec specifically coming from work OS offkith domain. This is using that firebase JWT package which makes this a lot easier to then uh keep those nice and tidy within your application.

  32. And then lastly within our routes, since the MCV package does kind of expect you to use something like Sanctum or Passport, I'm just overwriting some of the routes that it expects. This is just to say we're redirecting this to work OS instead of having it redirect and expect something within our application. There's this well-known OOTH protected resource route that it needs with this particular name.

  33. And again, we're just redirecting this instead to OKIT within that particular domain that we've set up. And I can show you what that looks like in work OS itself. Same thing with the OOTH authorization server. So within our works dashboard, because I have enabled this in production, there's a few things that you need to set up. First, I need to make sure that I have that actual uh authentication kit domain. And that's what we're going to put into our environment variable, the one that our routes are expecting and our JWT token is expecting as well.

  34. So using this as your environment variable for that setup. Of course, work OS does provide the option to be able to have a custom domain as well. And then lastly, we do need to tell work OS that we are wanting to have this API request because we're expecting JWT tokens from uh this client side request.

  35. So if I go into connect I and you can see here I've already been doing some testing but we just can go into configuration and make sure that this dynamic client registration is enabled because that enables you this is specifically for MCPO authentication. It enables you to create new clients based off of that public API. So claude chatgbt cloud code that kind of thing. So then I have the ability to add my MCP server to something like claude.

  36. Why don't we do that? Adding a custom connector. I'm going to say that this is bookmark it. And I'm just going to add the specific URL which is uh my bookmarks.jsheri.com/mcp.

  37. And I can go ahead and add this. And then we can since I've already actually enabled this, it's already authenticated. But I'm actually going to disconnect it. And then we can reconnect to see how it's redirecting to Okit because that's what our application expects. Clicking connect then redirects us tokit.

  38. Claude would like to access your account. And the neat thing is with work OS and Ogit, you do have the ability to add some custom branding here to make it look a little bit nicer and maybe a little bit more trustworthy for your users. So that would look like something like this. And yes, that's pretty ugly, but you get the idea. It's all customizable in the branding section of work OS. Allowing access red takes us back to Claude or wherever we're adding a connector. And now I can use all the tools that are available within this MCP server that we've set up.

  39. Now whether we're using claude code chat GBT or something like claude now you have the ability to maybe work within your own uh confines of how you normally might use AI or your users might use AI but now they have access to do things and enable uh further actions within your application. So now that we are authenticated into our MCP connector, we should be able to click configure and actually see all the tools that we have available.

  40. Uh some readonly tools to get bookmarks, get lists, list all lists. Uh but then we also have the write and delete tools and these are all that we've set up and defined in our Laravel MCP package. But now that we've authenticated within our specific user that I have my specific lists and bookmarks for, we should be able to see those and view those while we're chatting within Claude, but then also add some more too.

  41. And so I'll show you what I would do in this specific situation and what your users might expect from your application down the line when it comes to MCP. I might simply start to ask uh do I have any uh links or bookmarks uh in bookmarks that relate to uh a nice Tailwind package for a video.

  42. And of course, this is going to be able to then search my whole application. Well, I could add this into my application, but I'm already using Claude to maybe research, help write, um, or maybe just brainstorm ideas.

  43. Then, I'm already here. I might as well just start chatting within my application that I've built, but within the tools I'm already using. So, I might say, same thing. What about um a squirle kind of package? I vaguely remember saving that. So there we go. We have a a tool in cornershape URL that I remember saving. And of course, yes, tools like this already exist.

  44. But knowing how to then make your own tool have this kind of functionality within uh AI, all of a sudden you the limits are endless. So, if I want to start researching like let's let's research uh some great video ideas, new blog posts, maybe some um specific packages that would be of interest to my audience.

  45. And let's create a new list of them for me to review. They should be something as exciting, new, or just fun to see and play around with.

  46. Now, I can use the I don't know the the agentic approach that Cloud already has within research tools, but then just kind of leave this be and come back to a fully formed list within the application that I have, my own application. All right, editor Josh stepping in here real quick because as I was going through this video, I thought to myself, hey, we could add one more thing just for fun because it's always nice to learn new things.

  47. And so I was thinking, what if you wanted and you had an application where uh different users had different tiers of access to be able to access that MCP. Let's say my application bookmark it was a SAS and only paying users or certain uh subscribers or certain levels of subscribers could have access to certain MCP tools. Well, how would you do that?

  48. The neat thing is that work OS comes with RBAC role-based access control. I like to call it arbback. You can call it whatever you like. But within rolebased access control, you still have this flexibility of keeping everything within work OS because that's what we've been doing up until now. And we wouldn't want to say that there's specific roles that we keep in our database because then we got to keep them in sync with work OS.

  49. And the whole point of doing this is if your application scales, what if you need organizations within specific users, a company buys your SAS and they say, "Hey, we need specific permissions for users that go outside the scopes of what you have set up within your SAS to start with." Well, that's where Mac works comes in. So, I want to show real quick just what I did to help kind of set the stakes for this.

  50. But if you do want a little bit more indepth on how I did this or maybe even in-depth on how you might have subscribers within an application, something like cashier, let me know. The approach I took was to extend the tool that Laravel's MCP package gives you because then we're basically just checking before any one of these tools is called or even before it's available to be listed within the MCP package, we want to know is this person required or or able to use this.

  51. And so I have this own class that extends the tool uh MCP class that Laravel gives. That way each tool actually has a specific required permission. If a user has the permission of lists, write then it's going to check work OS. And the neat part is we already have that middleware to verify the work OS JWT.

  52. I kind of already mentioned that because we are accessing the information that works is already providing before redirecting to that offkit domain so that we know that we are logged in effectively to access that MCP server.

  53. And I didn't mention this part but work OS has a Laravel SDK. So that way we can access uh the user the roles that they have and the permissions that they have within work OS. Well, what does that look like within work OS? Let's look.

  54. So, I have users within work OS. Uh, this user by default has a free tier. I upgraded this user to a subscriber. So, they have different permissions because work OS gives you the ability to say, okay, we have roles and permissions set up. I have three permissions set up for free tier and then I have eight permissions set up for a subscriber. And of course, you can have different ones.

  55. The neat part about this is that all of our roles, all of our permissions have one central source of truth, work OS.

  56. And again, that could come in handy as your application scales because different organizations, different uh companies are going to want different things out of your application. Then in the code, I just need to make sure that they have the necessary permissions that it takes. If we're looping through all those permissions that work OS already has because we have that Laravel SDK to grab that ro grab the permissions associated with that role. Well then like I said any of those tools delete list tool has the list delete permission.

  57. If they don't have that permission they can't use that tool. So I'm logged into the free user. I have the MCP set up and you can see that if I was to view details we have only five tools. They're all readonly tools. So I should with this user only be able to read specific things.

  58. So if I was to say something like uh I don't know uh is there any bookmark uh link that I have that is related to an art piece perhaps because I know that this specific bookmark lists that I have is ones associated with uh one of the shows that I put on riff and refine which should have an art piece link.

  59. Let's check. And yeah, the fall vicorous art release countdown. So, it can read things, but if I was to ask it to do something like, hey, let's add a new one. I want to add a new one. Can we do that? And maybe I'll just say I want to add uh I don't know, art is cool.com.

  60. \[clears throat\] So, it's going to check what actual tools we have. Uh we're going to list the tags tools. And yeah, it's probably going to say you only have read only permission. It can't actually add new things. You have one list available links from the show. Before I add this bookmark, I need a few details.

  61. Uh, so let's just see what it does. I don't think it has access to be able to add that tool. It doesn't have that actual tool available. Yeah, now it's just going in a loop. So, this is probably something I could add and and define better within our instructions tools settings that if it doesn't have a specific tool that we can just return that that tool is not available. Yeah, looks like I only have read access. So, it did a little bit of a loop there. We could make that better. But now, just for fun, why don't I add a new permission to this particular user or maybe just upgrade the user?

  62. And again, if you're interested in seeing more videos about that process of tiers, maybe like a free tier to a subscriber tier, paid SAS application with something like Stripe, specifically within Laravel and Cashier, let me know in the comments below. But since we're checking when we're grabbing that authenticated user, we should be able to upgrade this particular user just in work OS, change their role, and we'll just say that we pretended to upgrade them within the actual application. But again, I haven't built that yet.

  63. Once that user is upgraded to that subscriber role, they should have the available tools to be able to add new bookmarks. I'm going to this free tier user that I currently have, and let's go ahead and make them a subscriber. Save changes.

  64. Now, we likely have to reauthenticate because this is cached. And I have a specific setting to be able to have it cached for a little bit because we don't want to check consistently if they have permissions. But if we go into MCP, we should see, yeah, we still only have five tools available. But let's go ahead and reauthenticate. You can see here that I'm logged in as a different user than I was previously. Allow access. And let's go ahead and check that MCP again now that we've reauthenticated. And we should see, yeah, 15 tools available.

  65. And yeah, all 15 tools that we have available for MCP because we have those permissions from work OS and we're getting them with that middleware JWT. And now we can do whatever we want with this. Clean up tags and bookmark. It should access the clean up tags tool.

  66. And there we go. We're going to clean up all the tags because I have 25 tags. No duplicate tags are found. So we should be good to go there. So yeah, thanks for jumping on board for this tangent where we took a look at some RO based access control. Good old arbback. But those permissions that you have in work OS then can just trickle down to anything that you might have. That's the beauty of having one single central source for everything that you're doing with an authentication and authorization. So anyways, back to uh current Josh. So you can start to see the possibilities.

  67. You have tools that your users are already using and hopefully they really like them. So how can you make them use them more if you just put them into a place that they are already spending time in?

  68. And of course this might not make sense for every single application, every single tool that you are using or you have built, but it does make sense for most of them. And while this list that AI generated probably is a little bit too generic, I probably would have spent more time on the prompt or just put it into actual uh research mode to spend a little bit more time. You can see how it grabbed everything, but then it also took 28 steps to use the tools available in the bookmark it MCP to be able to create that list.

  69. So, if I was to ask for uh grab me the list link, it should be able to grab me that link and then I'll just be able to head directly into the tool. Of course, I should already see this list link in my account as well, but selecting this uh bookmarks.jsh Josh Siri. And yeah, these are my video ideas to research everything here with again everything added that I would have spent time on if I was doing this all by hand.

  70. But the AI with MCP just tells my AI agent how to interact with my application. So let's go ahead and recap. We enabled our application that I already had working a CRUD type of application where I could add lists. I could add bookmarks to those lists and then have them be publicly available or privately available.

  71. But if I wanted AI to interact with this application, I could create my own API and maybe have AI use curl commands to interact with it. But no, that's where MCP comes in because we already using works within our starter kit. Again, I was just using LiveWire Starter Kit, but it works with everything since we're already using Work OS to authenticate for our web application.

  72. Well, then we can just use Work OS's OKit token system to be able to authenticate for an OOTH flow for MCP. So, with Laravel's MCP package, it's as simple as just adding the tools that we need in order for our AI agents to interact with our application where we want it. I think that's key because usually you think ah I don't want AIs to be able to interact with my application for everything. Well, good news is you don't have to.

  73. You get to control how and when and why an AI might interact with your application or how your users might use AI to interact with your application. That's really that simple.

  74. Using the tools that Laravel gives, work OS authentication out of the box with starter kit and then using that to authenticate for MCP with Laravel's MCP package. It just makes it simple to add this AI functionality to your existing application without changing anything on your front end. It's just telling the tools how to use things in the back end.

  75. So, it gives you the ability to keep building and keep creating the way you want. Now, I do have some other videos that you can find here and down there about MCP as well as about work OS, but let me know if there's anything else that you would like to see in this arena. It's something that I really find a lot of fun knowing that the future of MTP is here and it's only going to get better. So, keep building, keep creating.

just you here