@devries-cameron20 / t3code Mirror · read-only
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 04:45 UTC

main
ts 219 lines 7.5 KB
Raw
1 import chatgptLogo from "./logos/chatgpt.png";
2 import claudeLogo from "./logos/claude.png";
3 import geminiLogo from "./logos/gemini.png";
4 import grokBotLogo from "./logos/grokbot.png";
5 import hermesLogo from "./logos/hermes.png";
6 import instinctLogo from "./logos/instinct.png";
7 import museLogo from "./logos/muse.png";
8 import openClawLogo from "./logos/openclaw.png";
9 import pokeLogo from "./logos/poke.png";
10 import { msg } from "gt-react";
11
12 import { m, type MessageResolver } from "~/i18n/messages";
13
14 /** How the Connect step hands T3 Code's MCP URL to an app. Every `link` is https. */
15 export type McpAppHandoff =
16 /** Opens the app's add form with T3 Code filled in. */
17 | { readonly kind: "open"; readonly link: (mcpUrl: string) => string }
18 /** Copies the URL, then opens the page it goes on. */
19 | { readonly kind: "copy-url"; readonly link: string }
20 /** Copies a message for the app's chat, then opens the app. */
21 | {
22 readonly kind: "copy-message";
23 readonly link: string;
24 /**
25 * Opens the installed app first, given the message; `link` is the fallback. The desktop
26 * app opens only the link shapes `isAppLaunchUrl` in ElectronShell accepts.
27 */
28 readonly appLink?: (message: string) => string;
29 readonly message: (mcpUrl: string) => string;
30 }
31 /** Commands to run where the app runs. */
32 | { readonly kind: "commands"; readonly commands: (mcpUrl: string) => readonly string[] };
33
34 export interface McpApp {
35 readonly id: string;
36 readonly name: string;
37 readonly logo: string;
38 readonly handoff: McpAppHandoff;
39 /** "Set up another way", next to the URL. `msg()` strings. */
40 readonly steps: readonly string[];
41 /** One line under the primary action. A `msg()` string. */
42 readonly note?: string;
43 readonly docs?: string;
44 /** Kept out of the grid until its sign-in works. */
45 readonly hidden?: boolean;
46 }
47
48 const encoded = encodeURIComponent;
49
50 export const MCP_APPS: readonly McpApp[] = [
51 {
52 id: "poke",
53 name: "Poke",
54 logo: pokeLogo,
55 handoff: {
56 kind: "open",
57 link: (url) => `https://poke.com/integrations/new?name=T3%20Code&url=${encoded(url)}`,
58 },
59 steps: [msg("Open poke.com/integrations/new."), msg("Paste the URL and add the integration.")],
60 docs: "https://poke.com/docs/mcp-servers",
61 },
62 {
63 id: "claude",
64 name: "Claude",
65 logo: claudeLogo,
66 handoff: {
67 kind: "open",
68 link: (url) =>
69 `https://claude.ai/customize/connectors?modal=add-custom-connector&connectorName=T3%20Code&connectorUrl=${encoded(url)}`,
70 },
71 steps: [
72 msg("In Claude, open Customize, then Connectors."),
73 msg("Choose Add custom connector and paste the URL."),
74 msg("The Free plan allows one custom connector."),
75 ],
76 docs: "https://claude.com/docs/connectors/building/directory-vs-custom",
77 },
78 {
79 id: "chatgpt",
80 name: "ChatGPT",
81 logo: chatgptLogo,
82 handoff: { kind: "copy-url", link: "https://chatgpt.com/plugins" },
83 steps: [
84 msg("Open chatgpt.com/plugins on the web, then + and Add custom MCP server."),
85 msg("Paste the URL. Choose OAuth."),
86 msg("Create it as a plugin, then install it."),
87 ],
88 docs: "https://developers.openai.com/api/docs/guides/custom-mcp-server",
89 },
90 {
91 id: "grok-bot",
92 name: "Grok Bot",
93 logo: grokBotLogo,
94 // No web chat. The app link prefills the message only into an empty box, so it is copied too.
95 handoff: {
96 kind: "copy-message",
97 link: "https://x.ai/bot",
98 appLink: (message) => `grokbot://app/v1/prompt?text=${encoded(message)}`,
99 message: (url) => `Add the MCP server ${url} and connect it.`,
100 },
101 steps: [msg("Send this message to any of your Grok Bots.")],
102 note: msg("Shared with all your Grok Bots."),
103 docs: "https://docs.x.ai/grok-bot/computer-and-apps",
104 },
105 {
106 id: "gemini",
107 name: "Gemini",
108 logo: geminiLogo,
109 handoff: { kind: "copy-url", link: "https://gemini.google.com/apps" },
110 steps: [
111 msg("In Gemini, open Settings, then Connected apps."),
112 msg("Choose Custom apps, then Add, and paste the URL."),
113 ],
114 docs: "https://support.google.com/gemini/answer/17209137",
115 // Gemini's sign-in and its tool schema checks do not work with T3 Code yet.
116 hidden: true,
117 },
118 {
119 id: "muse",
120 name: "Muse",
121 logo: museLogo,
122 handoff: {
123 kind: "copy-message",
124 link: "https://muse.ai",
125 message: (url) => `Create a custom connector for the MCP server ${url}.`,
126 },
127 steps: [msg("Send this message to Muse.")],
128 docs: "https://www.meta.com/help/artificial-intelligence/1687253048996149/",
129 },
130 {
131 id: "instinct",
132 name: "Instinct",
133 logo: instinctLogo,
134 handoff: {
135 kind: "copy-message",
136 link: "https://app.instinct.com",
137 message: (url) => `Connect the MCP server ${url}.`,
138 },
139 steps: [msg("In Instinct, open Settings, then MCP connections, if your account has it.")],
140 },
141 {
142 id: "openclaw",
143 name: "OpenClaw",
144 logo: openClawLogo,
145 handoff: {
146 kind: "commands",
147 commands: (url) => [
148 // Its MCP commands refuse to write while the Gateway runs.
149 "openclaw gateway stop",
150 `openclaw mcp add t3code --url ${url} --transport streamable-http --auth oauth`,
151 "openclaw mcp login t3code",
152 "openclaw gateway start",
153 ],
154 },
155 steps: [
156 msg("Open the Control UI, then + and Plugins, and choose Add MCP server."),
157 msg("Paste the URL, and choose Streamable HTTP and OAuth."),
158 msg("Select Sign in for it under Settings → MCP."),
159 ],
160 docs: "https://docs.openclaw.ai/tools/mcp",
161 },
162 {
163 id: "hermes-agent",
164 name: "Hermes Agent",
165 logo: hermesLogo,
166 handoff: {
167 kind: "commands",
168 commands: (url) => [
169 // `add` signs in on its first connection (30 s by default, too short to get a code);
170 // `login` would clear that sign-in and need a second code.
171 `hermes mcp add t3code --url ${url} --auth oauth --connect-timeout 315`,
172 ],
173 },
174 steps: [
175 msg("Add t3code under mcp_servers in ~/.hermes/config.yaml, with the URL and auth: oauth."),
176 msg("Run hermes mcp login t3code."),
177 ],
178 note: msg("On a remote host, paste the final URL back when asked."),
179 docs: "https://hermes-agent.nousresearch.com/docs/user-guide/features/mcp",
180 },
181 ];
182
183 /** The "Something else…" choice: the URL and general steps only. */
184 export const OTHER_MCP_APP_STEPS = [msg("Add a remote MCP server with OAuth.")] as const;
185
186 /**
187 * The primary button for `app`: its label, the https page it opens, and what it copies first.
188 * Null for apps set up with commands. It never copies the approval code.
189 */
190 export function mcpHandoffAction(app: McpApp, mcpUrl: string, resolve: MessageResolver = m) {
191 const { handoff } = app;
192 switch (handoff.kind) {
193 case "open":
194 return {
195 label: resolve(msg("Open in {app}", { app: app.name })),
196 link: handoff.link(mcpUrl),
197 appLink: null,
198 copy: null,
199 };
200 case "copy-url":
201 return {
202 label: resolve(msg("Copy URL and open {app}", { app: app.name })),
203 link: handoff.link,
204 appLink: null,
205 copy: { text: mcpUrl, title: resolve(msg("URL copied")) },
206 };
207 case "copy-message": {
208 const message = handoff.message(mcpUrl);
209 return {
210 label: resolve(msg("Copy message and open {app}", { app: app.name })),
211 link: handoff.link,
212 appLink: handoff.appLink?.(message) ?? null,
213 copy: { text: message, title: resolve(msg("Message copied")) },
214 };
215 }
216 case "commands":
217 return null;
218 }
219 }