Implementation:1ay1 Agentty Plugin State Snapshot
| Knowledge Sources | |
|---|---|
| Domains | MCP, Model_State |
| Last Updated | 2026-10-28 12:00 GMT |
Overview
Value snapshot of plugin/tool state safe to hold across a concurrent pool swap, so the TEA Model can own it without an include cycle.
Description
The agentty::mcp::PluginModel struct is the single UI-facing truth for plugin/tool state: every configured server, its connection state, and its advertised tools, unified from config + live pool. Split out of `client.hpp` so it can live in the TEA Model (`model.hpp`) without dragging in the whole MCP client API (which depends on `tools::ToolDef` and would form an include cycle). Plain data type — `<string>`/`<vector>` only — so the Model can own it and `visual_hash` can treat the Plugins panel as a pure function of the Model.
Usage
Import this when you need to: hold plugin/tool state in the Model, render the Plugins panel, or access server/tool connection state as a value.
Code Reference
Source Location
- Repository: 1ay1_Agentty
- File: include/agentty/mcp/plugin_model.hpp
- Lines: 1-90
Signature
namespace agentty::mcp {
struct ToolState {
std::string name, description;
bool enabled = true, pinned = false, on_demand = false;
};
enum class Origin : std::uint8_t { User, Project, Explicit };
struct ServerState {
std::string name, command, url, error, config_dir;
bool connected = false, disabled = false, untrusted = false, passthrough = false;
Origin origin = Origin::User;
std::vector<ToolState> tools;
[[nodiscard]] std::size_t enabled_count() const noexcept;
};
struct PromptState { std::string name, description, hint; };
struct PluginModel {
std::vector<ServerState> servers;
std::vector<PromptState> prompts;
std::size_t native_tool_count = 0;
std::string loading; // "auto" | "all" | "on_demand"
std::size_t loaded_count = 0, on_demand_count = 0;
std::size_t schema_tokens = 0, context_window = 0;
bool capped_by_provider = false;
[[nodiscard]] std::size_t enabled_mcp() const noexcept;
};
}
Import
#include "agentty/mcp/plugin_model.hpp"
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| servers | std::vector<ServerState> | Yes | All configured MCP servers + connection state |
| loading | std::string | Yes | "all" | "on_demand") |
Outputs
| Name | Type | Description |
|---|---|---|
| enabled_mcp() | std::size_t | loaded_count + on_demand_count |
| enabled_count() | std::size_t | Per-server: count of enabled tools |
Usage Examples
Access Plugin State in the Model
#include "agentty/mcp/plugin_model.hpp"
auto& pm = model.d.plugins;
for (const auto& srv : pm.servers) {
if (srv.connected) {
// srv.name, srv.tools (each with enabled/pinned/on_demand)
}
if (srv.untrusted) {
// project config not vouched for — won't connect
}
}
// pm.loading == "on_demand" → tool_search finds on-demand tools