---
title: search_fields
description: Find fields and constants using direct PE metadata parsing.
---

import { Aside, Tabs, TabItem } from "@astrojs/starlight/components";

<span class="tool-badge tool-badge-metadata">Metadata</span>

Search for fields in an assembly by name pattern. This tool reads the Field metadata table directly using dnfile -- no ilspycmd required. Results include type information, visibility modifiers, and literal values for constants.

## Parameters

| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| `assembly_path` | `string` | Yes | -- | Full path to the .NET assembly (.dll or .exe) |
| `pattern` | `string` | Yes | -- | Search pattern to match against field names |
| `type_filter` | `string \| null` | No | `null` | Only search fields in types containing this string |
| `namespace_filter` | `string \| null` | No | `null` | Only search in namespaces containing this string |
| `public_only` | `bool` | No | `false` | Only return public fields |
| `constants_only` | `bool` | No | `false` | Only return constant (literal) fields |
| `case_sensitive` | `bool` | No | `false` | Whether pattern matching is case-sensitive |
| `use_regex` | `bool` | No | `false` | Treat pattern as a regular expression |

## Example

<Tabs>
  <TabItem label="MCP JSON">
    ```json
    {
      "tool": "search_fields",
      "arguments": {
        "assembly_path": "/path/to/MyApp.dll",
        "pattern": "Key",
        "constants_only": true
      }
    }
    ```
  </TabItem>
  <TabItem label="Python">
    ```python
    result = await client.call_tool("search_fields", {
        "assembly_path": "/path/to/MyApp.dll",
        "pattern": "Key",
        "constants_only": True,
    })
    ```
  </TabItem>
</Tabs>

## Response

Fields grouped by declaring type, each showing modifiers (`public`, `static`, `const`) and field name. Results support pagination via `max_results` and `offset` parameters.

<Aside type="tip">
  Enable `constants_only` to surface configuration values, magic numbers, API keys,
  and hardcoded connection strings. This pairs well with `search_strings` for a
  thorough secrets audit.
</Aside>

## Related Tools

- [`search_methods`](/reference/tools/search-methods/) -- find methods by name pattern
- [`search_strings`](/reference/tools/search-strings/) -- search string literals in the #US heap
- [`get_metadata_summary`](/reference/tools/get-metadata-summary/) -- assembly-level statistics
