Until now, an MCP server had two ways to deal with a dangerous request: do it, or refuse it. There was no third option — no way to stop mid-call, show the user exactly what is about to happen, and let them decide. On November 24, 2026, that changed. Anthropic marked the second anniversary of the Model Context Protocol by making two features generally available in Claude and Claude Code: elicitation, which lets a server pause a tool call and ask the user a question through a form, and Tasks, for long-running background work. A third feature, Skills over MCP, entered public beta: servers can now ship workflow guidance — skills — alongside their tools.

This tutorial builds a small server that uses the first and the third, and tests both end to end with the official Python SDK. The server is a notes keeper with four tools. Two of them are harmless. Two of them delete and publish — and those two never act without asking first. By the end you will have a working server, a scripted client that proves every path (accept, decline, cancel), and a skill the server ships to Claude. No API key, no GPU, no account: everything runs on your own machine.

What you’ll need#

  • Python 3.10 or newer. The sandbox run for this tutorial used Python 3.12.
  • The MCP Python SDK, pinned to mcp==2.3.0. Version 2.x renamed the high-level server class from FastMCP to MCPServer — if you follow an older guide that imports FastMCP, it will fail on this version with a clear error telling you exactly that.
  • pyyaml, for reading the skill’s frontmatter.
  • Nothing else. No model calls happen anywhere in this tutorial: the test client answers the server’s questions from a script, so the whole loop runs offline.

One thing to know before you start: elicitation is a client capability. The server can only ask a question if the client declares that it supports elicitation during the handshake. Claude and Claude Code do. The test client in Step 6 does too. A client that does not support it gets a clean failure from the server — never a silent delete.

Step 1: Install the SDK#

mkdir gatekeeper && cd gatekeeper
python3 -m venv .venv
.venv/bin/pip install "mcp==2.3.0" pyyaml

Verify the install and the version you got:

.venv/bin/pip show mcp | head -2
.venv/bin/python -c "import mcp; print('mcp ok')"
Name: mcp
Version: 2.3.0

Pinning matters here more than usual. The protocol is moving fast — the SDK negotiated protocol version 2025-11-25 in the test run below — and the 1.x to 2.x rename means unpinned installs can silently change the API you are reading about. Everything in this tutorial was run against exactly 2.3.0.

Step 2: A server with one dangerous tool#

Create server.py. The layout is deliberate: notes live in a notes/ folder next to the server, and skills live in skills/. All paths resolve from the server file itself, so the working directory does not matter when a client spawns it.

"""Gatekeeper: a tiny notes MCP server that asks before it acts."""
from __future__ import annotations

import re
from pathlib import Path
from typing import Any, Literal

from mcp.server.mcpserver import Context, MCPServer
from pydantic import BaseModel, Field

BASE = Path(__file__).resolve().parent
NOTES_DIR = BASE / "notes"
SKILLS_DIR = BASE / "skills"
NOTES_DIR.mkdir(exist_ok=True)

mcp = MCPServer(
    name="gatekeeper",
    instructions="A notes server that never deletes or publishes without asking first.",
    # extensions=[...] -- the skills extension arrives in Step 5.
)


def _note_path(title: str) -> Path:
    safe = re.sub(r"[^A-Za-z0-9._-]+", "-", title).strip("-") or "untitled"
    return NOTES_DIR / f"{safe}.md"


class DeleteConfirmation(BaseModel):
    confirm: bool = Field(description="Tick to permanently delete the note")
    reason: str = Field(default="", description="Why this note is being deleted (optional)")


class PublishDetails(BaseModel):
    audience: Literal["team", "public"] = Field(description="Who may read the published note")
    confirm: bool = Field(description="Tick to publish the note to this audience")


@mcp.tool()
def create_note(title: str, body: str) -> str:
    """Create a note. Safe to call without confirmation."""
    path = _note_path(title)
    path.write_text(f"# {title}\n\n{body}\n")
    return f"Created {path.name}"


