delete_portfolio
Permanently remove a stored investment portfolio by name. Returns confirmation of deletion.
Instructions
Delete a stored portfolio.
Permanently removes a portfolio from storage.
Args: name: The portfolio name to delete.
Returns: Dictionary with deletion status.
Example:
result = delete_portfolio(name="old_portfolio")
if result['deleted']:
print("Portfolio deleted successfully")
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- app/tools/portfolio.py:358-391 (handler)The delete_portfolio function (decorated with @mcp.tool) that implements the tool's logic: checks if the portfolio exists via store.exists(name), returns error if not found, otherwise calls store.delete(name) and returns deletion status.
@mcp.tool def delete_portfolio(name: str) -> dict[str, Any]: """Delete a stored portfolio. Permanently removes a portfolio from storage. Args: name: The portfolio name to delete. Returns: Dictionary with deletion status. Example: ``` result = delete_portfolio(name="old_portfolio") if result['deleted']: print("Portfolio deleted successfully") ``` """ if not store.exists(name): return { "deleted": False, "error": f"Portfolio '{name}' not found", } deleted = store.delete(name) return { "deleted": deleted, "name": name, "message": f"Portfolio '{name}' deleted successfully" if deleted else "Deletion failed", } - app/tools/portfolio.py:27-34 (registration)The register_portfolio_tools function registers all portfolio CRUD tools (including delete_portfolio) with the FastMCP server. It takes the mcp and store parameters used as closures by the nested tool functions.
def register_portfolio_tools(mcp: FastMCP, store: PortfolioStore) -> None: """Register portfolio CRUD tools with the FastMCP server. Args: mcp: The FastMCP server instance. store: The portfolio store for persistence. """ - app/tools/portfolio.py:359-376 (schema)The type signature and docstring of delete_portfolio: takes a single parameter name: str and returns dict[str, Any]. The docstring describes it as permanently removing a portfolio from storage.
def delete_portfolio(name: str) -> dict[str, Any]: """Delete a stored portfolio. Permanently removes a portfolio from storage. Args: name: The portfolio name to delete. Returns: Dictionary with deletion status. Example: ``` result = delete_portfolio(name="old_portfolio") if result['deleted']: print("Portfolio deleted successfully") ``` """ - app/server.py:42-57 (registration)The FastMCP server initialization where delete_portfolio is listed in the server instructions as one of the available portfolio management tools.
mcp = FastMCP( name="portfolio-mcp", # nosec B608 - This is not SQL, just a long documentation string instructions=f"""A financial portfolio management server with reference-based caching. Supports real market data from Yahoo Finance (stocks, ETFs) and CoinGecko (crypto). ## Portfolio Management Tools - create_portfolio: Create portfolio from real market data or synthetic data - source="yahoo": Fetch stocks/ETFs from Yahoo Finance (e.g., AAPL, MSFT, SPY) - source="crypto": Fetch crypto from CoinGecko (e.g., BTC, ETH, SOL) - source="synthetic": Generate GBM simulated data (default) - get_portfolio: Get detailed information about a stored portfolio - list_portfolios: List all stored portfolios - delete_portfolio: Delete a stored portfolio - update_portfolio_weights: Update allocation weights