agentleFS
phughesmcrphughesmcr/deno-mcp-template/.cursor/skills/implementing-mcp-prompts/SKILL.md

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.

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
  1. Very specific:

    Every prompt follows this structure.

    line 21
  2. Very specific:

    Import the prompt: import myPrompt from "./myPrompt.ts".

    line 72
  3. Very specific:

    Add it to the prompts array:

    line 73

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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 verify

Prompt 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:

  1. Import the prompt: import myPrompt from "./myPrompt.ts";
  2. Add it to the prompts array:
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> (not any)
  • Returns GetPromptResult (not CallToolResult)
  • Throws on validation failure (not error response objects)
  • No McpServer parameter — 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

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.