MCP Integration Architecture¶
APTL uses Model Context Protocol servers as scenario-aware adapters between an authorized AI client and the red- or blue-team systems in a realized lab.
For operator setup, availability, and supported tool naming, use the MCP reference. This page explains the component boundary. It does not duplicate the generated runtime configuration.
Runtime Flow¶
flowchart LR
Client[Project-aware MCP client]
Config[Generated private client config]
Servers[Scenario-enabled MCP servers]
Targets[Realized lab targets and APIs]
Client --> Config
Config --> Servers
Servers --> Targets
lilrae lab start realizes the scenario before it updates .mcp.json. This
ordering lets APTL include only supported servers, inject generated credentials,
and use runtime-resolved ports. A server artifact in the project tree does not
prove that its target exists in the current scenario.
Server Families¶
SSH-backed servers use aptl-mcp-common for connection pooling, bounded
sessions, tool definition generation, error handling, telemetry, and
redaction. API-backed servers use the common authenticated HTTP/TLS boundary
and their declared query or action configurations.
Every server owns a toolPrefix. The common generators apply that prefix to
the advertised tool name. This prevents collisions when several servers expose a similar capability. The connected server remains the authority for its exact
tool list and input schemas.
Configuration Boundary¶
The tracked docker-lab-config.json files describe server identity, prefix,
target type, and non-secret transport shape. The generated .mcp.json binds
those definitions to one realized project and can contain credentials. It is private runtime data, not a checked-in documentation source or shared template.
LilRAE updates its managed entries.
Each server limits the size of one tool result to server.maxToolResultTokens
in its docker-lab-config.json, estimated at 4 characters per token (default
4000). A predefined query can set its own max_result_tokens. The value null
returns the whole result. The indexer get_rule_file query uses null,
because create_rule replaces the whole rule file. A cut read would delete
rules when the agent writes the file back.
A larger result that is a JSON object stays valid JSON. Whole records are dropped from the end of its largest array. When not even one record fits, or the object has no array, long strings such as command output are cut at a line boundary. The short fields beside them, such as exit codes, stay.
A tail at
the end of the object gives the counts, for example "_truncated":
{"returned": 12, "total": 40, "note": "28 more results. Refine your query"}.
Other text is cut at a line boundary with a size tail. The tool span records
the original and returned sizes and whether the result was truncated. Neither
the tail nor the log repeats result content. The post-tool hook receives the
result that the client receives.
The build script builds the optional reverse-engineering artifact with the other servers. It is absent from default client configuration when the scenario has no reverse target.
Development¶
The shared library is a dependency of every MCP server. A library change affects all consumer artifacts. See build and verify MCP artifacts for development steps.