set_types
Define or update struct and enum types in Ghidra by providing C header declarations, with support for comments, padding, and references to existing types.
Instructions
Create or update one or more struct/enum types from C header text.
The input accepts normal C header style declarations, including `typedef
struct`, `typedef enum`, plain `struct`, and plain `enum` definitions.
Enum sizes can be set with comment directives such as
`/* ghidra-mcp enum-size: Name=1 */`.
Field comments are accepted from trailing `// ...` or `/* ... */`
comments and are applied to the resulting struct members.
To intentionally leave unknown bytes in a struct, add explicit placeholder
fields using Ghidra's undefined types, for example:
`undefined1 _pad[3];`, `undefined2 _pad;`, `undefined4 _reserved;`.
Use that for deliberate gaps; omitted fields only produce whatever natural
ABI padding the parsed C layout would normally create.
Missing referenced types are resolved from the current program's datatype
manager when possible, so new definitions can refer to already-existing
program types without re-declaring them inline.
Imported structs are stored as explicit-layout, non-packed Ghidra structs
so their size and padding remain directly editable after import.
The return value is the stored type definitions exported back out of Ghidra
as C header text.
Args:
types: One or more type declarations in C header syntax.
program: Required Ghidra project path or name to target.
timeout: Timeout in seconds for the bridge-side parse/import/export.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| types | Yes | ||
| program | Yes | ||
| timeout | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |