OsirisOsiris

Examples

Real-world MCP implementations built with Osiris SDK

Explore real-world MCP implementations built with the Osiris SDK. These examples showcase the power of authenticated, stateful, and policy-driven MCPs across different domains.

Productivity MCPs

Gmail MCP

Email management with OAuth authentication

import { createHubGmailClient } from '@osiris-ai/google-sdk';
import { createMcpServer, getAuthContext } from '@osiris-ai/sdk';

class GmailMCP {
    configureServer(server) {
        server.tool('send_email', 'Send an email through Gmail', {
            to: { type: 'string', description: 'Recipient email' },
            subject: { type: 'string', description: 'Email subject' },
            body: { type: 'string', description: 'Email content' }
        }, async ({ to, subject, body }) => {
            const gmail = this.getGmailClient();
            
            const emailContent = [
                `To: ${to}`,
                `Subject: ${subject}`,
                'MIME-Version: 1.0',
                'Content-Type: text/plain; charset=UTF-8',
                '',
                body
            ];
            
            const raw = Buffer.from(emailContent.join('\r\n'))
                .toString('base64')
                .replace(/\+/g, '-')
                .replace(/\//g, '_');
            
            const result = await gmail.users.messages.send({
                userId: 'me',
                requestBody: { raw }
            });
            
            return {
                content: [{
                    type: 'text',
                    text: `✅ Email sent successfully! Message ID: ${result.data.id}`
                }]
            };
        });
    }
}

Features:

  • OAuth authentication with Google
  • Send emails through Gmail API
  • Persistent token management
  • Multi-tenant isolation

Calendar MCP

Calendar management and scheduling

server.tool('create_event', 'Create a calendar event', {
    title: { type: 'string', description: 'Event title' },
    start: { type: 'string', description: 'Start time (ISO 8601)' },
    end: { type: 'string', description: 'End time (ISO 8601)' },
    description: { type: 'string', description: 'Event description' }
}, async ({ title, start, end, description }) => {
    const calendar = this.getCalendarClient();
    
    const event = await calendar.events.insert({
        calendarId: 'primary',
        requestBody: {
            summary: title,
            start: { dateTime: start },
            end: { dateTime: end },
            description: description
        }
    });
    
    return {
        content: [{
            type: 'text',
            text: `📅 Event created: ${event.data.htmlLink}`
        }]
    };
});

Discord MCP

Discord server and channel management

server.tool('send_message', 'Send a message to Discord channel', {
    channel_id: { type: 'string', description: 'Discord channel ID' },
    message: { type: 'string', description: 'Message content' }
}, async ({ channel_id, message }) => {
    const discord = this.getDiscordClient();
    
    const result = await discord.channels.createMessage(channel_id, {
        content: message
    });
    
    return {
        content: [{
            type: 'text',
            text: `💬 Message sent to Discord: ${result.id}`
        }]
    };
});

Web3 MCPs

Uniswap MCP

DeFi trading with policy enforcement

import { getAuthContext, EVMWalletClient } from '@osiris-ai/sdk';

class UniswapMCP {
    async swap(params: SwapTransactionParams): Promise<CallToolResult> {
        // Get wallet context - policy engine validates transactions
        const { token, context } = getAuthContext("osiris");
        if (!token || !context) {
            throw new Error("Wallet authentication required");
        }
        
        const client = new EVMWalletClient(
            this.hubBaseUrl, 
            token.access_token, 
            context.deploymentId, 
            this.chainId
        );
        
        const walletRecords = await client.getWalletRecords();
        const account = await client.getViemAccount(
            walletRecords[0].metadata.wallet.addresses[0]
        );
        
        // Policy engine automatically validates transaction
        const signedTx = await client.signTransaction(abi, serializedTx, account.address);
        const hash = await walletClient.sendRawTransaction({
            serializedTransaction: signedTx as `0x${string}`
        });
        
        return createSuccessResponse("Successfully swapped tokens", {
            hash: hash
        });
    }
}

Features:

