Skip to main content
Glama

swap_transaction

Execute cryptocurrency swap transactions by processing swap requests and returning transaction responses, enabling trading operations within crypto ecosystems.

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 and registration for 'swap_transaction'. Thin wrapper that checks authentication and delegates to ArmorWalletAPIClient.swap_transaction.
    @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 a single SwapTransactionRequest, containing the transaction_id from a prior swap quote.
    class SwapTransactionRequest(BaseModel): transaction_id: str = Field(description="unique id of the generated swap quote")
  • Container model for the input to swap_transaction tool, holding a list of SwapTransactionRequest.
    class SwapTransactionRequestContainer(BaseModel): swap_transaction_requests: List[SwapTransactionRequest]
  • Pydantic model for SwapTransactionResponse, defining the output structure of the tool.
    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")
  • Core implementation in ArmorWalletAPIClient that sends POST request to '/transactions/swap/' API endpoint with list of transaction_ids to execute the swaps.
    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/emmaThompson07/armor-crypto-mcp'

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