> ## 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.

# Prompts

> Template prompts for AI agents

# Prompts

Prompts are **user-driven** templates that provide shortcuts and working examples for AI interactions. They help users get started quickly without figuring out the right way to phrase requests.

## How Prompts Work

Prompts can be consumed in two ways, depending on how the client is built:

| Mode               | Who Triggers                 | How It Works                                                          |
| ------------------ | ---------------------------- | --------------------------------------------------------------------- |
| **User-Invoked**   | User explicitly selects      | Slash commands (`/analyze`), dropdown menus, keyboard shortcuts       |
| **Agent-Selected** | AI agent picks automatically | Agent browses available prompts and selects the best one for the task |

<Info>
  **Client Implementation Matters**: Whether prompts are user-invoked or agent-selected depends entirely on how the client application is developed. Some clients expose prompts as slash commands, others let the AI agent discover and use them automatically.
</Info>

## When to Use Prompts

* **Provide examples** of how to use your MCP server effectively
* **Create shortcuts** for common workflows users perform repeatedly
* **Include dynamic context** that would be tedious to type manually
* **Onboard new users** with working examples they can invoke immediately

## Basic Prompt

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

export class PromptService {
  @Prompt({ description: "Customer support assistant" })
  supportAssistant() {
    return {
      messages: [{
        role: "user",
        content: {
          type: "text",
          text: "You are a helpful customer support agent. Be polite and helpful."
        }
      }]
    };
  }
}
```

## Prompt with Arguments

```typescript theme={null}
import { Prompt, SchemaConstraint } from "@leanmcp/core";

class CodeReviewInput {
  @SchemaConstraint({ description: "Code to review" })
  code!: string;

  @SchemaConstraint({ description: "Programming language" })
  language!: string;
}

export class CodeService {
  @Prompt({ description: "Generate code review prompt" })
  codeReview(input: CodeReviewInput) {
    return {
      messages: [{
        role: "user",
        content: {
          type: "text",
          text: `Review this ${input.language} code for bugs, style, and best practices:\n\n${input.code}`
        }
      }]
    };
  }
}
```

## Multi-message Prompt

Set up a conversation with context:

```typescript theme={null}
@Prompt({ description: "Code review conversation" })
codeReviewer() {
  return {
    messages: [
      {
        role: "user",
        content: { type: "text", text: "You are a senior code reviewer." }
      },
      {
        role: "assistant", 
        content: { type: "text", text: "I'll review the code for bugs, style, and best practices." }
      }
    ]
  };
}
```

## Specialized Prompts

```typescript theme={null}
@Prompt({ description: "SQL query generator" })
sqlHelper(input: { schema: string }) {
  return {
    messages: [{
      role: "user",
      content: {
        type: "text",
        text: `You are a SQL expert. Generate queries for this schema:\n\n${input.schema}`
      }
    }]
  };
}

@Prompt({ description: "API documentation writer" })
apiDocWriter() {
  return {
    messages: [{
      role: "user",
      content: {
        type: "text",
        text: "You write clear, concise API documentation with examples."
      }
    }]
  };
}
```

## 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="Resources" icon="database" href="/core-concepts/resources">
    Expose data to AI agents
  </Card>
</CardGroup>
