Skip to content

Commit ddc63a9

Browse files
committed
P0: ethora-doctor fix suggestions
1 parent d8ce702 commit ddc63a9

1 file changed

Lines changed: 57 additions & 2 deletions

File tree

src/tools.ts

Lines changed: 57 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,63 @@ function doctorTool(server: McpServer) {
116116
hasAppToken: Boolean(state.hasAppToken),
117117
hasUserToken: Boolean(state.hasUserToken),
118118
}
119-
const pingRes = await apiPing(timeoutMs || 3000)
120-
return asToolResult(ok({ state, checks, ping: { status: pingRes.status, data: pingRes.data } }, meta))
119+
const suggestions: Array<{ severity: "info" | "warn"; message: string; action: string }> = []
120+
121+
if (!checks.hasApiUrl) {
122+
suggestions.push({
123+
severity: "warn",
124+
message: "ETHORA API URL is not configured.",
125+
action: "Set env ETHORA_API_URL (or ETHORA_BASE_URL) or call `ethora-configure` with apiUrl.",
126+
})
127+
}
128+
129+
// Login/register endpoints require appJwt.
130+
if (!checks.hasAppJwt) {
131+
suggestions.push({
132+
severity: "info",
133+
message: "App JWT is missing (needed for ethora-user-login / ethora-user-register).",
134+
action: "Set env ETHORA_APP_JWT (or ETHORA_APP_TOKEN) or call `ethora-configure` with appJwt.",
135+
})
136+
}
137+
138+
if (state.authMode === "app" && !checks.hasAppToken) {
139+
suggestions.push({
140+
severity: "warn",
141+
message: "Auth mode is app-token but appToken is not configured.",
142+
action: "Call `ethora-app-select` with { appId, appToken } or switch to user auth via `ethora-auth-use-user`.",
143+
})
144+
}
145+
146+
if (state.authMode === "user" && !checks.hasUserToken) {
147+
suggestions.push({
148+
severity: "info",
149+
message: "Auth mode is user-session but no user token is present.",
150+
action: "Call `ethora-user-login` or switch to app-token auth via `ethora-auth-use-app`.",
151+
})
152+
}
153+
154+
if (!state.currentAppId) {
155+
suggestions.push({
156+
severity: "info",
157+
message: "No current app is selected.",
158+
action: "Call `ethora-app-select` to set appId (and optionally appToken).",
159+
})
160+
}
161+
162+
let ping: any = null
163+
try {
164+
const pingRes = await apiPing(timeoutMs || 3000)
165+
ping = { ok: true, status: pingRes.status, data: pingRes.data }
166+
} catch (pingErr) {
167+
ping = { ok: false, ...fail(pingErr).error }
168+
suggestions.push({
169+
severity: "warn",
170+
message: "API connectivity check failed (ping).",
171+
action: "Verify ETHORA_API_URL points to a reachable Ethora API and that /v1/ping is exposed. Then rerun `ethora-doctor`.",
172+
})
173+
}
174+
175+
return asToolResult(ok({ state, checks, ping, suggestions }, meta))
121176
} catch (error) {
122177
return asToolResult(fail(error, meta))
123178
}

0 commit comments

Comments
 (0)