@mcp.tool()
def list_notes() -> str:
    """List all notes."""
    names = sorted(p.name for p in NOTES_DIR.glob("*.md"))
    return "\n".join(names) if names else "(no notes)"


@mcp.tool()
async def delete_note(title: str, ctx: Context) -> str:
    """Permanently delete a note. Asks the user to confirm before deleting."""
    path = _note_path(title)
    if not path.exists():
        return f"No note named {title!r}."
    try:
        answer = await ctx.elicit(
            message=f"Permanently delete the note '{title}'? This cannot be undone.",
            schema=DeleteConfirmation,
        )
    except Exception as exc:  # client does not support elicitation: fail closed
        return f"Could not ask for confirmation ({exc}); note NOT deleted."
    if answer.action == "accept" and answer.data and answer.data.confirm:
        path.unlink()
        return f"Deleted {path.name} (reason: {answer.data.reason or 'none given'})."
    return f"User {answer.action} the deletion. {path.name} was NOT deleted. Do not retry."


@mcp.tool()
async def publish_note(title: str, ctx: Context) -> str:
    """Publish a note. Asks the user for the audience and a final confirmation."""
    path = _note_path(title)
    if not path.exists():
        return f"No note named {title!r}."
    try:
        answer = await ctx.elicit(
            message=f"Publish '{title}'? Pick the audience and confirm.",
            schema=PublishDetails,
        )
    except Exception as exc:
        return f"Could not ask for confirmation ({exc}); note NOT published."
    if answer.action == "accept" and answer.data and answer.data.confirm:
        return f"Published {path.name} to {answer.data.audience}."
    return f"User {answer.action} the publish. {path.name} was NOT published."


if __name__ == "__main__":
    mcp.run()

Three design choices in that file are worth naming, because they are the difference between a demo and a gate you can trust.

First, the schema is a Pydantic model, and it is the form. ctx.elicit() takes a message and a model class, converts the model to JSON Schema, and sends it to the client as an elicitation/create request. The client renders a form from that schema. What the server sent for the delete confirmation, captured on the wire in Step 6, was exactly this:

{"properties": {"confirm": {"description": "Tick to permanently delete the note", "title": "Confirm", "type": "boolean"}, "reason": {"default": "", "description": "Why this note is being deleted (optional)", "title": "Reason", "type": "string"}}, "required": ["confirm"], "title": "DeleteConfirmation", "type": "object"}

The spec restricts elicitation schemas to flat objects with primitive properties — strings, numbers, booleans, and string enums. No nesting, no arrays of objects. That restriction is the point: any client can render the form without understanding your data model.

Second, the tool only acts on one of the three answers. Elicitation responses carry an action: accept, decline, or cancel. Only accept carries data, and only accept with confirm ticked deletes anything. A decline and a cancel take the same branch — nothing happens — and the tool tells the model not to retry. That last sentence matters: without it, a model that really wants the delete done will rephrase the request and ask again.

Third, failure is closed, not open. If the client does not support elicitation, ctx.elicit() raises, the except catches it, and the tool reports that the note was not deleted. A confirmation gate that deletes when the confirmation mechanism is missing is not a gate. This path was verified by accident during testing — a bug in the test client made the elicitation callback raise, and the server refused every delete until the client was fixed.

Diagram of the elicitation round trip: the client calls the tool, the server pauses and sends a form, the user accepts, declines or cancels, and the server continues or stops
Diagram drawn for AI Frontier Post: the elicitation round trip, and what the server does with each of the three answers.

Step 3: The three answers, and what each one means#

The distinction between the three actions is a user-interface distinction, and your server should respect what each one signals:

ActionWhat the user didWhat the server does
acceptSubmitted the formValidates the data against the schema and proceeds — only if confirm is true
declineExplicitly said noStops, reports it, does not retry
cancelDismissed the dialog without choosingStops, reports it, does not retry

