Skip to content

Add get prompt with arguments functionality #13

@kashifpk

Description

@kashifpk

Summary

Add the ability to get/execute prompts with arguments, not just list them.

Background

Currently Anvil can list available prompts but cannot retrieve prompt content with arguments. The MCP protocol supports prompts/get to fetch rendered prompt content.

Proposed Implementation

CLI

# Get a prompt (no arguments)
anvil get-prompt "code-review"

# Get a prompt with arguments
anvil get-prompt "code-review" --arg language=python --arg style=detailed

# With JSON arguments
anvil get-prompt "summarize" --json-args '{"text": "...", "length": "short"}'

# JSON output
anvil get-prompt "code-review" --json

Web UI

  • Add "Get" or "Execute" button for each prompt in the list
  • When clicked, show a form with argument fields (similar to tools)
  • Display the rendered prompt content (messages array)
  • Include description and any metadata

Technical Implementation

async def get_prompt(self, name: str, arguments: dict[str, str] | None = None) -> dict[str, Any]:
    """Get prompt content with optional arguments."""
    async with Client(self.server_url) as client:
        result = await client.get_prompt(name, arguments or {})
        return {
            "description": result.description,
            "messages": [
                {
                    "role": msg.role,
                    "content": _content_to_list(msg.content),
                }
                for msg in result.messages
            ],
        }

Acceptance Criteria

  • CLI command anvil get-prompt <name> implemented
  • Support for --arg key=value arguments
  • Support for --json-args for complex arguments
  • Web UI shows argument form based on prompt schema
  • Rendered messages displayed clearly
  • Error handling for missing required arguments

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions