Skip to content

Latest commit

 

History

History
424 lines (328 loc) · 15.8 KB

File metadata and controls

424 lines (328 loc) · 15.8 KB

Cambrian MCP Integration - Implementation Summary (Updated v2)

Overview

Successfully integrated two Cambrian MCP servers as separate action providers for comprehensive blockchain data and AI-powered research capabilities into the multi-agent trading system.

Architecture Change (November 23, 2025 v2)

Previous Implementation: Single unified provider handling both servers New Implementation: Two separate providers for better separation of concerns

Provider Split Benefits:

  1. Clear Separation: Data operations vs AI/social intelligence
  2. Independent Configuration: Each provider can be configured separately
  3. Selective Access: Agents can use one or both providers as needed
  4. Better Maintainability: Easier to update and debug individual providers
  5. Type Safety: More specific action signatures per provider

MCP Servers Configured

1. Cambrian Data MCP Server

  • URL: https://cambrian-mcp-server-prod-981646676182.us-central1.run.app/mcp
  • Purpose: DeFi and on-chain data (Solana/EVM focus)
  • Capabilities:
    • Trending tokens analysis
    • Token security metrics
    • Price and volume data
    • Pool liquidity metrics
    • Trader leaderboards
    • DEX analytics

2. Deep42 MCP Server (NEW)

  • URL: https://mcp.deep42.org/mcp
  • Purpose: AI-powered research and social intelligence
  • Capabilities:
    • AI Orchestration Agent - Multi-tool blockchain research
    • Social data and sentiment analysis
    • GitHub developer intelligence
    • Influencer credibility rankings
    • Alpha signal detection
    • Project discovery
    • Content generation

Implementation Date

  • Initial: November 23, 2025
  • Deep42 Integration: November 23, 2025
  • Provider Split: November 23, 2025 (v2)

What Was Implemented

1. Package Installation ✅

  • Installed @modelcontextprotocol/sdk@1.22.0 via Bun
  • Package provides MCP client capabilities for connecting to external MCP servers

2. Separate Provider Architecture ✅

Files:

  • app/providers/cambrianDataActionProvider.ts (450+ lines)
  • app/providers/deep42ActionProvider.ts (780+ lines)

Architecture:

  • Two independent providers for specialized functionality
  • Each provider connects to its respective MCP server
  • Unified JSON-RPC interface for all MCP tool calls
  • Proper error handling and logging for both providers
  • Agents can use one or both providers as needed

3. Cambrian Data MCP Actions (4 actions) ✅

Provider: cambrianDataActionProvider Class: CambrianDataActionProvider Server: Cambrian Data MCP

  1. getTrendingTokens - Solana trending tokens by price/volume

    • Parameters: orderBy, limit, offset
    • Returns: Trending token list with metrics
  2. getTokenSecurity - Token security analysis

    • Parameters: tokenAddress
    • Returns: Security scores, risk indicators
  3. getTokenPriceVolume - Price and volume data

    • Parameters: tokenAddress, timeframe (1h-24h)
    • Returns: Current price, volume, changes
  4. getTraderLeaderboard - Top traders for tokens

    • Parameters: tokenAddress, interval
    • Returns: Top traders, statistics, volumes

4. Deep42 AI-Powered Actions (7 actions) ✅

Provider: deep42ActionProvider Class: Deep42ActionProvider Server: Deep42 MCP

Deep42 Actions:

  1. askDeep42AgentMOST POWERFUL - AI orchestration agent

    • Parameters: question, continueChatId (optional)
    • Uses AI to orchestrate multiple tools automatically
    • Provides comprehensive blockchain research
    • Supports multi-turn conversations
  2. querySocialData - Social data and sentiment agent

    • Parameters: question, conversationContext (optional)
    • Returns: Alpha signals, sentiment, influencer insights
  3. getInfluencerCredibility - Influencer rankings

    • Parameters: minTweets, limit, tokenFocus, timeWindow
    • Returns: Credibility scores, track records
  4. detectAlphaTweets - High-alpha tweet detection

    • Parameters: limit, tokenFilter
    • Returns: Early signals, opportunities, insights
  5. searchProjects - Blockchain project discovery

    • Parameters: query, technology, category, chain, socialActivity, limit, hasGithub
    • Returns: DeFi, NFT, gaming, infra projects
  6. analyzeTokenSocial - Deep social analysis for tokens

    • Parameters: tokenSymbol, daysBack, granularity
    • Returns: Sentiment, engagement, influencer mentions
  7. getTrendingMomentumNEW - Trending momentum detection

    • Parameters: lookbackHours, minVelocity, limit, granularity
    • Returns: Tokens with momentum scores, velocities, quality metrics, sentiment
    • Business Value: Early trend detection, risk assessment, market timing

5. Provider Registration ✅

File: app/api/agent/prepare-agentkit.ts

Changes:

  • Imported cambrianDataActionProvider and deep42ActionProvider
  • Initialized provider instances separately
  • Added to provider map with distinct keys:
    • cambrianData: cambrianDataProvider
    • deep42: deep42Provider
  • Included in default providers list for agents without specific config

6. Cambrian Agent Definition ✅

File: data/agents.json

Updated Agent:

{
  "id": "cambrian-bot",
  "name": "Cambrian Social Researcher",
  "description": "Social data analyst providing insights from Deep42/Cambrian API",
  "strategiesFile": "strategies_cambrian.json",
  "triggerHistoryFile": "trigger_history_cambrian.json",
  "providers": ["cambrianData", "deep42", "pyth", "dexScreener", "walletAssets"],
  "systemPrompt": "...",
  "tone": "analytical",
  "isActive": true,
  "createdAt": 1732400000000
}

Agent Capabilities:

  • Solana token data (trending, security, price/volume, traders)
  • Social sentiment analysis
  • Community engagement metrics
  • Trending token identification with momentum detection
  • Project reputation assessment
  • Influencer credibility tracking
  • Alpha signal detection
  • Analytical tone focused on actionable intelligence

7. Data Files Created ✅

Files:

  • data/strategies_cambrian.json - Empty array (ready for strategies)
  • data/trigger_history_cambrian.json - Empty array (ready for events)

8. Environment Configuration ✅

File: .env.local

Added:

# Cambrian API for social data via MCP
CAMBRIAN_API_KEY=qvhzvNP8K5sGpmlC0xul4MIKCOGqGRRH

9. Documentation Updates ✅

File: AGENTS.md