  • Embedded wallet integration
  • Policy engine validation
  • Transaction limits and safety checks
  • Support for EVM chains

Hyperliquid Trading MCP

Professional trading assistant with policy-enforced wallet security

import { EVMWalletClient } from '@osiris-ai/web3-evm-sdk';
import { createMcpServer, getAuthContext } from '@osiris-ai/sdk';

export class HyperliquidMCP {
    private hubBaseUrl: string;
    private walletToSession: Record<string, string> = {};

    constructor(hubBaseUrl: string) {
        this.hubBaseUrl = hubBaseUrl;
    }

    configureServer(server: McpServer) {
        // Wallet Management
        server.tool('getUserAddresses', 'Get user wallet addresses', {}, 
            () => this.getUserAddresses()
        );

        server.tool('chooseWallet', 'Select wallet for trading session', {
            address: { type: 'string', description: 'Wallet address to use' }
        }, ({ address }) => this.chooseWallet(address));

        // Market Data
        server.tool('getBalance', 'Get user balances (perp + spot)', {
            address: { type: 'string', description: 'User wallet address' }
        }, ({ address }) => this.getBalance(address));

        server.tool('getPositions', 'Get current trading positions', {
            address: { type: 'string', description: 'User wallet address' }
        }, ({ address }) => this.getPositions(address));

        server.tool('getSpotAndPerpPrices', 'Get real-time prices', {
            symbol: { type: 'string', description: 'Trading symbol (e.g., ETH, BTC)' }
        }, ({ symbol }) => this.getSpotAndPerpPrices(symbol));

        server.tool('getOrderbook', 'Get orderbook depth', {
            symbol: { type: 'string', description: 'Trading symbol' }
        }, ({ symbol }) => this.getOrderbook(symbol));

        // Trading Operations
        server.tool('leveragePerpTrade', 'Execute leveraged perpetual trade', {
            requestBody: {
                type: 'object',
                description: 'Hyperliquid order request with policy validation'
            }
        }, ({ requestBody }) => this.leveragePerpTrade(requestBody));

        server.tool('placeTwapOrder', 'Place Time-Weighted Average Price order', {
            requestBody: {
                type: 'object', 
                description: 'TWAP order configuration'
            }
        }, ({ requestBody }) => this.placeTwapOrder(requestBody));

        server.tool('updateLeverage', 'Update position leverage', {
            requestBody: {
                type: 'object',
                description: 'Leverage update request'
            }
        }, ({ requestBody }) => this.updateLeverage(requestBody));

        server.tool('transferUsd', 'Transfer USD between accounts', {
            requestBody: {
                type: 'object',
                description: 'USD transfer request'
            }
        }, ({ requestBody }) => this.transferUsd(requestBody));
    }

    // Core trading implementation with policy enforcement
    async leveragePerpTrade(requestBody: any) {
        const { token, context } = getAuthContext("osiris");
        if (!token || !context) {
            throw new Error("Wallet authentication required");
        }

        const wallet = this.walletToSession[context.sessionId];
        if (!wallet) {
            throw new Error("No wallet selected. Use chooseWallet first.");
        }

        // Build Hyperliquid-specific signed payload
        const nonce = Date.now();
        const signTypedDataPayload = this.buildSignTypedDataPayload(
            requestBody, 
            nonce, 
            false // isTestnet
        );

        // Policy engine validates transaction before signing
        const client = new EVMWalletClient(
            this.hubBaseUrl,
            token.access_token,
            context.deploymentId
        );

        const signature = await client.signTypedData(
            signTypedDataPayload,
            "evm:eip155:999", // Hyperliquid chain
            wallet,
            {
                operation: "leveragePerpTrade",
                ordersCount: requestBody.orders.length,
                rawAction: requestBody,
                nonce: nonce
            }
        );

        // Execute on Hyperliquid exchange
        return await this.executeOnExchange(requestBody, signature, nonce);
    }
}

Key Features:

Wallet Integration

  • Embedded Wallets: Turnkey-powered wallets with hardware security
  • Policy Enforcement: User-defined trading policies prevent unauthorized transactions
  • Multi-Chain Support: Optimized for Hyperliquid's unique chain requirements

Comprehensive Trading Suite

  • Perpetual Futures: Leveraged trading with up to 50x leverage
  • Spot Trading: Direct token purchases and sales
  • TWAP Orders: Time-weighted average price execution
  • Advanced Orders: Stop-loss, take-profit, and conditional orders

Professional Market Data

  • Real-time Pricing: Spot and perpetual prices with funding rates
  • Order Book Depth: Level 2 market data for price discovery
  • Trade History: Complete transaction and position tracking
  • Portfolio Analytics: P&L tracking and risk metrics

Risk Management

  • Position Limits: User-configurable maximum position sizes
  • Leverage Controls: Asset-specific leverage restrictions
  • Loss Prevention: Automatic stop-loss policies
  • Withdrawal Limits: Daily/weekly withdrawal restrictions

Enterprise Security

  • Multi-Signature: Optional multi-sig wallet requirements
  • Policy Engine: Granular transaction validation rules
  • Audit Trail: Complete transaction history and compliance logs
  • Session Management: Secure wallet selection per trading session

Gaming MCPs

World of AI MCP

LLM-powered historical strategy game

server.tool('start_conquest', 'Initialize a new World of AI game session', {
    player_name: { type: 'string', description: 'Name of the player/character' },
    scenario_id: { type: 'string', description: 'Historical scenario to play' }
}, async ({ player_name, scenario_id }) => {
    const session = await gameEngine.initializeGame({
        playerId: 'user_' + Date.now(),
        playerName: player_name,
        scenarioId: scenario_id
    });

    const summary = await gameEngine.getGameSummary(session.sessionId);
    const latestComic = await stateManager.getLatestComicPanel(session.sessionId);

    return {
        content: [{
            type: 'text',
            text: `🏛️ **CONQUEST BEGINS: ${session.scenario.name}**\n\n` +
                  `Welcome, ${player_name}! ${session.scenario.description}\n\n` +
                  `**Setting:** ${session.scenario.geographicLocation}\n` +
                  `**Period:** ${session.scenario.historicalPeriod}\n\n` +
                  `**Session ID:** ${session.sessionId}\n\n` +
                  (latestComic ? `**Comic Panel:** ${latestComic.imageUrl}\n\n` : '') +
                  `Your story begins now. The fate of history is in your hands!`
        }]
    };
});

Features:

  • Persistent game sessions across conversations
  • AI-generated comic panels
  • Complex game state management
  • Historical scenario simulation

Multiplayer D&D MCP

Cross-platform multiplayer campaigns

server.tool('create_campaign', 'Start a new D&D campaign', {
    campaign_name: { type: 'string' },
    max_players: { type: 'number' },
    setting: { type: 'string' }
}, async ({ campaign_name, max_players, setting }) => {
    const campaign = await gameEngine.createCampaign({
        name: campaign_name,
        dmId: 'ai-dungeon-master',
        maxPlayers: max_players,
        setting: setting || 'fantasy'
    });
    
    return {
        content: [{
            type: 'text',
            text: `🏰 **CAMPAIGN CREATED: ${campaign_name}**\n\n` +
                  `Campaign ID: ${campaign.id}\n` +
                  `Setting: ${campaign.setting}\n` +
                  `Max Players: ${max_players}\n\n` +
                  `Share this campaign ID with friends to invite them!`
        }]
    };
});

Features:

