Installation
Requirements
- Node.js 18+ (for native fetch)
- TypeScript 5+ (recommended)
Prerequisites
Before using the API, complete setup at ctxprotocol.com:1
Sign in
Creates your embedded wallet
2
Enable Auto Pay
Approve USDC spending for tool payments
3
Fund wallet
Add USDC for tool execution fees
4
Generate API key
In Settings page
Quick Start
Configuration
Client Options
| Option | Type | Required | Default | Description |
|---|---|---|---|---|
apiKey | string | Yes | — | Your Context Protocol API key |
baseUrl | string | No | https://ctxprotocol.com | API base URL (for development) |
API Reference
Discovery
client.discovery.search(query, limit?)
Search for tools matching a query string.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
query | string | Yes | Search query |
limit | number | No | Maximum results to return |
Promise<Tool[]>
client.discovery.getFeatured(limit?)
Get featured/popular tools.
Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
limit | number | No | Maximum results to return |
Promise<Tool[]>
Tools
client.tools.execute(options)
Execute a tool method.
Parameters:
| Option | Type | Required | Description |
|---|---|---|---|
toolId | string | Yes | UUID of the tool |
toolName | string | Yes | Name of the method to call |
args | object | No | Arguments matching the tool’s inputSchema |
Promise<ExecutionResult>
Types
Import Types
Tool
McpTool
ExecutionResult
Context Requirement Types
For MCP server contributors building tools that need user context (e.g., wallet data, portfolio positions):Why Context Injection Matters:
- No Auth Required: Public blockchain/user data is fetched by the platform, so you don’t need to handle API keys or user login.
- Security: Your MCP server never handles private keys or sensitive credentials.
- Simplicity: You receive structured, type-safe data directly in your tool arguments.
Injected Context Types
HyperliquidContext
PolymarketContext
WalletContext
Error Handling
The SDK throwsContextError with specific error codes:
Error Codes
| Code | Description | Handling |
|---|---|---|
unauthorized | Invalid API key | Check configuration |
no_wallet | Wallet not set up | Direct user to helpUrl |
insufficient_allowance | Auto Pay not enabled | Direct user to helpUrl |
payment_failed | USDC payment failed | Check balance |
execution_failed | Tool error | Retry with different args |
Securing Your Tool (MCP Contributors)
If you’re building an MCP server, verify incoming requests are legitimate:Quick Implementation
Security Model
| MCP Method | Auth Required | Reason |
|---|---|---|
tools/list | ❌ No | Discovery - just returns tool schemas |
tools/call | ✅ Yes | Execution - runs code, may cost money |
initialize | ❌ No | Session setup |
resources/list | ❌ No | Discovery |
prompts/list | ❌ No | Discovery |
Manual Verification
For more control, use the lower-level utilities:Verification Options
| Option | Type | Required | Description |
|---|---|---|---|
authorizationHeader | string | Yes | Full Authorization header (e.g., "Bearer eyJ...") |
audience | string | No | Expected audience claim for stricter validation |
Payment Flow
When you execute a tool:- Your pre-approved USDC allowance is used
- 90% goes to the tool developer
- 10% goes to the protocol
- Tool executes and returns results
Links
- Context Protocol — Main website
- GitHub — Main project
- NPM Package