Added Sections:

  1. Available Agents - Updated Cambrian Social Researcher (Agent #5)

    • Now uses both cambrianData and deep42 providers
    • Updated capabilities list
  2. Provider System - Split provider descriptions

    • cambrianData: DeFi/on-chain data (Solana/EVM)
    • deep42: AI-powered social intelligence
  3. Model Context Protocol (MCP) Integration - Updated section

    • Two separate MCP server URLs
    • Two separate provider implementations
    • Benefits of separated architecture
    • Updated available MCP actions (now 11 total: 4 data + 7 social/AI)

Technical Architecture

Separated Provider Pattern

Cambrian Data MCP Server              Deep42 MCP Server
                                              
HTTP Transport with API Key           HTTP Transport with API Key
                                              
CambrianDataActionProvider            Deep42ActionProvider
                                              
AgentKit ActionProvider Interface     AgentKit ActionProvider Interface
                                              
         └──────────────┬──────────────────────┘
                        
              AI Agents (can call both sets of actions)

Integration Benefits

  1. Standardized Protocol: MCP provides consistent way for AI to interact with external APIs
  2. Separation of Concerns: Two providers, each focused on specific domain (data vs intelligence)
  3. API Logic Isolation: API logic stays on respective MCP servers
  4. Dynamic Capabilities: Tools can be updated server-side without client changes
  5. Flexible Integration: Easy to add to existing agent workflows, use one or both providers
  6. Independent Scaling: Each provider can be updated/maintained independently

Files Modified

New Files:

  • app/providers/cambrianDataActionProvider.ts (450 lines)
  • app/providers/deep42ActionProvider.ts (780 lines)
  • data/strategies_cambrian.json
  • data/trigger_history_cambrian.json

Modified Files:

  • app/api/agent/prepare-agentkit.ts (updated imports and provider map)
  • data/agents.json (updated Cambrian agent providers)
  • AGENTS.md (updated provider system and MCP sections)
  • CAMBRIAN_MCP_IMPLEMENTATION.md (this file, v2 update)
  • .env.local (CAMBRIAN_API_KEY)
  • package.json (added @modelcontextprotocol/sdk dependency)
  • bun.lock (updated)

Deleted Files:

  • app/providers/cambrianActionProvider.ts (replaced by two separate providers)

Usage Examples

Using Cambrian Bot with Both Providers

// User: "What Solana tokens are trending?"
// Agent: Calls getTrendingTokens from cambrianData provider
// Returns: Trending tokens with price changes and volumes

// User: "Show me social momentum for these tokens"
// Agent: Calls getTrendingMomentum from deep42 provider
// Returns: Tokens with high social velocity and quality scores

// User: "What's the sentiment for SOL?"
// Agent: Calls analyzeTokenSocial from deep42 provider
// Returns: Sentiment analysis, engagement metrics, community insights

Adding Providers to Existing Agents

To give any agent access to DeFi data or social intelligence:

{
  "id": "warren-debuffett",
  "providers": ["fearAndGreed", "pyth", "swap", "walletAssets", "dexScreener", "cambrianData", "deep42"]
}

Testing Recommendations

  1. Test Cambrian Data MCP actions (cambrianData provider):

    • Query trending Solana tokens: getTrendingTokens({ orderBy: "price_change_percentage", limit: 10 })
    • Check token security: getTokenSecurity({ tokenAddress: "So11111111111111111111111111111111111111112" })
    • Get price/volume: getTokenPriceVolume({ tokenAddress: "So11111111111111111111111111111111111112", timeframe: "24h" })
    • Get trader leaderboard: getTraderLeaderboard({ tokenAddress: "...", interval: "24 HOUR" })
  2. Test Deep42 AI-powered actions (deep42 provider):

    • Ask AI agent: askDeep42Agent({ question: "What are the top trending tokens on Solana?" })
    • Query social data: querySocialData({ question: "Show me alpha signals for SOL" })
    • Detect alpha tweets: detectAlphaTweets({ limit: 5 })
    • Get influencer rankings: getInfluencerCredibility({ limit: 10, tokenFocus: "SOL" })
    • Search projects: searchProjects({ category: "DeFi", chain: "solana", limit: 10 })
    • Analyze token social: analyzeTokenSocial({ tokenSymbol: "SOL", daysBack: 7 })
    • Get trending momentum: getTrendingMomentum({ lookbackHours: 24, minVelocity: 1.5, limit: 15 })
  3. Integration testing:

    • Start dev server: bun run dev
    • Select Cambrian bot in UI
    • Test both data-focused and AI-focused questions
    • Test trending momentum specifically
    • Verify API calls in console logs
    • Confirm both providers work independently and together

Known Capabilities

Cambrian Data MCP Tools (50+ tools available)

  • Solana: trending_tokens, token_security, price_volume, traders_leaderboard, pool transactions, wallet balances
  • EVM: Aerodrome, AlienBase, Clones, PancakeSwap, SushiSwap, Uniswap V3 pools
  • Price Data: current prices, hourly/daily aggregations, OHLCV data
  • DEX Analytics: pool info, liquidity maps, fee metrics, volume analysis

Deep42 MCP Tools (16 tools available)

  • executeDeep42Agent: AI orchestration with multi-tool access
  • querySocialDataAgent: Social sentiment and alpha signals
  • queryGithubAgent: Developer intelligence (direct/enhanced/hybrid modes)
  • getInfluencerCredibility: Influencer rankings and track records
  • detectAlphaTweets: High-alpha tweet detection
  • getTrendingMomentumNEW: Trending momentum with velocity metrics
  • analyzeTwitterUserAlphaMetrics: User-specific alpha analysis
  • searchDiscoveredProjects: Project discovery across chains
  • getSocialAssociations: Token-influencer associations
  • queryRepositoryMarketData: GitHub repo market correlations
  • getSentimentShifts: Major sentiment shift detection
  • getTokenSocialAnalysis: Deep social analysis for tokens
  • executeContentGenerationPipeline: Content generation
  • executeResearchPipeline (deprecated): Multi-stage research

Key Insights

Why Two MCP Servers?

Specialization & Scalability:

  1. Data Server: Optimized for high-frequency on-chain queries, DEX analytics, price feeds
  2. Deep42 Server: AI-powered analysis, social intelligence, GitHub research

Benefits:

  • Separation of concerns (data vs AI)
  • Independent scaling and optimization
  • Specialized infrastructure for different workloads
  • Better fault tolerance (one server down doesn't affect the other)

Most Powerful Features

  1. askDeep42Agent (Deep42 provider) - The AI orchestrator that can:

    • Automatically select and combine multiple tools
    • Provide comprehensive research reports
    • Support multi-turn conversations with context
    • Adapt to complex, open-ended questions
  2. getTrendingMomentum (Deep42 provider) ⭐ NEW - Momentum detection:

    • Early trend detection with velocity metrics
    • Quality scores and sentiment analysis
    • Risk assessment via engagement patterns
    • Market timing insights
    • Filter by lookback period and minimum velocity
  3. Social Intelligence Stack (Deep42 provider) - Unique competitive advantage:

    • Real-time alpha tweet detection
    • Influencer credibility tracking
    • Sentiment shift detection
    • Project discovery with social metrics
    • Trending momentum analysis
  4. On-Chain + Social Fusion - Combine both providers:

    • Get trending tokens from Cambrian Data MCP
    • Analyze social momentum from Deep42 MCP
    • Cross-reference trader leaderboards with influencer credibility
    • Make informed decisions with complete picture

Future Enhancements

  1. Enhanced Provider Coordination:

    • Cross-provider query optimization
    • Caching layer for frequently accessed data
    • Unified error handling across providers
  2. Additional Social Metrics:

    • Time-series momentum tracking
    • Network analysis and influence graphs
    • Sentiment trends over time with visualization
  3. Strategy Integration:

    • Create social momentum-based trading strategies
    • Combine Fear & Greed Index with trending momentum
    • Alert system for viral tokens and velocity spikes
    • Automated trading based on momentum thresholds

References

Success Criteria - ALL MET ✅

  • MCP SDK package installed
  • Cambrian Data Action Provider created with proper MCP structure
  • Deep42 Action Provider created with proper MCP structure
  • Both providers registered in AgentKit setup
  • Cambrian agent updated with both providers
  • Trending momentum action added to Deep42 provider
  • Data files exist for agent
  • Environment variable configured
  • Documentation updated in AGENTS.md and CAMBRIAN_MCP_IMPLEMENTATION.md
  • No linting errors
  • All todos completed

Status

IMPLEMENTATION COMPLETE v2

All planned features have been implemented successfully, including:

  • Provider split into two separate providers
  • Trending momentum endpoint added
  • Documentation updated to reflect new architecture

The Cambrian MCP integration is ready for testing and use with improved separation of concerns.