Skip to main content
Glama

prompt_from_file

Generate responses from multiple LLM models by sending a prompt stored in a file. Specify the absolute file path and optional models to streamline model testing and integration.

Instructions

Send a prompt from a file to multiple LLM models. IMPORTANT: You MUST provide an absolute file path (e.g., /path/to/file or C:\path\to\file), not a relative path.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
abs_file_pathYesAbsolute path to the file containing the prompt (must be an absolute path, not relative)
models_prefixed_by_providerNoList of models with provider prefixes (e.g., 'openai:gpt-4o' or 'o:gpt-4o'). If not provided, uses default models.

Implementation Reference

  • Core handler function that reads the content from the specified absolute file path, validates the file, and delegates to the prompt function with multiple models.
    def prompt_from_file(abs_file_path: str, models_prefixed_by_provider: List[str] = None) -> List[str]:
        """
        Read text from a file and send it as a prompt to multiple models.
        
        Args:
            abs_file_path: Absolute path to the text file (must be an absolute path, not relative)
            models_prefixed_by_provider: List of model strings in format "provider:model"
                                        If None, uses the DEFAULT_MODELS environment variable
            
        Returns:
            List of responses from the models
        """
        file_path = Path(abs_file_path)
        
        # Validate file
        if not file_path.exists():
            raise FileNotFoundError(f"File not found: {abs_file_path}")
        
        if not file_path.is_file():
            raise ValueError(f"Not a file: {abs_file_path}")
        
        # Read file content
        try:
            with open(file_path, 'r', encoding='utf-8') as f:
                text = f.read()
        except Exception as e:
            logger.error(f"Error reading file {abs_file_path}: {e}")
            raise ValueError(f"Error reading file: {str(e)}")
        
        # Send prompt with file content
        return prompt(text, models_prefixed_by_provider)
  • Pydantic input schema for validating the tool arguments: absolute file path and optional list of models.
    class PromptFromFileSchema(BaseModel):
        abs_file_path: str = Field(..., description="Absolute path to the file containing the prompt (must be an absolute path, not relative)")
        models_prefixed_by_provider: Optional[List[str]] = Field(
            None, 
            description="List of models with provider prefixes (e.g., 'openai:gpt-4o' or 'o:gpt-4o'). If not provided, uses default models."
        )
  • MCP Tool registration in the list_tools() method, specifying name, description, and input schema.
    Tool(
        name=JustPromptTools.PROMPT_FROM_FILE,
        description="Send a prompt from a file to multiple LLM models. IMPORTANT: You MUST provide an absolute file path (e.g., /path/to/file or C:\\path\\to\\file), not a relative path.",
        inputSchema=PromptFromFileSchema.schema(),
    ),
  • Dispatch handler in the MCP call_tool method that invokes the prompt_from_file function and formats the responses as TextContent.
    elif name == JustPromptTools.PROMPT_FROM_FILE:
        models_to_use = arguments.get("models_prefixed_by_provider")
        responses = prompt_from_file(arguments["abs_file_path"], models_to_use)
        
        # Get the model names that were actually used
        models_used = models_to_use if models_to_use else [model.strip() for model in os.environ.get("DEFAULT_MODELS", DEFAULT_MODEL).split(",")]
        
        return [TextContent(
            type="text",
            text="\n".join([f"Model: {models_used[i]}\nResponse: {resp}" 
                          for i, resp in enumerate(responses)])
        )]
  • Tool name constant definition in JustPromptTools enum-like class.
    PROMPT_FROM_FILE = "prompt_from_file"
Behavior3/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. It adds value by specifying the absolute path requirement and hinting at default model behavior if 'models_prefixed_by_provider' is not provided. However, it lacks details on error handling, rate limits, authentication needs, or output format, leaving gaps in behavioral transparency for a tool that interacts with LLMs.

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

Conciseness5/5

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

The description is appropriately sized and front-loaded, with two sentences that directly convey the tool's purpose and a critical requirement. Every sentence earns its place by providing essential information without redundancy, making it efficient and easy to parse.

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

Completeness3/5

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

Given the tool's moderate complexity (interacting with LLMs), no annotations, and no output schema, the description is incomplete. It covers the basic operation and path requirement but lacks details on output format, error handling, or model behavior, which are important for effective use. This is adequate as a minimum viable description but has clear gaps.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description adds minimal semantic context beyond the schema, such as emphasizing the absolute path requirement and giving examples for model prefixes. This meets the baseline of 3, as the schema does the heavy lifting, but doesn't provide significant additional meaning.

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

Purpose4/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: 'Send a prompt from a file to multiple LLM models.' It specifies the verb ('send'), resource ('prompt from a file'), and target ('multiple LLM models'), making it easy to understand what the tool does. However, it doesn't explicitly differentiate from sibling tools like 'prompt' or 'prompt_from_file_to_file', which would require a 5.

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

Usage Guidelines3/5

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

The description provides some usage guidance by emphasizing the requirement for an absolute file path, but it doesn't explicitly state when to use this tool versus alternatives like 'prompt' (which might accept direct text input) or 'prompt_from_file_to_file' (which might output to a file). The guidance is implied rather than explicit, falling short of the highest scores.

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

Related 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/disler/just-prompt'

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