Skip to main content
Glama

get_code

Read-only

Retrieve the Python script and required packages for a forecasting plan, cross-validation strategy, backtest, forecast, or comparison, including a specified candidate.

Instructions

Return the Python script of an object and the packages it needs: the one that ran, or that would run for a plan (a profile has none). For a run that failed, use get_failure.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "object_id": "<object_id>"
    },
    "name": "get_code"
  }
}

Input Schema

NameRequiredDescriptionDefault
candidateNoFor a comparison, the candidate whose script to return. Null for the best one.
object_idYesId of a plan (its forecasting script), a cross-validation strategy (the code that builds it), a backtest, a forecast or a comparison (the script that ran).

Output Schema

NameRequiredDescriptionDefault
idYes
codeYes
kindYes
filesNo
candidateNo
requirementsNo
code_truncatedNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.1.1
    • changedOutput schema / description
      Previous value: -"Script of an object, returned by the `get_code` tool.\n\nAttributes\n----------\nid : str\n    Id of the object.\nkind : str\n    Kind of the object.\ncandidate : str, None\n    Candidate of a comparison whose script it is.\ncode : str\n    Python code, cut to 20,000 characters.\ncode_truncated : bool\n    Whether `code` was cut; the full code is then in `files['code']`.\nrequirements : list of str\n    Packages to install to run the script outside the server: those of\n    the modules it imports and the backend of its foundation model,\n    each with the version installed where the server runs\n    (`'skforecast==0.26.0'`).\nfiles : dict\n    Absolute path of the file with the full code, when it was cut."New value: +"Script of an object, returned by the `get_code` tool.\n\nAttributes\n----------\nid : str\n    Id of the object.\nkind : str\n    Kind of the object.\ncandidate : str, None\n    Candidate of a comparison whose script it is.\ncode : str\n    Python code, cut to 20,000 characters.\ncode_truncated : bool\n    Whether `code` was cut; the full code is then in `files['code']`.\nrequirements : list of str\n    Packages to install to run the script outside the server: those of\n    the modules it imports and the backend of its foundation model,\n    each with the version installed where the server runs\n    (`'skforecast==0.27.0'`).\nfiles : dict\n    Absolute path of the file with the full code, when it was cut."
  2. First observedv0.1.0

TDQS

A3.9/5.0
Behavior3/5

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

Annotations already declare readOnlyHint=true, destructiveHint=false, openWorldHint=false, so the safety profile is covered. The description adds useful behavior beyond that: the return includes package requirements, plan scripts are hypothetical ('would run'), and profiles yield nothing. It does not discuss size, volatility, or how the script relates to the deployed state.

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?

Two sentences, front-loaded with what is returned, followed by the exception and the alternative tool. No filler or restated name.

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?

An output schema exists, so return values need not be enumerated; annotations cover safety. The description supplies the object-type scope, the profile edge case, and the failure alternative, which is everything needed to call it correctly.

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 coverage is 100% and the schema already enumerates exactly which object types object_id accepts and documents `candidate` as the optional comparison selector with null meaning best. The description adds only the marginal fact that a profile object yields no script, so baseline 3 is appropriate.

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?

States a specific verb and resource: return the Python script of an object plus the packages it needs. The scope nuance ('the one that ran, or that would run for a plan (a profile has none)') distinguishes it further, and it names the sibling used instead for failed runs, so an agent can tell it apart from get_failure.

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?

Gives one explicit routing rule: for a failed run, use `get_failure` instead. That is real when-not guidance, but there is no guidance on when to prefer this over describe_object or the other introspection-style siblings, and no mention of the comparison/candidate case in the prose.

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