- TypeScript 99.3%
- Shell 0.7%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
```
❯ gemini
███ █████████ ██████████ ██████ ██████ █████ ██████ █████ █████
░░░███ ███░░░░░███░░███░░░░░█░░██████ ██████ ░░███ ░░██████ ░░███ ░░███
░░░███ ███ ░░░ ░███ █ ░ ░███░█████░███ ░███ ░███░███ ░███ ░███
░░░███ ░███ ░██████ ░███░░███ ░███ ░███ ░███░░███░███ ░███
███░ ░███ █████ ░███░░█ ░███ ░░░ ░███ ░███ ░███ ░░██████ ░███
███░ ░░███ ░░███ ░███ ░ █ ░███ ░███ ░███ ░███ ░░█████ ░███
███░ ░░█████████ ██████████ █████ █████ █████ █████ ░░█████ █████
░░░ ░░░░░░░░░ ░░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░
Tips for getting started:
1. Ask questions, edit files, or run commands.
2. Be specific for the best results.
3. Create GEMINI.md files to customize your interactions with Gemini.
4. /help for more information.
> When the assistant responds with a longer message including markdown markup, the UI renders it out but it ends up looking too spaced out. Can you investigate what library we're using
to render the mark down and whether it's possible to tweak the visual spacing to keep things a little bit tighter. I'm thinking in particular headings and lists as well as the overall
line height is a touch too big.
✦ Of course. I'll investigate the markdown rendering and propose changes to tighten up the spacing. First, I'll check the project's dependencies to identify the markdown library being
used.
╭───────────────────────────╮
│ ✔ ReadFile package.json │
╰───────────────────────────╯
✦ react-markdown is being used. Spacing is likely controlled by the @tailwindcss/typography plugin. I'll find where react-markdown is used to see how to adjust the styles.
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✔ SearchText 'react-markdown' within src │
│ │
│ Found 2 matche(s) │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ The search results indicate that react-markdown is used in AssistantMessage.tsx and ChatMessage.tsx. I'll examine AssistantMessage.tsx to see how the typography styles are applied.
╭────────────────────────────────────────────────╮
│ ✔ ReadFile src/messages/AssistantMessage.tsx │
╰────────────────────────────────────────────────╯
✦ The prose and prose-zinc classes from @tailwindcss/typography are being used. I'll now inspect the tailwind.config.js file to see how the typography plugin is configured. This will
help me determine the best way to override the default spacing.
╭─────────────────────────────────╮
│ ✔ ReadFile tailwind.config.js │
╰─────────────────────────────────╯
✦ The tailwind.config.js file has some basic overrides, but nothing that affects the spacing of headings or lists. I can add some CSS to the typography configuration to reduce the
margins on headings and lists.
Here's the plan:
1. I'll modify the tailwind.config.js to add custom CSS to the typography plugin that reduces the top and bottom margins for headings (h1, h2, h3) and lists (ul, ol).
2. I'll also reduce the line-height of the prose.
I'll start by modifying the tailwind.config.js file.
╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✔ Edit tailwind.config.js: DEFAULT: {... => DEFAULT: {... │
│ │
│ 5 typography: { │
│ 6 DEFAULT: { │
│ 7 css: { │
│ 8 + '--tw-prose-body': '14px', │
│ 9 + h1: { │
│ 10 + marginTop: '1em', │
│ 11 + marginBottom: '0.5em', │
│ 12 + }, │
│ 13 + h2: { │
│ 14 + marginTop: '1em', │
│ 15 + marginBottom: '0.5em', │
│ 16 + }, │
│ 17 + h3: { │
│ 18 + marginTop: '1em', │
│ 19 + marginBottom: '0.5em', │
│ 20 + }, │
│ 21 + ul: { │
│ 22 + marginTop: '0.5em', │
│ 23 + marginBottom: '0.5em', │
│ 24 + }, │
│ 25 + ol: { │
│ 26 + marginTop: '0.5em', │
│ 27 + marginBottom: '0.5em', │
│ 28 + }, │
│ 29 pre: { │
│ 30 padding: '0', │
│ 31 filter: 'brightness(96%)', │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ Now that I've modified the tailwind.config.js file, you'll need to restart the development server to see the changes. After you've done that, the spacing in the markdown should be
much tighter. Let me know if you'd like any further adjustments
> /quit
╭──────────────────────────────────╮
│ │
│ Agent powering down. Goodbye! │
│ │
│ │
│ Cumulative Stats (1 Turns) │
│ │
│ Input Tokens 52,193 │
│ Output Tokens 864 │
│ Thoughts Tokens 379 │
│ ────────────────────────────── │
│ Total Tokens 53,436 │
│ │
│ Total duration (API) 25.7s │
│ Total duration (wall) 17m 57s │
│ │
╰──────────────────────────────────╯
1 Gemini CLI
```
|
||
| .github/workflows | ||
| examples | ||
| src | ||
| .gitignore | ||
| .prettierignore | ||
| .prettierrc | ||
| AGENT.md | ||
| LICENSE | ||
| oranda.json | ||
| package.json | ||
| pnpm-lock.yaml | ||
| README.md | ||
| tsconfig.json | ||
| wrangler.jsonc | ||
🦑 use-mcp 🦑
A lightweight React hook for connecting to Model Context Protocol (MCP) servers. Simplifies authentication and tool calling for AI systems implementing the MCP standard.
Try it out: MCP Inspector | Cloudflare Workers AI Playground
Installation
npm install use-mcp
# or
pnpm add use-mcp
# or
yarn add use-mcp
Features
- 🔄 Automatic connection management with reconnection and retries
- 🔐 OAuth authentication flow handling with popup and fallback support
- 📦 Simple React hook interface for MCP integration
- 🧰 TypeScript types for editor assistance and type checking
- 📝 Comprehensive logging for debugging
- 🌐 Works with both HTTP and SSE (Server-Sent Events) transports
Quick Start
import { useMcp } from 'use-mcp/react'
function MyAIComponent() {
const {
state, // Connection state: 'discovering' | 'authenticating' | 'connecting' | 'loading' | 'ready' | 'failed'
tools, // Available tools from MCP server
error, // Error message if connection failed
callTool, // Function to call tools on the MCP server
retry, // Retry connection manually
authenticate, // Manually trigger authentication
clearStorage, // Clear stored tokens and credentials
} = useMcp({
url: 'https://your-mcp-server.com',
clientName: 'My App',
autoReconnect: true,
})
// Handle different states
if (state === 'failed') {
return (
<div>
<p>Connection failed: {error}</p>
<button onClick={retry}>Retry</button>
<button onClick={authenticate}>Authenticate Manually</button>
</div>
)
}
if (state !== 'ready') {
return <div>Connecting to AI service...</div>
}
// Use available tools
const handleSearch = async () => {
try {
const result = await callTool('search', { query: 'example search' })
console.log('Search results:', result)
} catch (err) {
console.error('Tool call failed:', err)
}
}
return (
<div>
<h2>Available Tools: {tools.length}</h2>
<ul>
{tools.map(tool => (
<li key={tool.name}>{tool.name}</li>
))}
</ul>
<button onClick={handleSearch}>Search</button>
</div>
)
}
Setting Up OAuth Callback
To handle the OAuth authentication flow, you need to set up a callback endpoint in your app.
With React Router
// App.tsx with React Router
import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'
import { useEffect } from 'react'
import { onMcpAuthorization } from 'use-mcp'
function OAuthCallback() {
useEffect(() => {
onMcpAuthorization()
}, [])
return (
<div>
<h1>Authenticating...</h1>
<p>This window should close automatically.</p>
</div>
)
}
function App() {
return (
<Router>
<Routes>
<Route path="/oauth/callback" element={<OAuthCallback />} />
<Route path="/" element={<YourMainComponent />} />
</Routes>
</Router>
)
}
With Next.js Pages Router
// pages/oauth/callback.tsx
import { useEffect } from 'react'
import { onMcpAuthorization } from 'use-mcp'
export default function OAuthCallbackPage() {
useEffect(() => {
onMcpAuthorization()
}, [])
return (
<div>
<h1>Authenticating...</h1>
<p>This window should close automatically.</p>
</div>
)
}
API Reference
useMcp Hook
function useMcp(options: UseMcpOptions): UseMcpResult
Options
| Option | Type | Description |
|---|---|---|
url |
string |
Required. URL of your MCP server |
clientName |
string |
Name of your client for OAuth registration |
clientUri |
string |
URI of your client for OAuth registration |
callbackUrl |
string |
Custom callback URL for OAuth redirect (defaults to /oauth/callback on the current origin) |
storageKeyPrefix |
string |
Storage key prefix for OAuth data in localStorage (defaults to "mcp:auth") |
clientConfig |
object |
Custom configuration for the MCP client identity |
debug |
boolean |
Whether to enable verbose debug logging |
autoRetry |
boolean | number |
Auto retry connection if initial connection fails, with delay in ms |
autoReconnect |
boolean | number |
Auto reconnect if an established connection is lost, with delay in ms (default: 3000) |
Return Value
| Property | Type | Description |
|---|---|---|
state |
string |
Current connection state: 'discovering', 'authenticating', 'connecting', 'loading', 'ready', 'failed' |
tools |
Tool[] |
Available tools from the MCP server |
error |
string | undefined |
Error message if connection failed |
authUrl |
string | undefined |
Manual authentication URL if popup is blocked |
log |
{ level: 'debug' | 'info' | 'warn' | 'error'; message: string; timestamp: number }[] |
Array of log messages |
callTool |
(name: string, args?: Record<string, unknown>) => Promise<any> |
Function to call a tool on the MCP server |
retry |
() => void |
Manually attempt to reconnect |
disconnect |
() => void |
Disconnect from the MCP server |
authenticate |
() => void |
Manually trigger authentication |
clearStorage |
() => void |
Clear all stored authentication data |
License
MIT