Admin tools for Claude: an MCP server, connected with an admin's approval
- services/mcp: the MCP server at /mcp (Streamable HTTP, stateless): the admin's reading tools, the daily tasks and the forum's moderation; every tool calls the site's API with the caller's token, and members' e-mail addresses and names are masked in the answers. - Backend: OAuth 2.1 for MCP clients (registration with Claude's or a local return address only, PKCE, rotating refresh tokens, revocation); the admin guards accept the token for reading and the writes in MCP_WRITES only. - Forum: an admin's token reaches the moderator endpoints only. - Frontend: the approval page (/oauth/engedely), Admin → Claude to revoke a connection, the authorization server's metadata at its standard address. - Deploy: the mcp service in compose, Caddy, CI; the worker removes old codes, tokens and clients. docs/mcp.md. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
"use client";
|
||||
|
||||
import { useState } from "react";
|
||||
|
||||
import { api, errorText } from "@/lib/api";
|
||||
|
||||
export type OauthParams = Partial<
|
||||
Record<
|
||||
| "response_type"
|
||||
| "client_id"
|
||||
| "redirect_uri"
|
||||
| "code_challenge"
|
||||
| "code_challenge_method"
|
||||
| "scope"
|
||||
| "state"
|
||||
| "resource",
|
||||
string
|
||||
>
|
||||
>;
|
||||
|
||||
/** The admin's answer: the backend gives the address back to the client (with a code, or a refusal). */
|
||||
export function Approve({ params }: { params: OauthParams }) {
|
||||
const [busy, setBusy] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
async function answer(deny: boolean) {
|
||||
setBusy(true);
|
||||
setError(null);
|
||||
try {
|
||||
const r = await api<{ redirect_to: string }>("/oauth/authorize", { body: { ...params, deny } });
|
||||
window.location.assign(r.redirect_to);
|
||||
} catch (e) {
|
||||
setError(errorText(e));
|
||||
setBusy(false);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="oauth-actions">
|
||||
<button type="button" className="btn btn-primary" disabled={busy} onClick={() => answer(false)}>
|
||||
Engedélyezem
|
||||
</button>
|
||||
<button type="button" className="btn" disabled={busy} onClick={() => answer(true)}>
|
||||
Mégse
|
||||
</button>
|
||||
{error && (
|
||||
<p className="msg msg-error" role="alert">
|
||||
{error}
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user