Skip to content

Instantly share code, notes, and snippets.

View perfectbase's full-sized avatar

Ravi perfectbase

View GitHub Profile
@perfectbase
perfectbase / chat_route.ts
Last active April 25, 2025 09:24
Integration of the StreamableHTTP MCP tools with the ai-sdk
//...
const transport = new StreamableHTTPTransport(
createStreamableHTTPTransportConfig("http://localhost:3000/mcp"),
);
mcpClient = await experimental_createMCPClient({
transport,
});
const mcpTools = await mcpClient.tools();
@perfectbase
perfectbase / await.tsx
Last active April 29, 2025 23:03
Await component for tRPC with prefetch
/* eslint-disable @typescript-eslint/no-explicit-any */
import { type TRPCQueryOptions } from '@trpc/tanstack-react-query';
import { unstable_noStore } from 'next/cache';
import { Fragment, Suspense, type ReactNode } from 'react';
import { ErrorBoundary } from 'react-error-boundary';
import { HydrateClient, prefetch as prefetchTRPC } from '@/trpc/server';
type AwaitProps<T> =
| {
promise: Promise<T>;
@perfectbase
perfectbase / await.tsx
Last active April 27, 2025 14:24
Await component for Next.js
import { Fragment, Suspense, type ReactNode } from 'react';
import { ErrorBoundary } from 'react-error-boundary';
type AwaitProps<T> =
| {
promise: Promise<T>;
children: (data: T) => ReactNode;
fallback?: ReactNode;
errorComponent?: ReactNode | null;
}