Besides tools, MCP offers two more capabilities: Resources (providing data) and Prompts (predefined interaction patterns). Together they form a complete ecosystem for AI model integration.
Resources are data an MCP server makes available to the client. Unlike tools, which are actively called, resources are passive — they provide context.
server.resource(
"docs://api-reference",
"API documentation for the product",
async () => ({
contents: [{
uri: "docs://api-reference",
text: apiDocumentation,
mimeType: "text/markdown"
}]
})
);
server.resource(
"data://sales/{period}",
"Sales data for a time period",
async (uri) => {
const period = uri.pathname.split("/").pop();
const data = await db.query(`SELECT * FROM sales WHERE period = ?`, [period]);
return {
contents: [{
uri: uri.href,
text: JSON.stringify(data),
mimeType: "application/json"
}]
};
}
);
| Type | URI Schema | Example |
|---|---|---|
| Files | file:// | file:///docs/readme.md |
| Database | db:// | db://users/123 |
| API | api:// | api://weather/berlin |
| Config | config:// | config://app/settings |
| Custom | Own schema | crm://contacts/active |
Prompts are predefined interaction patterns provided by the server. The client can request them and offer them to the user.
server.prompt(
"code_review",
"Perform code review with best practices",
{
code: z.string().describe("The code to review"),
language: z.string().describe("Programming language"),
focus: z.enum(["security", "performance", "readability"]).optional()
},
async ({ code, language, focus }) => ({
messages: [{
role: "user",
content: {
type: "text",
text: [
`Perform a code review for the following ${language} code.`,
focus ? `Focus especially on: ${focus}` : "",
`\n\n\`\`\`${language}\n${code}\n\`\`\``,
"\nEvaluate: correctness, best practices, potential bugs, improvement suggestions."
].join("\n")
}
}]
})
);
// Client side
const { prompts } = await client.listPrompts();
// Request prompt
const result = await client.getPrompt({
name: "code_review",
arguments: {
code: "function add(a, b) { return a + b }",
language: "javascript",
focus: "readability"
}
});
MCP supports sampling — the server can request the AI model via the client:
Server → Client: "Analyze this data"
Client → AI Model → Client → Server: "Analysis result"
This enables server-side workflows that use the AI model as a reasoning engine.
// Only load relevant resources
const resources = await client.listResources();
const relevant = resources.filter(r =>
r.uri.includes(currentTopic)
);
for (const resource of relevant) {
const content = await client.readResource(resource.uri);
context.push(content);
}
Practical tip: Resources are excellent for documentation, configuration, and reference data. Prompts standardize recurring interaction patterns. Use both to make your MCP server valuable beyond pure tool integration.