Skip to main content
Glama
l4b4r4b4b4
by l4b4r4b4b4

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

TableJSON Schema
NameRequiredDescriptionDefault
nameYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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",
        }
  • 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.
        """
  • 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
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are present, so the description bears full responsibility. It discloses irreversible deletion ('permanently removes'), which is critical. However, it does not mention potential side effects (e.g., affecting other data), authorization needs, or error handling behavior beyond the example's success case.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is highly concise: two short paragraphs plus a clear code example. Every sentence serves a purpose—specifying action, permanence, parameter, return value, and usage example. No redundant information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (one parameter, clear output schema example), the description covers purpose, parameter meaning, return value, and a usage example. It lacks error handling details or mention of whether the portfolio must exist, but for a basic delete tool, it is sufficiently complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has 0% coverage for the 'name' parameter, so the description's docstring ('The portfolio name to delete.') adds essential meaning beyond the schema's type-only definition. The example also clarifies usage. However, no additional constraints like format or existence checks are mentioned.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description clearly states 'Delete a stored portfolio. Permanently removes a portfolio from storage.' The verb 'delete' and resource 'portfolio' are explicit, and the specific action (permanent removal) distinguishes it from sibling tools like clone_portfolio or create_portfolio.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for removing portfolios but does not explicitly state when to use this tool versus keeping portfolios, nor does it mention prerequisites or safety checks like ensuring the portfolio exists. The permanence is noted, but no exclusion criteria are provided.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/l4b4r4b4b4/portfolio-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server