MCP Prompts
MCP Prompts register reusable instruction templates in your server -- with parameters. Build a code review prompt that enforces a style guide and see how prompts differ from resources.
You've seen tools (LLM calls them) and resources (user attaches them). The third primitive is prompts -- canned instruction templates that users can invoke from within the client, optionally with parameters.
Tools vs Resources vs Prompts
Before diving in, let's anchor the distinction clearly:
A prompt is like a fill-in-the-blank instruction card. You define the template in your MCP server. The user triggers it from the client with their own parameters.
A Practical Use Case: Code Review
Imagine your team uses the Airbnb JavaScript style guide. Everyone on the team does code reviews differently. Some catch style issues, some don't.
An MCP prompt can standardize this:
- Register a
review-codeprompt in your server - The prompt includes the entire Airbnb style guide as context
- Any team member connects to your server, invokes the prompt, pastes the code
- Every review is done against the same ruleset
Building the Style Checker
First, create a style guide file. Brian uses the Airbnb JavaScript guide (4000+ lines of markdown), but Standard JS is a shorter option:
# Create the file:
touch style-guide.md
# Paste your style guide content into itThen build the server:
// style-checker.js
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";
import { readFileSync } from "fs";
// Load the style guide at server startup
const styleGuidePath = "/full/path/to/your/style-guide.md";
const styleGuideMarkdown = readFileSync(styleGuidePath, "utf-8");
const server = new McpServer({
name: "code-review-server",
version: "1.0.0",
});
server.registerPrompt(
"review-code", // prompt name
{
title: "Code Review",
description: "Review code against our team style guide",
argsSchema: {
code: z.string().describe("The code to review"),
}
},
async ({ code }) => ({
messages: [
{
role: "user",
content: {
type: "text",
text: `Please review this code to see if it follows our best practices.
Use this style guide as a reference for the rules:
==================================================
${styleGuideMarkdown}
==================================================
Here is the code to review:
${code}`,
}
}
]
})
);
const transport = new StdioServerTransport();
await server.connect(transport);Anatomy of registerPrompt
The Messages Return Shape
The handler returns an array of { role, content } objects -- exactly like a chat API message array:
return {
messages: [
{
role: "user", // or "assistant"
content: {
type: "text",
text: "Your prompt content here"
}
}
]
};This looks like writing a ChatGPT API call -- because it is the same pattern. MCP reuses the chat message format.
Using Prompts in Claude Desktop
- Open a new chat
- Click the + icon
- You'll see "Use prompt from [server-name]"
- Select your prompt
- Fill in the parameters (the code you want reviewed)
- Submit -- the prompt is injected into the conversation
Lab -- Understand the Prompt Format
var should be const, the anonymous function should be an arrow function, and the explicit return is unnecessary when the body is a single expression.Lab 2 -- Multi-Parameter Prompt
Real-World Prompt Use Cases
Beyond code review, prompts shine for:
Team onboarding: Register a create-component prompt that follows your team's component structure. New team members use the same template as veterans.
Issue creation: Register create-bug-report with fields for steps to reproduce, expected vs actual behavior. Every bug report is structured the same way.
PR reviews: Like the lab above -- standardized review criteria for your team.
Devin / AI coding agents: If you use Devin (an AI that opens GitHub issues and PRs), you can provide prompts for how it should structure its work.
Key Takeaways
- Prompts = user-triggered instruction templates with optional parameters
- Different from resources -- resources are content, prompts are commands
- Return format is
{ messages: [{ role, content }] }-- same as chat API - Best use cases: code review standards, team conventions, structured tasks, PR descriptions
- Tome doesn't support prompts -- Claude Desktop required
- Think team-scale: prompts become most valuable as shared, versioned team knowledge
What's Next
You've now covered all three MCP primitives. Before moving to a real-world project, let's look at three advanced MCP features that are still in progress: Roots, Sampling, and Elicitation.
Keep reading