get_transactions
Retrieve detailed transaction history from DIDLogic by specifying transaction type, start date, and end date. Returns a CSV table with date, time, type, comment, amount, balance, and status for accurate financial tracking.
Instructions
Load transaction history from DIDLogic
Args: transaction_type: Type of transaction to search where: adjustment = Adjustments made by DIDLogic finances activation = Activation payments for DID month = Monthly payments for DID paypal_in = Paypal TopUps call = Per minute charges for inbound calls call_fix_fee = Per minute charges for PSTN DID destinations sms = SMS charges inbound_sms = Inbound SMS charges cc_in = Credit card TopUps stripe_in = Stripe express payments TopUps porting = Porting Fees start_date: Search start date in format YYYY-MM-DD end_date: Search end date in format YYYY-MM-DD
Returns a CSV table of transactions where: Date: Date of transaction Time: Time of transaction Transaction type: Type of transaction Comment: Comment for transaction Amount: Transaction Amount Balance: Balance after transaction creation Status: Transaction status where: Confirmed = transaction confirmed but not commited yet Committed = transaction settled Rejected = transaction reverted back
Example:
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| end_date | Yes | Search end date in format YYYY-MM-DD | |
| start_date | Yes | Search start date in format YYYY-MM-DD | |
| transaction_type | No | Transaction type for search | month |
Implementation Reference
- The core handler function for the 'get_transactions' MCP tool. Defines input schema via Pydantic Fields and Literal, comprehensive docstring, constructs query params, calls the DIDLogic API via helper, and returns CSV response.async def get_transactions( ctx: Context, transaction_type: Literal[ "adjustment", "activation", "month", "paypal_in", "call", "call_fix_fee", "sms", "cc_in", "stripe_in", "porting", "inbound_sms" ] = Field(description="Transaction type for search", default="month"), start_date: str = Field( description="Search start date in format YYYY-MM-DD" ), end_date: str = Field( description="Search end date in format YYYY-MM-DD" ), ) -> str: """ Load transaction history from DIDLogic Args: transaction_type: Type of transaction to search where: adjustment = Adjustments made by DIDLogic finances activation = Activation payments for DID month = Monthly payments for DID paypal_in = Paypal TopUps call = Per minute charges for inbound calls call_fix_fee = Per minute charges for PSTN DID destinations sms = SMS charges inbound_sms = Inbound SMS charges cc_in = Credit card TopUps stripe_in = Stripe express payments TopUps porting = Porting Fees start_date: Search start date in format YYYY-MM-DD end_date: Search end date in format YYYY-MM-DD Returns a CSV table of transactions where: Date: Date of transaction Time: Time of transaction Transaction type: Type of transaction Comment: Comment for transaction Amount: Transaction Amount Balance: Balance after transaction creation Status: Transaction status where: Confirmed = transaction confirmed but not commited yet Committed = transaction settled Rejected = transaction reverted back Example: ``` Date,Time,Transaction type,Comment,Amount,Balance,Status 01/05/25,06:00 am,Monthly fees,Monthly fee for 18565999999,$-0.9900,$16.1273,Committed ``` """ params = {} if transaction_type is not None: params["type"] = transaction_type if start_date is not None: params["start_date"] = start_date if end_date is not None: params["end_date"] = end_date result = await base.call_didlogic_api( ctx, "GET", "/v1/transactions", params=params ) return result.text
- src/didlogic_mcp/server.py:105-105 (registration)Top-level registration of the transactions module's tools, including 'get_transactions', in the main MCP server setup.tools.transactions.register_tools(mcp)
- src/didlogic_mcp/tools/base.py:9-54 (helper)Shared helper function used by get_transactions to make authenticated HTTP requests to the DIDLogic API, handling token extraction from MCP context.async def call_didlogic_api( ctx: Context, method: str, path: str, params: Optional[Dict] = None, data: Optional[Dict] = None, json: Optional[Dict] = None ) -> httpx.Response: """ Make a call to the Didlogic API. In HTTP/SSE mode, extracts Bearer token from request context and adds it to the Authorization header for each API call. In STDIO mode, uses the API key already configured in the client headers. """ client = ctx.request_context.lifespan_context.client # In HTTP/SSE mode, get API key from request.state (set by middleware) extra_headers = {} # Check if we have a request object (indicates HTTP/SSE mode) request = getattr(ctx.request_context, "request", None) if request and hasattr(request, 'state') and hasattr(request.state, 'didlogic_api_key'): # HTTP/SSE mode: extract API key from request state api_key = request.state.didlogic_api_key if api_key: extra_headers["Authorization"] = f"Bearer {api_key}" logger.debug(f"Using API key from request state: {api_key[:8]}...") else: logger.warning("No API key found in request state") else: # STDIO mode: API key already in client headers from lifespan logger.debug("Using API key from client headers (STDIO mode)") response = await client.request( method=method, url=path, params=params, data=data, json=json, headers=extra_headers ) response.raise_for_status() return response
- src/didlogic_mcp/tools/transactions.py:7-8 (registration)Module-level registration function that applies the @mcp.tool() decorator to the get_transactions handler.def register_tools(mcp: FastMCP): @mcp.tool()