From latestaiagents
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 claudepluginhub latestaiagents/agent-skills --plugin skills-authoringThis skill uses the workspace's default tool permissions.
**Resources are read-only, URI-addressable data. Get them right and your server feels like a filesystem the agent can browse.**
Guides mcp-use best practices for MCP servers: scaffolding projects, adding tools/resources/prompts/widgets, debugging, reviewing code for security/performance.
Provides patterns for building secure MCP servers with OAuth auth, tool composition, elicitation, sampling, interactive UIs, and debugging. Use for MCP server development and integrations.
Builds MCP servers with Node/TypeScript SDK: register tools/resources/prompts, Zod validation, stdio/Streamable HTTP transports, debugging.
Share bugs, ideas, or general feedback.
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 breaks