> ## Documentation Index
> Fetch the complete documentation index at: https://docs.leanmcp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Resources

> Expose data to AI agents

# Resources

Resources are **read-only but dynamic** data that applications can expose to AI agents. Unlike Tools (which perform actions), Resources provide contextual information that helps the AI understand your environment.

## How Resources Work

Resources are **application-driven** — the client application decides how to use them:

| Actor           | Control Type                       | Example                                   |
| --------------- | ---------------------------------- | ----------------------------------------- |
| **User**        | Selects which resources to include | "Add my calendar as context"              |
| **Application** | Decides how to consume resources   | Build embeddings, cache, transform        |
| **AI Model**    | Reads resource data                | Uses context to generate better responses |

<Info>
  **Client Support Matters**: Resources are only useful if the client application provides UI for users to select and manage them. If your client doesn't expose resource controls, users can't leverage this feature effectively.
</Info>

## Real-World Examples

Resources aren't just for code editors. They provide context in any domain:

| Use Case                      | Resource Examples                                       |
| ----------------------------- | ------------------------------------------------------- |
| **Coding (Cursor, Windsurf)** | Open files, project structure, git history              |
| **Travel Agent**              | Calendar schedule, travel preferences, past itineraries |
| **Customer Support**          | User profile, order history, support tickets            |
| **Research Assistant**        | PDF documents, bookmarks, notes                         |
| **Personal Assistant**        | Email drafts, contacts, reminders                       |

## Basic Resource

```typescript theme={null}
import { Resource } from "@leanmcp/core";

export class StatusService {
  // Function name "getServerStatus" becomes resource name
  @Resource({ description: "Server status", mimeType: "application/json" })
  getServerStatus() {
    return {
      status: "running",
      uptime: process.uptime(),
      memory: process.memoryUsage()
    };
  }
}
```

## Resource with Configuration

```typescript theme={null}
@Resource({ description: "System configuration", mimeType: "application/json" })
getConfig() {
  return {
    version: "1.0.0",
    environment: process.env.NODE_ENV,
    features: {
      analytics: true,
      notifications: true
    }
  };
}
```

## Async Resources

Resources can be async for database queries or API calls:

```typescript theme={null}
@Resource({ description: "Database statistics", mimeType: "application/json" })
async getDatabaseStats() {
  const stats = await db.getStats();
  return {
    connections: stats.connections,
    queries: stats.queryCount,
    uptime: stats.uptime
  };
}
```

## Resource with Dynamic Data

```typescript theme={null}
@Resource({ description: "Available models", mimeType: "application/json" })
getAvailableModels() {
  return {
    contents: [{
      uri: "models://available",
      mimeType: "application/json",
      text: JSON.stringify({
        "gpt-5.2": "Advanced reasoning",
        "gpt-5.2": "Fast, cost-effective",
        "gemini-pro": "Multimodal"
      })
    }]
  };
}
```

## The Three MCP Primitives

Understanding when to use each:

| Primitive     | Control            | Purpose                 | Example                            |
| ------------- | ------------------ | ----------------------- | ---------------------------------- |
| **Tools**     | Model-driven       | Actions the AI performs | Send email, create task, query API |
| **Resources** | Application-driven | Context data for AI     | Files, preferences, schedules      |
| **Prompts**   | User-driven        | Templates users invoke  | `/analyze`, `/review`, `/support`  |

## Next Steps

<CardGroup cols={2}>
  <Card title="Tools" icon="wrench" href="/core-concepts/tools">
    Create actions AI can execute
  </Card>

  <Card title="Prompts" icon="message" href="/core-concepts/prompts">
    Template prompts for AI
  </Card>
</CardGroup>
