ActionMCP::Prompt
# ActionMCP::Prompt
## Overview
ActionMCP::Prompt provides a framework for creating reusable prompt templates that can be used with LLMs. Each prompt
defines required and optional arguments, and generates messages that guide the LLM conversation with support for
multiple content types including text, images, audio, and resources.
## Core Components
### Prompt Definition
- Each prompt is a Ruby class inheriting from `ApplicationMCPPrompt`
- Required elements:
- `description`: Explain what the prompt does
- `argument`: Define expected inputs with descriptions, requirements, and possible constraints
- `perform`: Core logic that executes the prompt's function
### Callbacks
ActionMCP::Prompt supports callbacks that run around the `perform` method, allowing you to:
- Validate or transform arguments before processing
- Perform pre-processing actions before the main logic executes
- Handle post-processing of results after the main logic completes
- Check for malicious input or implement security measures
- Add logging or instrumentation around prompt execution
These callbacks provide powerful hooks to extend and customize prompt behavior without modifying the core logic.
### Adding Content to Prompts
Use these methods to structure the prompt interaction with various content types:
#### Adding Messages via Render
- `render(text: "message")`: Add a user message with text content
- `render(text: "message", role: :assistant)`: Add an assistant message with text content
- `render(image: "base64_data", mime_type: "image/png")`: Add an image to the conversation
- `render(audio: "base64_data", mime_type: "audio/mpeg")`: Add audio content
- `render(resource: "file://path/to/resource", mime_type: "application/json", text: "{}")`: Add a resource with text
content
- `render(resource: "file://path/to/resource", mime_type: "application/octet-stream", blob: "base64_data")`: Add a
resource with binary content
#### Adding Messages Directlywhen to use it
Community prompt sourced from the open-source GitHub repo seuros/action_mcp (MIT). A "ActionMCP::Prompt" style prompt — adapt the placeholders and specifics to your task. Imported as-is and not independently retested here, so check the output before relying on it.
tags
roleplaycommunitygeneral
source
seuros/action_mcp · MIT