implementing-mcp-prompts
Skill33 starsChanged 8 months agoMITView on GitHub
Implement new MCP prompts in the deno-mcp-template project. Provides the exact file structure, type signatures, registration steps, and patterns for prompts with static arguments or dynamic completions. Use when adding a new prompt, creating MCP prompts, or asking how prompts work in this project.
In this repository3 other files it gives its agents.
- .cursor/rules/project.mdcCursor rule
- implementing-mcp-resourcesSkill
- implementing-mcp-toolsSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 21
Every prompt follows this structure.
- Very specific: line 72
Import the prompt: import myPrompt from "./myPrompt.ts".
- Very specific: line 73
Add it to the prompts array:
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Implementing MCP Prompts
Workflow
Task Progress:
- [ ] Step 1: Create prompt file in src/mcp/prompts/
- [ ] Step 2: Define Zod schema, name, config, and callback
- [ ] Step 3: Export as default PromptPlugin
- [ ] Step 4: Register in src/mcp/prompts/mod.ts
- [ ] Step 5: Run `deno task ci` to verifyPrompt File Template
Every prompt follows this structure. Create a new file in src/mcp/prompts/.
import type { GetPromptResult } from "@modelcontextprotocol/sdk/types.js";
import { z } from "zod/v3";
import type { PromptPlugin } from "$/shared/types.ts";
// 1. Validation schema
const schema = z.object({
myArg: z.string().min(1, "Required"),
});
// 2. Prompt name (kebab-case)
const name = "my-prompt-name";
// 3. Config — choose one of the two argument styles below
const config = {
title: "Human-readable title",
description: "What this prompt does — shown to the LLM",
argsSchema: {
myArg: schema.shape.myArg,
},
};
// 4. Callback — returns GetPromptResult with messages array
async function callback(args: Record<string, unknown>): Promise<GetPromptResult> {
const { success, data, error } = schema.safeParse(args);
if (!success) throw new Error(error.message);
return {
messages: [{
role: "user",
content: {
type: "text",
text: `Do something with: ${data.myArg}`,
},
}],
};
}
// 5. Export as PromptPlugin tuple
const prompt: PromptPlugin = [name, config, callback];
export default prompt;Registration
In src/mcp/prompts/mod.ts:
- Import the prompt:
import myPrompt from "./myPrompt.ts"; - Add it to the
promptsarray:
export const prompts: PromptPlugin[] = [
// ... existing prompts
myPrompt,
];The server registers each prompt via server.registerPrompt(...prompt).
Key Type
From src/shared/types.ts:
export type PromptPlugin = Parameters<McpServer["registerPrompt"]>;This is a tuple: [name, config, callback] matching McpServer.registerPrompt() parameters.
Argument Styles
Style A: argsSchema (preferred)
Uses Zod shapes directly. Supports completable() for dynamic suggestions.
import { completable } from "@modelcontextprotocol/sdk/server/completable.js";
const config = {
title: "My Prompt",
description: "...",
argsSchema: {
language: completable(schema.shape.language, (value) => {
const prefix = value.trim().toLowerCase();
return options.filter((o) => o.toLowerCase().startsWith(prefix)).slice(0, 5);
}),
goal: schema.shape.goal,
},
};Style B: arguments array (legacy)
Uses the Prompt type from the SDK. No dynamic completions.
import type { Prompt } from "@modelcontextprotocol/sdk/types.js";
const config: Prompt = {
name,
title: "My Prompt",
description: "...",
arguments: [
{ name: "code", description: "The code to review", required: true },
],
};Callback Pattern
Callbacks return GetPromptResult — an object with a messages array:
async function callback(args: Record<string, unknown>): Promise<GetPromptResult> {
const { success, data, error } = schema.safeParse(args);
if (!success) throw new Error(error.message);
return {
messages: [
{
role: "user",
content: { type: "text", text: `Your prompt text with ${data.myArg}` },
},
],
};
}Key differences from tool callbacks:
- Receives
args: Record<string, unknown>(notany) - Returns
GetPromptResult(notCallToolResult) - Throws on validation failure (not error response objects)
- No
McpServerparameter — prompts don't need server access - Can return multiple messages for multi-turn prompt templates
Multi-Message Prompts
Return multiple messages for system + user prompt patterns:
return {
messages: [
{
role: "assistant",
content: { type: "text", text: "You are a code reviewer..." },
},
{
role: "user",
content: { type: "text", text: `Review this code:\n\n${data.code}` },
},
],
};Additional Resources
- For complete prompt examples, see examples.md
- MCP Prompts spec: https://modelcontextprotocol.io/specification/2025-06-18/server/prompts
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

