'use client'; import { useState, useCallback } from 'react'; import { useRouter } from 'next/navigation'; import { ArrowLeft, ArrowRight, Check, Loader2 } from 'lucide-react'; import { SpecUploader } from '@/components/spec-upload/SpecUploader'; import { AnalysisStream } from '@/components/spec-upload/AnalysisStream'; type Step = 1 | 2 | 3; interface DiscoveredTool { name: string; method: string; description: string; paramCount: number; enabled: boolean; } export default function NewProjectPage() { const router = useRouter(); const [step, setStep] = useState(1); const [name, setName] = useState(''); const [description, setDescription] = useState(''); const [analysisInput, setAnalysisInput] = useState<{ type: 'url' | 'raw'; value: string } | null>(null); const [analyzing, setAnalyzing] = useState(false); const [creating, setCreating] = useState(false); const steps = [ { num: 1, label: 'Project Info' }, { num: 2, label: 'API Spec' }, { num: 3, label: 'Discover Tools' }, ]; const canProceedStep1 = name.trim().length >= 2; const handleAnalyze = useCallback((input: { type: 'url' | 'raw'; value: string }) => { setAnalysisInput(input); setAnalyzing(true); setStep(3); }, []); const handleAnalysisComplete = useCallback((_tools: DiscoveredTool[]) => { setAnalyzing(false); }, []); const handleContinue = useCallback( async (selectedTools: DiscoveredTool[]) => { setCreating(true); try { // Create the project const res = await fetch('/api/projects', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name: name.trim(), description: description.trim(), specUrl: analysisInput?.type === 'url' ? analysisInput.value : undefined, specRaw: analysisInput?.type === 'raw' ? analysisInput.value : undefined, tools: selectedTools, }), }); if (!res.ok) throw new Error('Failed to create project'); const { data } = await res.json(); router.push(`/projects/${data.id}`); } catch (err) { console.error('[NewProject]', err); setCreating(false); } }, [name, description, analysisInput, router], ); return (
{/* Back to projects */} {/* Title */}

Create New Project

Build an MCP server from any API specification.

{/* Step indicator */}
{steps.map((s, i) => (
s.num ? 'bg-indigo-600 text-white' : step === s.num ? 'bg-indigo-600 text-white ring-4 ring-indigo-600/20' : 'bg-gray-800 text-gray-500' } `} > {step > s.num ? : s.num}
{i < steps.length - 1 && (
s.num ? 'bg-indigo-600' : 'bg-gray-800' }`} /> )}
))}
{/* Step 1: Name + Description */} {step === 1 && (
setName(e.target.value)} placeholder="My API Server" className="w-full px-4 py-3 rounded-xl bg-gray-800 border border-gray-700 text-gray-100 placeholder-gray-500 text-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition-all" />