"use client"; /** * MCP Playground Component * * Interactive demo of Vibn's MCP capabilities */ import { useState } from 'react'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import { Textarea } from '@/components/ui/textarea'; import { auth } from '@/lib/firebase/config'; import { toast } from 'sonner'; import { Code2, Database, MessageSquare, Zap } from 'lucide-react'; interface MCPRequest { action: string; params?: any; } export function MCPPlayground() { const [loading, setLoading] = useState(false); const [result, setResult] = useState(null); const [selectedTool, setSelectedTool] = useState(null); const callMCP = async (request: MCPRequest) => { setLoading(true); setResult(null); try { const user = auth.currentUser; if (!user) { toast.error('Please sign in to use MCP'); return; } const token = await user.getIdToken(); const response = await fetch('/api/mcp', { method: 'POST', headers: { 'Authorization': `Bearer ${token}`, 'Content-Type': 'application/json', }, body: JSON.stringify(request), }); if (!response.ok) { const error = await response.json(); throw new Error(error.error || 'MCP request failed'); } const data = await response.json(); setResult(data); toast.success('MCP request completed'); } catch (error) { console.error('MCP error:', error); toast.error(error instanceof Error ? error.message : 'MCP request failed'); } finally { setLoading(false); } }; const tools = [ { id: 'list_resources', name: 'List Resources', description: 'View all available MCP resources', icon: Database, action: () => callMCP({ action: 'list_resources' }), }, { id: 'read_projects', name: 'Read Projects', description: 'Get all your projects via MCP', icon: Code2, action: () => { const user = auth.currentUser; if (!user) { toast.error('Please sign in'); return; } callMCP({ action: 'read_resource', params: { uri: `vibn://projects/${user.uid}` }, }); }, }, { id: 'read_sessions', name: 'Read Sessions', description: 'Get all your coding sessions', icon: Zap, action: () => { const user = auth.currentUser; if (!user) { toast.error('Please sign in'); return; } callMCP({ action: 'read_resource', params: { uri: `vibn://sessions/${user.uid}` }, }); }, }, ]; return (

MCP Playground

Test Vibn's Model Context Protocol capabilities. This is what AI assistants see when they query your project data.

{/* Tool Cards */}
{tools.map((tool) => ( { setSelectedTool(tool.id); tool.action(); }} >
{tool.name}
{tool.description}
))}
{/* Loading State */} {loading && (
Processing MCP request...
)} {/* Results */} {result && ( MCP Response This is the data that would be sent to an AI assistant