Skip to main content
Glama

execute_arcpy_code

Run Python code inside a live ArcGIS Pro session to perform geoprocessing, layer management, and queries when no dedicated tool fits the task.

Instructions

Run Python inside ArcGIS Pro. arcpy is already imported and arcpy.mp.ArcGISProject('CURRENT') is the open project. Variables persist between calls, print() output is captured, and the value of a final expression is returned. Use this whenever no dedicated tool covers the task.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesPython source to run.
reset_namespaceNoForget variables kept from earlier calls.

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed2 schema fields changedv1.1.1
    • addedInput schema / properties / code / description
      Added value: +"Python source to run."
    • addedInput schema / properties / reset_namespace
      Added value: +{
      +  "default": false,
      +  "description": "Forget variables kept from earlier calls.",
      +  "title": "Reset Namespace",
      +  "type": "boolean"
      +}
  2. First observedv0.1.0

TDQS

A4.7/5.0
Behavior5/5

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

No annotations provided, so the description must carry full behavioral load and does: it discloses that the ArcGISProject('CURRENT') binding is pre-initialized, that variables persist between calls (a significant stateful behavior), and that print() output is captured and final expressions returned. These are non-obvious execution semantics critical to correct invocation.

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?

Three tightly packed sentences: first the what/where, then the execution semantics, then the routing rule. Zero waste, front-loaded purpose.

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 no annotations, an output schema, and a straightforward 2-param schema, the description covers purpose, environment, statefulness, output handling, and usage guidance. Nothing an agent needs to call it correctly is missing.

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% (both 'code' and 'reset_namespace' are documented in the schema), so the schema already carries parameter meaning. The description adds only context about the execution environment rather than parameter-level guidance. Baseline 3 is appropriate.

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?

States a specific action (run Python) on a specific resource/context (inside ArcGIS Pro) with an environment detail (arcpy pre-imported). Clearly distinguishes itself from the many dedicated sibling tools by framing itself as the general-purpose escape hatch.

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?

Explicitly states when to use: 'whenever no dedicated tool covers the task.' This is a textbook routing rule for a fallback tool within a large sibling set of CRUD operations.

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

Deploy Server

Other Tools