
Lesson Description
The "Prompts" Lesson is part of the full, Complete Intro to MCP course featured in this preview video. Here's what you'd learn in this lesson:
Brian introduces the prompts API for registering prompts within an MCP server. A prompt is created to review code generated from the LLM and ensure it conforms to a provided coding style guide.
Transcript from the "Prompts" Lesson
[00:00:00]
>> Brian Holt: So a resource is essentially handing a piece of content to the LLM and saying, interpret this. This goes with whatever prompt I'm handing you. Do things with it. The key here is it's not really a prompt, it's not really a command to the LLM, right? So even if I put in my doc here, hey, LLM, please do this, it's really not going to be interpreted as that because it's not meant to be.
[00:00:30]
It's meant to be not command. That is different than a prompt. A prompt. You can actually have your MCP server give canned prompts to the user and say, hey, if you're going to be doing something like this, then you can use a prompt from the MCP server to do it for you.
[00:00:50]
So a very dumb one that I decided to build is a style checker, an eslint style checker. You can actually have your LLM do the style checking for you. And we can do that with a prompt because the prompt is gonna have to give it a bunch of information of, here's all the rules, check them this way.
[00:01:08]
Use these kind of rules and report them in this particular way. Terrible idea, right? Very expensive way to run eslint. But we're going to do it because it's for science. Let's pop it back over here. Resources are meant to be more context. Prompts are meant to be more commands.
[00:01:31]
And the cool thing about prompts is that you actually can provide them with parameters and kind of change things on the fly, which is helpful. And if you're like this, seems like we're splitting hairs here. I agree with you. It does feel like I'm splitting hairs here. But that is the intention behind these two different things being separate.
[00:01:53]
Like I said here, I still think there's some iterations left before you really settle on what the forever MCP protocol is going to look like. So let's say you're having Claude build some sort of code for you and you really want it to follow some sort of coding style.
[00:02:11]
I put some ones down here. Idiomatic JS, Airbnb standard. They're all ways of writing JavaScript. So we're going to copy one of these and put them in the MCP directory, and then we're going to tell our MCP servers whenever you write code to follow these kind of commands.
[00:02:28]
We're going to go back to our VS Code and I'm gonna make a. And we're going to leave this project one behind for a little bit. The MCP issue tracker One and we're going to go back to the other one that we were working on because this has nothing to do with this particular project.
[00:02:47]
So I'm just gonna minimize that one. I'm going to go back to this MyMCP one that I was working on before, okay? We're going to make a new one and we're going to call this style checker JS And I'm also going to create a file here called, I don't know, Style Guide MD or something like that.
[00:03:08]
Style-guide.md and just paste all that in there, almost or past 4,000 lines of markdown here. So feel free to use standard. It is much shorter. But YOLO, as the kids say, which is funny because no kid says that anymore, right? Like it's just millennials saying that kids say that, which is me.
[00:03:33]
Let's go make a little MCP server for this. This should be pretty fast. So we'll just go ahead and code this by hand as well. Your style checker, there it is. Import MCP server. We're going to import standard IO server transport import Z from Zod and import read file sync from fs, which stands for file system.
[00:04:12]
Let's make this a bit bigger. Just make this full screen. That's fine. Okay, and const airbnbMarkdownPath = /Users/brianholt. This is wherever yours is. Mine's at this. And I didn't put this on desktop. Desktop/my-mcp/, I called it what, style-guide.md. Whatever you put for your full path needs to go there.
[00:04:58]
Const airbnbMarkdown = readFileSync(airbnbMarkdownPath), and it is in utf-8. Okay, now Airbnb markdown. This should be whatever the content of that particular file is. We are going to create a new file or a new server. Const server equals new MCP server. And the name is going to be Code review server.
[00:05:35]
And version is going to be. Doesn't need to be in quotes, 1.0.0. And then we're going to do server dot register prompt. It's going to review code. It's gonna be the prompt. And then we're going to do title code review. So we're doing something really dumb, which is just passing it a full on style guide for that somebody else wrote.
[00:06:11]
But this actually could be somewhat useful if you had a bunch of style guide and ideas and more macro level ways of constructing your repos and like, hey, this is a Monorepo. If you have a new style of server to Create, please create a new directory. You could be really broad and prescriptive with this, and you could then have Claude code respect these things via an MCP server.
[00:06:39]
Hopefully you're seeing ways that you could apply this. Or another good one would be Devin, have you ever used Devin? Devin's a pretty cool coding agent that just plugs into your GitHub and so you just open issues on GitHub and say, hey, Devin, go fix this. And then you could use an MCP server to fix things the way that you want them to be fixed.
[00:07:01]
And you could say, before you open a pull request, please do these things and then open the pull request and file it this way. You can do a bunch of stuff like that, all using an MCP server. And you could do it with probably a prompt. I have not tried that, but seems like a good idea.
[00:07:23]
Okay, ARG schema, codeZ string. Okay, and then here we're just going to give it the function to run once it actually has it. So it's going to take in the code like we described, then it's going to return back, essentially something that you want to pass back to the LLM messages.
[00:07:53]
This will feel like writing an API call for ChatGPT or something like that, where you give it a messages array and you tell it what kind of role you're using. This is role is "User", content is, right, if you've ever written code that calls ChatGPT, it looks just like this.
[00:08:20]
Type is text and text is something like. Please review this code to see if it follows our best practices. Use this Airbnb style guide as a reference and the rules. Okay, and then we're going to do something like new line, new line here and then a bunch of equal signs because you know, you want to like, add some separation.
[00:09:12]
Okay, and then Airbnb markdown like this. And then we'll do the same thing kind of here. We'll put the code. Here is the code to review. New line, new line code. I'm not going to pretend this is any sort of good prompt, by the way. It's meant to be fairly short, but a longer prompt would be like, here's the block and respect it these ways and apply it in these certain other ways.
[00:09:55]
But this will be sufficient for our needs. But you can see here, we're formatting this like we would format a prompt, right? And then that's it. We're just gonna say const transport = new StdioServerTransport and await server.connect(transport). Okay, that's it. That's how you do a prompt. Let's go add it to our Claude config here.
[00:10:31]
Again, doesn't work on tome so please don't try. Or maybe it does by the time you watch this, but as of writing this does not work on tome and actually we want to do it because it's going to be the same as the weather one. So we'll call this code-style-server and this was style-checker.js, and then save.
[00:11:07]
Okay, let's go restart CLAUDE and see what happens. Okay, what did we do this time? So open logs here, code. I called it code style, didn't I? Yep. Okay. Cannot find module style check. So I probably just didn't spell right. Style checker, right? Is it style checker? Yep, okay.
[00:11:58]
Okay, +, use from code-style-server. Review code and then it's going to ask me for the code that I want to review. So let's review. Let's get extra meta and have it review itself. Seems pretty funny. So I'm just gonna put all that in there and I'm gonna say Add prompt, and now I have this whole prompt in here.
[00:12:29]
Please do the code review, but be extra polite. I have sensitive feelings. I'm going to start doing all my prompts this way where it's just like, you're almost there, buddy. Pat, Pat, Pat. It's okay. This is great. So anyway, hopefully you're seeing the value here as well. What?
[00:13:17]
You did really well. I got a gold star from Claude. Please treat me like a kindergartener. I'm so happy with this. So does that make sense? It's basically you're adding like additional lines to your prompt and you're just, you're allowing that to happen from an MCP server where I would actually probably be more apt to apply.
[00:13:39]
This is, let's say that I have a joint project where all of us are using like cloud desktop or on it or something like that. I could see going in there and say like, hey, I'm about to do a code review on a coworker's thing. Please highlight all the areas that I should look for.
[00:13:55]
And then I would put that into like a really nice self contained prompt that we could all kind of collaborate on and then we could all share all those things together, right? Does that make sense? Yeah. Question.
>> Student: Yeah. Do you get a larger context window with the max plan?
[00:14:08]
Cuz I'm getting that this conversation is 18% over the length limit.
>> Brian Holt: Probably, yeah.
>> Student: I knew it.
>> Brian Holt: So I wrote this entire thing on Pro. So this was all working for me on Pro. I then bought Max cuz I was terrified I was gonna run out of credits mid course.
[00:14:26]
And so I was like, for $200, I just don't have to worry about this. So I went full send on a Max plan, but I did have to cut down a bunch of stuff before. Maybe try Standard.
>> Student: Yeah.
>> Brian Holt: Yeah, standard's, I think, a quarter the size.
Learn Straight from the Experts Who Shape the Modern Web
- In-depth Courses
- Industry Leading Experts
- Learning Paths
- Live Interactive Workshops