Serving and Verifying Agent Skills over MCP: FastMCP + Inspector

Serving and Verifying Agent Skills over MCP: FastMCP + Inspector

A skill used to live as a folder on every machine: each agent kept its own copy, and an update meant reinstalling everywhere. The Skills extension (SEP-2640, io.modelcontextprotocol/skills) moves the folder behind an MCP server: the server hosts one copy next to the tools the skill describes, clients discover it with skills/list, fetch it with skills/get and resources/read, and — because every file is advertised with a SHA-256 digest and a byte size — verify exactly what they received before loading it.

This page walks the whole path against one tiny skill: serve it with FastMCP 4.2, read and verify it with Client.read_skill(), then audit the catalog with MCP Inspector --verify. At the end one digest is broken on purpose, and both clients refuse it.

What this page is. Every command and output below was really run on 2026-11-17: Python 3.12.16, fastmcp==4.2.0 (tag v4.2.0, commit 5e71792d), Inspector 2.15.0 (tag 2.15.0, commit 488c30d) on Node v22.23.4, macOS x86_64, stdio transport, loopback only. The skill is a two-file teaching fixture; nothing here touches auth, sessions or remote hosts.

We verified the example output by rerunning the scripts below. Use it to check skill discovery, file reads, successful digest verification, and the error messages and exit codes for a digest mismatch.

What you need

  • Python ≥ 3.11 (the version FastMCP 4.2 requires) in a fresh virtual environment:

    python3 -m venv .venv && source .venv/bin/activate
    pip install fastmcp==4.2.0
  • Node ^22.23.4 || ^24.22.1 || >=26.12.1 for the Inspector step (it arrives via npx, no global install).

1. Create the skill

A skill is a folder whose SKILL.md carries a frontmatter block (name, description) and instructions; extra files live next to it. Create this exact fixture — the digests later on are the digests of these bytes:

skills/greet/SKILL.md
skills/greet/scripts/greet.txt

skills/greet/SKILL.md:

---
name: greet
description: Compose a short greeting for a name.
---
# Greet

Read the helper for the wording rules, then greet the user.

skills/greet/scripts/greet.txt:

Hello, {name}! Nice to meet you.

Two files, 139 and 33 bytes. Hashing them locally is worth doing once — it is the same hash the protocol advertises:

$ shasum -a 256 skills/greet/SKILL.md skills/greet/scripts/greet.txt
e43024282c001ba7...  skills/greet/SKILL.md
3b7286df9434f14...  skills/greet/scripts/greet.txt

2. Serve it

Skill.from_directory builds the skill from the folder — frontmatter, instructions, and a manifest that lists every file with its digest and size. SkillCatalogProvider serves that catalog: as skill:// resources for any client, and through the Skills extension for clients that declare it.

server.py:

"""Serve one agent skill over MCP with the Skills extension (stdio)."""
from pathlib import Path

from fastmcp import FastMCP, Skill
from fastmcp.skills.provider import SkillCatalogProvider

SKILLS_DIR = Path(__file__).parent / "skills"

greet = Skill.from_directory(SKILLS_DIR / "greet")

mcp = FastMCP("team-skills")
mcp.add_provider(SkillCatalogProvider([greet]))

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

3. Discover, read and verify

The client declares the extension with SkillsClientExtension(); without it the client will not opt in, and a server may refuse skills/list to a client that did not. read_skill() then does the whole job: it fetches the manifest, reads every file, and checks that each one matches the promised size and digest before returning it. to_directory() installs it into a folder named after the skill — the folder name must equal the skill’s name, so Skill.from_directory can read it back — and the export below lives in a private temporary directory that is removed when the block exits.

client.py:

"""List, read and verify the skills a server serves (SEP-2640)."""
import asyncio
import tempfile
from contextlib import contextmanager
from pathlib import Path

from fastmcp import Client, Skill
from fastmcp.client.transports import StdioTransport
from fastmcp.skills.client import SkillsClientExtension

SERVER = Path(__file__).with_name("server.py")


@contextmanager
def exported_skill(skill: Skill):
    """Export into a private temp dir that is removed on exit."""
    with tempfile.TemporaryDirectory() as tmp:
        export = Path(tmp) / skill.name  # folder name must equal the skill's name
        skill.to_directory(export)
        yield export


async def main() -> None:
    async with Client(
        StdioTransport("python", [str(SERVER)]),
        extensions=[SkillsClientExtension()],  # declares io.modelcontextprotocol/skills
    ) as client:
        for entry in await client.list_skills():
            print(f"{entry.uri}  ({entry.frontmatter.root['description']})")
            for resource in entry.resources:
                print(f"  {resource.uri}  {resource.size} B  {resource.digest}")

        skill = await client.read_skill(entry.uri)  # verifies every file
        print(f"read_skill ok: {skill.name}, files={sorted(skill.files)}")

        with exported_skill(skill) as export:
            again = Skill.from_directory(export)
            print(f"round trip equal: {again.files == skill.files}")


asyncio.run(main())

Real output:

$ python client.py
skill://greet/SKILL.md  (Compose a short greeting for a name.)
  skill://greet/SKILL.md  139 B  sha256:e43024282c001ba73a4d23a901f5810128179bf8e183cc7f621abcb4614fe550
  skill://greet/scripts/greet.txt  33 B  sha256:3b7286df9434f141ae6c6dd362555ec2b86cf5d96cb28a1a2f161a444eeb57f8
read_skill ok: greet, files=['SKILL.md', 'scripts/greet.txt']
round trip equal: True

The digests are the ones hashed in step 1. That is the entire contract: the manifest says what each file should be, and the client refuses anything else.

4. Audit the catalog with Inspector

The Inspector CLI verifies a whole catalog in one shot. One flag matters before anything else: --protocol-era modern. An ad-hoc target defaults to the legacy era, which does not negotiate extensions at all — you would get {"error":{"code":"skills_unsupported", ...}} and exit 1 even though the server is fine.

$ npx -y @modelcontextprotocol/[email protected] --cli python server.py \
    --protocol-era modern --method skills/list --verify
{"uri":"skill://greet/SKILL.md","name":"greet","conformance":[],"frontmatter":[],"files":[
  {"uri":"skill://greet/SKILL.md","status":"verified",
   "actualDigest":"sha256:e4302428...","expectedDigest":"sha256:e4302428...","expectedSize":139,"actualSize":139},
  {"uri":"skill://greet/scripts/greet.txt","status":"verified",
   "actualDigest":"sha256:3b7286df...","expectedDigest":"sha256:3b7286df...","expectedSize":33,"actualSize":33}],
 "ok":true,"outcome":"verified"}
$ echo $?
0

One JSON report per skill on stdout; exit 0 means no violation was found. The exit codes are a contract for scripts: 7 a SEP-2640 violation (digest or size mismatch, unreadable manifest), 8 the read bounds stopped the walk before the catalog was fully checked, 9 --require-digests met a skill that advertises no digests. skills/get works the same way for a single skill with --uri skill://greet/SKILL.md.

5. When verification fails

FastMCP’s Skill and SkillManifest objects are immutable on purpose — you cannot “accidentally” edit a manifest in memory. To see a lying manifest, subclass the lower-level SkillManifestProvider: it serves whatever manifests load_manifests() returns and reads file bytes in read_file(). server_bad.py changes exactly one thing — the digest of scripts/greet.txt becomes a well-formed SHA-256 of all zeros:

"""Same server, but the manifest lies about one file's digest."""
from pathlib import Path

from fastmcp import FastMCP, Skill
from fastmcp.skills.provider import SkillManifestProvider

ROOT = Path(__file__).parent / "skills"


class LyingDigest(SkillManifestProvider):
    async def load_manifests(self):
        skill = Skill.from_directory(ROOT / "greet")
        files = dict(skill.manifest.files)
        files["scripts/greet.txt"] = files["scripts/greet.txt"].model_copy(
            update={"digest": "sha256:" + "0" * 64}  # valid format, wrong value
        )
        return {"greet": skill.manifest.model_copy(update={"files": files})}

    async def read_file(self, resource):
        return (ROOT / resource.skill_path / resource.file_path).read_bytes()


mcp = FastMCP("team-skills-bad")
mcp.add_provider(LyingDigest())

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

Point the same client at it — change SERVER = Path(__file__).with_name("server.py") to server_bad.py, nothing else — and run it verbatim. There is no try/except in the published client, so the failed verification surfaces as an uncaught exception; the listing prints first (note the all-zero digest), then the process ends with a traceback and exit code 1:

$ python client.py
skill://greet/SKILL.md  (Compose a short greeting for a name.)
  skill://greet/SKILL.md  139 B  sha256:e43024282c001ba73a4d23a901f5810128179bf8e183cc7f621abcb4614fe550
  skill://greet/scripts/greet.txt  33 B  sha256:0000000000000000000000000000000000000000000000000000000000000000
Traceback (most recent call last):
  File "client.py", line 41, in <module>
    asyncio.run(main())
  ...
ValueError: Skill file 'scripts/greet.txt' does not match its manifest digest
$ echo $?
1

list_skills still succeeds — the lie is in the manifest, and only verification catches it. The Inspector agrees, with exit 7:

$ npx -y @modelcontextprotocol/[email protected] --cli python server_bad.py \
    --protocol-era modern --method skills/list --verify
{"uri":"skill://greet/SKILL.md","name":"greet",...,"files":[
  {"uri":"skill://greet/SKILL.md","status":"verified",...},
  {"uri":"skill://greet/scripts/greet.txt","status":"mismatch",
   "actualDigest":"sha256:3b7286df...","expectedDigest":"sha256:0000000000000000...",
   "expectedSize":33,"actualSize":33}],
 "ok":false,"outcome":"failed"}
$ echo $?
7

Recovery is the point of the exercise: point the client back at server.py (or delete server_bad.py) and it exits 0 again with round trip equal: True — exactly the step 3 output. A size lie behaves identically ("is 33 bytes; the manifest promised 34" from the client, exit 7 from Inspector); a manifest entry whose file cannot be read surfaces as read-error and exit 7; a skill that advertises resources: "dynamic" advertises no digests at all — the client refuses it with has no static manifest to read, while Inspector reports outcome:"unverifiable" and exits 0 unless you pass --require-digests, which makes it exit 9. Exit 0 therefore does not prove everything was verified; read the per-skill outcome too.

6. Clean up

Everything this tutorial creates lives in the one practice directory you started in. The export from step 3 was already removed when its TemporaryDirectory block exited; nothing was written outside the directory.

deactivate                    # leave the venv
rm -rf .venv skills/ server.py server_bad.py client.py   # inside your practice dir only

The npx cache is a shared, reusable cache — leave it alone; it is what makes the next Inspector run start fast.

What this page does not cover

  • Hosts beyond these two clients: which agent hosts discover, load or execute skills — and with what user confirmation — is per-host; see the extension support matrix before assuming anything.
  • Transports other than stdio, OAuth-protected servers, and remote serving (the same code runs over streamable HTTP; not tested here).
  • Trust: a matching digest proves the bytes equal the manifest, not that the skill’s instructions are safe to follow. Hashes verify content, not intent.

Further reading