chad-code 1.3.1 → 1.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (338) hide show
  1. package/README.md +55 -6
  2. package/chad-code-0.0.0-main-202601090906.tgz +0 -0
  3. package/package.json +35 -97
  4. package/AGENTS.md +0 -27
  5. package/Dockerfile +0 -18
  6. package/README.npm.md +0 -64
  7. package/bunfig.toml +0 -7
  8. package/eslint.config.js +0 -29
  9. package/parsers-config.ts +0 -253
  10. package/script/build.ts +0 -167
  11. package/script/publish-registries.ts +0 -187
  12. package/script/publish.ts +0 -93
  13. package/script/schema.ts +0 -47
  14. package/src/acp/README.md +0 -164
  15. package/src/acp/agent.ts +0 -1086
  16. package/src/acp/session.ts +0 -101
  17. package/src/acp/types.ts +0 -22
  18. package/src/agent/agent.ts +0 -253
  19. package/src/agent/generate.txt +0 -75
  20. package/src/agent/prompt/compaction.txt +0 -12
  21. package/src/agent/prompt/explore.txt +0 -18
  22. package/src/agent/prompt/summary.txt +0 -11
  23. package/src/agent/prompt/title.txt +0 -36
  24. package/src/auth/index.ts +0 -70
  25. package/src/bun/index.ts +0 -130
  26. package/src/bus/bus-event.ts +0 -43
  27. package/src/bus/global.ts +0 -10
  28. package/src/bus/index.ts +0 -105
  29. package/src/cli/bootstrap.ts +0 -17
  30. package/src/cli/cmd/acp.ts +0 -69
  31. package/src/cli/cmd/agent.ts +0 -257
  32. package/src/cli/cmd/auth.ts +0 -132
  33. package/src/cli/cmd/cmd.ts +0 -7
  34. package/src/cli/cmd/debug/agent.ts +0 -28
  35. package/src/cli/cmd/debug/config.ts +0 -15
  36. package/src/cli/cmd/debug/file.ts +0 -91
  37. package/src/cli/cmd/debug/index.ts +0 -45
  38. package/src/cli/cmd/debug/lsp.ts +0 -48
  39. package/src/cli/cmd/debug/ripgrep.ts +0 -83
  40. package/src/cli/cmd/debug/scrap.ts +0 -15
  41. package/src/cli/cmd/debug/skill.ts +0 -15
  42. package/src/cli/cmd/debug/snapshot.ts +0 -48
  43. package/src/cli/cmd/export.ts +0 -88
  44. package/src/cli/cmd/generate.ts +0 -38
  45. package/src/cli/cmd/github.ts +0 -32
  46. package/src/cli/cmd/import.ts +0 -98
  47. package/src/cli/cmd/mcp.ts +0 -670
  48. package/src/cli/cmd/models.ts +0 -42
  49. package/src/cli/cmd/pr.ts +0 -112
  50. package/src/cli/cmd/run.ts +0 -374
  51. package/src/cli/cmd/serve.ts +0 -16
  52. package/src/cli/cmd/session.ts +0 -135
  53. package/src/cli/cmd/stats.ts +0 -402
  54. package/src/cli/cmd/tui/app.tsx +0 -705
  55. package/src/cli/cmd/tui/attach.ts +0 -32
  56. package/src/cli/cmd/tui/component/border.tsx +0 -21
  57. package/src/cli/cmd/tui/component/dialog-agent.tsx +0 -31
  58. package/src/cli/cmd/tui/component/dialog-command.tsx +0 -124
  59. package/src/cli/cmd/tui/component/dialog-mcp.tsx +0 -86
  60. package/src/cli/cmd/tui/component/dialog-model.tsx +0 -232
  61. package/src/cli/cmd/tui/component/dialog-provider.tsx +0 -228
  62. package/src/cli/cmd/tui/component/dialog-session-list.tsx +0 -115
  63. package/src/cli/cmd/tui/component/dialog-session-rename.tsx +0 -31
  64. package/src/cli/cmd/tui/component/dialog-stash.tsx +0 -86
  65. package/src/cli/cmd/tui/component/dialog-status.tsx +0 -162
  66. package/src/cli/cmd/tui/component/dialog-tag.tsx +0 -44
  67. package/src/cli/cmd/tui/component/dialog-theme-list.tsx +0 -50
  68. package/src/cli/cmd/tui/component/did-you-know.tsx +0 -85
  69. package/src/cli/cmd/tui/component/logo.tsx +0 -43
  70. package/src/cli/cmd/tui/component/prompt/autocomplete.tsx +0 -654
  71. package/src/cli/cmd/tui/component/prompt/history.tsx +0 -108
  72. package/src/cli/cmd/tui/component/prompt/index.tsx +0 -1078
  73. package/src/cli/cmd/tui/component/prompt/stash.tsx +0 -101
  74. package/src/cli/cmd/tui/component/textarea-keybindings.ts +0 -73
  75. package/src/cli/cmd/tui/component/tips.ts +0 -92
  76. package/src/cli/cmd/tui/component/todo-item.tsx +0 -32
  77. package/src/cli/cmd/tui/context/args.tsx +0 -14
  78. package/src/cli/cmd/tui/context/directory.ts +0 -13
  79. package/src/cli/cmd/tui/context/exit.tsx +0 -23
  80. package/src/cli/cmd/tui/context/helper.tsx +0 -25
  81. package/src/cli/cmd/tui/context/keybind.tsx +0 -101
  82. package/src/cli/cmd/tui/context/kv.tsx +0 -49
  83. package/src/cli/cmd/tui/context/local.tsx +0 -392
  84. package/src/cli/cmd/tui/context/prompt.tsx +0 -18
  85. package/src/cli/cmd/tui/context/route.tsx +0 -46
  86. package/src/cli/cmd/tui/context/sdk.tsx +0 -75
  87. package/src/cli/cmd/tui/context/sync.tsx +0 -384
  88. package/src/cli/cmd/tui/context/theme/aura.json +0 -69
  89. package/src/cli/cmd/tui/context/theme/ayu.json +0 -80
  90. package/src/cli/cmd/tui/context/theme/catppuccin-frappe.json +0 -233
  91. package/src/cli/cmd/tui/context/theme/catppuccin-macchiato.json +0 -233
  92. package/src/cli/cmd/tui/context/theme/catppuccin.json +0 -112
  93. package/src/cli/cmd/tui/context/theme/chad.json +0 -245
  94. package/src/cli/cmd/tui/context/theme/cobalt2.json +0 -228
  95. package/src/cli/cmd/tui/context/theme/cursor.json +0 -249
  96. package/src/cli/cmd/tui/context/theme/dracula.json +0 -219
  97. package/src/cli/cmd/tui/context/theme/everforest.json +0 -241
  98. package/src/cli/cmd/tui/context/theme/flexoki.json +0 -237
  99. package/src/cli/cmd/tui/context/theme/github.json +0 -233
  100. package/src/cli/cmd/tui/context/theme/gruvbox.json +0 -95
  101. package/src/cli/cmd/tui/context/theme/kanagawa.json +0 -77
  102. package/src/cli/cmd/tui/context/theme/lucent-orng.json +0 -227
  103. package/src/cli/cmd/tui/context/theme/material.json +0 -235
  104. package/src/cli/cmd/tui/context/theme/matrix.json +0 -77
  105. package/src/cli/cmd/tui/context/theme/mercury.json +0 -252
  106. package/src/cli/cmd/tui/context/theme/monokai.json +0 -221
  107. package/src/cli/cmd/tui/context/theme/nightowl.json +0 -221
  108. package/src/cli/cmd/tui/context/theme/nord.json +0 -223
  109. package/src/cli/cmd/tui/context/theme/one-dark.json +0 -84
  110. package/src/cli/cmd/tui/context/theme/orng.json +0 -245
  111. package/src/cli/cmd/tui/context/theme/osaka-jade.json +0 -93
  112. package/src/cli/cmd/tui/context/theme/palenight.json +0 -222
  113. package/src/cli/cmd/tui/context/theme/rosepine.json +0 -234
  114. package/src/cli/cmd/tui/context/theme/solarized.json +0 -223
  115. package/src/cli/cmd/tui/context/theme/synthwave84.json +0 -226
  116. package/src/cli/cmd/tui/context/theme/tokyonight.json +0 -243
  117. package/src/cli/cmd/tui/context/theme/vercel.json +0 -245
  118. package/src/cli/cmd/tui/context/theme/vesper.json +0 -218
  119. package/src/cli/cmd/tui/context/theme/zenburn.json +0 -223
  120. package/src/cli/cmd/tui/context/theme.tsx +0 -1137
  121. package/src/cli/cmd/tui/event.ts +0 -46
  122. package/src/cli/cmd/tui/routes/home.tsx +0 -138
  123. package/src/cli/cmd/tui/routes/session/dialog-fork-from-timeline.tsx +0 -64
  124. package/src/cli/cmd/tui/routes/session/dialog-message.tsx +0 -109
  125. package/src/cli/cmd/tui/routes/session/dialog-subagent.tsx +0 -26
  126. package/src/cli/cmd/tui/routes/session/dialog-timeline.tsx +0 -47
  127. package/src/cli/cmd/tui/routes/session/footer.tsx +0 -88
  128. package/src/cli/cmd/tui/routes/session/header.tsx +0 -125
  129. package/src/cli/cmd/tui/routes/session/index.tsx +0 -1814
  130. package/src/cli/cmd/tui/routes/session/permission.tsx +0 -416
  131. package/src/cli/cmd/tui/routes/session/sidebar.tsx +0 -318
  132. package/src/cli/cmd/tui/spawn.ts +0 -48
  133. package/src/cli/cmd/tui/thread.ts +0 -111
  134. package/src/cli/cmd/tui/ui/dialog-alert.tsx +0 -57
  135. package/src/cli/cmd/tui/ui/dialog-confirm.tsx +0 -83
  136. package/src/cli/cmd/tui/ui/dialog-export-options.tsx +0 -204
  137. package/src/cli/cmd/tui/ui/dialog-help.tsx +0 -38
  138. package/src/cli/cmd/tui/ui/dialog-prompt.tsx +0 -77
  139. package/src/cli/cmd/tui/ui/dialog-select.tsx +0 -345
  140. package/src/cli/cmd/tui/ui/dialog.tsx +0 -171
  141. package/src/cli/cmd/tui/ui/link.tsx +0 -28
  142. package/src/cli/cmd/tui/ui/spinner.ts +0 -368
  143. package/src/cli/cmd/tui/ui/toast.tsx +0 -100
  144. package/src/cli/cmd/tui/util/clipboard.ts +0 -127
  145. package/src/cli/cmd/tui/util/editor.ts +0 -32
  146. package/src/cli/cmd/tui/util/signal.ts +0 -7
  147. package/src/cli/cmd/tui/util/terminal.ts +0 -114
  148. package/src/cli/cmd/tui/util/transcript.ts +0 -98
  149. package/src/cli/cmd/tui/worker.ts +0 -68
  150. package/src/cli/cmd/uninstall.ts +0 -344
  151. package/src/cli/cmd/upgrade.ts +0 -67
  152. package/src/cli/cmd/web.ts +0 -73
  153. package/src/cli/error.ts +0 -56
  154. package/src/cli/network.ts +0 -53
  155. package/src/cli/ui.ts +0 -87
  156. package/src/cli/upgrade.ts +0 -25
  157. package/src/command/index.ts +0 -131
  158. package/src/command/template/initialize.txt +0 -10
  159. package/src/command/template/review.txt +0 -97
  160. package/src/config/config.ts +0 -1124
  161. package/src/config/markdown.ts +0 -41
  162. package/src/env/index.ts +0 -26
  163. package/src/file/ignore.ts +0 -83
  164. package/src/file/index.ts +0 -411
  165. package/src/file/ripgrep.ts +0 -402
  166. package/src/file/time.ts +0 -64
  167. package/src/file/watcher.ts +0 -117
  168. package/src/flag/flag.ts +0 -52
  169. package/src/format/formatter.ts +0 -359
  170. package/src/format/index.ts +0 -137
  171. package/src/global/index.ts +0 -55
  172. package/src/id/id.ts +0 -73
  173. package/src/ide/index.ts +0 -77
  174. package/src/index.ts +0 -159
  175. package/src/installation/index.ts +0 -198
  176. package/src/lsp/client.ts +0 -252
  177. package/src/lsp/index.ts +0 -485
  178. package/src/lsp/language.ts +0 -119
  179. package/src/lsp/server.ts +0 -2023
  180. package/src/mcp/auth.ts +0 -135
  181. package/src/mcp/index.ts +0 -874
  182. package/src/mcp/oauth-callback.ts +0 -200
  183. package/src/mcp/oauth-provider.ts +0 -154
  184. package/src/patch/index.ts +0 -622
  185. package/src/permission/arity.ts +0 -163
  186. package/src/permission/index.ts +0 -210
  187. package/src/permission/next.ts +0 -268
  188. package/src/plugin/index.ts +0 -106
  189. package/src/project/bootstrap.ts +0 -31
  190. package/src/project/instance.ts +0 -78
  191. package/src/project/project.ts +0 -263
  192. package/src/project/state.ts +0 -65
  193. package/src/project/vcs.ts +0 -76
  194. package/src/provider/auth.ts +0 -143
  195. package/src/provider/models-macro.ts +0 -4
  196. package/src/provider/models.ts +0 -77
  197. package/src/provider/provider.ts +0 -516
  198. package/src/provider/transform.ts +0 -114
  199. package/src/pty/index.ts +0 -212
  200. package/src/server/error.ts +0 -36
  201. package/src/server/mdns.ts +0 -57
  202. package/src/server/project.ts +0 -79
  203. package/src/server/server.ts +0 -2866
  204. package/src/server/tui.ts +0 -71
  205. package/src/session/compaction.ts +0 -225
  206. package/src/session/index.ts +0 -469
  207. package/src/session/llm.ts +0 -213
  208. package/src/session/message-v2.ts +0 -742
  209. package/src/session/message.ts +0 -189
  210. package/src/session/processor.ts +0 -402
  211. package/src/session/prompt/anthropic-20250930.txt +0 -166
  212. package/src/session/prompt/anthropic.txt +0 -105
  213. package/src/session/prompt/anthropic_spoof.txt +0 -1
  214. package/src/session/prompt/beast.txt +0 -147
  215. package/src/session/prompt/build-switch.txt +0 -5
  216. package/src/session/prompt/codex.txt +0 -318
  217. package/src/session/prompt/copilot-gpt-5.txt +0 -143
  218. package/src/session/prompt/gemini.txt +0 -155
  219. package/src/session/prompt/max-steps.txt +0 -16
  220. package/src/session/prompt/plan-reminder-anthropic.txt +0 -67
  221. package/src/session/prompt/plan.txt +0 -26
  222. package/src/session/prompt/qwen.txt +0 -109
  223. package/src/session/prompt.ts +0 -1621
  224. package/src/session/retry.ts +0 -90
  225. package/src/session/revert.ts +0 -108
  226. package/src/session/status.ts +0 -76
  227. package/src/session/summary.ts +0 -194
  228. package/src/session/system.ts +0 -108
  229. package/src/session/todo.ts +0 -37
  230. package/src/share/share-next.ts +0 -194
  231. package/src/share/share.ts +0 -23
  232. package/src/shell/shell.ts +0 -67
  233. package/src/skill/index.ts +0 -1
  234. package/src/skill/skill.ts +0 -124
  235. package/src/snapshot/index.ts +0 -197
  236. package/src/storage/storage.ts +0 -226
  237. package/src/tool/bash.ts +0 -262
  238. package/src/tool/bash.txt +0 -116
  239. package/src/tool/batch.ts +0 -175
  240. package/src/tool/batch.txt +0 -24
  241. package/src/tool/codesearch.ts +0 -132
  242. package/src/tool/codesearch.txt +0 -12
  243. package/src/tool/edit.ts +0 -655
  244. package/src/tool/edit.txt +0 -10
  245. package/src/tool/glob.ts +0 -75
  246. package/src/tool/glob.txt +0 -6
  247. package/src/tool/grep.ts +0 -132
  248. package/src/tool/grep.txt +0 -8
  249. package/src/tool/invalid.ts +0 -17
  250. package/src/tool/ls.ts +0 -119
  251. package/src/tool/ls.txt +0 -1
  252. package/src/tool/lsp.ts +0 -94
  253. package/src/tool/lsp.txt +0 -19
  254. package/src/tool/multiedit.ts +0 -46
  255. package/src/tool/multiedit.txt +0 -41
  256. package/src/tool/patch.ts +0 -210
  257. package/src/tool/patch.txt +0 -1
  258. package/src/tool/read.ts +0 -191
  259. package/src/tool/read.txt +0 -12
  260. package/src/tool/registry.ts +0 -137
  261. package/src/tool/skill.ts +0 -77
  262. package/src/tool/task.ts +0 -167
  263. package/src/tool/task.txt +0 -60
  264. package/src/tool/todo.ts +0 -53
  265. package/src/tool/todoread.txt +0 -14
  266. package/src/tool/todowrite.txt +0 -167
  267. package/src/tool/tool.ts +0 -73
  268. package/src/tool/webfetch.ts +0 -182
  269. package/src/tool/webfetch.txt +0 -13
  270. package/src/tool/websearch.ts +0 -144
  271. package/src/tool/websearch.txt +0 -11
  272. package/src/tool/write.ts +0 -84
  273. package/src/tool/write.txt +0 -8
  274. package/src/util/archive.ts +0 -16
  275. package/src/util/color.ts +0 -19
  276. package/src/util/context.ts +0 -25
  277. package/src/util/defer.ts +0 -12
  278. package/src/util/eventloop.ts +0 -20
  279. package/src/util/filesystem.ts +0 -83
  280. package/src/util/fn.ts +0 -11
  281. package/src/util/iife.ts +0 -3
  282. package/src/util/keybind.ts +0 -102
  283. package/src/util/lazy.ts +0 -18
  284. package/src/util/locale.ts +0 -81
  285. package/src/util/lock.ts +0 -98
  286. package/src/util/log.ts +0 -180
  287. package/src/util/queue.ts +0 -32
  288. package/src/util/rpc.ts +0 -42
  289. package/src/util/scrap.ts +0 -10
  290. package/src/util/signal.ts +0 -12
  291. package/src/util/timeout.ts +0 -14
  292. package/src/util/token.ts +0 -7
  293. package/src/util/wildcard.ts +0 -54
  294. package/src/worktree/index.ts +0 -217
  295. package/sst-env.d.ts +0 -9
  296. package/test/agent/agent.test.ts +0 -448
  297. package/test/bun.test.ts +0 -53
  298. package/test/cli/github-action.test.ts +0 -129
  299. package/test/cli/github-remote.test.ts +0 -80
  300. package/test/cli/tui/transcript.test.ts +0 -297
  301. package/test/config/agent-color.test.ts +0 -66
  302. package/test/config/config.test.ts +0 -870
  303. package/test/config/markdown.test.ts +0 -89
  304. package/test/file/ignore.test.ts +0 -10
  305. package/test/file/path-traversal.test.ts +0 -115
  306. package/test/fixture/fixture.ts +0 -45
  307. package/test/fixture/lsp/fake-lsp-server.js +0 -77
  308. package/test/ide/ide.test.ts +0 -82
  309. package/test/keybind.test.ts +0 -421
  310. package/test/lsp/client.test.ts +0 -95
  311. package/test/mcp/headers.test.ts +0 -153
  312. package/test/patch/patch.test.ts +0 -348
  313. package/test/permission/arity.test.ts +0 -33
  314. package/test/permission/next.test.ts +0 -652
  315. package/test/preload.ts +0 -63
  316. package/test/project/project.test.ts +0 -120
  317. package/test/provider/amazon-bedrock.test.ts +0 -236
  318. package/test/provider/provider.test.ts +0 -2127
  319. package/test/provider/transform.test.ts +0 -980
  320. package/test/server/session-select.test.ts +0 -78
  321. package/test/session/compaction.test.ts +0 -251
  322. package/test/session/message-v2.test.ts +0 -570
  323. package/test/session/retry.test.ts +0 -131
  324. package/test/session/revert-compact.test.ts +0 -285
  325. package/test/session/session.test.ts +0 -71
  326. package/test/skill/skill.test.ts +0 -185
  327. package/test/snapshot/snapshot.test.ts +0 -939
  328. package/test/tool/__snapshots__/tool.test.ts.snap +0 -9
  329. package/test/tool/bash.test.ts +0 -232
  330. package/test/tool/grep.test.ts +0 -109
  331. package/test/tool/patch.test.ts +0 -261
  332. package/test/tool/read.test.ts +0 -167
  333. package/test/util/iife.test.ts +0 -36
  334. package/test/util/lazy.test.ts +0 -50
  335. package/test/util/timeout.test.ts +0 -21
  336. package/test/util/wildcard.test.ts +0 -55
  337. package/tsconfig.json +0 -16
  338. /package/{script/postinstall.mjs → postinstall.mjs} +0 -0
