Skip to main content
Glama

swap_transaction

Execute swap transactions on the Armor Crypto MCP server. Processes SwapTransactionRequestContainer to return a list of SwapTransactionResponse for efficient crypto swaps.

Instructions

Execute a swap transaction. Expects a SwapTransactionRequestContainer, returns a list of SwapTransactionResponse.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
swap_transaction_requestsYes

Implementation Reference

  • MCP tool handler for 'swap_transaction': decorated with @mcp.tool(), validates input using SwapTransactionRequestContainer, calls armor_client.swap_transaction, handles errors and returns List[SwapTransactionResponse]
    @mcp.tool() async def swap_transaction(swap_transaction_requests: SwapTransactionRequestContainer) -> List[SwapTransactionResponse]: """ Execute a swap transaction. Expects a SwapTransactionRequestContainer, returns a list of SwapTransactionResponse. """ if not armor_client: return [{"error": "Not logged in"}] try: result: List[SwapTransactionResponse] = await armor_client.swap_transaction(swap_transaction_requests) return result except Exception as e: return [{"error": str(e)}]
  • Pydantic model for individual swap transaction request input, containing the transaction_id from a prior swap quote.
    class SwapTransactionRequest(BaseModel): transaction_id: str = Field(description="unique id of the generated swap quote")
  • Pydantic model for swap transaction response, including transaction details, URL, amounts, status, and optional error.
    class SwapTransactionResponse(BaseModel): id: str = Field(description="unique id of the swap transaction") transaction_error: Optional[str] = Field(description="error message if the transaction fails") transaction_url: str = Field(description="public url of the transaction") input_amount: float = Field(description="input amount in input token") output_amount: float = Field(description="output amount in output token") status: str = Field(description="status of the transaction")
  • Container model for batch input to swap_transaction tool, holding a list of SwapTransactionRequest.
    class SwapTransactionRequestContainer(BaseModel): swap_transaction_requests: List[SwapTransactionRequest]
  • Client method in ArmorWalletAPIClient that executes the actual API POST to /transactions/swap/ with the prepared payload, invoked by the MCP handler.
    async def swap_transaction(self, data: SwapTransactionRequestContainer) -> List[SwapTransactionResponse]: """Execute the swap transactions.""" # payload = [v.model_dump() for v in data.swap_transaction_requests] payload = data.model_dump(exclude_none=True)['swap_transaction_requests'] return await self._api_call("POST", "transactions/swap/", payload)

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/armorwallet/armor-crypto-mcp'

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