modscode / 図鑑 / agent-discover
agent-discover
Find, install and enable MCP servers mid-session. Search tools across installed and marketplace servers, approve installs with full provenance, and manage everything in the /discover pane.
何をするか
- 欄・プロンプトの上の帯・トーストを描く
- /discover を足す
- session.startにフックする
- ネットワークに出る
良いところ
- プロセスを起こさない
- TypeScript で書かれている
- エラーを扱う
- ファイルを書かない
作り始めるためのコード
2 種類あります。上のデザインから modscode が書いた雛形と、その Mod 自身のコードのうち描いている部分です。
雛形(register.tsx)
import type { Register } from 'claude-code'
// Drawn like agent-discover by keshrath (pane, band, status, toast), as modscode read it from the mod's code:
// https://modscode.com/gallery/keshrath-agent-discover/
// Written by modscode from that reading, not copied from the mod: use it as you like.
// Each value below stands for one the mod works out at run time; put in your own.
export const register: Register = on => {
// the pane: open it with $.ui.open({ id: 'my-pane', title: "agent-discover" })
on('ui.render', { component: 'Pane', requestId: 'my-pane' }, async ($, e) => {
const { Box, Button, Text, Select } = $.ui.resolve(e)
const label = '…'
const enabled = '…'
const length = '…'
const busy = '…'
const server = '…'
const message = '…'
const title = '…'
const server2 = '…'
const message2 = '…'
const server3 = '…'
const message3 = '…'
return (
<Box flexDirection="column" gap={1}>
<Box flexWrap="wrap" columnGap={1}>
<Button label={`${label}`} />
<Button label={`${label}`} />
<Button label={`${label}`} />
<Button label="Refresh" dimColor />
<Text dimColor>
{"MCP "}
{enabled}
/
{length}
</Text>
</Box>
<Text dimColor wrap="truncate">
Tab / shift+Tab move · Enter presses · ↑↓ scroll · Esc back to the prompt
</Text>
<Text color="yellow">
{busy}
...
</Text>
<Box flexDirection="column" borderStyle="round" borderColor="yellow" paddingX={1}>
<Text color="yellow">
{server}
{" asks:"}
</Text>
<Text>
{message}
</Text>
<Select label={`${title}`} />
<Select label={`${title}`} />
<Select label={`${title}`} />
<Box flexWrap="wrap" columnGap={1}>
<Button label="Accept" variant="primary" />
<Button label="Decline" />
<Button label="Cancel" dimColor />
</Box>
</Box>
<Box flexDirection="column" borderStyle="round" borderColor="yellow" paddingX={1}>
<Text color="yellow">
{server2}
{" asks:"}
</Text>
<Text>
{message2}
</Text>
<Select label={`${title}`} />
<Select label={`${title}`} />
<Select label={`${title}`} />
<Box flexWrap="wrap" columnGap={1}>
<Button label="Accept" variant="primary" />
<Button label="Decline" />
<Button label="Cancel" dimColor />
</Box>
</Box>
<Box flexDirection="column" borderStyle="round" borderColor="yellow" paddingX={1}>
<Text color="yellow">
{server3}
{" asks:"}
</Text>
<Text>
{message3}
</Text>
<Select label={`${title}`} />
<Select label={`${title}`} />
<Select label={`${title}`} />
<Box flexWrap="wrap" columnGap={1}>
<Button label="Accept" variant="primary" />
<Button label="Decline" />
<Button label="Cancel" dimColor />
</Box>
</Box>
</Box>
)
})
// the band above the prompt; what else goes there is drawn under it
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
const { Box, Text, Button } = $.ui.resolve(e)
const what = '…'
return (
<Box flexDirection="column">
<Box columnGap={1} flexWrap="wrap">
<Text color="yellow">
{"agent-discover: "}
{what}
</Text>
<Button label="Review" variant="primary" />
<Button label="Dismiss" dimColor />
</Box>
{await next(e)}
</Box>
)
})
on('session.start', async ($, e, next) => {
const name = '…'
const server = '…'
await $.ui.toast(`agent-discover: ${name} quarantined, review before use`)
await $.ui.toast(`agent-discover: ${server} asks a question (/discover)`)
return next(e)
})
}
Mod 自身のコード
Mod のライセンス(MIT)に従って載せています。全文は下にあります。写すときは著作権表示を残してください。
plugin/hooks/register.tsx 752〜777 行 · ペイン
on('ui.render', { component: 'Pane', requestId: PANE }, async ($, e) => {
const el = $.ui.resolve(e);
const snap = await read($, snapshot);
if (!snap) return <el.Text dimColor>Loading...</el.Text>;
return (
<Pane
el={el}
snap={snap}
route={await read($, route)}
detail={await read($, detail)}
tool={await read($, tool)}
confirm={await read($, confirm)}
browse={await read($, browse)}
plan={await read($, plan)}
logs={await read($, logs)}
audit={await read($, audit)}
busy={await read($, busy)}
notice={await read($, notice)}
isFocused={e.props.isFocused}
masked={await read($, masked)}
editing={await read($, editing)}
on={actions($)}
/>
);
});plugin/hooks/view.tsx 165〜225 行 · ペイン
export function Pane(p: PaneProps) {
const { Box, Text, Button } = p.el;
const { snap, route, on } = p;
const enabled = snap.servers.filter((s) => s.enabled).length;
let body;
if (!snap.isUp) body = <Text color="red">The daemon does not answer at {snap.origin}.</Text>;
else if (route.tab === 'servers' && route.server)
body = p.detail ? (
<Detail
el={p.el}
on={on}
d={p.detail}
tool={p.tool}
confirm={p.confirm}
masked={p.masked}
editing={p.editing}
/>
) : (
<Text dimColor>Loading {route.server}...</Text>
);
else if (route.tab === 'servers') body = <Servers el={p.el} on={on} servers={snap.servers} />;
else if (route.tab === 'browse')
body = <Browse el={p.el} on={on} browse={p.browse} plan={p.plan} masked={p.masked} />;
else if (route.tab === 'logs') body = <Logs el={p.el} on={on} logs={p.logs} />;
else body = <Audit el={p.el} on={on} audit={p.audit} />;
return (
<Box flexDirection="column" gap={1}>
<Box flexWrap="wrap" columnGap={1}>
{TABS.map(([tab, label]) => (
<Button
key={`tab:${tab}`}
label={label}
{...primary(route.tab === tab)}
onPress={() => on.go(tab)}
/>
))}
<Button key="refresh" label="Refresh" dimColor onPress={on.refresh} />
{snap.isUp && (
<Text dimColor>
MCP {enabled}/{snap.servers.length}
</Text>
)}
</Box>
<Text dimColor wrap="truncate">
{p.isFocused
? 'Tab / shift+Tab move · Enter presses · ↑↓ scroll · Esc back to the prompt'
: 'ctrl+x tab: use this pane from the keyboard'}
</Text>
{p.busy ? (
<Text color="yellow">{p.busy}...</Text>
) : (
p.notice && <Text dimColor>{p.notice}</Text>
)}
{snap.elicitations.map((q) => (
<Question key={`q:${q.id}`} el={p.el} on={on} q={q} />
))}
{body}
</Box>
);
}plugin/hooks/view.tsx 227〜273 行 · ペイン
function Question({ el, on, q }: ViewProps & { q: AgentDiscoverElicitation }) {
const { Box, Text, Button, Input, Select } = el;
return (
<Box flexDirection="column" borderStyle="round" borderColor="yellow" paddingX={1}>
<Text color="yellow">{q.server} asks:</Text>
<Text>{q.message}</Text>
{q.fields.map((f) =>
f.options.length && Select ? (
<Select
key={`q:${q.id}:${f.name}`}
label={f.title}
options={f.options.map((o) => ({ value: o, label: o }))}
onSelect={(v) => on.answer(q.id, f.name, v)}
/>
) : (
Input && (
<Input
key={`q:${q.id}:${f.name}`}
label={`${f.title}${f.required ? ' *' : ''}`}
submitLabel="set"
onSubmit={(v) => on.answer(q.id, f.name, v)}
/>
)
),
)}
<Box flexWrap="wrap" columnGap={1}>
<Button
key={`q:${q.id}:accept`}
label="Accept"
variant="primary"
onPress={() => on.respond(q.id, 'accept')}
/>
<Button
key={`q:${q.id}:decline`}
label="Decline"
onPress={() => on.respond(q.id, 'decline')}
/>
<Button
key={`q:${q.id}:cancel`}
label="Cancel"
dimColor
onPress={() => on.respond(q.id, 'cancel')}
/>
</Box>
</Box>
);
}plugin/hooks/register.tsx 779〜791 行 · バンド
on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
const snap = await read($, snapshot);
if (
e.props.hasSurvey ||
!snap?.isUp ||
(snap.attention.length === 0 && snap.elicitations.length === 0) ||
(await read($, dismissed)) === signature(snap)
) {
return next(e);
}
return <Band el={$.ui.resolve(e)} snap={snap} on={actions($)} />;
});plugin/hooks/view.tsx 843〜857 行 · バンド
export function Band({ el, snap, on }: ViewProps & { snap: AgentDiscoverSnapshot }) {
const { Box, Text, Button } = el;
const what = [
snap.attention.length > 0 && `needs a look: ${snap.attention.join(', ')}`,
snap.elicitations.length > 0 && `${snap.elicitations.length} question(s) waiting for you`,
].filter(Boolean);
return (
<Box columnGap={1} flexWrap="wrap">
<Text color="yellow">agent-discover: {what.join('; ')}</Text>
<Button key="open" label="Review" variant="primary" onPress={on.openFromBand} />
<Button key="dismiss" label="Dismiss" dimColor onPress={on.dismiss} />
</Box>
);
}ライセンスの全文(MIT)
MIT License Copyright (c) 2026 MuK IT GmbH Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
コードが呼ぶもの
通信環境変数
コードから読み取ったデザイン
読み取ったコミットのソースから描いたもので、動かした結果ではありません。一覧は 3 回描き、条件はデスクトップアプリで描く最初の分岐を取り、動かしたときにだけ決まる値は仮の例(点線の下線)にするか省きます。色と書体はこのサイトのものです。
コードから読めること
2026-10-06 に読んだコミット bec8b70ade10 のソースから。最初のまとまりが載せる条件で、残りは自分で判断するための材料です。後のコミットは、次に読むまで見ていません。
| 載せる条件: 確かめやすいコード | |
|---|---|
| 入口を読んだ | hooks/hooks.json が名指すモジュールをすべて読んだ。plugin/hooks/register.tsx |
| 解析できる | すべてのファイルが TypeScript か JavaScript として解析できる。2 ファイルを解析 |
| コードが Mod の中で完結 | import は Mod 自身のファイルかエンジンのモジュールだけ。パッケージも require もない。コードはすべて Mod の中 |
| 読める | 圧縮した行・eval・new Function・計算した道の import()・符号化した塊がない。圧縮・eval・符号化した塊なし |
| 呼び出しが見える | 通信とプログラム起動はその場で $.http.fetch・$.process.run と書き、他へ渡さない。外への呼び出しはすべてその場の $ で |
| 入れる前に自分で判断する材料 | |
| 描く場所 | コードから読んだ、描く先。ターミナル・デスクトップアプリ・両方・何も描かない(フックだけ: 見張りやプロンプトの書き換え)のどれか。出すだけで、外す理由にはしない。ターミナルとデスクトップアプリに同じように描く |
| 入れる手順 | リポジトリ自身の .claude-plugin/marketplace.json にこの Mod が載っていて、ページに書いた手順でそのマーケットプレイスから入れられるか。リポジトリの .claude-plugin/marketplace.json に載っており、そこから入れられる |
| Windows のプログラム | $.process で起動するプログラムが Windows にあるか(tail・date・open・osascript・/usr/… などは無い)。Windows にないプログラムを使わない |
| 通信 | fetch の送り先(https のホスト)がコードに書いてあるか。plugin/hooks/register.tsx:71 fetch(`${base}/api/token`); plugin/hooks/register.tsx:76 fetch(`${base}${path}`) |
| プログラム | 起動するプログラムの名前がコードに書いてあり、シェル・インタプリタ・通信用の道具でないか。プログラムを起動しない |
| 読んで送る | ファイルや環境変数を読み、かつ通信するか。読んだうえで通信する |
| ソースの鍵 | ソースに API キーや秘密鍵らしきものがあるか。ソースに鍵なし |
| ライセンス | オープンなライセンス(MIT・Apache-2.0・BSD・ISC・Unlicense・0BSD・CC0)で全文があれば、modscode にコードを載せる。違えばリンクだけ。MIT |
コードの文面を読んだだけで、安全の審査ではありません。動かしてはおらず、起動するプログラムの中で何が起きるかも見えません。入れる前の確認はあなたの役目です。 載せる条件
入れる
入れる前に、必ず自分で確かめてください。Mod はサンドボックスなしで、あなたの権限で動きます。modscode はこのコードの安全を保証しません。下のコードを読み(またはフォルダーで claude plugin validate .)、触るものを見て、読んだコミットを入れてください。
リポジトリがそのままマーケットプレイスです。このマーケットプレイスを足し(ターミナルでは次のコマンド、デスクトップアプリではプラグインの設定)、そこから Mod を入れます。
/plugin marketplace add keshrath/agent-discover/plugin install agent-discover@agent-discover入るのはマーケットプレイスの最新のコミットで、ここで読んだもの(bec8b70ade10)と違うことがあります。入れる前に見比べてください。
Claude に聞く
modscode のコネクタを入れると、Claude がこのデザイン・コードが触るもの・コードを読んで、それをもとに作れます。たとえば:
modscode のデザイン「keshrath-agent-discover」をコードごと読んで、同じようなペインを作って似たデザイン
-
Claude に頼む…clawdifybuild 3build 3build 3Presets layer on top of what you have. Reset first for a clean slate.Empty = Claude Code default · lists are comma-separated · tokens {model} {cwd} {time} {date}buildbuildbuildYours bring back exactly the look you saved. /clawdify delete <name> removes one.buildbuildbuildSave current as my-look savecopy JSONreset allWhile thinking
-
Claude に頼む…QuestList 1 Kanban 2Fleet f This repo l Refs g Refresh r Normal size z Collapse cOpen FilterokAll reposDoneClosedClose itList* marks a task whose refs disagree about its status; origin/dev is drawn where it has one. Resolving it is that reposit…New task in acme/app CreateClosed tracker change in acme/app not committed yet. Until they land, this repository's other checkouts cannot see the ids in them and can mint the same… Ask Claude to land them⋯
-
何をするか
- 欄・プロンプトの上の帯・ステータス行を描く
- /pet を足す
- ツールの呼び出しを見張る(止めることがある)
- prompt.submit・session.end・session.start・turn.complete ほか 2 個にフックする
-
Claude に頼む…2h 10m · █████░░░✓ build ✓ build ✓ buildJavaKotlin3 Python■ ok 3 ■ ok 3 ■ ok 3 Razor proven 3 Razor proven 3 Razor proven 3Phases ──────── 3/3build Pythonbuild Pythonbuild Python… 3 more phasesLua ──────── 3/Kotlin■ the whole upgrade Ruby■ build build Ruby■ build build Ruby■ build build Ruby … 3 moreNext ──────── PythonRuby (by hand)Podsclick a button, or ctrl+x tab then Tab, EnterAttention ──────── 3! Scala ! Scala ! Scala … 3 moreSession ──────── okJava
-
● pace Write · Park to1 park 12 dismiss 2pace: resume point 2h 10m · Fix login · 33 resume 34 discard 45 all 3 5pace: Park to resume point older than 7 days6 clear 6Claude に頼む…
-
Claude に頼む…────────Clear doneClaude⋯└─ buildCancelCancelCancel└─ buildCancelCancelCancel└─ buildCancelCancelCancel