TypeScript MCP Server Implementation
Built a type-safe MCP server enabling AI-assisted workflows for an open source product. Includes vector database integration for intelligent context retrieval.
Our TypeScript developers aren't gig workers chasing the next contract. They're experienced professionals building careers here, which means the developers you hire from us can build your products for years to come.
When developers stay, they accumulate deep expertise in your codebase. 72% of our clients have stayed 5+ years because our developers became their genuine long-term team members.
72% of clients have stayed 5+ years
Some of our developers have worked over 10 years with the same client
We're employers - our developers have careers here, not gigs
We test developers on internal projects before trusting them with yours
22 years of outlasting platforms that came and went
72% of clients have stayed 5+ years
Some of our developers have worked over 10 years with the same client
We're employers - our developers have careers here, not gigs
We test developers on internal projects before trusting them with yours
22 years of outlasting platforms that came and went
72% of clients have stayed 5+ years
Some of our developers have worked over 10 years with the same client
We're employers - our developers have careers here, not gigs
We test developers on internal projects before trusting them with yours
22 years of outlasting platforms that came and went
// React 18 + TypeScript - Production Chat with ARIA & Security
import React, { useEffect, useCallback, useRef, useState, useId } from 'react';
import DOMPurify from 'dompurify';
import { z } from 'zod';
import { logger } from '@/lib/logging/logger';
import { WebSocketService } from '@/services/websocket/WebSocketService';
import { useToast } from '@/hooks/useToast';
import { ErrorBoundary, useErrorBoundary } from 'react-error-boundary';
import { MessageSchema, WebSocketEventSchema } from '@/schemas/websocket';
import { RateLimiter } from '@/utils/rate-limiter';
import type { Message, ConnectionState } from '@/types/chat';
interface ChatRoomProps {
userId: string;
roomId: string;
serverUrl?: string;
}
// Rate limiter instance (10 messages per second)
const rateLimiter = new RateLimiter({ maxRequests: 10, windowMs: 1000 });
export const ChatRoom: React.FC<ChatRoomProps> = React.memo(({
userId,
roomId,
serverUrl = import.meta.env.VITE_WS_URL
}) => {
// Generate unique IDs for ARIA relationships
const inputId = useId();
const messagesId = useId();
const statusId = useId();
const [messages, setMessages] = useState<Message[]>([]);
const [connectionState, setConnectionState] = useState<ConnectionState>('disconnected');
const [messageInput, setMessageInput] = useState('');
const [error, setError] = useState<string | null>(null);
const [announcement, setAnnouncement] = useState('');
const messagesEndRef = useRef<HTMLDivElement>(null);
const inputRef = useRef<HTMLTextAreaElement>(null);
const wsRef = useRef<WebSocketService>();
const { showBoundary } = useErrorBoundary();
const toast = useToast();
// Announce to screen readers
const announce = useCallback((message: string) => {
setAnnouncement(message);
setTimeout(() => setAnnouncement(''), 1000);
}, []);
// Sanitize user input to prevent XSS
const sanitizeInput = useCallback((input: string): string => {
return DOMPurify.sanitize(input, { ALLOWED_TAGS: [] }).trim();
}, []);
// Initialize WebSocket with security measures
useEffect(() => {
if (!userId?.trim() || !roomId?.trim()) {
showBoundary(new Error('User ID and Room ID are required'));
return;
}
const ws = new WebSocketService({
// URL encode parameters to prevent injection
url: `${serverUrl}/room/${encodeURIComponent(roomId)}`,
userId: encodeURIComponent(userId),
protocols: ['wss'], // Enforce secure WebSocket
reconnectAttempts: 5,
onOpen: () => {
setConnectionState('connected');
announce('Connected to chat room');
toast.success('Connected');
},
onMessage: (event) => {
try {
const data = WebSocketEventSchema.parse(JSON.parse(event.data));
handleMessage(data);
} catch (err) {
logger.error('Invalid message', { error: err });
}
},
onError: () => {
setConnectionState('error');
setError('Connection error. Retrying...');
},
onClose: () => {
setConnectionState('disconnected');
announce('Disconnected from chat');
}
});
ws.connect();
wsRef.current = ws;
return () => ws.disconnect();
}, [userId, roomId, serverUrl, showBoundary, announce, toast]);
// Handle incoming messages
const handleMessage = useCallback((data: z.infer<typeof WebSocketEventSchema>) => {
switch (data.type) {
case 'message':
setMessages(prev => [...prev, data.payload].slice(-100));
announce('New message received');
break;
case 'history':
setMessages(data.messages);
break;
}
}, [announce]);
// Send message with rate limiting and validation
const sendMessage = useCallback(async () => {
if (!messageInput.trim() || connectionState !== 'connected') return;
// Client-side rate limiting
if (!rateLimiter.tryAcquire()) {
toast.warning('Sending too fast. Please wait.');
return;
}
try {
setError(null);
const sanitized = sanitizeInput(messageInput);
const message = MessageSchema.parse({
id: crypto.randomUUID(),
text: sanitized,
userId,
timestamp: Date.now()
});
await wsRef.current?.send({ type: 'message', payload: message });
setMessageInput('');
announce('Message sent');
} catch (err) {
const msg = err instanceof Error ? err.message : 'Failed to send';
setError(msg);
logger.error('Send failed', { error: err });
}
}, [messageInput, connectionState, userId, sanitizeInput, announce, toast]);
// Keyboard handler
const handleKeyDown = useCallback((e: React.KeyboardEvent) => {
if (e.key === 'Enter' && !e.shiftKey) {
e.preventDefault();
sendMessage();
} else if (e.key === 'Escape') {
setMessageInput('');
inputRef.current?.blur();
}
}, [sendMessage]);
// Auto-scroll respecting user preferences
useEffect(() => {
const prefersReducedMotion =
window.matchMedia('(prefers-reduced-motion: reduce)').matches;
messagesEndRef.current?.scrollIntoView({
behavior: prefersReducedMotion ? 'auto' : 'smooth'
});
}, [messages]);
const canSend = connectionState === 'connected' && messageInput.trim().length > 0;
return (
<section aria-label={`Chat room: ${roomId}`} className="flex flex-col h-full">
{/* Screen reader announcements */}
<div role="status" aria-live="polite" aria-atomic="true" className="sr-only">
{announcement}
</div>
{/* Connection status */}
<div
id={statusId}
role="status"
aria-live="polite"
className={`px-4 py-2 text-sm ${connectionState === 'connected' ? 'bg-green-100' : 'bg-yellow-100'}`}
>
{connectionState === 'connected' ? 'Connected' : 'Reconnecting...'}
</div>
{/* Error display */}
{error && (
<div role="alert" className="px-4 py-2 bg-red-100 text-red-800">
{error}
<button onClick={() => setError(null)} aria-label="Dismiss error">×</button>
</div>
)}
{/* Messages area */}
<div
id={messagesId}
role="log"
aria-label="Chat messages"
aria-live="polite"
tabIndex={0}
className="flex-1 overflow-y-auto p-4 focus:ring-2 focus:outline-none"
>
{messages.map(msg => (
<article key={msg.id} aria-label={`Message from ${msg.userId}`} className="mb-2">
<span className="font-semibold">{msg.userId}:</span>
<p>{msg.text}</p>
<time dateTime={new Date(msg.timestamp).toISOString()} className="text-xs text-gray-500">
{new Date(msg.timestamp).toLocaleTimeString()}
</time>
</article>
))}
<div ref={messagesEndRef} />
</div>
{/* Input area */}
<form onSubmit={(e) => { e.preventDefault(); sendMessage(); }} className="border-t p-4">
<label htmlFor={inputId} className="sr-only">Type your message</label>
<textarea
ref={inputRef}
id={inputId}
value={messageInput}
onChange={(e) => setMessageInput(e.target.value)}
onKeyDown={handleKeyDown}
disabled={connectionState !== 'connected'}
placeholder="Type a message... (Enter to send)"
aria-describedby={`${statusId} char-count`}
maxLength={1000}
rows={2}
className="w-full px-4 py-2 border rounded-lg resize-none"
/>
<div className="flex justify-between mt-2">
<span id="char-count" className="text-xs text-gray-500">
{messageInput.length}/1000
</span>
<button
type="submit"
disabled={!canSend}
className="px-4 py-2 bg-blue-600 text-white rounded disabled:opacity-50"
>
Send
</button>
</div>
</form>
</section>
);
});We're not a platform matching you with strangers. We employ developers who build careers here. See how that changes everything.
Our high staff retention means your developer will accumulate deep knowledge of your systems over time. Avoid disruptive staff changes.
We test developers on our own internal projects before trusting them with yours. CTO-level technical evaluation, not just algorithm matching.
All our developers complete secure coding training. They can fortify your vibe coded output and can write secure code from scratch.
Senior managers respond to every inquiry, both pre- and post-sale. Enjoy the professionalism of a large organization with the care of a boutique service.
Access elite TypeScript talent without platform prices. $1,199-$2,499/month with no hidden fees. We can afford to charge less because we retain more.
$100/month in AI credits included. Your developer can leverage Claude, GPT-4, and other tools (with your consent) for accelerated delivery.
Transform rough code into professional products
Ship faster without compromising on quality
A glimpse of what our developers are building with TypeScript and modern frameworks.
Full project details shared only with client consent.
" I have to say that in my entire life I have never ever come across the dedication to detail and the willingness to work at high pressure levels to deadlines as I have experienced with your employees. Your company has my respect. "
Graeme
" I am amazed with Bidhun. He is very responsive to tasks that I give him. His communication is excellent - way above my expectations and the quality of his work is superior to anyone I have worked with before. "
AK
" The programmer assigned to me is doing a fine job. He seems to work consistently, he communicates clearly, and he offers good insights concerning our projects. I appreciate his short accurate daily project reports. "
Paul
" Under no circumstances can I lose my developer. I'd rather lose my right arm than him. "
CF
" Thank you so much for all your detailed responses. I have never dealt with a programming company that is so professional. "
Brian
" I find your company and service to be VERY professional and I get more and more excited about our future work! "
Eric
Reach out - a senior manager will personally discuss your TypeScript needs.
We pair you with a developer we've already vetted and tested on internal projects.
One week of real work on your projects. No payment unless you want to continue.
Month-to-month from there. Your developer learns your codebase, your business, and stays.
One-week obligation-free trial
No credit card required
One-week obligation-free trial
No credit card required
One-week obligation-free trial
No credit card required
Our development clients get instant access to seasoned staff by the week. No contracts. No minimum commitment. Just extra capacity when you need it.
Full-stack QA: manual, automation, performance, security, mobile.
$499/week
UI/UX, Figma, responsive design, brand consistency.
$499/week
Linux, Docker, security, DevOps support for your infrastructure.
$499/week
All from the same trusted partner. 22 years in business. Staff who stay.
Ask About Hiring TeamsEnterprise professionalism. Boutique human touch.