Resources
Create and register custom resources with the ISA MCP platform.
Overview
Resources are read-only data sources accessible via URI patterns. The platform includes 9 built-in resource types.
Resource Types
| Resource | URI Pattern | Description |
|---|---|---|
| Data Analytics | analytics://... | Analytics data access |
| Digital | digital://... | Digital content |
| Graph Knowledge | graph://... | Knowledge graph data |
| Guardrail | guardrail://... | Safety/policy resources |
| Process | process://... | Process definitions |
| Skill | skill://... | Skill definitions |
| Vibe Skill | vibe://... | Vibe skill workflows |
| Symbolic Model | model://... | Model definitions |
Creating Custom Resources
Simple Pattern
# resources/my_resources.py
from mcp.server.fastmcp import FastMCP
from datetime import datetime
def register_my_resources(mcp: FastMCP):
"""Register custom resources."""
@mcp.resource("config://settings/{key}")
async def get_config(key: str) -> str:
"""
Get configuration value by key.
Returns configuration data for the specified key.
"""
configs = {
"app_name": "ISA Platform",
"version": "1.0.0",
"environment": "production"
}
if key in configs:
return f"""# Configuration: {key}
**Value**: {configs[key]}
**Retrieved**: {datetime.now().isoformat()}
"""
return f"# Configuration Not Found: {key}"
@mcp.resource("status://health")
async def get_health_status() -> str:
"""Get system health status."""
return """# System Health
**Status**: Healthy
**Uptime**: 99.9%
**Last Check**: Now
"""
print("Custom resources registered")Using BaseResource Class
For advanced resources with security and formatting:
from resources.base_resource import BaseResource
from core.security import SecurityLevel
class DataResources(BaseResource):
def __init__(self):
super().__init__()
def register_all_resources(self, mcp):
# Low security - public data
self.register_resource(
mcp,
"data://public/{dataset}",
self.get_public_data,
security_level=SecurityLevel.LOW
)
# High security - sensitive data
self.register_resource(
mcp,
"data://private/{dataset}",
self.get_private_data,
security_level=SecurityLevel.HIGH
)
async def get_public_data(self, dataset: str) -> str:
data = await self.fetch_dataset(dataset)
return self.create_success_response(data)
async def get_private_data(self, dataset: str) -> str:
data = await self.fetch_secure_dataset(dataset)
return self.create_success_response(data)
def register_data_resources(mcp):
resources = DataResources()
resources.register_all_resources(mcp)URI Patterns
Resources use URI templates with path parameters:
| Pattern | Example | Parameters |
|---|---|---|
type://fixed | status://health | None |
type://{param} | user://{id} | id |
type://{a}/{b} | data://{category}/{id} | a, b |
BaseResource Features
Response Helpers
# Success response
return self.create_success_response(
data={"key": "value"},
uri="resource://uri"
)
# Error response
return self.create_error_response(
uri="resource://uri",
error_message="Something went wrong"
)
# Not found response
return self.create_not_found_response(
uri="resource://uri",
resource_type="dataset"
)Security Levels
from core.security import SecurityLevel
# Available levels
SecurityLevel.LOW # Public access
SecurityLevel.MEDIUM # Authenticated users
SecurityLevel.HIGH # Authorized users only
SecurityLevel.CRITICAL # Admin onlyDecorator Pattern
Quick resource definition:
from resources.base_resource import simple_resource
from core.security import SecurityLevel
@simple_resource("cache://data/{key}", SecurityLevel.LOW)
async def get_cached_data(key: str) -> str:
return f"Cached value for {key}"Resource Response Formats
Markdown (Recommended)
async def get_report(id: str) -> str:
return f"""# Report: {id}
## Summary
This is the report summary.
## Details
- Item 1
- Item 2
## Metadata
**Generated**: {datetime.now().isoformat()}
"""JSON
async def get_data(id: str) -> str:
import json
return json.dumps({
"id": id,
"data": {"key": "value"}
}, indent=2)Best Practices
- URI design - Use clear, hierarchical patterns
- Security levels - Apply appropriate access controls
- Response format - Use markdown for human-readable, JSON for structured
- Error handling - Use helper methods for consistent errors
- Documentation - Include docstrings for discovery
Accessing Resources
# Client code
result = await client.read_resource("config://settings/app_name")
print(result)