Resources Overview
Expose read-only data to your AI agents through the MCP resource system.
What are Resources?
Resources are read-only data sources exposed via the Model Context Protocol (MCP). They allow your AI agents to access structured data without modifying it. Resources can represent anything from database tables and files to external API responses and computed data.
Agent Dojo supports the following resource types:
databaseQuery results from a database table or view
fileContents of a file or document
apiResponse from an external API endpoint
staticFixed content that rarely changes
dynamicContent generated on each read request
functionOutput of a serverless function invocation
Resource Properties
Every resource has the following properties:
| Property | Type | Description |
|---|---|---|
| id | string | Unique identifier (UUID), auto-generated |
| server_id | string | ID of the server this resource belongs to |
| name | string | Human-readable name for the resource |
| uri | string | Unique URI identifying the resource (e.g., db://users) |
| description | string | Brief description of the resource and its contents |
| mime_type | string | MIME type of the resource content (e.g., application/json) |
| resource_type | string | One of: database, file, api, static, dynamic, function |
| requires_credentials | boolean | Whether the resource needs credentials to be read |
| cache_ttl_seconds | number | How long to cache the resource content (in seconds) |
| is_active | boolean | Whether the resource is currently active and available |
Registering a Resource
Register a new resource by sending a POST request to the resources endpoint:
curl -X POST https://api.agentdojo.dev/mcp/resources \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"server_id": "srv_001",
"name": "User Directory",
"uri": "db://users",
"description": "Read-only access to the user directory",
"mime_type": "application/json",
"resource_type": "database",
"requires_credentials": false,
"cache_ttl_seconds": 300,
"is_active": true
}'Listing Resources
List all resources registered on a server:
curl -X POST https://api.agentdojo.dev/mcp/resources/list \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"server_id": "srv_001"
}'Response:
{
"resources": [
{
"uri": "db://users",
"name": "User Directory",
"description": "Read-only access to the user directory",
"mimeType": "application/json"
}
]
}Reading a Resource
Read the contents of a specific resource by providing its URI:
curl -X POST https://api.agentdojo.dev/mcp/resources/read \
-H "X-API-Key: your-api-key" \
-H "Content-Type: application/json" \
-d '{
"uri": "db://users"
}'Response:
{
"contents": [
{
"uri": "db://users",
"mimeType": "application/json",
"text": "[{\"id\": 1, \"name\": \"Alice\"}, {\"id\": 2, \"name\": \"Bob\"}]"
}
]
}Via MCP Protocol
Resources are also accessible through the standard MCP JSON-RPC protocol. AI agents typically use these methods to discover and read resources.
resources/list
{
"jsonrpc": "2.0",
"id": 1,
"method": "resources/list"
}resources/read
{
"jsonrpc": "2.0",
"id": 2,
"method": "resources/read",
"params": {
"uri": "db://users"
}
}