Principle:1mcp app Agent Preset System Management
| Knowledge Sources | |
|---|---|
| Domains | Configuration, Filtering |
| Last Updated | 2026-10-29 00:00 GMT |
Overview
Pattern that manages named server-filter presets with file-backed storage, debounced hot-reload, and change notifications to connected clients.
Description
Preset System Management provides a user-facing abstraction for selecting subsets of MCP servers by tag queries. It stores presets as JSON on disk, watches the file for external edits, and reloads with a debounce to avoid processing intermediate states. When a preset's resolved server list changes, the system notifies all connected clients so they can refresh their tool catalogs. This decouples the act of grouping servers from the runtime that serves them.
Usage
Use this principle when:
- Users need to switch between different sets of MCP servers without editing individual entries
- Server selection criteria are expressed as tag queries (AND/OR/NOT expressions)
- Preset definitions should persist across restarts and be editable by external tools
- Connected clients must be notified when a preset's effective server set changes
Theoretical Basis
The core mechanism is a file-watched store with debounce + diff + notify:
// Abstract algorithm (NOT real implementation)
watch(presetsFile, (eventType) => {
if (eventType === 'change') {
debounce(500ms, () => {
previous = currentServerLists(presets);
reload(presetsFile);
current = currentServerLists(presets);
changed = diff(previous, current);
if (changed.length > 0) notifyClients(changed);
});
}
});
The tag query evaluator resolves preset criteria to a server list:
Where is the set of all configured servers and evaluates a boolean tag expression.
Practical Guide
- Store presets in a single JSON file within the config directory
- Use a debounce delay (e.g. 500ms) to batch rapid file writes into one reload
- Compare resolved server lists before and after reload to detect meaningful changes
- Notify clients only when the effective server set actually changes, not on every file write
- Handle missing preset files gracefully by starting with an empty preset set