Skip to main content
Glama

execute_prompt_with_llm

Execute prompts with LLMs by retrieving templates from MCP servers, filling variables, and returning structured responses with metadata for testing workflows.

Instructions

Execute a prompt with an LLM and return the response.

This tool performs the complete workflow:

  1. Retrieves the prompt from the connected MCP server with prompt_arguments

  2. Optionally fills template variables in the prompt messages

  3. Sends the prompt messages to an LLM

  4. Returns the LLM's response along with metadata

Supports two prompt patterns:

  • Standard MCP prompts: Pass arguments via prompt_arguments, server handles substitution

  • Template variables: Use fill_variables to replace {variable} placeholders in messages

Args: prompt_name: Name of the prompt to execute prompt_arguments: Dictionary of arguments to pass to the MCP prompt (default: {}) fill_variables: Dictionary of template variables to fill in prompt messages (default: None) Used for manual string replacement of {variable_name} patterns. Values are JSON-serialized before substitution if they're not strings. llm_config: Optional LLM configuration with keys: - url: LLM endpoint URL (default: from LLM_URL env var) - model: Model name (default: from LLM_MODEL_NAME env var) - api_key: API key (default: from LLM_API_KEY env var) - max_tokens: Maximum tokens in response (default: 1000) - temperature: Sampling temperature (default: 0.7)

Returns: Dictionary with execution results including: - success: True if execution succeeded - prompt: Original prompt information - llm_request: The request sent to the LLM - llm_response: The LLM's response - parsed_response: Attempted JSON parsing if response looks like JSON - metadata: Timing and configuration information

Raises: Returns error dict for various failure scenarios: - not_connected: No active MCP connection - prompt_not_found: Prompt doesn't exist - llm_config_error: Missing or invalid LLM configuration - llm_request_error: LLM request failed

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
prompt_nameYesName of the prompt to execute
prompt_argumentsNoArguments to pass to the MCP prompt (JSON object or string)
fill_variablesNoTemplate variables to fill in prompt messages (JSON object or string)
llm_configNoLLM configuration (url, model, api_key, etc.)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure and does so comprehensively. It details the complete 4-step workflow, explains error scenarios (raises section), describes the return structure, and mentions environmental variable defaults for LLM configuration.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with clear sections (workflow, patterns, args, returns, raises) and efficiently conveys complex information. While comprehensive, some sections like the detailed llm_config defaults could be slightly more concise, but overall it earns its length.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (4 parameters, workflow with multiple steps) and the presence of an output schema, the description is complete. It covers purpose, usage patterns, parameter semantics, return structure, and error conditions, providing everything needed for effective tool invocation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The description adds significant value beyond the 100% schema coverage by explaining the purpose and interaction of parameters. It clarifies that prompt_arguments are for MCP server substitution while fill_variables are for manual template replacement, and details the structure and defaults of llm_config. The only minor gap is not explicitly stating prompt_name is required.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('execute a prompt with an LLM and return the response') and distinguishes it from siblings by detailing its unique workflow. It explicitly mentions retrieving prompts from an MCP server, which differentiates it from generic LLM tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for usage by explaining the two prompt patterns (standard MCP prompts and template variables) and when to use each. However, it doesn't explicitly mention when NOT to use this tool or name specific alternatives among the sibling tools.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/rdwj/mcp-test-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server