Decline and cancel are deliberately identical in the server code. The difference is information for the user, not a branch for the server: a decline is a decision, a cancel is an interruption. Either way the note survives. If your workflow needs to distinguish them — say, re-asking later after a cancel but never after a decline — split the branch there and say so in the tool’s return text, so the model does not invent its own policy.

Step 4: Elicitation is not only for confirmation#

The delete tool uses elicitation as a guard. The publish tool uses it as input gathering — the other half of the feature. When the model calls publish_note with only a title, the server asks for the two things it cannot guess: the audience and the final confirmation. The schema the client received for that call was:

{"properties": {"audience": {"description": "Who may read the published note", "enum": ["team", "public"], "title": "Audience", "type": "string"}, "confirm": {"description": "Tick to publish the note to this audience", "title": "Confirm", "type": "boolean"}}, "required": ["audience", "confirm"], "title": "PublishDetails", "type": "object"}

Notice the enum: the client renders a picker with exactly two options, and the answer comes back validated. This is the pattern the spec was designed for — a server that is missing a small, structured piece of information asks for it mid-call instead of failing, guessing, or bouncing the question back through the model as free text. Supabase uses the same shape to confirm costs before creating a paid project; GitHub’s server asks for the repository name before deleting one. The shape is always the same: pause, ask for the missing field, continue.

One hard rule from the spec: never ask for sensitive information through elicitation. No passwords, API keys, access tokens, or payment credentials — in form mode or any other. If a flow needs a secret, it belongs in an OAuth redirect or a URL-mode elicitation that keeps the secret out of the MCP conversation entirely.

Step 5: Ship a skill with the server#

Tools tell Claude what a server can do. Skills tell it how — the workflow, the order of operations, the rules that keep a multi-step job safe. Skills over MCP is in public beta in Claude and Claude Code as of November 24, and the shape is defined by SEP-2640, now final: a skill is a directory containing a SKILL.md with YAML frontmatter (name and description are required), plus optional supporting files. Every file in the directory is exposed as an MCP resource under a skill:// URI. Two methods discover them: skills/list enumerates the skills with a manifest of every file (URI, SHA-256 digest, byte size), and skills/get returns one skill by URI.

Create the skill. The directory name must match the name in the frontmatter — the server enforces that in Step 5’s code.

skills/
└── safe-deletes/
    ├── SKILL.md
    └── references/
        └── CHECKLIST.md
---
name: safe-deletes
description: Delete or publish notes only after the user confirms through elicitation. Use when a request involves deleting or publishing a note.
---

# Safe deletes

Never delete or publish a note on a bare instruction. The gatekeeper server
asks the user first, every time.

## Workflow

1. Call `list_notes` to confirm the note exists and check the exact title.
2. Call `delete_note` (or `publish_note`). The server pauses and asks the
   user to confirm through a form.
3. If the user accepts, the server deletes or publishes and reports what
   happened. If the user declines or cancels, the note is untouched — do
   not retry the call, and do not rephrase the request to get around the
   refusal.
4. Never ask the user for a password, API key, or payment details as part
   of a delete or publish. Elicitation is for confirmation, not secrets.

## Why this exists

A single misheard title can wipe the wrong note. The confirmation form is
the blast-radius control: the human sees the exact title before anything
irreversible happens.

Now the serving code. The Python SDK 2.3.0 does not ship a skills helper yet — there is no skills module in the package — so this step implements SEP-2640 directly on the SDK’s public Extension API. An extension contributes resources and new request methods; the server advertises it under its identifier, io.modelcontextprotocol/skills. Add this to server.py, above the MCPServer(...) construction, and pass extensions=[SkillsExtension(SKILLS_DIR)] to the constructor (replacing the placeholder comment from Step 2):

import hashlib
import yaml
from mcp.server.extension import Extension, MethodBinding
from mcp.types import RequestParams