package/src/mcp/index.ts DELETED
@@ -1,874 +0,0 @@
1
- import { dynamicTool, type Tool, jsonSchema, type JSONSchema7 } from "ai"
2
- import { Client } from "@modelcontextprotocol/sdk/client/index.js"
3
- import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js"
4
- import { SSEClientTransport } from "@modelcontextprotocol/sdk/client/sse.js"
5
- import { StdioClientTransport } from "@modelcontextprotocol/sdk/client/stdio.js"
6
- import { UnauthorizedError } from "@modelcontextprotocol/sdk/client/auth.js"
7
- import {
8
- CallToolResultSchema,
9
- type Tool as MCPToolDef,
10
- ToolListChangedNotificationSchema,
11
- } from "@modelcontextprotocol/sdk/types.js"
12
- import { Config } from "../config/config"
13
- import { Log } from "../util/log"
14
- import { NamedError } from "@opencode-ai/util/error"
15
- import z from "zod/v4"
16
- import { Instance } from "../project/instance"
17
- import { Installation } from "../installation"
18
- import { withTimeout } from "@/util/timeout"
19
- import { McpOAuthProvider } from "./oauth-provider"
20
- import { McpOAuthCallback } from "./oauth-callback"
21
- import { McpAuth } from "./auth"
22
- import { BusEvent } from "../bus/bus-event"
23
- import { Bus } from "@/bus"
24
- import { TuiEvent } from "@/cli/cmd/tui/event"
25
- import open from "open"
26
-
27
- export namespace MCP {
28
- const log = Log.create({ service: "mcp" })
29
- const DEFAULT_TIMEOUT = 30_000
30
-
31
- export const Resource = z
32
- .object({
33
- name: z.string(),
34
- uri: z.string(),
35
- description: z.string().optional(),
36
- mimeType: z.string().optional(),
37
- client: z.string(),
38
- })
39
- .meta({ ref: "McpResource" })
40
- export type Resource = z.infer<typeof Resource>
41
-
42
- export const ToolsChanged = BusEvent.define(
43
- "mcp.tools.changed",
44
- z.object({
45
- server: z.string(),
46
- }),
47
- )
48
-
49
- export const Failed = NamedError.create(
50
- "MCPFailed",
51
- z.object({
52
- name: z.string(),
53
- }),
54
- )
55
-
56
- type MCPClient = Client
57
-
58
- export const Status = z
59
- .discriminatedUnion("status", [
60
- z
61
- .object({
62
- status: z.literal("connected"),
63
- })
64
- .meta({
65
- ref: "MCPStatusConnected",
66
- }),
67
- z
68
- .object({
69
- status: z.literal("disabled"),
70
- })
71
- .meta({
72
- ref: "MCPStatusDisabled",
73
- }),
74
- z
75
- .object({
76
- status: z.literal("failed"),
77
- error: z.string(),
78
- })
79
- .meta({
80
- ref: "MCPStatusFailed",
81
- }),
82
- z
83
- .object({
84
- status: z.literal("needs_auth"),
85
- })
86
- .meta({
87
- ref: "MCPStatusNeedsAuth",
88
- }),
89
- z
90
- .object({
91
- status: z.literal("needs_client_registration"),
92
- error: z.string(),
93
- })
94
- .meta({
95
- ref: "MCPStatusNeedsClientRegistration",
96
- }),
97
- ])
98
- .meta({
99
- ref: "MCPStatus",
100
- })
101
- export type Status = z.infer<typeof Status>
102
-
103
- // Register notification handlers for MCP client
104
- function registerNotificationHandlers(client: MCPClient, serverName: string) {
105
- client.setNotificationHandler(ToolListChangedNotificationSchema, async () => {
106
- log.info("tools list changed notification received", { server: serverName })
107
- Bus.publish(ToolsChanged, { server: serverName })
108
- })
109
- }
110
-
111
- // Convert MCP tool definition to AI SDK Tool type
112
- async function convertMcpTool(mcpTool: MCPToolDef, client: MCPClient): Promise<Tool> {
113
- const inputSchema = mcpTool.inputSchema
114
-
115
- // Spread first, then override type to ensure it's always "object"
116
- const schema: JSONSchema7 = {
117
- ...(inputSchema as JSONSchema7),
118
- type: "object",
119
- properties: (inputSchema.properties ?? {}) as JSONSchema7["properties"],
120
- additionalProperties: false,
121
- }
122
- const config = await Config.get()
123
-
124
- return dynamicTool({
125
- description: mcpTool.description ?? "",
126
- inputSchema: jsonSchema(schema),
127
- execute: async (args: unknown) => {
128
- return client.callTool(
129
- {
130
- name: mcpTool.name,
131
- arguments: args as Record<string, unknown>,
132
- },
133
- CallToolResultSchema,
134
- {
135
- resetTimeoutOnProgress: true,
136
- timeout: config.experimental?.mcp_timeout,
137
- },
138
- )
139
- },
140
- })
141
- }
142
-
143
- // Store transports for OAuth servers to allow finishing auth
144
- type TransportWithAuth = StreamableHTTPClientTransport | SSEClientTransport
145
- const pendingOAuthTransports = new Map<string, TransportWithAuth>()
146
-
147
- // Prompt cache types
148
- type PromptInfo = Awaited<ReturnType<MCPClient["listPrompts"]>>["prompts"][number]
149
-
150
- type ResourceInfo = Awaited<ReturnType<MCPClient["listResources"]>>["resources"][number]
151
- type McpEntry = NonNullable<Config.Info["mcp"]>[string]
152
- function isMcpConfigured(entry: McpEntry): entry is Config.Mcp {
153
- return typeof entry === "object" && entry !== null && "type" in entry
154
- }
155
-
156
- const state = Instance.state(
157
- async () => {
158
- const cfg = await Config.get()
159
- const config = cfg.mcp ?? {}
160
- const clients: Record<string, MCPClient> = {}
161
- const status: Record<string, Status> = {}
162
-
163
- await Promise.all(
164
- Object.entries(config).map(async ([key, mcp]) => {
165
- if (!isMcpConfigured(mcp)) {
166
- log.error("Ignoring MCP config entry without type", { key })
167
- return
168
- }
169
-
170
- // If disabled by config, mark as disabled without trying to connect
171
- if (mcp.enabled === false) {
172
- status[key] = { status: "disabled" }
173
- return
174
- }
175
-
176
- const result = await create(key, mcp).catch(() => undefined)
177
- if (!result) return
178
-
179
- status[key] = result.status
180
-
181
- if (result.mcpClient) {
182
- clients[key] = result.mcpClient
183
- }
184
- }),
185
- )
186
- return {
187
- status,
188
- clients,
189
- }
190
- },
191
- async (state) => {
192
- await Promise.all(
193
- Object.values(state.clients).map((client) =>
194
- client.close().catch((error) => {
195
- log.error("Failed to close MCP client", {
196
- error,
197
- })
198
- }),
199
- ),
200
- )
201
- pendingOAuthTransports.clear()
202
- },
203
- )
204
-
205
- // Helper function to fetch prompts for a specific client
206
- async function fetchPromptsForClient(clientName: string, client: Client) {
207
- const prompts = await client.listPrompts().catch((e) => {
208
- log.error("failed to get prompts", { clientName, error: e.message })
209
- return undefined
210
- })
211
-
212
- if (!prompts) {
213
- return
214
- }
215
-
216
- const commands: Record<string, PromptInfo & { client: string }> = {}
217
-
218
- for (const prompt of prompts.prompts) {
219
- const sanitizedClientName = clientName.replace(/[^a-zA-Z0-9_-]/g, "_")
220
- const sanitizedPromptName = prompt.name.replace(/[^a-zA-Z0-9_-]/g, "_")
221
- const key = sanitizedClientName + ":" + sanitizedPromptName
222
-
223
- commands[key] = { ...prompt, client: clientName }
224
- }
225
- return commands
226
- }
227
-
228
- async function fetchResourcesForClient(clientName: string, client: Client) {
229
- const resources = await client.listResources().catch((e) => {
230
- log.error("failed to get prompts", { clientName, error: e.message })
231
- return undefined
232
- })
233
-
234
- if (!resources) {
235
- return
236
- }
237
-
238
- const commands: Record<string, ResourceInfo & { client: string }> = {}
239
-
240
- for (const resource of resources.resources) {
241
- const sanitizedClientName = clientName.replace(/[^a-zA-Z0-9_-]/g, "_")
242
- const sanitizedResourceName = resource.name.replace(/[^a-zA-Z0-9_-]/g, "_")
243
- const key = sanitizedClientName + ":" + sanitizedResourceName
244
-
245
- commands[key] = { ...resource, client: clientName }
246
- }
247
- return commands
248
- }
249
-
250
- export async function add(name: string, mcp: Config.Mcp) {
251
- const s = await state()
252
- const result = await create(name, mcp)
253
- if (!result) {
254
- const status = {
255
- status: "failed" as const,
256
- error: "unknown error",
257
- }
258
- s.status[name] = status
259
- return {
260
- status,
261
- }
262
- }
263
- if (!result.mcpClient) {
264
- s.status[name] = result.status
265
- return {
266
- status: s.status,
267
- }
268
- }
269
- s.clients[name] = result.mcpClient
270
- s.status[name] = result.status
271
-
272
- return {
273
- status: s.status,
274
- }
275
- }
276
-
277
- async function create(key: string, mcp: Config.Mcp) {
278
- if (mcp.enabled === false) {
279
- log.info("mcp server disabled", { key })
280
- return {
281
- mcpClient: undefined,
282
- status: { status: "disabled" as const },
283
- }
284
- }
285
-
286
- log.info("found", { key, type: mcp.type })
287
- let mcpClient: MCPClient | undefined
288
- let status: Status | undefined = undefined
289
-
290
- if (mcp.type === "remote") {
291
- // OAuth is enabled by default for remote servers unless explicitly disabled with oauth: false
292
- const oauthDisabled = mcp.oauth === false
293
- const oauthConfig = typeof mcp.oauth === "object" ? mcp.oauth : undefined
294
- let authProvider: McpOAuthProvider | undefined
295
-
296
- if (!oauthDisabled) {
297
- authProvider = new McpOAuthProvider(
298
- key,
299
- mcp.url,
300
- {
301
- clientId: oauthConfig?.clientId,
302
- clientSecret: oauthConfig?.clientSecret,
303
- scope: oauthConfig?.scope,
304
- },
305
- {
306
- onRedirect: async (url) => {
307
- log.info("oauth redirect requested", { key, url: url.toString() })
308
- // Store the URL - actual browser opening is handled by startAuth
309
- },
310
- },
311
- )
312
- }
313
-
314
- const transports: Array<{ name: string; transport: TransportWithAuth }> = [
315
- {
316
- name: "StreamableHTTP",
317
- transport: new StreamableHTTPClientTransport(new URL(mcp.url), {
318
- authProvider,
319
- requestInit: mcp.headers ? { headers: mcp.headers } : undefined,
320
- }),
321
- },
322
- {
323
- name: "SSE",
324
- transport: new SSEClientTransport(new URL(mcp.url), {
325
- authProvider,
326
- requestInit: mcp.headers ? { headers: mcp.headers } : undefined,
327
- }),
328
- },
329
- ]
330
-
331
- let lastError: Error | undefined
332
- const connectTimeout = mcp.timeout ?? DEFAULT_TIMEOUT
333
- for (const { name, transport } of transports) {
334
- try {
335
- const client = new Client({
336
- name: "opencode",
337
- version: Installation.VERSION,
338
- })
339
- await withTimeout(client.connect(transport), connectTimeout)
340
- registerNotificationHandlers(client, key)
341
- mcpClient = client
342
- log.info("connected", { key, transport: name })
343
- status = { status: "connected" }
344
- break
345
- } catch (error) {
346
- lastError = error instanceof Error ? error : new Error(String(error))
347
-
348
- // Handle OAuth-specific errors
349
- if (error instanceof UnauthorizedError) {
350
- log.info("mcp server requires authentication", { key, transport: name })
351
-
352
- // Check if this is a "needs registration" error
353
- if (lastError.message.includes("registration") || lastError.message.includes("client_id")) {
354
- status = {
355
- status: "needs_client_registration" as const,
356
- error: "Server does not support dynamic client registration. Please provide clientId in config.",
357
- }
358
- // Show toast for needs_client_registration
359
- Bus.publish(TuiEvent.ToastShow, {
360
- title: "MCP Authentication Required",
361
- message: `Server "${key}" requires a pre-registered client ID. Add clientId to your config.`,
362
- variant: "warning",
363
- duration: 8000,
364
- }).catch((e) => log.debug("failed to show toast", { error: e }))
365
- } else {
366
- // Store transport for later finishAuth call
367
- pendingOAuthTransports.set(key, transport)
368
- status = { status: "needs_auth" as const }
369
- // Show toast for needs_auth
370
- Bus.publish(TuiEvent.ToastShow, {
371
- title: "MCP Authentication Required",
372
- message: `Server "${key}" requires authentication. Run: opencode mcp auth ${key}`,
373
- variant: "warning",
374
- duration: 8000,
375
- }).catch((e) => log.debug("failed to show toast", { error: e }))
376
- }
377
- break
378
- }
379
-
380
- log.debug("transport connection failed", {
381
- key,
382
- transport: name,
383
- url: mcp.url,
384
- error: lastError.message,
385
- })
386
- status = {
387
- status: "failed" as const,
388
- error: lastError.message,
389
- }
390
- }
391
- }
392
- }
393
-
394
- if (mcp.type === "local") {
395
- const [cmd, ...args] = mcp.command
396
- const cwd = Instance.directory
397
- const transport = new StdioClientTransport({
398
- stderr: "ignore",
399
- command: cmd,
400
- args,
401
- cwd,
402
- env: {
403
- ...process.env,
404
- ...(cmd === "opencode" ? { BUN_BE_BUN: "1" } : {}),
405
- ...mcp.environment,
406
- },
407
- })
408
-
409
- const connectTimeout = mcp.timeout ?? DEFAULT_TIMEOUT
410
- try {
411
- const client = new Client({
412
- name: "opencode",
413
- version: Installation.VERSION,
414
- })
415
- await withTimeout(client.connect(transport), connectTimeout)
416
- registerNotificationHandlers(client, key)
417
- mcpClient = client
418
- status = {
419
- status: "connected",
420
- }
421
- } catch (error) {
422
- log.error("local mcp startup failed", {
423
- key,
424
- command: mcp.command,
425
- cwd,
426
- error: error instanceof Error ? error.message : String(error),
427
- })
428
- status = {
429
- status: "failed" as const,
430
- error: error instanceof Error ? error.message : String(error),
431
- }
432
- }
433
- }
434
-
435
- if (!status) {
436
- status = {
437
- status: "failed" as const,
438
- error: "Unknown error",
439
- }
440
- }
441
-
442
- if (!mcpClient) {
443
- return {
444
- mcpClient: undefined,
445
- status,
446
- }
447
- }
448
-
449
- const result = await withTimeout(mcpClient.listTools(), mcp.timeout ?? DEFAULT_TIMEOUT).catch((err) => {
450
- log.error("failed to get tools from client", { key, error: err })
451
- return undefined
452
- })
453
- if (!result) {
454
- await mcpClient.close().catch((error) => {
455
- log.error("Failed to close MCP client", {
456
- error,
457
- })
458
- })
459
- status = {
460
- status: "failed",
461
- error: "Failed to get tools",
462
- }
463
- return {
464
- mcpClient: undefined,
465
- status: {
466
- status: "failed" as const,
467
- error: "Failed to get tools",
468
- },
469
- }
470
- }
471
-
472
- log.info("create() successfully created client", { key, toolCount: result.tools.length })
473
- return {
474
- mcpClient,
475
- status,
476
- }
477
- }
478
-
479
- export async function status() {
480
- const s = await state()
481
- const cfg = await Config.get()
482
- const config = cfg.mcp ?? {}
483
- const result: Record<string, Status> = {}
484
-
485
- // Include all configured MCPs from config, not just connected ones
486
- for (const [key, mcp] of Object.entries(config)) {
487
- if (!isMcpConfigured(mcp)) continue
488
- result[key] = s.status[key] ?? { status: "disabled" }
489
- }
490
-
491
- return result
492
- }
493
-
494
- export async function clients() {
495
- return state().then((state) => state.clients)
496
- }
497
-
498
- export async function connect(name: string) {
499
- const cfg = await Config.get()
500
- const config = cfg.mcp ?? {}
501
- const mcp = config[name]
502
- if (!mcp) {
503
- log.error("MCP config not found", { name })
504
- return
505
- }
506
-
507
- if (!isMcpConfigured(mcp)) {
508
- log.error("Ignoring MCP connect request for config without type", { name })
509
- return
510
- }
511
-
512
- const result = await create(name, { ...mcp, enabled: true })
513
-
514
- if (!result) {
515
- const s = await state()
516
- s.status[name] = {
517
- status: "failed",
518
- error: "Unknown error during connection",
519
- }
520
- return
521
- }
522
-
523
- const s = await state()
524
- s.status[name] = result.status
525
- if (result.mcpClient) {
526
- s.clients[name] = result.mcpClient
527
- }
528
- }
529
-
530
- export async function disconnect(name: string) {
531
- const s = await state()
532
- const client = s.clients[name]
533
- if (client) {
534
- await client.close().catch((error) => {
535
- log.error("Failed to close MCP client", { name, error })
536
- })
537
- delete s.clients[name]
538
- }
539
- s.status[name] = { status: "disabled" }
540
- }
541
-
542
- export async function tools() {
543
- const result: Record<string, Tool> = {}
544
- const s = await state()
545
- const clientsSnapshot = await clients()
546
-
547
- for (const [clientName, client] of Object.entries(clientsSnapshot)) {
548
- // Only include tools from connected MCPs (skip disabled ones)
549
- if (s.status[clientName]?.status !== "connected") {
550
- continue
551
- }
552
-
553
- const toolsResult = await client.listTools().catch((e) => {
554
- log.error("failed to get tools", { clientName, error: e.message })
555
- const failedStatus = {
556
- status: "failed" as const,
557
- error: e instanceof Error ? e.message : String(e),
558
- }
559
- s.status[clientName] = failedStatus
560
- delete s.clients[clientName]
561
- return undefined
562
- })
563
- if (!toolsResult) {
564
- continue
565
- }
566
- for (const mcpTool of toolsResult.tools) {
567
- const sanitizedClientName = clientName.replace(/[^a-zA-Z0-9_-]/g, "_")
568
- const sanitizedToolName = mcpTool.name.replace(/[^a-zA-Z0-9_-]/g, "_")
569
- result[sanitizedClientName + "_" + sanitizedToolName] = await convertMcpTool(mcpTool, client)
570
- }
571
- }
572
- return result
573
- }
574
-
575
- export async function prompts() {
576
- const s = await state()
577
- const clientsSnapshot = await clients()
578
-
579
- const prompts = Object.fromEntries<PromptInfo & { client: string }>(
580
- (
581
- await Promise.all(
582
- Object.entries(clientsSnapshot).map(async ([clientName, client]) => {
583
- if (s.status[clientName]?.status !== "connected") {
584
- return []
585
- }
586
-
587
- return Object.entries((await fetchPromptsForClient(clientName, client)) ?? {})
588
- }),
589
- )
590
- ).flat(),
591
- )
592
-
593
- return prompts
594
- }
595
-
596
- export async function resources() {
597
- const s = await state()
598
- const clientsSnapshot = await clients()
599
-
600
- const result = Object.fromEntries<ResourceInfo & { client: string }>(
601
- (
602
- await Promise.all(
603
- Object.entries(clientsSnapshot).map(async ([clientName, client]) => {
604
- if (s.status[clientName]?.status !== "connected") {
605
- return []
606
- }
607
-
608
- return Object.entries((await fetchResourcesForClient(clientName, client)) ?? {})
609
- }),
610
- )
611
- ).flat(),
612
- )
613
-
614
- return result
615
- }
616
-
617
- export async function getPrompt(clientName: string, name: string, args?: Record<string, string>) {
618
- const clientsSnapshot = await clients()
619
- const client = clientsSnapshot[clientName]
620
-
621
- if (!client) {
622
- log.warn("client not found for prompt", {
623
- clientName,
624
- })
625
- return undefined
626
- }
627
-
628
- const result = await client
629
- .getPrompt({
630
- name: name,
631
- arguments: args,
632
- })
633
- .catch((e) => {
634
- log.error("failed to get prompt from MCP server", {
635
- clientName,
636
- promptName: name,
637
- error: e.message,
638
- })
639
- return undefined
640
- })
641
-
642
- return result
643
- }
644
-
645
- export async function readResource(clientName: string, resourceUri: string) {
646
- const clientsSnapshot = await clients()
647
- const client = clientsSnapshot[clientName]
648
-
649
- if (!client) {
650
- log.warn("client not found for prompt", {
651
- clientName: clientName,
652
- })
653
- return undefined
654
- }
655
-
656
- const result = await client
657
- .readResource({
658
- uri: resourceUri,
659
- })
660
- .catch((e) => {
661
- log.error("failed to get prompt from MCP server", {
662
- clientName: clientName,
663
- resourceUri: resourceUri,
664
- error: e.message,
665
- })
666
- return undefined
667
- })
668
-
669
- return result
670
- }
671
-
672
- /**
673
- * Start OAuth authentication flow for an MCP server.
674
- * Returns the authorization URL that should be opened in a browser.
675
- */
676
- export async function startAuth(mcpName: string): Promise<{ authorizationUrl: string }> {
677
- const cfg = await Config.get()
678
- const mcpConfig = cfg.mcp?.[mcpName]
679
-
680
- if (!mcpConfig) {
681
- throw new Error(`MCP server not found: ${mcpName}`)
682
- }
683
-
684
- if (!isMcpConfigured(mcpConfig)) {
685
- throw new Error(`MCP server ${mcpName} is disabled or missing configuration`)
686
- }
687
-
688
- if (mcpConfig.type !== "remote") {
689
- throw new Error(`MCP server ${mcpName} is not a remote server`)
690
- }
691
-
692
- if (mcpConfig.oauth === false) {
693
- throw new Error(`MCP server ${mcpName} has OAuth explicitly disabled`)
694
- }
695
-
696
- // Start the callback server
697
- await McpOAuthCallback.ensureRunning()
698
-
699
- // Generate and store a cryptographically secure state parameter BEFORE creating the provider
700
- // The SDK will call provider.state() to read this value
701
- const oauthState = Array.from(crypto.getRandomValues(new Uint8Array(32)))
702
- .map((b) => b.toString(16).padStart(2, "0"))
703
- .join("")
704
- await McpAuth.updateOAuthState(mcpName, oauthState)
705
-
706
- // Create a new auth provider for this flow
707
- // OAuth config is optional - if not provided, we'll use auto-discovery
708
- const oauthConfig = typeof mcpConfig.oauth === "object" ? mcpConfig.oauth : undefined
709
- let capturedUrl: URL | undefined
710
- const authProvider = new McpOAuthProvider(
711
- mcpName,
712
- mcpConfig.url,
713
- {
714
- clientId: oauthConfig?.clientId,
715
- clientSecret: oauthConfig?.clientSecret,
716
- scope: oauthConfig?.scope,
717
- },
718
- {
719
- onRedirect: async (url) => {
720
- capturedUrl = url
721
- },
722
- },
723
- )
724
-
725
- // Create transport with auth provider
726
- const transport = new StreamableHTTPClientTransport(new URL(mcpConfig.url), {
727
- authProvider,
728
- })
729
-
730
- // Try to connect - this will trigger the OAuth flow
731
- try {
732
- const client = new Client({
733
- name: "opencode",
734
- version: Installation.VERSION,
735
- })
736
- await client.connect(transport)
737
- // If we get here, we're already authenticated
738
- return { authorizationUrl: "" }
739
- } catch (error) {
740
- if (error instanceof UnauthorizedError && capturedUrl) {
741
- // Store transport for finishAuth
742
- pendingOAuthTransports.set(mcpName, transport)
743
- return { authorizationUrl: capturedUrl.toString() }
744
- }
745
- throw error
746
- }
747
- }
748
-
749
- /**
750
- * Complete OAuth authentication after user authorizes in browser.
751
- * Opens the browser and waits for callback.
752
- */
753
- export async function authenticate(mcpName: string): Promise<Status> {
754
- const { authorizationUrl } = await startAuth(mcpName)
755
-
756
- if (!authorizationUrl) {
757
- // Already authenticated
758
- const s = await state()
759
- return s.status[mcpName] ?? { status: "connected" }
760
- }
761
-
762
- // Get the state that was already generated and stored in startAuth()
763
- const oauthState = await McpAuth.getOAuthState(mcpName)
764
- if (!oauthState) {
765
- throw new Error("OAuth state not found - this should not happen")
766
- }
767
-
768
- // The SDK has already added the state parameter to the authorization URL
769
- // We just need to open the browser
770
- log.info("opening browser for oauth", { mcpName, url: authorizationUrl, state: oauthState })
771
- await open(authorizationUrl)
772
-
773
- // Wait for callback using the OAuth state parameter
774
- const code = await McpOAuthCallback.waitForCallback(oauthState)
775
-
776
- // Validate and clear the state
777
- const storedState = await McpAuth.getOAuthState(mcpName)
778
- if (storedState !== oauthState) {
779
- await McpAuth.clearOAuthState(mcpName)
780
- throw new Error("OAuth state mismatch - potential CSRF attack")
781
- }
782
-
783
- await McpAuth.clearOAuthState(mcpName)
784
-
785
- // Finish auth
786
- return finishAuth(mcpName, code)
787
- }
788
-
789
- /**
790
- * Complete OAuth authentication with the authorization code.
791
- */
792
- export async function finishAuth(mcpName: string, authorizationCode: string): Promise<Status> {
793
- const transport = pendingOAuthTransports.get(mcpName)
794
-
795
- if (!transport) {
796
- throw new Error(`No pending OAuth flow for MCP server: ${mcpName}`)
797
- }
798
-
799
- try {
800
- // Call finishAuth on the transport
801
- await transport.finishAuth(authorizationCode)
802
-
803
- // Clear the code verifier after successful auth
804
- await McpAuth.clearCodeVerifier(mcpName)
805
-
806
- // Now try to reconnect
807
- const cfg = await Config.get()
808
- const mcpConfig = cfg.mcp?.[mcpName]
809
-
810
- if (!mcpConfig) {
811
- throw new Error(`MCP server not found: ${mcpName}`)
812
- }
813
-
814
- if (!isMcpConfigured(mcpConfig)) {
815
- throw new Error(`MCP server ${mcpName} is disabled or missing configuration`)
816
- }
817
-
818
- // Re-add the MCP server to establish connection
819
- pendingOAuthTransports.delete(mcpName)
820
- const result = await add(mcpName, mcpConfig)
821
-
822
- const statusRecord = result.status as Record<string, Status>
823
- return statusRecord[mcpName] ?? { status: "failed", error: "Unknown error after auth" }
824
- } catch (error) {
825
- log.error("failed to finish oauth", { mcpName, error })
826
- return {
827
- status: "failed",
828
- error: error instanceof Error ? error.message : String(error),
829
- }
830
- }
831
- }
832
-
833
- /**
834
- * Remove OAuth credentials for an MCP server.
835
- */
836
- export async function removeAuth(mcpName: string): Promise<void> {
837
- await McpAuth.remove(mcpName)
838
- McpOAuthCallback.cancelPending(mcpName)
839
- pendingOAuthTransports.delete(mcpName)
840
- await McpAuth.clearOAuthState(mcpName)
841
- log.info("removed oauth credentials", { mcpName })
842
- }
843
-
844
- /**
845
- * Check if an MCP server supports OAuth (remote servers support OAuth by default unless explicitly disabled).
846
- */
847
- export async function supportsOAuth(mcpName: string): Promise<boolean> {
848
- const cfg = await Config.get()
849
- const mcpConfig = cfg.mcp?.[mcpName]
850
- if (!mcpConfig) return false
851
- if (!isMcpConfigured(mcpConfig)) return false
852
- return mcpConfig.type === "remote" && mcpConfig.oauth !== false
853
- }
854
-
855
- /**
856
- * Check if an MCP server has stored OAuth tokens.
857
- */
858
- export async function hasStoredTokens(mcpName: string): Promise<boolean> {
859
- const entry = await McpAuth.get(mcpName)
860
- return !!entry?.tokens
861
- }
862
-
863
- export type AuthStatus = "authenticated" | "expired" | "not_authenticated"
864
-
865
- /**
866
- * Get the authentication status for an MCP server.
867
- */
868
- export async function getAuthStatus(mcpName: string): Promise<AuthStatus> {
869
- const hasTokens = await hasStoredTokens(mcpName)
870
- if (!hasTokens) return "not_authenticated"
871
- const expired = await McpAuth.isTokenExpired(mcpName)
872
- return expired ? "expired" : "authenticated"
873
- }
874
- }