execute_arcpy_code
Run custom Python with arcpy inside the open ArcGIS Pro project to handle tasks no dedicated tool covers. Variables persist between calls, print output is captured, and final expression values are returned.
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.
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": {
"code": "<code>"
},
"name": "execute_arcpy_code"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | Python source to run. | |
| reset_namespace | No | Forget variables kept from earlier calls. | |
| timeout_seconds | No | Stop the code after this many seconds (0 = no limit). A call blocked inside a tool or an external process stops when it returns. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |