Principle:1mcp app Agent Template Server Indexing
| Knowledge Sources | |
|---|---|
| Domains | Configuration, MCP_Protocol |
| Last Updated | 2026-10-29 00:00 GMT |
Overview
Pattern that separates static server definitions from template servers, validating and indexing templates at startup so they can be instantiated per-client with context-aware configuration.
Description
Template Server Indexing distinguishes between static servers (always running, loaded at startup) and template servers (created on demand when a client connects with specific context). At startup, the configuration manager loads all declared server definitions and separates them into static and template sets. The template server manager rebuilds its index from the template definitions, enabling per-client instantiation with context rendering (e.g., Handlebars templates). Static servers that conflict with template names are removed to preserve template identity authority.
Usage
Use this principle when:
- Some MCP servers need per-client context (e.g., workspace paths, project IDs) that varies per session
- Template servers should not start at boot but be instantiated lazily on client connection
- Static and template server names must not conflict; template identity takes precedence
- The index must be rebuilt when configuration changes so new templates are discoverable
Theoretical Basis
The separation is a declaration vs instantiation split:
// Abstract algorithm (NOT real implementation)
const { staticServers, templateServers, errors } = loadDeclaredServerConfigs();
if (errors.length === 0) {
templateServerManager.rebuildTemplateIndex({ mcpTemplates: templateServers });
}
// staticServers are started immediately; templateServers wait for client context
Conflict resolution gives templates priority:
Practical Guide
- Load declared server configs and separate into static and template sets at startup
- Skip template index rebuild if declared configuration has validation errors
- Remove static servers whose names conflict with template definitions
- Rebuild the template index whenever configuration changes via hot-reload
- Template instances are created per-client with rendered context, not at boot