Structured Data
LocalData MCP handles JSON, YAML, and TOML files as navigable trees, and XML and INI files as flat SQL tables. The connection interface is the same for all five formats; the storage model determines which tools are available after connection.
Tree storage (JSON, YAML, TOML)
When connected, these files are parsed into a tree where each node is individually addressable. Nodes can hold key-value properties and any number of child nodes. An LLM agent can navigate, query, edit, and export the tree without loading the entire file into context.
connect_database("cfg", "json", "./config.json")
connect_database("settings", "yaml", "./settings.yaml")
connect_database("pyproject", "toml", "./pyproject.toml")
The connection response includes a tree summary: root nodes, maximum depth, and total property count.
Tree tools
Tool |
Description |
|---|---|
|
View a node’s properties and whether it has children |
|
List child nodes with pagination |
|
Create a node; missing ancestors are created automatically |
|
Remove a node and all its descendants |
|
List key-value pairs at a node |
|
Read a single property value |
|
Create or update a property; type is inferred automatically |
|
Remove a property from a node |
|
Export the tree as JSON, YAML, or TOML |
The path argument uses dot notation to address nodes: "server" addresses a top-level node,
"server.tls" addresses a child node named tls under server.
Editing
set_value("cfg", "server", "port", "9090")
# Dot-notation path; "monitoring" and "alerts" are created if absent
set_value("cfg", "monitoring.alerts", "enabled", "true")
delete_key("cfg", "server", "deprecated_setting")
delete_node("cfg", "monitoring.alerts") # Removes the node and all children
Format conversion
export_structured converts the in-memory tree to any of the three supported formats, regardless of the
source format:
connect_database("cfg", "toml", "./config.toml")
export_structured("cfg", "json") # Emit as JSON
export_structured("cfg", "yaml") # Emit as YAML
This lets an agent convert between TOML, JSON, and YAML without writing any conversion logic.
Type inference
set_value infers the type of the supplied string before storing it:
"true"/"false"→ booleanNumeric strings → integer or float
"null"→ nullAnything else → string
Lists and dicts must be supplied as JSON-serialized strings; they are stored as-is and returned in that form.
XML and INI (flat handling)
XML and INI files connect with the same call but are stored as flat SQL tables rather than trees. After
connection, use the standard database tools (execute_query, describe_table, and so on).
connect_database("config_xml", "xml", "./config.xml")
connect_database("app_ini", "ini", "./app.ini")
Both land in a single table named data_table.
XML table layout
The file is flattened with pandas read_xml: each direct child of the root
element becomes a row, and the columns come from that child’s attributes and its
own sub-elements. Column names have spaces and hyphens replaced by underscores.
There is no id, tag, text or parent_id column, and attribute names are
not prefixed.
For this file:
<root>
<item enabled="true">alpha</item>
<item enabled="false">beta</item>
</root>
the table has columns enabled (from the attribute) and item (from the
element text), two rows:
execute_query("config_xml", "SELECT item FROM data_table WHERE enabled = 1")
Deeply nested XML does not flatten cleanly. Run describe_table("config_xml", "data_table") after connecting to see the columns you actually got.
INI table layout
Each key-value pair becomes a row:
Column |
Content |
|---|---|
|
Section name from the INI file |
|
Key within that section |
|
Value as a string |
execute_query("app_ini", "SELECT value FROM data_table WHERE section = 'database' AND key = 'host'")
Available tools for XML and INI
Because these formats map to SQL tables, all standard database tools apply:
describe_database(name)— list tables and row countsdescribe_table(name, table)— column names and typesexecute_query(name, sql)— run any read queryfind_table(table_name)— report which connections hold a table of that name; it searches every active connection and takes no connection argument
The tree tools (get_node, get_value, etc.) are not available for XML or INI connections.