Skip to content

API Reference parrot.handlers.mcp_persistence

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

parrot.handlers.mcp_persistence

View source

MCP Persistence Service — DocumentDB CRUD for user MCP server configs.

Provides save, load, and soft-delete operations for :class:~parrot.mcp.registry.UserMCPServerConfig documents, scoped by (user_id, agent_id).

The user_mcp_configs collection is created implicitly on the first write. Secret values are never stored here — they live in the Vault. The vault_credential_name field in each document points to the relevant Vault entry.

Usage::

service = MCPPersistenceService()
await service.save_user_mcp_config(config)
configs = await service.load_user_mcp_configs(user_id, agent_id)
removed = await service.remove_user_mcp_config(user_id, agent_id, "perplexity")

Attribute COLLECTION

Type: str

Alias DocumentDb

Re-exported from parrot.interfaces.documentdb.DocumentDb.

Class MCPPersistenceService

Handles saving and loading user MCP server configurations in DocumentDB.

All documents are scoped by the compound key (user_id, agent_id, server_name). Deactivation is a soft-delete that sets active=False so the configuration can be re-activated in the future without data loss.

Method MCPPersistenceService.save_user_mcp_config

Upsert a user MCP server configuration in DocumentDB.

If a document with the same (user_id, agent_id, server_name) already exists it is updated; otherwise a new document is inserted. The created_at timestamp is set only on first insert; updated_at is refreshed on every save.

save_user_mcp_config(config: UserMCPServerConfig) -> None

Parameter Type Default Description
config UserMCPServerConfig The :class:~parrot.mcp.registry.UserMCPServerConfig to persist. The params dict must not contain any secret values — those belong in the Vault.

Method MCPPersistenceService.load_user_mcp_configs

Load all active MCP server configs for a given user and agent.

Inactive configs (active=False) are excluded from the results.

load_user_mcp_configs(user_id: str, agent_id: str) -> List[UserMCPServerConfig]

Parameter Type Default Description
user_id str Owner user identifier.
agent_id str Agent identifier to scope the query.

Returns: List[UserMCPServerConfig] — List of :class:~parrot.mcp.registry.UserMCPServerConfig instances. Returns an empty list if none are found.

Method MCPPersistenceService.remove_user_mcp_config

Soft-delete a user MCP server configuration.

Sets active=False on the document rather than hard-deleting it, so the configuration can be re-activated later.

remove_user_mcp_config(user_id: str, agent_id: str, server_name: str) -> bool

Parameter Type Default Description
user_id str Owner user identifier.
agent_id str Agent identifier.
server_name str Registry slug of the server to deactivate.

Returns: bool — True if a matching document was found and deactivated. False if no document with the given compound key exists.

Alias UserMCPServerConfig

Re-exported from parrot.mcp.registry.UserMCPServerConfig.

Attribute logger

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