一键导入
mcp-builderadd-resource
Add a resource to your MCP server for agent context (schemas, templates, reference data)
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Add a resource to your MCP server for agent context (schemas, templates, reference data)
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Scaffold a new MCP server with your chosen pattern (basic, tool-heavy, widget-enabled, or database-backed)
Test your MCP server with MCP Inspector and verify tool functionality
Scaffold a complete MCP App with visual UI tools (TypeScript + React + Tailwind)
Add OAuth authentication to your MCP server using Auth0 or custom providers
Add a new tool to your MCP server using "true task" design principles
Generate deployment configuration for Cloud Run, Render, or Fly.io
| name | mcp-builder:add-resource |
| description | Add a resource to your MCP server for agent context (schemas, templates, reference data) |
You are helping the user add a resource to their MCP server. Resources provide context that agents can read before calling tools.
Resources are data the agent can READ to understand context:
| Use Case | Resource or Tool? |
|---|---|
| Agent needs to read a schema before querying | Resource |
| Agent needs to fetch live data | Tool |
| Agent needs reference documentation | Resource |
| Agent needs to perform an action | Tool |
Ask the user:
Common Resource Types:
| Type | URI Pattern | Example |
|---|---|---|
| Schema | schema://{name} | schema://database |
| Template | template://{name} | template://report |
| Reference | ref://{category}/{name} | ref://api/endpoints |
| Config | config://{name} | config://settings |
Python (FastMCP):
# Static resource
@mcp.resource("schema://database")
def get_database_schema() -> str:
"""Database schema for the task management system.
Read this before querying to understand table structure."""
return """
Tables:
- tasks (id, subject, content_md, status, due_at, assignee_id)
- users (id, email, name, role)
- comments (id, task_id, user_id, content, created_at)
Relationships:
- tasks.assignee_id -> users.id
- comments.task_id -> tasks.id
- comments.user_id -> users.id
"""
# Dynamic resource with template
@mcp.resource("template://task-report")
def get_task_report_template() -> str:
"""Template for generating task status reports."""
return """
# Task Report: {title}
## Summary
- Total Tasks: {total}
- Completed: {completed}
- In Progress: {in_progress}
- Pending: {pending}
## Details
{task_list}
"""
TypeScript (MCP SDK):
server.setRequestHandler(ListResourcesRequestSchema, async () => ({
resources: [
{
uri: "schema://database",
name: "Database Schema",
description: "Task management database structure",
mimeType: "text/plain",
},
],
}));
server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
const { uri } = request.params;
if (uri === "schema://database") {
return {
contents: [{
uri,
mimeType: "text/plain",
text: `Tables:\n- tasks (id, subject, status...)\n- users (id, email...)`,
}],
};
}
throw new Error(`Unknown resource: ${uri}`);
});
Add a clear description:
@mcp.resource("schema://database")
def get_database_schema() -> str:
"""Database schema for the task management system.
Read this resource before:
- Building database queries
- Understanding data relationships
- Validating user input
The schema includes tables, columns, types, and relationships.
"""
Resource (Schema):
@mcp.resource("schema://database")
def get_schema() -> str:
"""Returns the database schema for reference."""
return "Tables: tasks, users, comments..."
Tool (Query):
@mcp.tool()
def query_database(sql: str) -> str:
"""Execute a read-only SQL query against the database."""
return db.execute(sql)
Agent Workflow:
schema://database resourcequery_database toolschema://, template://, ref://After adding the resource, update .mcp-builder/state.json:
{
"resources": [
{ "uri": "schema://database", "name": "Database Schema" }
]
}