Skip to content

API Reference parrot.mcp.toolkit_config

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot.mcp.toolkit_config

View source

Configuration models and loader for local MCP toolkit servers.

FEAT-485/FEAT-570: Toolkit configuration is read exclusively from .parrot/mcp-toolkits.yaml. Nothing is implicit — a toolkit resolves only if the file declares a section for it. Each section names a toolkit class via dotted path and provides instantiation kwargs, optional tool filtering via include/exclude, and optional LLM wiring.

The loader enforces Pydantic validation with clear error messages naming the file and offending section/key.

Attribute AGENT_SECTION_PREFIX

Type: str

Attribute AGENT_TOOLKIT_CLASS_PATH

Type: str

Class MCPToolkitsConfig

Root configuration for all exposable toolkits.

Fields:

Field Type Default Description
toolkits dict[str, ToolkitSection] Dictionary mapping toolkit names to their configuration sections.

Class ToolkitSection

Configuration for a single exposable toolkit.

Fields:

Field Type Default Description
class_path str Dotted path to the AbstractToolkit subclass (e.g., "parrot_tools.scraping.toolkit.WebScrapingToolkit"). Aliased as "class" in YAML and file dictionaries.
enabled bool True Whether this toolkit is available for serving. Defaults to True. Disabled toolkits are retained in the config but not exposed by runners or installers.
kwargs dict[str, Any] Constructor keyword arguments for the toolkit instance. File sections replace the built-in kwargs dict wholesale (not merged).
include list[str] | None None Optional whitelist of tool names to expose. If set, only these tools are exposed (exclude is ignored).
exclude list[str] | None None Optional blacklist of tool names to exclude. Only used when include is None.
llm str | None None Optional LLM identifier string (e.g., "openai:gpt-4o", "anthropic:claude-3-opus"). When set, the runner passes an LLMFactory-created client to the toolkit constructor as llm_client. When unset, tools named in the toolkit's llm_dependent_tools metadata are automatically excluded from exposure.
llm_kwargs dict[str, Any] Optional constructor keyword arguments forwarded verbatim to LLMFactory.create(llm, **llm_kwargs) — e.g. fallback_model: null, max_retries, read_timeout. This is trusted server configuration, never an LLM-callable argument. Requires llm to be set, and may not contain an llm key (it would collide with the factory's first argument). See examples/tool-optimizations-mcp.yaml.
env dict[str, str] Dictionary of environment variables to pass to the toolkit server process (via installer entries). Useful for API keys or secrets.

Function agent_section_name

Return the .parrot/mcp-toolkits.yaml section name for an agent.

Lower-cases the name, collapses every run of characters outside [a-z0-9] into one - and strips leading/trailing -.

agent_section_name(agent_name: str) -> str

Parameter Type Default Description
agent_name str Registered agent name.

Returns: str — "agent-<slug>".

Raises:

  • ValueError — The name has no [a-z0-9] character.

Function is_agent_section

Return whether the section serves an agent through AgentToolkit.

is_agent_section(section: ToolkitSection) -> bool

Parameter Type Default Description
section ToolkitSection

Returns: bool

Function load_toolkits_config

Load toolkit configuration.

Reads .parrot/mcp-toolkits.yaml from the project root if present. A toolkit resolves ONLY if the file declares a section for it — nothing is implicit (FEAT-570).

For each section:

  • New sections in the file are appended to the config.
  • Disabled sections (enabled: false) are retained in the config for inspection and control; they are filtered by consumers (runners, installers).

load_toolkits_config(root: Path, config_path: Path | None = None) -> MCPToolkitsConfig

Parameter Type Default Description
root Path Project root directory.
config_path Path | None None Optional explicit config file path (the parrot mcp-local --config override). When given it is used instead of <root>/.parrot/mcp-toolkits.yaml, and — unlike the default path, whose absence silently returns an empty config — a missing explicit file raises ValueError: an operator who named a file expects it to be read.

Returns: MCPToolkitsConfig — MCPToolkitsConfig with the file's sections (empty when the default path is absent).

Raises:

  • ValueError — If the file exists but is malformed YAML, contains unknown top-level keys, or has a non-mapping toolkits: value — or if an explicit config_path does not exist. Error message names the file path and the offending section/key.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally