Resources & Prompts

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:

database

Query results from a database table or view

file

Contents of a file or document

api

Response from an external API endpoint

static

Fixed content that rarely changes

dynamic

Content generated on each read request

function

Output of a serverless function invocation

Resource Properties

Every resource has the following properties:

PropertyTypeDescription
idstringUnique identifier (UUID), auto-generated
server_idstringID of the server this resource belongs to
namestringHuman-readable name for the resource
uristringUnique URI identifying the resource (e.g., db://users)
descriptionstringBrief description of the resource and its contents
mime_typestringMIME type of the resource content (e.g., application/json)
resource_typestringOne of: database, file, api, static, dynamic, function
requires_credentialsbooleanWhether the resource needs credentials to be read
cache_ttl_secondsnumberHow long to cache the resource content (in seconds)
is_activebooleanWhether 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"
  }
}

Next Steps