skills/mcp-mastery/mcp-resource-patterns/SKILL.md
Use MCP Resources correctly — the read-only, URI-addressable data primitive — and know when to pick resources, tools, or prompts. Covers templated URIs, subscriptions, and common mistakes. Use this skill when designing MCP servers that expose data, deciding between tool vs resource, or implementing resource subscriptions for live data. Activate when: MCP resource, resource template, resource vs tool, subscribe resource, MCP URI schema.
npx skillsauth add latestaiagents/agent-skills mcp-resource-patternsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Resources are read-only, URI-addressable data. Get them right and your server feels like a filesystem the agent can browse.
| Aspect | Tool | Resource | Prompt |
|---|---|---|---|
| Invocation | Agent calls it | Agent reads it | User selects it |
| Side effects | Allowed | No | No |
| Addressing | Name + args | URI | Name |
| Result | Agent-chosen | User/agent-attached | Template expansion |
| Example | create_issue | github://issues/123 | /summarize-pr |
Rule of thumb: if the agent needs to decide whether to read it, it's a tool. If the user or agent needs to attach specific known data to context, it's a resource.
server.resource(
"changelog",
"file://changelog.md",
async () => ({
contents: [{
uri: "file://changelog.md",
mimeType: "text/markdown",
text: await fs.readFile("CHANGELOG.md", "utf-8"),
}],
}),
);
Use URI templates (RFC 6570) for addressable collections:
server.resource(
"issue",
"github://repos/{owner}/{repo}/issues/{number}",
async (uri, { owner, repo, number }) => {
const issue = await gh.issues.get({ owner, repo, issue_number: +number });
return {
contents: [{
uri: uri.href,
mimeType: "application/json",
text: JSON.stringify(issue.data),
}],
};
},
);
The client auto-discovers the template and can fetch any matching URI.
server.setRequestHandler(ListResourcesRequestSchema, async () => ({
resources: [
{ uri: "github://repos/acme/api/issues", name: "Open issues", mimeType: "application/json" },
{ uri: "github://repos/acme/api/prs", name: "Open PRs", mimeType: "application/json" },
],
}));
Keep the list short — this is what the user sees in the resource picker.
For data that changes (logs, metrics, ticket state), support subscriptions so the client re-reads on update:
server.resource(
"live-log",
"logs://app/{stream}",
{ subscribe: true },
async (uri, { stream }) => ({ contents: [{ uri: uri.href, text: await tail(stream) }] }),
);
// When data changes:
logStream.on("update", (stream) => {
server.sendResourceUpdated({ uri: `logs://app/${stream}` });
});
The client listens for notifications/resources/updated and re-fetches.
A good scheme is:
github://repos/{owner}/{repo}/issues/{number}, not github://issue?id=123&repo=...github://repos/acme/api/issues/5, it can guess .../issues/6github://, not resource://)mimeType so the client renders correctlyAvoid opaque IDs in URIs when human-readable keys exist — linear://issues/ENG-42 beats linear://issues/a3f8c21d.
return {
contents: [{
uri: uri.href,
mimeType: "image/png",
blob: base64Encode(pngBytes),
}],
};
Clients that support vision models will attach PNGs directly. Text-only clients will skip binary resources.
MCP has no native pagination. Two conventions:
github://issues?page=2 as a distinct URInextPageUri and let the agent fetch itPrefer (1) — clients cache per-URI.
get_issue should be github://issues/{number} so the user can attach it as contextmimeType — breaks rich clients and model understandinggithub://issues/123 points to different data tomorrow, caching breaksdevelopment
Test skills for correct activation, content quality, and regression — both automated checks (frontmatter validity, lint) and manual verification (query-suite activation testing). Covers CI integration and how to catch skill regressions before users do. Use this skill when adding skills to a repo, setting up CI for a skill library, or debugging "the skill exists but doesn't work". Activate when: test skills, validate skills, skill CI, skill linting, skill activation test, skill regression.
documentation
Write the YAML frontmatter for a SKILL.md file so it activates reliably — name, description, and activation keywords that the model matches against. Covers length, tone, and the most common frontmatter mistakes. Use this skill when authoring a new skill, fixing a skill that isn't auto-activating, or reviewing skills for publication. Activate when: SKILL.md frontmatter, skill description, skill activation, skill YAML, write a skill, author a skill.
development
Design skills that fire at the right moment — neither over-eager (noise) nor under-eager (silent). Covers activation specificity, trigger phrases, disambiguation between overlapping skills, and debugging activation. Use this skill when multiple skills could fire on the same query, a skill never fires, or a skill fires too often. Activate when: skill won't activate, skill over-activates, overlapping skills, skill triggers, skill selection, skill disambiguation.
development
Structure SKILL.md content so the model reads just enough — concise summary up front, progressively deeper detail, examples on demand. Covers section ordering, length budgets, when to split into multiple skills. Use this skill when writing or refactoring a skill body, one skill has grown too long, or a skill is wordy but not useful. Activate when: SKILL.md structure, skill content, skill too long, split skill, progressive disclosure, skill body.