supabase
Handles the full Supabase workflow from schema changes to deployment, with built-in security guardrails that catch common traps like RLS...
mcp-resource-exposure-patterns
Resources provide read-only context to Claude using URI-based identification. PROACTIVELY activate for: (1) exposing data as MCP resources, (2) URI scheme design, (3) list_resources implementation. Triggers: "mcp resources", "uri patterns", "read_resource"
Full skill instructions
Keywords: resources, uri, context provisioning, list_resources, read_resource
File Patterns: */resources/.py, **/providers.py
Modes: backend_python
Resources (app-controlled):
Tools (model-controlled):
Rule: If it's read-only context provisioning → Resource. If it performs an action → Tool.
Resources use URI schemes for identification:
# File resources
"file:///project/README.md"
"file:///docs/api/authentication.md"
# Database resources
"db:///schemas/users"
"db:///tables/orders/schema"
# API resources
"api:///endpoints/v1/users"
"api:///swagger.json"
# Log resources
"log:///app/2024-01-15"
"log:///errors/recent"
# Custom schemes
"config:///settings/database"
"metric:///cpu/usage"
from pydantic import BaseModel, ConfigDict
from typing import Literal
class ResourceDescriptor(BaseModel):
"""Resource metadata returned by list_resources."""
model_config = ConfigDict(strict=True)
uri: str
name: str
mimeType: str
description: str | None = None
@server.list_resources()
async def list_resources() -> list[dict]:
"""List all available resources."""
resources = []
# File-based resources
docs_dir = Path("docs")
if docs_dir.exists():
for md_file in docs_dir.rglob("*.md"):
resources.append(
ResourceDescriptor(
uri=f"file:///{md_file}",
name=md_file.stem,
mimeType="text/markdown",
description=f"Documentation: {md_file.stem}"
).model_dump()
)
# Database schema resources
db_schemas = await get_database_schemas()
for schema in db_schemas:
resources.append(
ResourceDescriptor(
uri=f"db:///schemas/{schema.name}",
name=f"{schema.name} Schema",
mimeType="application/json",
description=f"Database schema for {schema.name}"
).model_dump()
)
return resources
import aiofiles
from pathlib import Path
class ResourceContent(BaseModel):
"""Content returned by read_resource."""
model_config = ConfigDict(strict=True)
uri: str
text: str | None = None
blob: str | None = None # Base64 encoded binary
mimeType: str
@server.read_resource()
async def read_resource(uri: str) -> dict:
"""Read resource content by URI."""
# Validate URI scheme
if uri.startswith("file:///"):
return await read_file_resource(uri)
elif uri.startswith("db:///"):
return await read_database_resource(uri)
elif uri.startswith("log:///"):
return await read_log_resource(uri)
else:
raise ValueError(f"Unsupported URI scheme: {uri}")
async def read_file_resource(uri: str) -> dict:
"""Read file-based resource."""
# Security: validate path
path = uri.removeprefix("file://")
path = Path(path).resolve()
# Prevent path traversal
if ".." in str(path):
raise ValueError("Path traversal not allowed")
if not path.exists():
raise FileNotFoundError(f"Resource not found: {uri}")
# Async file reading
async with aiofiles.open(path, "r") as f:
content = await f.read()
return {
"contents": [
ResourceContent(
uri=uri,
text=content,
mimeType=get_mime_type(path)
).model_dump()
]
}
@server.list_resources()
async def list_resources() -> list[dict]:
"""List resources with dynamic content."""
# Current date logs (past 7 days)
resources = []
for days_ago in range(7):
date = datetime.now() - timedelta(days=days_ago)
date_str = date.strftime("%Y-%m-%d")
resources.append(
ResourceDescriptor(
uri=f"log:///app/{date_str}",
name=f"App Logs - {date_str}",
mimeType="text/plain",
description=f"Application logs for {date_str}"
).model_dump()
)
return resources
@server.read_resource()
async def read_resource(uri: str) -> dict:
"""Read dynamic log resource."""
if uri.startswith("log:///app/"):
date_str = uri.removeprefix("log:///app/")
log_content = await fetch_logs_for_date(date_str)
return {
"contents": [
ResourceContent(
uri=uri,
text=log_content,
mimeType="text/plain"
).model_dump()
]
}
import mimetypes
def get_mime_type(path: Path) -> str:
"""Determine MIME type from file extension."""
mime_type, _ = mimetypes.guess_type(str(path))
# Fallback mapping
if mime_type is None:
extension_map = {
".md": "text/markdown",
".json": "application/json",
".yaml": "text/yaml",
".yml": "text/yaml",
".log": "text/plain",
".sql": "application/sql"
}
mime_type = extension_map.get(path.suffix, "text/plain")
return mime_type
from pathlib import Path
class UriValidator:
"""Validate resource URIs for security."""
@staticmethod
def validate_file_uri(uri: str, allowed_roots: list[Path]) -> Path:
"""Validate file URI against allowed roots."""
path = uri.removeprefix("file://")
resolved = Path(path).resolve()
# Check path traversal
if ".." in str(path):
raise ValueError("Path traversal not allowed")
# Check against allowed roots
if not any(resolved.is_relative_to(root) for root in allowed_roots):
raise ValueError(f"Access denied: {uri}")
return resolved
# Usage
@server.read_resource()
async def read_resource(uri: str) -> dict:
if uri.startswith("file:///"):
allowed_roots = [
Path("/project/docs"),
Path("/project/config")
]
path = UriValidator.validate_file_uri(uri, allowed_roots)
# Proceed with reading
import base64
async def read_binary_resource(uri: str) -> dict:
"""Read binary resource (images, PDFs, etc.)."""
path = Path(uri.removeprefix("file://"))
async with aiofiles.open(path, "rb") as f:
binary_content = await f.read()
# Base64 encode binary data
encoded = base64.b64encode(binary_content).decode("utf-8")
return {
"contents": [
ResourceContent(
uri=uri,
blob=encoded, # Use blob for binary
mimeType=get_mime_type(path)
).model_dump()
]
}
@server.read_resource()
async def read_resource(uri: str) -> dict:
"""Read database schema resource."""
if uri.startswith("db:///schemas/"):
table_name = uri.removeprefix("db:///schemas/")
# Fetch schema asynchronously
schema = await fetch_table_schema(table_name)
schema_json = {
"table": table_name,
"columns": [
{
"name": col.name,
"type": col.type,
"nullable": col.nullable,
"primary_key": col.primary_key
}
for col in schema.columns
]
}
return {
"contents": [
ResourceContent(
uri=uri,
text=json.dumps(schema_json, indent=2),
mimeType="application/json"
).model_dump()
]
}
❌ Using Tools for Read-Only Operations
# WRONG - should be a resource
@server.call_tool()
async def call_tool(name, args):
if name == "read_docs": # This should be a resource!
return await read_documentation()
❌ Missing URI Validation
# WRONG - security risk
path = uri.removeprefix("file://")
content = open(path).read() # No validation!
❌ Synchronous File I/O
# WRONG - blocking operation
with open(path, "r") as f: # Should use aiofiles
content = f.read()
❌ Hardcoded Resource List
# WRONG - not dynamic
@server.list_resources()
async def list_resources():
return [{"uri": "file:///README.md"}] # Should scan filesystem
MCP Resources Spec: https://spec.modelcontextprotocol.io/specification/server/resources/ aiofiles Docs: https://github.com/Tinche/aiofiles URI RFC: https://datatracker.ietf.org/doc/html/rfc3986
Handles the full Supabase workflow from schema changes to deployment, with built-in security guardrails that catch common traps like RLS...
Comprehensive guides and best practices for Neon Serverless Postgres, covering setup, connection methods, authentication, and platform APIs.
Guide for setting up and using Firebase Authentication. Use this skill when the user's app requires user sign-in, user management, or secure data access using auth rules.
A skill to evaluate how secure Firestore security rules are. Use this when Firestore security rules are updated to ensure that the generated rules are extremely secure and robust.
Official skill for integrating Firebase AI Logic (Gemini API) into web applications. Covers setup, multimodal inference, structured output, and security.
Complete Better Auth server and client setup with database adapters, session management, plugins, and security configuration.
Deploy and manage projects on Vercel using token-based authentication. Use when working with Vercel CLI using access tokens rather than interactive login — e.g. "deploy to vercel", "set up vercel", "add environment variables to vercel".
Complete Cloudflare platform integration with decision trees for compute, storage, AI, networking, security, and infrastructure-as-code.
Run Azure compliance and security audits with azqr plus Key Vault expiration checks. Covers best-practice assessment, resource review, policy/compliance validation, and security posture checks. WHEN: compliance scan, security audit, BEFORE running azqr (compliance cli tool), Azure best practices, Key Vault expiration check, expired certificates, expiring secrets, orphaned resources, compliance assessment.
Send, read, and manage Gmail messages, drafts, labels, and account settings.
Comprehensive website auditing across 230+ rules in 21 categories including SEO, performance, security, and accessibility.
Shared authentication, CLI syntax, and output formatting patterns for gws Google Workspace commands.
Discover your celebrity doppelgänger with StarByFace!
GeoSpy: Pricing, Features, FAQs, and Alternatives for AI Teams
Detect AI-generated voices to protect against audio fraud.
Ensure Your Content's Originality with AI Plagiarism Checker
Upscale images by 400% without quality loss
Protect your social media from copyright disputes
Accurately Detect AI-Generated Content with TheChecker.AI
Chrome extension that detects and flags AI-generated content