class SkillResourceEntry(BaseModel):
    uri: str
    sha256: str
    size: int


class SkillEntry(BaseModel):
    uri: str
    frontmatter: dict[str, Any]
    resources: list[SkillResourceEntry]


class SkillsListParams(RequestParams):
    cursor: str | None = None


class SkillsGetParams(RequestParams):
    uri: str


class SkillsListResult(BaseModel):
    skills: list[SkillEntry]
    nextCursor: str | None = None


def load_skill_catalog(skills_dir: Path) -> list[SkillEntry]:
    """Read every <skills_dir>/<name>/SKILL.md into SEP-2640 entries."""
    catalog: list[SkillEntry] = []
    for skill_dir in sorted(p for p in skills_dir.iterdir() if p.is_dir()):
        skill_md = skill_dir / "SKILL.md"
        if not skill_md.exists():
            continue
        text = skill_md.read_text()
        m = re.match(r"^---\n(.*?)\n---\n", text, re.DOTALL)
        frontmatter = yaml.safe_load(m.group(1)) if m else {}
        name = frontmatter.get("name")
        assert name == skill_dir.name, f"SKILL.md name {name!r} != dir {skill_dir.name!r}"
        entries: list[SkillResourceEntry] = []
        for f in sorted(p for p in skill_dir.rglob("*") if p.is_file()):
            data = f.read_bytes()
            rel = f.relative_to(skill_dir).as_posix()
            entries.append(SkillResourceEntry(
                uri=f"skill://{skill_dir.name}/{rel}",
                sha256=hashlib.sha256(data).hexdigest(),
                size=len(data),
            ))
        catalog.append(SkillEntry(
            uri=f"skill://{skill_dir.name}/SKILL.md",
            frontmatter=frontmatter, resources=entries))
    return catalog


class SkillsExtension(Extension):
    """Minimal SEP-2640 implementation on the public Extension API."""

    identifier = "io.modelcontextprotocol/skills"

    def __init__(self, skills_dir: Path):
        self._catalog = load_skill_catalog(skills_dir)

    def methods(self):
        async def list_skills(ctx, params: SkillsListParams):
            return SkillsListResult(skills=self._catalog)

        async def get_skill(ctx, params: SkillsGetParams):
            for entry in self._catalog:
                if entry.uri == params.uri:
                    return entry
            raise ValueError(f"unknown skill: {params.uri}")

        return [
            MethodBinding(method="skills/list", params_type=SkillsListParams, handler=list_skills),
            MethodBinding(method="skills/get", params_type=SkillsGetParams, handler=get_skill),
        ]

Each skill file also needs to be served as a resource, so a client can read it with resources/read. Register every file under its skill:// URI, right after the server is constructed:

def _make_reader(text: str):
    def _reader() -> str:
        return text
    return _reader


for _skill_file in sorted(SKILLS_DIR.rglob("*")):
    if not _skill_file.is_file():
        continue
    _rel = _skill_file.relative_to(SKILLS_DIR).as_posix()
    mcp.resource(f"skill://{_rel}", mime_type="text/markdown")(
        _make_reader(_skill_file.read_text()))

One honest caveat, verified on the wire: the extension’s methods answer when called, but the current SDK does not advertise the extension in the handshake. The negotiated protocol version is 2025-11-25, and the extensions capability field the spec uses for the advertisement belongs to the newer 2026-07-28 revision — the raw initialize response carries no extensions key, and server/discover answers “method not found” at this protocol version. The SEP tells clients to call skills/list only after observing the server’s declaration, so a client that insists on seeing the declaration first will not find it from this SDK yet. In practice that is a transitional gap, not a blocker: the methods work, the files are served, and hosts implementing the beta — Claude and Claude Code — read skills from servers that implement SEP-2640. Re-check the advertisement when you upgrade the SDK; the day the handshake carries the extension, nothing in your server code needs to change.

