Skip to main content
Glama
JosueM1109

personal-finance-mcp

Get Investment Transactions

get_investment_transactions
Read-only

Fetch investment transactions within a date range, including ticker symbols and security names. Automatically paginates and clips wide windows to ensure performance.

Instructions

Fetch investment transactions in [start_date, end_date] across all healthy Items.

Dates are ISO YYYY-MM-DD. Uses offset pagination (count=500 per page). If start_date is older than ~2 years before end_date, the window is clipped and a warning is emitted. Each transaction is joined with security metadata (ticker symbol, name) from the same response.

Returns: {"investment_transactions": [...], "warnings": [...]}

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
start_dateYes
end_dateYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The main handler implementation for the get_investment_transactions tool. Fetches investment transactions from Plaid API across all healthy Items with offset pagination, clipping date windows to ~2 years, and joining with security metadata.
    def _get_investment_transactions_impl(
        start_date: str,
        end_date: str,
    ) -> dict:
        """Fetch investment transactions in [start_date, end_date] across all healthy Items.
    
        Dates are ISO YYYY-MM-DD. Uses offset pagination (count=500 per page).
        If start_date is older than ~2 years before end_date, the window is clipped
        and a warning is emitted. Each transaction is joined with security metadata
        (ticker symbol, name) from the same response.
    
        Returns:
            {"investment_transactions": [...], "warnings": [...]}
        """
        api = build_api()
        investment_transactions: list[dict] = []
        warnings: list[dict] = []
    
        clipped_start, clipped_end, clip_reason = _clip_window(start_date, end_date)
        if clip_reason:
            warnings.append({"code": "WINDOW_CLIPPED", "reason": clip_reason, "message": clip_reason})
    
        for env_key, token, health in all_items(api):
            if health.status != "healthy":
                warnings.append(_warning_from_health(health))
                continue
            offset = 0
            try:
                while True:
                    resp = api.investments_transactions_get(
                        InvestmentsTransactionsGetRequest(
                            access_token=token.reveal(),
                            start_date=date.fromisoformat(clipped_start),
                            end_date=date.fromisoformat(clipped_end),
                            options=InvestmentsTransactionsGetRequestOptions(
                                count=500,
                                offset=offset,
                            ),
                        )
                    ).to_dict()
                    secs_by_id = {
                        s["security_id"]: s
                        for s in resp.get("securities", []) or []
                    }
                    batch = resp.get("investment_transactions", []) or []
                    for t in batch:
                        investment_transactions.append({
                            "investment_transaction_id": t.get("investment_transaction_id"),
                            "account_id": t.get("account_id"),
                            "date": str(t.get("date")) if t.get("date") else None,
                            "type": t.get("type"),
                            "subtype": t.get("subtype"),
                            "amount": t.get("amount"),
                            "quantity": t.get("quantity"),
                            "price": t.get("price"),
                            "fees": t.get("fees"),
                            "currency": t.get("iso_currency_code"),
                            "symbol": secs_by_id.get(t.get("security_id"), {}).get("ticker_symbol"),
                            "name": secs_by_id.get(t.get("security_id"), {}).get("name"),
                            "institution": health.institution_name,
                        })
                    total = resp.get("total_investment_transactions") or 0
                    offset += len(batch)
                    if offset >= total or not batch:
                        break
            except ApiException as e:
                mapped = map_plaid_error(e, health.institution_name)["error"]
                warnings.append({"institution": health.institution_name, **mapped})
    
        return {"investment_transactions": investment_transactions, "warnings": warnings}
  • server.py:446-449 (registration)
    Registers _get_investment_transactions_impl as the MCP tool named 'get_investment_transactions' with readOnlyHint and title annotations.
    get_investment_transactions = mcp.tool(
        annotations={"readOnlyHint": True, "title": "Get Investment Transactions"},
        name="get_investment_transactions",
    )(_get_investment_transactions_impl)
  • Helper function that clips the date window to a maximum of ~2 years lookback (730 days), returning the clipped start date and a warning reason if clipping occurred. Used by the investment transactions handler.
    def _clip_window(start_date: str, end_date: str) -> tuple[str, str, str | None]:
        """Return (start, end, warning_reason_or_None) clipped to the 2-year window."""
        start = date.fromisoformat(start_date)
        end = date.fromisoformat(end_date)
        earliest = end - timedelta(days=_MAX_LOOKBACK_DAYS)
        if start < earliest:
            return earliest.isoformat(), end.isoformat(), (
                f"clipped start from {start.isoformat()} to {earliest.isoformat()} "
                "(Plaid max lookback ~2 years)"
            )
        return start.isoformat(), end.isoformat(), None
  • Helper that formats a warning dict from an ItemHealth object for unhealthy items. Used by the handler when skipping unhealthy Items.
    def _warning_from_health(h: ItemHealth) -> dict:
        return {
            "institution": h.institution_name or h.env_key,
            "status": h.status,
            "reason": h.reason,
        }
  • Constant defining the maximum lookback window of 730 days (~2 years) used for clipping date ranges in investment transactions (and other) queries.
    _MAX_LOOKBACK_DAYS = 730  # ~2 years
Behavior5/5

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

Adds significant details beyond readOnlyHint: fetches across all healthy Items, offset pagination, date clipping, and security metadata joining. No contradiction with annotations.

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

Conciseness4/5

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

Concise but could be more front-loaded. Every sentence adds value; no fluff.

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

Completeness5/5

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

Covers pagination, date handling, security metadata, warnings, and return format. Output schema exists, so no need to detail return values further.

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

Parameters5/5

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

Adds meaning beyond schema: explains ISO format, clipping behavior for start_date, and that dates are inclusive. Schema has 0% description coverage, so description carries full burden.

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?

Clearly states it fetches investment transactions within a date range across all healthy Items. Distinguishes from siblings like get_transactions (non-investment) and get_investment_holdings (holdings vs transactions).

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

Usage Guidelines4/5

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

Provides context on pagination and date window clipping. Does not explicitly state when not to use or alternatives, but the scope is clear.

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/JosueM1109/personal-finance-mcp'

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