This guide connects an AI agent to a reldir database through the Model Context
Protocol, so the agent can query, check and change it under the same
validation as the command line. It assumes reldir is on the PATH of the
program that runs the agent. The tools, resources and prompts the server
offers are listed in the MCP reference.
From the project that holds the database, add the server and name the database’s folder:
claude mcp add reldir -- reldir --db ./data mcp
Any client that launches MCP servers on stdin and stdout takes the same command. In a client configured by JSON, give the database’s absolute path, since the client may start the server from any directory:
{
"mcpServers": {
"reldir": { "command": "reldir", "args": ["--db", "/path/to/data", "mcp"] }
}
}
If the agent should only look – to answer questions, or to report faults –
put --readonly before mcp:
claude mcp add reldir-readonly -- reldir --db ./data --readonly mcp
The session then writes nothing at all: no rows, no history, no derived state.
Every tool that changes the database answers READ_ONLY.
Flags before mcp apply to every call of the session. To stop a runaway query
or an answer too large for the agent’s context, give limits:
claude mcp add reldir -- reldir --db ./data --timeout 5 --max-result-rows 5000 mcp
query also answers a page at a time, 200 rows unless the agent asks for
more. The other limits are listed in configuration.
The agent cannot change the database in one step. Each change tool first
returns a plan – every file it would write or delete, every referential
action – and commits only when called again with that plan’s plan_id, and
only if the database has not changed since.
When a plan removes data – deletes a row, or runs a referential action – it also needs your confirmation:
confirm: true. Tell the agent, in its
instructions or in the conversation, to ask you before it does.Every change is a revision in history, so a change you regret can be undone; see How to undo a change.
The server offers prompts that set the agent to a task. In a client that lists prompts, choose one:
explore-database, to learn the tables, how they relate and what is wrong,
changing nothing;design-schema, to design or change one table, showing each plan;repair-database, to find every fault and repair it, confirming removals
with you.Every call reads the folder as it is at that moment. On a large folder, run
reldir serve beside the agent, so each call examines only what changed; see
How to keep a large folder fast.