Diagram of the three layers one MCP server ships: skills for how to do the work, tools for what it can do, and resources for context Claude can read
Diagram drawn for AI Frontier Post: one server, three layers — skills, tools, and resources travel together.

Step 6: Test it end to end#

Do not wire this into Claude Code before you have watched every path run. The test client below spawns the server over stdio, plays a scripted user through the elicitation callback — accept the first delete, decline the second, accept the publish — and calls the skills methods with raw requests, since the SDK has no typed client helper for them yet. The important details: the callback signature is (context, params), the schema arrives as a plain dict on params.requested_schema, and a raw skills/get request needs its params wrapped in a typed model, or the SDK silently drops the fields.

import asyncio, json
from pathlib import Path
from mcp import ClientSession, StdioServerParameters, stdio_client
from mcp.types import ElicitResult, Request, RequestParams as RP
from pydantic import BaseModel, TypeAdapter

SCRIPT = {
    "delete the note 'draft'": ("accept", {"confirm": True, "reason": "superseded by final"}),
    "delete the note 'keep'": ("decline", None),
    "Publish 'launch'": ("accept", {"audience": "team", "confirm": True}),
}


async def elicitation_callback(context, params):
    for key, (action, content) in SCRIPT.items():
        if key in params.message:
            return ElicitResult(action=action, content=content)
    return ElicitResult(action="decline")


async def main() -> None:
    server = StdioServerParameters(
        command=".venv/bin/python", args=["server.py"])
    async with stdio_client(server) as (read, write):
        async with ClientSession(read, write,
                                 elicitation_callback=elicitation_callback) as session:
            await session.initialize()
            print("tools:", [t.name for t in (await session.list_tools()).tools])
            await session.call_tool("create_note", {"title": "draft", "body": "rough notes"})
            await session.call_tool("create_note", {"title": "keep", "body": "do not delete"})
            await session.call_tool("create_note", {"title": "launch", "body": "go live"})
            r = await session.call_tool("delete_note", {"title": "draft"})
            print("delete draft ->", r.content[0].text)
            r = await session.call_tool("delete_note", {"title": "keep"})
            print("delete keep ->", r.content[0].text)
            r = await session.call_tool("publish_note", {"title": "launch"})
            print("publish launch ->", r.content[0].text)
            print("notes after:",
                  (await session.call_tool("list_notes", {})).content[0].text)

            resources = await session.list_resources()
            print("resources:", [str(r.uri) for r in resources.resources])

            class SkillsGetParams(RP):
                uri: str

            listed = await session.send_request(
                Request(method="skills/list", params={}),
                TypeAdapter(dict))
            print("skills/list ->", json.dumps(listed, indent=2)[:400])
            got = await session.send_request(
                Request[SkillsGetParams, str](method="skills/get",
                    params=SkillsGetParams(uri="skill://safe-deletes/SKILL.md")),
                TypeAdapter(dict))
            print("skills/get ->", got["frontmatter"]["name"], "| files:",
                  len(got["resources"]))


asyncio.run(main())

Run it from the project directory. The output below is the real output of this run, not a mock:

[client] tools: ['create_note', 'list_notes', 'delete_note', 'publish_note']
[client] notes: draft.md
keep.md
launch.md
[client] elicitation asked: "Permanently delete the note 'draft'? This cannot be undone."
[client] scripted answer: accept {'confirm': True, 'reason': 'superseded by final'}
[client] delete draft -> Deleted draft.md (reason: superseded by final).
[client] elicitation asked: "Permanently delete the note 'keep'? This cannot be undone."
[client] scripted answer: decline None
[client] delete keep -> User decline the deletion. keep.md was NOT deleted. Do not retry.
[client] elicitation asked: "Publish 'launch'? Pick the audience and confirm."
[client] scripted answer: accept {'audience': 'team', 'confirm': True}
[client] publish launch -> Published launch.md to team.
[client] notes after: keep.md
launch.md
[client] resources: ['skill://safe-deletes/SKILL.md', 'skill://safe-deletes/references/CHECKLIST.md']
[client] skills/list -> {
      "uri": "skill://safe-deletes/SKILL.md",
        "name": "safe-deletes",
        "description": "Delete or publish notes only after the user confirms through elicitation. ..."
          "uri": "skill://safe-deletes/SKILL.md",
          "uri": "skill://safe-deletes/references/CHECKLIST.md",
[client] skills/get name: safe-deletes | files: 2

Every path behaved as designed. The accept deleted the note and reported the reason. The decline left the note in place. A separate run with the scripted answer changed to cancel produced User cancel the deletion. keep.md was NOT deleted. Do not retry. The publish collected the audience from the form and reported it. And the skills methods returned the full SEP-2640 entry: the SKILL.md digest is a617c191… (1,067 bytes), the checklist 80366f0f… (262 bytes) — a client can verify every file it reads against that manifest before loading the skill.

Step 7: Wire it into Claude Code#

With the test run green, add the server to a project. Create .mcp.json in the project root (project scope — it is checked in, so the team shares it):

{
  "mcpServers": {
    "gatekeeper": {
      "command": "/path/to/gatekeeper/.venv/bin/python",
      "args": ["/path/to/gatekeeper/server.py"]
    }
  }
}

Use absolute paths: Claude Code spawns the server itself, and a relative command would resolve against wherever the CLI happens to run. Confirm it loaded with claude mcp list, then try the flow in chat: ask Claude to delete a note. The tool call pauses, Claude Code shows the confirmation form with the exact note title, and the delete only happens if you submit it. The skill ships with the server, so there is nothing separate to install — Claude loads safe-deletes when a request touches deleting or publishing, and the workflow in SKILL.md is what it follows.

Skills over MCP is on by default for Pro, Max, and Ultra plans, and available to Team plans once an admin enables it; Tasks and Elicitation are generally available on the same plans. If your plan or organization does not have the beta yet, the tools and the elicitation form still work — the skill is the only part gated on the beta.

Which approach should you use?#

Elicitation is one of several ways to put a human in the loop. Pick by what the server needs at the moment it needs it:

PatternUse whenWatch out for
Elicitation (form)The server needs a small, structured answer mid-call — a confirmation, a missing field, a choice from a listFlat schemas only; never secrets; the client must support it
Elicitation (URL)The answer needs a flow the form cannot hold — OAuth sign-in, a payment pageNewer (spec 2025-11-25); fewer clients implement it yet
SamplingThe server needs the model’s judgement, not the user’s — summarising, drafting, classifyingCosts model calls; the answer is generated, not given
Plain tool designThe confirmation can be an argument the model fills in itself, with no human neededA model filling in its own confirm: true is not a human approval
TasksThe work takes minutes or runs an agent loop, and Claude should keep working meanwhileAlso new (GA November 24); the server returns a handle and the client polls for the result

The rule of thumb: if a human’s judgement is the missing input, elicit. If the model’s judgement is the missing input, sample. If nobody’s judgement is needed, the tool should not ask at all.

The takeaway#

MCP’s second birthday changed what a server is allowed to be. It is no longer just a bag of tools the model calls and hopes for the best: it can pause and ask, run long work in the background, and ship the workflow that explains how its tools are meant to be used. The two pieces in this tutorial are the ones you can build today, with the stable SDK, and verify without spending anything — a confirmation gate that fails closed, and a skill that travels with the server that enforces it.

The pattern generalises directly. Replace notes with anything irreversible — deleting a repository, creating a paid project, running destructive SQL — and the shape is identical: a Pydantic model for the question, one branch that acts only on accept, and a skill that writes down the workflow so the next agent does not have to guess it. Start with the gatekeeper, then point the same pattern at your own dangerous tools.