  • Cross-platform multiplayer (ChatGPT, Claude, etc.)
  • Persistent character sheets and campaigns
  • Cross-conversation notifications
  • AI dungeon master with dynamic storytelling

Utility MCPs

Notion MCP

Workspace and knowledge management

server.tool('create_page', 'Create a new Notion page', {
    parent_id: { type: 'string', description: 'Parent page or database ID' },
    title: { type: 'string', description: 'Page title' },
    content: { type: 'string', description: 'Page content in markdown' }
}, async ({ parent_id, title, content }) => {
    const notion = this.getNotionClient();
    
    const page = await notion.pages.create({
        parent: { page_id: parent_id },
        properties: {
            title: {
                title: [{ text: { content: title } }]
            }
        },
        children: [
            {
                object: 'block',
                type: 'paragraph',
                paragraph: {
                    rich_text: [{ text: { content } }]
                }
            }
        ]
    });
    
    return {
        content: [{
            type: 'text',
            text: `📝 Page created: ${page.url}`
        }]
    };
});

GitHub MCP

Repository and issue management

server.tool('create_issue', 'Create a GitHub issue', {
    repo: { type: 'string', description: 'Repository name (owner/repo)' },
    title: { type: 'string', description: 'Issue title' },
    body: { type: 'string', description: 'Issue description' },
    labels: { type: 'array', description: 'Issue labels' }
}, async ({ repo, title, body, labels }) => {
    const github = this.getGitHubClient();
    const [owner, repoName] = repo.split('/');
    
    const issue = await github.rest.issues.create({
        owner,
        repo: repoName,
        title,
        body,
        labels
    });
    
    return {
        content: [{
            type: 'text',
            text: `🐛 Issue created: ${issue.data.html_url}`
        }]
    };
});

Stateful Examples

Nutrition Tracker MCP

Persistent health data management

interface NutritionEntry {
    timestamp: Date;
    mealType: 'breakfast' | 'lunch' | 'dinner' | 'snack';
    foods: FoodItem[];
    macroBreakdown: MacroBreakdown;
}

export class NutritionTracker {
    async logMeal(userId: string, entry: NutritionEntry) {
        // Store in structured format
        await this.database.nutritionEntries.create({
            userId,
            ...entry,
            calculatedCalories: entry.foods.reduce((sum, food) => 
                sum + (food.calories * food.quantity), 0)
        });
        
        // Update daily totals
        await this.updateDailyTotals(userId, entry.timestamp);
    }
    
    async getWeeklyAnalysis(userId: string): Promise<WeeklyNutrition> {
        const entries = await this.database.nutritionEntries.findMany({
            where: { 
                userId,
                timestamp: { gte: sevenDaysAgo }
            }
        });
        
        return {
            avgCalories: entries.reduce((sum, e) => sum + e.calculatedCalories, 0) / 7,
            macroBreakdown: this.calculateMacroBreakdown(entries),
            adherenceRate: this.calculateAdherenceToGoals(entries)
        };
    }
}

Features:

  • Persistent nutrition data
  • Trend analysis and insights
  • Goal tracking with real metrics
  • Cross-conversation memory

Key Benefits Demonstrated

🔐 Authenticated

  • User data stays private and secure
  • OAuth integration with major services
  • Multi-tenant isolation

🧠 Stateful

  • MCPs learn and improve from every interaction
  • Data accumulates value over time
  • Personalized experiences

🔄 Persistent

  • Information survives conversation resets
  • Cross-platform data sharing
  • Long-term relationship building

🚀 Scalable

  • Handle complex workflows
  • Multiple service integrations
  • Enterprise-grade infrastructure

🛡️ Policy-Safe

  • Wallet transactions protected by user-defined policies
  • Risk management and limits
  • Automatic validation

🌐 Social

  • Shared leaderboards and challenges
  • Multiplayer experiences
  • Community features

Getting Started


These examples showcase the unique power of authenticated, stateful MCPs with cross-platform capabilities that only the Osiris SDK can provide. Each example demonstrates how to build intelligent assistants that grow smarter with every use while maintaining complete privacy and security.