Cap Bet LogoCap Bet Docs

MCP Server Integration

Connect AI agents to Cap Bet using the Model Context Protocol

MCP Server Integration

The Model Context Protocol (MCP) allows AI agents to interact with Cap Bet seamlessly. This guide will help you integrate your AI agents with our MCP server.

What is MCP?

The Model Context Protocol is a standardized way for AI agents to interact with external services. Cap Bet's MCP server provides AI agents with:

  • Market data access
  • Betting capabilities
  • Real-time updates
  • Position management

Getting Started

Installation

npm install @capbet/mcp-client

Basic Setup

import { CapBetMCPClient } from '@capbet/mcp-client';

const client = new CapBetMCPClient({
  apiKey: process.env.CAPBET_API_KEY,
  cluster: 'devnet',
});

// Connect to MCP server
await client.connect();

Available Tools

Get Markets

Query available betting markets:

const markets = await client.tools.getMarkets({
  status: 'active',
  category: 'crypto',
});

Create Market

AI agents can create new betting markets:

const market = await client.tools.createMarket({
  title: 'Will Bitcoin reach $100k this year?',
  description: 'Resolves YES if BTC hits $100k',
  lockTime: '2024-12-31T23:59:59Z',
});

Place Bet

Place a bet on behalf of a user:

const position = await client.tools.placeBet({
  marketId: 'market_123',
  side: 'yes',
  amount: 10,
});

Get Position Status

Check position status:

const position = await client.tools.getPosition({
  marketId: 'market_123',
  userPublicKey: 'ABC123...',
});

Agent Capabilities

Cap Bet MCP server provides these capabilities to AI agents:

  1. Market Discovery: Search and filter betting markets
  2. Risk Assessment: Analyze market data and odds
  3. Position Management: Create and monitor positions
  4. Real-time Monitoring: Subscribe to market updates
  5. Automated Resolution: Track and claim winnings

Configuration

Environment Variables

CAPBET_MCP_API_KEY=your_api_key
CAPBET_MCP_CLUSTER=devnet
CAPBET_MCP_RPC_URL=https://api.devnet.solana.com

Authentication

MCP clients authenticate using API keys:

const client = new CapBetMCPClient({
  apiKey: process.env.CAPBET_API_KEY,
  authentication: {
    walletPrivateKey: process.env.WALLET_PRIVATE_KEY,
  },
});

Examples

AI Betting Agent

import { CapBetMCPClient } from '@capbet/mcp-client';
import Anthropic from '@anthropic-ai/sdk';

// Initialize clients
const capbet = new CapBetMCPClient({ apiKey: process.env.CAPBET_API_KEY });
const anthropic = new Anthropic({ apiKey: process.env.ANTHROPIC_API_KEY });

// AI agent makes betting decisions
async function analyzeBet(marketId: string) {
  const market = await capbet.tools.getMarket({ marketId });

  const response = await anthropic.messages.create({
    model: 'claude-3-5-sonnet-20241022',
    messages: [{
      role: 'user',
      content: `Analyze this betting market: ${JSON.stringify(market)}`,
    }],
  });

  // Agent decides to place bet
  if (shouldBet(response)) {
    await capbet.tools.placeBet({
      marketId,
      side: 'yes',
      amount: 5,
    });
  }
}

Rate Limits

MCP API rate limits:

  • Standard tier: 100 requests/minute
  • Premium tier: 1000 requests/minute
  • Enterprise: Custom limits

Security

  • All MCP connections use TLS encryption
  • API keys should never be exposed in client-side code
  • Use environment variables for sensitive data
  • Implement proper error handling

Coming Soon

  • Claude Desktop MCP integration
  • Advanced analytics tools
  • Multi-agent coordination
  • Custom tool definitions

Resources

MCP Server Integration | Cap Bet Docs