Jotley / website · jotley.ai / src / app / mcp / MCPBoard.tsx
| 1 | 'use client'; |
| 2 | |
| 3 | import { useEffect, useRef, useState, type KeyboardEvent, type ReactNode } from 'react'; |
| 4 | import Link from 'next/link'; |
| 5 | import { Eye, PencilLine, type LucideIcon } from 'lucide-react'; |
| 6 | |
| 7 | type AccessId = 'read-only' | 'read-write'; |
| 8 | type ClientId = 'claude-code' | 'codex'; |
| 9 | |
| 10 | interface AccessMode { |
| 11 | id: AccessId; |
| 12 | name: string; |
| 13 | works: string; |
| 14 | can: string; |
| 15 | note: string; |
| 16 | prompt: string; |
| 17 | icon: LucideIcon; |
| 18 | } |
| 19 | |
| 20 | const ACCESS_MODES: AccessMode[] = [ |
| 21 | { |
| 22 | id: 'read-only', |
| 23 | name: 'Read only', |
| 24 | works: 'Search and read your notes', |
| 25 | can: 'Your agent can list, search and read your notes, including titles, dates, tags, transcripts and summaries.', |
| 26 | note: 'Nothing in your library changes. Agents work with the library open in Jotley, including notes synced from your iPhone or iPad.', |
| 27 | prompt: 'Search my Jotley notes for release planning and tell me who owns each action.', |
| 28 | icon: Eye, |
| 29 | }, |
| 30 | { |
| 31 | id: 'read-write', |
| 32 | name: 'Read & write', |
| 33 | works: 'Create, edit and organize notes', |
| 34 | can: 'Everything in Read only, plus creating, editing, copying and deleting notes and managing tags, folders and summary templates.', |
| 35 | note: 'Review your agent’s approvals before it makes changes. Deletion is permanent, so try it on a test note first.', |
| 36 | prompt: 'Rename that note Launch checklist and rewrite its summary as action items. Keep the transcript unchanged.', |
| 37 | icon: PencilLine, |
| 38 | }, |
| 39 | ]; |
| 40 | |
| 41 | const CLIENTS: { id: ClientId; name: string }[] = [ |
| 42 | { id: 'claude-code', name: 'Claude Code' }, |
| 43 | { id: 'codex', name: 'Codex' }, |
| 44 | ]; |
| 45 | |
| 46 | const ACCESS_IDS = ACCESS_MODES.map((mode) => mode.id); |
| 47 | const CLIENT_IDS = CLIENTS.map((client) => client.id); |
| 48 | |
| 49 | function CopyButton({ text, label }: { text: string; label: string }) { |
| 50 | const [copied, setCopied] = useState(false); |
| 51 | const copy = async () => { |
| 52 | try { |
| 53 | await navigator.clipboard.writeText(text); |
| 54 | setCopied(true); |
| 55 | setTimeout(() => setCopied(false), 1800); |
| 56 | } catch { |
| 57 | setCopied(false); |
| 58 | } |
| 59 | }; |
| 60 | return ( |
| 61 | <button type="button" className="mcp-copy" onClick={copy} aria-label={copied ? 'Copied' : label}> |
| 62 | <span aria-live="polite">{copied ? 'Copied' : 'Copy'}</span> |
| 63 | </button> |
| 64 | ); |
| 65 | } |
| 66 | |
| 67 | function CopyValue({ value, label }: { value: string; label: string }) { |
| 68 | return ( |
| 69 | <span className="mcp-value"> |
| 70 | <code>{value}</code> |
| 71 | <CopyButton text={value} label={label} /> |
| 72 | </span> |
| 73 | ); |
| 74 | } |
| 75 | |
| 76 | // Arrow keys move between tabs, as in the WAI-ARIA tabs pattern. |
| 77 | function onTabKeyDown<T extends string>(event: KeyboardEvent<HTMLButtonElement>, ids: T[], current: T, select: (id: T) => void) { |
| 78 | const moves: Record<string, number> = { ArrowRight: 1, ArrowDown: 1, ArrowLeft: -1, ArrowUp: -1 }; |
| 79 | let next: T | null = null; |
| 80 | if (event.key in moves) next = ids[(ids.indexOf(current) + moves[event.key] + ids.length) % ids.length]; |
| 81 | if (event.key === 'Home') next = ids[0]; |
| 82 | if (event.key === 'End') next = ids[ids.length - 1]; |
| 83 | if (!next) return; |
| 84 | event.preventDefault(); |
| 85 | select(next); |
| 86 | const tabs = event.currentTarget.parentElement?.querySelectorAll<HTMLButtonElement>('[role="tab"]'); |
| 87 | tabs?.[ids.indexOf(next)]?.focus(); |
| 88 | } |
| 89 | |
| 90 | function JotleySteps({ access }: { access: AccessMode }) { |
| 91 | return ( |
| 92 | <> |
| 93 | <li>Open Jotley’s Settings gear, then choose <strong>Integrations → MCP</strong>.</li> |
| 94 | <li>Turn on <strong>Enable MCP access</strong>. Wait for <strong>Server ready</strong> and keep Jotley open.</li> |
| 95 | <li>Choose <strong>{access.name}</strong>, then click <strong>Test connection</strong> to check Jotley’s server.</li> |
| 96 | </> |
| 97 | ); |
| 98 | } |
| 99 | |
| 100 | function ClaudeSteps({ access }: { access: AccessMode }) { |
| 101 | return ( |
| 102 | <> |
| 103 | <ol className="mcp-steps"> |
| 104 | <JotleySteps access={access} /> |
| 105 | <li>Still in Jotley’s MCP settings, choose <strong>Claude Code app → Save project connection…</strong> and select your project folder.</li> |
| 106 | <li>Open the Claude Mac app’s <strong>Code</strong> tab. Start a local session on <strong>This computer</strong> using that same folder.</li> |
| 107 | <li>Review Claude’s project trust prompt and approve Jotley. Open the session’s <strong>Connectors</strong> panel and check Jotley. Start a new session if the project was already open.</li> |
| 108 | </ol> |
| 109 | <details className="mcp-aside"> |
| 110 | <summary>Using regular Claude chat instead?</summary> |
| 111 | <p>Use the Code tab for this connection. Regular Claude chat uses the separate extension available under Jotley’s advanced setup options.</p> |
| 112 | </details> |
| 113 | </> |
| 114 | ); |
| 115 | } |
| 116 | |
| 117 | function CodexSteps({ access }: { access: AccessMode }) { |
| 118 | return ( |
| 119 | <> |
| 120 | <ol className="mcp-steps"> |
| 121 | <JotleySteps access={access} /> |
| 122 | <li>Still in Jotley’s MCP settings, choose <strong>Codex app</strong>.</li> |
| 123 | <li>In Codex, open <strong>Settings → MCP servers → Add server</strong>. Name it <CopyValue value="jotley" label="Copy the server name jotley" /> and choose <strong>STDIO</strong>.</li> |
| 124 | <li>Copy <strong>Command</strong> from Jotley into Codex’s Command field without extra quotes.</li> |
| 125 | <li>Add one argument: <CopyValue value="--mcp-stdio" label="Copy the argument --mcp-stdio" />. Leave environment variables empty.</li> |
| 126 | <li>Save, restart the server, then start a local chat. Type <CopyValue value="/mcp" label="Copy the command /mcp" /> to check Jotley.</li> |
| 127 | </ol> |
| 128 | <details className="mcp-aside"> |
| 129 | <summary>Moved Jotley to another folder?</summary> |
| 130 | <p>Moving the app changes its launch path. Update the Command path in Codex with the current value from Jotley.</p> |
| 131 | </details> |
| 132 | </> |
| 133 | ); |
| 134 | } |
| 135 | |
| 136 | function Info({ id, title, children }: { id: string; title: string; children: ReactNode }) { |
| 137 | return ( |
| 138 | <details className="mcp-info" id={id}> |
| 139 | <summary><span>{title}</span></summary> |
| 140 | <div className="mcp-info-body">{children}</div> |
| 141 | </details> |
| 142 | ); |
| 143 | } |
| 144 | |
| 145 | export default function MCPBoard() { |
| 146 | const [accessId, setAccessId] = useState<AccessId>('read-only'); |
| 147 | const [client, setClient] = useState<ClientId>('claude-code'); |
| 148 | const boardRef = useRef<HTMLDivElement>(null); |
| 149 | const access = ACCESS_MODES.find((mode) => mode.id === accessId) ?? ACCESS_MODES[0]; |
| 150 | |
| 151 | // Deep links: #claude-code and #codex open that agent's steps. |
| 152 | useEffect(() => { |
| 153 | const applyHash = () => { |
| 154 | const id = window.location.hash.replace(/^#/, '') as ClientId; |
| 155 | if (!CLIENT_IDS.includes(id)) return; |
| 156 | setClient(id); |
| 157 | requestAnimationFrame(() => boardRef.current?.scrollIntoView({ block: 'start' })); |
| 158 | }; |
| 159 | applyHash(); |
| 160 | window.addEventListener('hashchange', applyHash); |
| 161 | return () => window.removeEventListener('hashchange', applyHash); |
| 162 | }, []); |
| 163 | |
| 164 | const selectClient = (next: ClientId) => { |
| 165 | setClient(next); |
| 166 | window.history.replaceState(null, '', `#${next}`); |
| 167 | }; |
| 168 | |
| 169 | return ( |
| 170 | <> |
| 171 | <div className="mcp-board" ref={boardRef}> |
| 172 | <div className="mcp-apps" role="tablist" aria-label="Choose what your agent can do"> |
| 173 | {ACCESS_MODES.map((mode) => ( |
| 174 | <button |
| 175 | key={mode.id} |
| 176 | type="button" |
| 177 | role="tab" |
| 178 | id={`tab-${mode.id}`} |
| 179 | className="mcp-app" |
| 180 | aria-selected={accessId === mode.id} |
| 181 | aria-controls={`brief-${mode.id}`} |
| 182 | tabIndex={accessId === mode.id ? 0 : -1} |
| 183 | onClick={() => setAccessId(mode.id)} |
| 184 | onKeyDown={(event) => onTabKeyDown(event, ACCESS_IDS, accessId, setAccessId)} |
| 185 | > |
| 186 | <span className="mcp-app-icon"><mode.icon size={22} aria-hidden="true" /></span> |
| 187 | <span className="mcp-app-text"> |
| 188 | <span className="mcp-app-name">{mode.name}</span> |
| 189 | <span className="mcp-app-works">{mode.works}</span> |
| 190 | </span> |
| 191 | </button> |
| 192 | ))} |
| 193 | </div> |
| 194 | |
| 195 | <div className="mcp-panel"> |
| 196 | <div className="mcp-brief"> |
| 197 | <header className="mcp-brief-head"> |
| 198 | <h2><img src="/jotley-logo.png" alt="" width="44" height="44" />Jotley</h2> |
| 199 | <p className="mcp-chips"> |
| 200 | <span className="mcp-chip is-brand">Mac only</span> |
| 201 | <span className="mcp-chip">Off by default</span> |
| 202 | <span className="mcp-chip">Free</span> |
| 203 | </p> |
| 204 | </header> |
| 205 | |
| 206 | {ACCESS_MODES.map((mode) => ( |
| 207 | <div |
| 208 | key={mode.id} |
| 209 | id={`brief-${mode.id}`} |
| 210 | role="tabpanel" |
| 211 | aria-labelledby={`tab-${mode.id}`} |
| 212 | className="mcp-mode" |
| 213 | hidden={accessId !== mode.id} |
| 214 | > |
| 215 | <p className="mcp-can">{mode.can}</p> |
| 216 | <p className="mcp-access">{mode.note}</p> |
| 217 | <figure className="mcp-ask"> |
| 218 | <figcaption>Try asking your agent</figcaption> |
| 219 | <blockquote>{mode.prompt}</blockquote> |
| 220 | <CopyButton text={mode.prompt} label={`Copy the ${mode.name} example prompt`} /> |
| 221 | </figure> |
| 222 | </div> |
| 223 | ))} |
| 224 | |
| 225 | <ul className="mcp-downloads"> |
| 226 | <li><Link href="/download">Download Jotley for Mac</Link></li> |
| 227 | <li><Link href="/privacy#mcp">Read the MCP privacy details</Link></li> |
| 228 | </ul> |
| 229 | </div> |
| 230 | |
| 231 | <div className="mcp-connect"> |
| 232 | <div className="mcp-connect-head"> |
| 233 | <h3>Connect Jotley with</h3> |
| 234 | <div className="mcp-clients" role="tablist" aria-label="Choose your agent"> |
| 235 | {CLIENTS.map((item) => ( |
| 236 | <button |
| 237 | key={item.id} |
| 238 | type="button" |
| 239 | role="tab" |
| 240 | id={`tab-${item.id}`} |
| 241 | aria-selected={client === item.id} |
| 242 | aria-controls={item.id} |
| 243 | tabIndex={client === item.id ? 0 : -1} |
| 244 | onClick={() => selectClient(item.id)} |
| 245 | onKeyDown={(event) => onTabKeyDown(event, CLIENT_IDS, client, selectClient)} |
| 246 | > |
| 247 | {item.name} |
| 248 | </button> |
| 249 | ))} |
| 250 | </div> |
| 251 | </div> |
| 252 | <div id="claude-code" role="tabpanel" aria-labelledby="tab-claude-code" className="mcp-client" hidden={client !== 'claude-code'}> |
| 253 | <ClaudeSteps access={access} /> |
| 254 | </div> |
| 255 | <div id="codex" role="tabpanel" aria-labelledby="tab-codex" className="mcp-client" hidden={client !== 'codex'}> |
| 256 | <CodexSteps access={access} /> |
| 257 | </div> |
| 258 | </div> |
| 259 | </div> |
| 260 | </div> |
| 261 | |
| 262 | <section className="mcp-more" aria-labelledby="mcp-more-title"> |
| 263 | <h2 id="mcp-more-title">Before you connect</h2> |
| 264 | <div className="mcp-infos"> |
| 265 | <Info id="local" title="How the connection works"> |
| 266 | <p>MCP is the connection between Jotley and your agent. It runs on your Mac while Jotley is open, and setup happens in the apps. No separate runtime or copied token is needed.</p> |
| 267 | <p>MCP is unavailable on iPhone or iPad, and cloud sessions cannot reach this local connection.</p> |
| 268 | </Info> |
| 269 | <Info id="privacy" title="Your notes and your agent’s AI provider"> |
| 270 | <p>Access is off by default, and you can turn it off in Jotley at any time. The connection itself stays on your Mac, but connected agents may send retrieved notes to their AI provider or retain copies.</p> |
| 271 | <p><Link href="/privacy#mcp">Read the MCP privacy details</Link></p> |
| 272 | </Info> |
| 273 | <Info id="access" title="Read only or Read & write"> |
| 274 | <p><strong>Read only</strong> lets your agent search and read. <strong>Read & write</strong> also lets it create, edit, copy and delete notes and manage tags, folders and templates. Deletion is permanent.</p> |
| 275 | <p>You can switch between them in Jotley’s MCP settings whenever you like.</p> |
| 276 | </Info> |
| 277 | <Info id="check" title="Checking that it works"> |
| 278 | <p>After a change, open the note in Jotley to see what was saved. <strong>Last agent seen</strong> and <strong>Last successful request</strong> in Jotley’s MCP settings show actual connection activity.</p> |
| 279 | <p>If you move Jotley, update the Command path in Codex or save the Claude Code project connection again.</p> |
| 280 | </Info> |
| 281 | </div> |
| 282 | </section> |
| 283 | </> |
| 284 | ); |
| 285 | } |