Overview
The Handshake Architecture enables MCP tools to request user interaction for actions that require explicit approval:- Signature Requests: EIP-712 typed data signing (Hyperliquid, dYdX)
- Transaction Proposals: direct on-chain transactions (Uniswap, NFT mints)
- OAuth Requests: external service authentication (Discord, Twitter)
Why “Handshake”? The tool proposes an action, the user approves it, and the result is returned to the tool. That is the secure handshake between AI and human.
When to Use Handshakes
Quick Start (TypeScript)
1. Install the SDK
2. Import Handshake Helpers
3. Return a Handshake from Your Tool
Quick Start (Python)
1. Install the SDK
2. Import Handshake Helpers
3. Return a Handshake from Your Tool
How It Works
Action Types
Signature Request (EIP-712)
Best for platforms with proxy wallets that accept EIP-712 signatures directly (Hyperliquid, dYdX).Gasless & Chain-Agnostic: EIP-712 signatures don’t require gas or network switching. The
chainId in the domain is purely informational: signing works from any network.Transaction Proposal
For direct on-chain actions (Uniswap swaps, NFT mints, etc.).Auth Required (OAuth)
For external service authentication.Security: The
authUrl domain must match your tool’s endpoint domain. Context appends the user’s DID as ?context_did=... for you to associate the auth with the user.Response Format
Handshake actions must be placed instructuredContent._meta.handshakeAction:
Helper Functions
TypeScript SDK
Python SDK
Complete Example: Hyperliquid Order Tool
Complete Example: Discord Notifications (OAuth)
This example shows how to build a tool that posts messages to a user’s Discord channel, requiring OAuth authentication.Tool Definition
OAuth Endpoint (Your Backend)
You must host OAuth endpoints on your MCP server’s domain:How It Works
Domain Requirement: Your
authUrl must be on the same domain as your MCP endpoint. This prevents phishing attacks where a malicious tool redirects to a fake auth page.UI Preview
When a handshake is detected, the Context app shows an approval card: The card displays:- Protocol name and action type
- Human-readable description
- Token amount (if applicable)
- Gas status (gasless for signatures)
- Sign/Reject buttons
Best Practices
Always include descriptive meta
Always include descriptive meta
The
meta field powers the approval UI. Include:description: What the user is approvingprotocol: Which platform (builds trust)tokenAmount+tokenSymbol: For financial actionswarningLevel: “caution” for large amounts, “danger” for irreversible actions
Use signatures over transactions
Use signatures over transactions
EIP-712 signatures are:
- Gasless (no ETH needed)
- Chain-agnostic (no network switching)
- Faster (no block confirmation)
Validate inputs before requesting signature
Validate inputs before requesting signature
Don’t ask users to sign invalid orders. Validate:
- Asset exists on the platform
- Price is reasonable (not 100x above/below market)
- Size is within platform limits
- User has sufficient balance (if portfolio context available)
Use callbackToolName for multi-step flows
Use callbackToolName for multi-step flows
For flows that need the signature result:The platform will call this tool with
{ signature, originalParams } after signing.Security Considerations
No Private Keys: The user’s wallet signs the data client-side. Your tool never sees private keys, only the resulting signature.
Platform Philosophy
The Context marketplace supports authentication flows that are generalizable, so solving the problem once enables infinite integrations.Why no API key support? Platforms like Polymarket require API keys derived from wallet signatures on their site, with custom HMAC authentication for every request. This cannot be delegated through the handshake architecture.If your tool requires API keys, you have two options:
- Provide read-only features with a redirect link for write actions
- Accept user-provided keys as input parameters (user manages their own credentials)

