Admin tools for Claude: an MCP server, connected with an admin's approval
CI / build (push) Skipped
CI / deploy (push) Skipped
CI / test (push) Successful in 4m27s

- 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:
feco
2026-11-27 17:09:14 +00:00
co-authored by Claude Opus 5.5
parent 08ad7b0a79
commit 2c63384606
40 changed files with 3695 additions and 49 deletions
+25 -1
View File
@@ -117,8 +117,23 @@ pub struct Config {
/// `S3_CREATE_BUCKET` (default false): create the bucket at startup if it
/// is missing (development; in production it is made in the console).
pub storage_create_bucket: bool,
/// `OAUTH_REDIRECT_URIS`: comma-separated return addresses an MCP client
/// may register (docs/mcp.md); a trailing `*` stands for any port (and
/// path). Default: Claude's callbacks and local ones for Claude Code.
pub oauth_redirect_uris: Vec<String>,
/// `MCP_RESOURCE_URL`: the MCP server's address, the audience of the
/// tokens (default `PUBLIC_BASE_URL` + `/mcp`).
pub mcp_resource_url: String,
}
/// The default `OAUTH_REDIRECT_URIS`.
pub const DEFAULT_OAUTH_REDIRECT_URIS: [&str; 4] = [
"https://claude.ai/api/mcp/auth_callback",
"https://claude.com/api/mcp/auth_callback",
"http://localhost:*",
"http://127.0.0.1:*",
];
/// `STRIPE_SECRET_KEY` (`sk_test_…` or `sk_live_…`), `STRIPE_WEBHOOK_SECRET`
/// (`whsec_…`, from the webhook endpoint in the Stripe dashboard) and
/// `STRIPE_API_URL` (default `https://api.stripe.com`, tests change it).
@@ -182,7 +197,6 @@ impl Config {
let config = Self {
database_url: var("DATABASE_URL").context("DATABASE_URL is required")?,
horoscope_api_url: var("HOROSCOPE_API_URL").unwrap_or_else(|| "http://localhost:8080".into()),
public_base_url,
cors_allowed_origins,
cookie_secure: parsed("COOKIE_SECURE", true)?,
cookie_domain: var("COOKIE_DOMAIN"),
@@ -250,6 +264,14 @@ impl Config {
}),
},
storage_create_bucket: parsed("S3_CREATE_BUCKET", false)?,
oauth_redirect_uris: match list("OAUTH_REDIRECT_URIS") {
uris if uris.is_empty() => DEFAULT_OAUTH_REDIRECT_URIS.map(String::from).to_vec(),
uris => uris,
},
mcp_resource_url: var("MCP_RESOURCE_URL")
.map(|u| u.trim_end_matches('/').to_string())
.unwrap_or_else(|| format!("{public_base_url}/mcp")),
public_base_url,
};
if config.session_ttl_days < 1 {
bail!("SESSION_TTL_DAYS must be at least 1");
@@ -300,6 +322,8 @@ impl Config {
secret_key: "test-secret".into(),
}),
storage_create_bucket: false,
oauth_redirect_uris: DEFAULT_OAUTH_REDIRECT_URIS.map(String::from).to_vec(),
mcp_resource_url: "https://sorsfonalak.test/mcp".into(),
}
}
}