list_available_accounts
Lists all configured email accounts, displaying masked credentials for security.
Instructions
List all configured email accounts with masked credentials.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- mcp_email_server/app.py:29-32 (handler)The actual handler function for the 'list_available_accounts' MCP tool. It retrieves all configured email and provider accounts via get_settings().get_accounts() and returns them with masked credentials.
@mcp.tool(description="List all configured email accounts with masked credentials.") async def list_available_accounts() -> list[AccountAttributes]: settings = get_settings() return [account.masked() for account in settings.get_accounts()] - mcp_email_server/app.py:29-29 (registration)The tool is registered as an MCP tool via the @mcp.tool decorator on the FastMCP instance named 'mcp'.
@mcp.tool(description="List all configured email accounts with masked credentials.") - mcp_email_server/config.py:50-83 (schema)The AccountAttributes Pydantic base model that defines the schema for accounts returned by list_available_accounts. Includes a masked() method.
class AccountAttributes(BaseModel): model_config = ConfigDict(json_encoders={datetime.datetime: lambda v: v.isoformat()}) account_name: str description: str = "" created_at: datetime.datetime = Field(default_factory=lambda: datetime.datetime.now(ZoneInfo("UTC"))) updated_at: datetime.datetime = Field(default_factory=lambda: datetime.datetime.now(ZoneInfo("UTC"))) @model_validator(mode="after") @classmethod def update_updated_at(cls, obj: AccountAttributes) -> AccountAttributes: """Update updated_at field.""" # must disable validation to avoid infinite loop obj.model_config["validate_assignment"] = False # update updated_at field obj.updated_at = datetime.datetime.now(ZoneInfo("UTC")) # enable validation again obj.model_config["validate_assignment"] = True return obj def __eq__(self, other: object) -> bool: if not isinstance(other, AccountAttributes): return NotImplemented return self.model_dump(exclude={"created_at", "updated_at"}) == other.model_dump( exclude={"created_at", "updated_at"} ) @field_serializer("created_at", "updated_at") def serialize_datetime(self, v: datetime.datetime) -> str: return v.isoformat() def masked(self) -> AccountAttributes: return self.model_copy() - mcp_email_server/config.py:295-299 (helper)The Settings.get_accounts() helper method that combines emails and providers into a single list. Called by the tool handler to retrieve all accounts.
def get_accounts(self, masked: bool = False) -> list[EmailSettings | ProviderSettings]: accounts = self.emails + self.providers if masked: return [account.masked() for account in accounts] return accounts - mcp_email_server/config.py:341-346 (helper)The singleton helper that provides the Settings instance to the tool handler.
def get_settings(reload: bool = False) -> Settings: global _settings if not _settings or reload: logger.info(f"Loading settings from {CONFIG_PATH}") _settings = Settings() return _settings