Most teams now keep agent skills as folders of Markdown: a SKILL.md with instructions, plus the references it links to. The hard part is sharing them. Copying folders into every repo goes stale quickly.
Version 2.4.0 of the MCP TypeScript SDK adds Skills over MCP (SEP-2640). One loadSkills() call turns a folder of skills into an MCP server. Clients list the skills, load only the ones they need, and check every file against a SHA-256 digest the server published.
In this tutorial you will build a small team-skills server over stdio, read its skills from a client, and see what happens when a file changes while the server runs.
1. Set up the project
Create a folder and install the server and client packages. tsx runs the TypeScript files directly.
mkdir team-skills && cd team-skills
npm init -y && npm pkg set type=module
npm i @modelcontextprotocol/[email protected] @modelcontextprotocol/[email protected]
npm i -D tsx2. Write two skills
A skill is a folder that contains a SKILL.md. Its frontmatter needs a name and a description, and the name must match the folder name. Other files in the folder are part of the skill.
---
name: code-review
description: Review a pull request against the team checklist.
---
# Code review
Read the diff first, then go through [the checklist](references/CHECKLIST.md).
Leave one comment per problem, and say how to fix it.# Review checklist
- Tests cover the change.
- No secrets or tokens in the diff.
- Errors are handled, not swallowed.---
name: release-notes
description: Write release notes from the merged pull requests since the last tag.
---
# Release notes
1. List merged pull requests since the last tag with `git log --merges`.
2. Group them under Added, Changed and Fixed.
3. Write one line per change, in the past tense, with the PR number.The layout follows the Agent Skills specification, the same format agent tools read from disk.
3. Serve the folder
loadSkills() scans the folder once and builds a catalog. attach() adds the skills methods to a server.
import { McpServer } from '@modelcontextprotocol/server';
import { loadSkills } from '@modelcontextprotocol/server/ext/skills/node';
import { serveStdio } from '@modelcontextprotocol/server/stdio';
// Scan the folder once. The catalog keeps paths, sizes and digests, not file contents.
const skills = await loadSkills(new URL('./skills', import.meta.url).pathname, { prefix: 'team' });
void serveStdio(() => {
const server = new McpServer({ name: 'team-skills', version: '1.0.0' });
skills.attach(server);
return server;
});
console.error(`[server] serving ${skills.entries.length} skills over stdio`);The prefix option puts every skill under skill://team/…. Use one prefix per server, so skills from different servers don't share URIs.
The server logs to stderr because stdout carries the protocol messages.
4. List and load skills from a client
SkillsClient wraps a connected MCP client. This client starts the server as a child process.
import { Client } from '@modelcontextprotocol/client';
import { SkillsClient } from '@modelcontextprotocol/client/ext/skills';
import { StdioClientTransport } from '@modelcontextprotocol/client/stdio';
const client = new Client({ name: 'skills-demo', version: '1.0.0' });
await client.connect(new StdioClientTransport({ command: 'npx', args: ['tsx', 'server.ts'] }));
const skills = new SkillsClient(client);
// 1. List: frontmatter and file lists only. No skill file is read yet.
const { skills: entries } = await skills.list();
for (const entry of entries) {
console.log(`${entry.uri}\n ${entry.frontmatter.description}`);
}
// 2. Load one skill: SKILL.md is checked for size, SHA-256 digest and frontmatter.
const review = entries.find((entry) => entry.frontmatter.name === 'code-review')!;
const manifest = await skills.read(review);
console.log('\nverified:', manifest.verified);
console.log(manifest.body);
// 3. Follow the link in SKILL.md. The path resolves against the skill's folder.
const checklist = await skills.read(review, 'references/CHECKLIST.md');
console.log(checklist.text);
await client.close();npx tsx client.ts[server] serving 2 skills over stdio
skill://team/code-review/SKILL.md
Review a pull request against the team checklist.
skill://team/release-notes/SKILL.md
Write release notes from the merged pull requests since the last tag.
verified: true
# Code review
Read the diff first, then go through [the checklist](references/CHECKLIST.md).
Leave one comment per problem, and say how to fix it.
# Review checklist
- Tests cover the change.
- No secrets or tokens in the diff.
- Errors are handled, not swallowed.This is the point of the design. An agent host can show the model every skill's name and description at almost no cost. It reads the full instructions only when a skill is chosen, and reads references only when the instructions point to them.
5. What the client checks
Each entry from list() carries the file list, with a size and digest for every file. Here is one entry, as JSON.stringify printed it:
{
"uri": "skill://team/code-review/SKILL.md",
"frontmatter": {
"name": "code-review",
"description": "Review a pull request against the team checklist."
},
"resources": [
{
"uri": "skill://team/code-review/SKILL.md",
"digest": "sha256:882a20ccde0c5d31443bfc5d6daaad26db31beeb7400f7a750a8fe432fabd12e",
"size": 238
},
{
"uri": "skill://team/code-review/references/CHECKLIST.md",
"digest": "sha256:80ea096821fb997205a4c8fcc7cb4c9cfa47af5721cb03494abe7d33c346c949",
"size": 119
}
]
}read() refuses a file whose size or digest doesn't match, or whose frontmatter differs from the entry. It also refuses any path that isn't in the list. It throws a SkillVerificationError with a reason of unlisted, size, digest or frontmatter, and never returns the content.
The server checks too. If someone edits CHECKLIST.md after loadSkills() ran, a read fails until the catalog is rescanned:
[mcp-sdk] skills: code-review/references/CHECKLIST.md: changed since the catalog was loaded; call reload()The client gets a ProtocolError with the message skill://team/code-review/references/CHECKLIST.md changed since the skills catalog was loaded. A half-edited file never reaches a model.
6. Pick up edits with reload()
For a long-running server, rescan when the folder changes. reload() swaps the new catalog in all at once. If the rescan fails, the old catalog keeps serving.
Replace server.ts with this version:
import { watch } from 'node:fs';
import { McpServer } from '@modelcontextprotocol/server';
import { loadSkills } from '@modelcontextprotocol/server/ext/skills/node';
import { serveStdio } from '@modelcontextprotocol/server/stdio';
const folder = new URL('./skills', import.meta.url).pathname;
const skills = await loadSkills(folder, { prefix: 'team' });
void serveStdio(() => {
const server = new McpServer({ name: 'team-skills', version: '1.0.0' });
skills.attach(server);
return server;
});
// Rescan 200 ms after the last change. An editor save fires several events.
let timer: NodeJS.Timeout | undefined;
const watcher = watch(folder, { recursive: true }, () => {
clearTimeout(timer);
timer = setTimeout(async () => {
try {
const changes = await skills.reload();
console.error('[server] reloaded', JSON.stringify(changes));
} catch (error) {
// A failed rescan keeps the old catalog serving.
console.error('[server] reload failed:', (error as Error).message);
}
}, 200);
});
// Don't keep the process alive just for the watcher once the client is gone.
watcher.unref();
console.error(`[server] serving ${skills.entries.length} skills over stdio`);The unref() call matters. A stdio server exits when its input closes and nothing else is pending. An active watcher counts as pending, so without unref() the server keeps running after a client that crashed or was killed.
This script edits two skills while the server runs. It changes the files in your skills folder.
import { appendFile, writeFile, readFile } from 'node:fs/promises';
import { setTimeout as sleep } from 'node:timers/promises';
import { Client } from '@modelcontextprotocol/client';
import { SkillsClient, SkillVerificationError } from '@modelcontextprotocol/client/ext/skills';
import { StdioClientTransport } from '@modelcontextprotocol/client/stdio';
const client = new Client(
{ name: 'skills-demo', version: '1.0.0' },
{ listChanged: { resources: { onChanged: () => console.log('[client] server says the skill list changed') } } }
);
await client.connect(new StdioClientTransport({ command: 'npx', args: ['tsx', 'server.ts'] }));
const skills = new SkillsClient(client);
const { skills: before } = await skills.list();
const review = before.find((entry) => entry.frontmatter.name === 'code-review')!;
// Someone edits the checklist while the server runs.
await appendFile('skills/code-review/references/CHECKLIST.md', '- Public functions have doc comments.\n');
await sleep(1000);
// The old entry still holds the old digest, so the client refuses the new bytes.
try {
await skills.read(review, 'references/CHECKLIST.md');
} catch (error) {
if (!(error instanceof SkillVerificationError)) throw error;
console.log(`[client] refused: ${error.reason} ${error.uri}`);
}
// List again to get the new digest, then read.
const { skills: after } = await skills.list();
const fresh = after.find((entry) => entry.frontmatter.name === 'code-review')!;
console.log((await skills.read(fresh, 'references/CHECKLIST.md')).text);
// A new description changes the list itself, so the server notifies the client.
const path = 'skills/release-notes/SKILL.md';
const md = await readFile(path, 'utf8');
await writeFile(path, md.replace('since the last tag', 'since the last release tag'));
await sleep(1000);
await client.close();npx tsx live-edit.ts[server] serving 2 skills over stdio
[server] reloaded {"added":[],"removed":[],"changed":["skill://team/code-review/SKILL.md"],"listChanged":false}
[client] refused: size skill://team/code-review/references/CHECKLIST.md
# Review checklist
- Tests cover the change.
- No secrets or tokens in the diff.
- Errors are handled, not swallowed.
- Public functions have doc comments.
[server] reloaded {"added":[],"removed":[],"changed":["skill://team/release-notes/SKILL.md"],"listChanged":true}
[client] server says the skill list changedThe output shows three things:
- After the reload, the server serves the new checklist. The client still held the old entry, so it refused the new bytes. The size check failed first, before the digest check.
- An entry is a snapshot. List again after a change, and then reads succeed.
listChangedistrueonly when a skill is added, removed, renamed or gets a new description. A stdio server then sendsnotifications/resources/list_changedby itself. A content-only edit doesn't notify, so a host that caches entries should list again before it loads a skill.
If you serve over HTTP with createMcpHandler, each server lives for one request. Call handler.notify.resourcesChanged() when listChanged is true instead. The server guide shows the pattern.
When not to use it
- Skills that live in one repo. If one project uses the skills, a
skills/folder in that repo is simpler. MCP pays off when many repos or agents share one set. - Hosts without support. Serving skills doesn't make a host load them. The extension overview says host and SDK support is still being built. Check the client support matrix for the host you use.
- Production rollouts.
attach()is marked experimental, and its wiring may change in a minor release. Pin the SDK version. - Untrusted servers. Digests prove a file matches what the server listed. They don't prove the instructions are safe. The client guide asks hosts to get approval before loading a skill, and to record which server it came from.
Skills work on both the 2025-11-25 and 2026-07-28 protocol versions. This client negotiated 2025-11-25, the default. The protocol versions page covers the differences, such as cache hints on the newer version.
Next steps
- Serve skills without a file system, such as on Workers, with
memorySkillFilesor your ownSkillFilesadapter. Both are in the server guide. - Add skills to an existing server built in Build a Stateless MCP Server with the 2026-07-28 Spec.
- Read the SDK's own skills example, which also runs over HTTP.
- See all changes in the 2.4.0 release notes.