Skip to main content
Glama
ChronulusAI

Chronulus MCP Server

Official

save_forecast

Saves Chronulus forecast data and explanations to CSV and TXT files for analysis and reference, with optional rescaling capabilities.

Instructions

A tool that saves a Chronulus forecast from NormalizedForecaster to separate CSV and TXT files

When to use this tool:

  • Use this tool when you need to save both the forecast data and its explanation to files

  • The forecast data will be saved as a CSV file for data analysis

  • The forecast explanation will be saved as a TXT file for reference

  • Both files will be saved in the same directory specified by output_path

  • This tool can also be used to directly save rescaled predictions without first calling the rescaling tool

How to use this tool:

  • Provide the prediction_id from a previous forecast

  • Specify the output_path where both files should be saved

  • Provide csv_name for the forecast data file (must end in .csv)

  • Provide txt_name for the explanation file (must end in .txt)

  • Optionally provide y_min and y_max to rescale the predictions (defaults to 0)

  • Set invert_scale to True if the target units run in the opposite direction

  • The tool will provide status updates through the MCP context

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
prediction_idYesThe prediction_id from a prediction result
output_pathYesThe path where the CSV file should be saved. Should end in .csv
csv_nameYesThe path where the CSV file should be saved. Should end in .csv
txt_nameYesThe name of the TXT file to be saved. Should end in .txt
y_minNoThe expected smallest value for the use case. E.g., for product sales, 0 would be the least possible value for sales.
y_maxNoThe expected largest value for the use case. E.g., for product sales, 0 would be the largest possible value would be given by the user or determined from this history of sales for the product in question or a similar product.
invert_scaleNoSet this flag to true if the scale of the new units will run in the opposite direction from the inputs.

Implementation Reference

  • The handler function that executes the save_forecast tool: fetches the normalized forecast by prediction_id, rescales it using provided y_min/y_max/invert_scale, saves the rescaled data to CSV and the original text explanation to TXT, returns confirmation message.
    async def save_forecast(
        prediction_id: Annotated[str, Field(description="The prediction_id from a prediction result")],
        output_path: Annotated[str, Field(description="The path where the CSV file should be saved. Should end in .csv")],
        csv_name: Annotated[str, Field(description="The path where the CSV file should be saved. Should end in .csv")],
        txt_name: Annotated[str, Field(description="The name of the TXT file to be saved. Should end in .txt")],
        ctx: Context,
        y_min: Annotated[float, Field(default=0.0, description="The expected smallest value for the use case. E.g., for product sales, 0 would be the least possible value for sales.")],
        y_max: Annotated[float, Field(default=1.0, description="The expected largest value for the use case. E.g., for product sales, 0 would be the largest possible value would be given by the user or determined from this history of sales for the product in question or a similar product.")],
        invert_scale: Annotated[bool, Field(default=False, description="Set this flag to true if the scale of the new units will run in the opposite direction from the inputs.")],
    ) -> str:
        """Saves the forecast from a NormalizedForecaster agent to CSV and the explanation to TXT
    
        Args:
            prediction_id (str): The prediction_id for the prediction you would like to rescale as returned by the forecasting agent
            output_path (str): The path where the CSV and TXT file should be saved.
            csv_name (str): The name of the CSV file to be saved. Should end in .csv
            txt_name (str): The name of the TXT file to be saved. Should end in .txt
            ctx (Context): Context object providing access to MCP capabilities.
            y_min (float): The expected smallest value for the use case. E.g., for product sales, 0 would be the least possible value for sales.
            y_max (float): The expected largest value for the use case. E.g., for product sales, 0 would be the largest possible value would be given by the user or determined from this history of sales for the product in question or a similar product.
            invert_scale (bool): Set this flag to true if the scale of the new units will run in the opposite direction from the inputs.
    
    
        Returns:
            str: A message confirming the file was saved and its location
        """
        # Get normalized forecast and rescale it
        _ = await ctx.info(f"Fetching prediction data for {prediction_id}")
        normalized_forecast = NormalizedForecaster.get_prediction_static(prediction_id, verbose=False)
        rescaled_forecast = RescaledForecast.from_forecast(
            forecast=normalized_forecast,
            y_min=y_min,
            y_max=y_max,
            invert_scale=invert_scale
        )
    
        # Convert to pandas using built-in method
        df = rescaled_forecast.to_pandas()
    
        # Save to CSV
        df.to_csv(os.path.join(output_path, csv_name), index_label="ds")
    
        with open(os.path.join(output_path, txt_name), "w") as f:
            f.write(normalized_forecast.text)
    
        return f"Forecast saved successfully to {output_path}"
  • Registers the save_forecast function as an MCP tool with its description.
    mcp.add_tool(save_forecast, description=SAVE_FORECAST_DESCRIPTION)
  • Tool description providing usage instructions and parameter explanations, used in registration.
    SAVE_FORECAST_DESCRIPTION = """
    A tool that saves a Chronulus forecast from NormalizedForecaster to separate CSV and TXT files
    
    When to use this tool:
    - Use this tool when you need to save both the forecast data and its explanation to files
    - The forecast data will be saved as a CSV file for data analysis
    - The forecast explanation will be saved as a TXT file for reference
    - Both files will be saved in the same directory specified by output_path
    - This tool can also be used to directly save rescaled predictions without first calling the rescaling tool
    
    How to use this tool:
    - Provide the prediction_id from a previous forecast
    - Specify the output_path where both files should be saved
    - Provide csv_name for the forecast data file (must end in .csv)
    - Provide txt_name for the explanation file (must end in .txt)
    - Optionally provide y_min and y_max to rescale the predictions (defaults to 0)
    - Set invert_scale to True if the target units run in the opposite direction
    - The tool will provide status updates through the MCP context
    """
  • Imports the save_forecast function from io.py for use in this module.
    from .io import save_forecast, save_prediction_analysis_html
Behavior4/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 effectively describes key behaviors: it saves files to a specified directory, handles optional rescaling parameters, provides status updates via MCP context, and explains the dual-file output (CSV for data, TXT for explanation). However, it lacks details on error handling or file overwriting policies.

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 ('When to use this tool', 'How to use this tool'), making it easy to scan. However, some sentences are slightly redundant (e.g., repeating file format requirements), and the overall length could be tightened without losing clarity.

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

Completeness4/5

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

For a tool with 7 parameters, no annotations, and no output schema, the description does a good job covering purpose, usage, and behavioral context. It explains the tool's role in the workflow and output behavior. However, it lacks details on the output format (e.g., CSV/TXT structure) and error scenarios, leaving some gaps in completeness.

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 all parameters thoroughly. The description adds minimal value beyond the schema, mainly reiterating parameter purposes (e.g., 'Provide csv_name for the forecast data file') without providing additional context or usage nuances. This meets the baseline for high schema coverage.

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: 'saves a Chronulus forecast from NormalizedForecaster to separate CSV and TXT files.' It specifies the verb ('saves'), resource ('forecast'), and output formats (CSV and TXT), distinguishing it from sibling tools like 'save_prediction_analysis_html' which outputs HTML instead.

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

Usage Guidelines5/5

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

The description provides explicit guidance in a dedicated 'When to use this tool' section, listing specific scenarios (e.g., saving both data and explanation files, saving rescaled predictions without prior rescaling). It also implicitly distinguishes from alternatives by not overlapping with sibling tools focused on creation, rescaling, or HTML output.

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/ChronulusAI/chronulus-mcp'

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