import { createRoot } from "react-dom/client";
import { ThemeProvider } from "@cloudflare/agents-ui/hooks";
import { ModeToggle, PoweredByAgents } from "@cloudflare/agents-ui";
import { Badge, Surface, Text } from "@cloudflare/kumo";
import {
ShieldCheckIcon,
WrenchIcon,
GlobeIcon,
TerminalIcon,
InfoIcon
} from "@phosphor-icons/react";
import "./styles.css";
const TOOLS = [
{
name: "hello",
description:
"Returns a greeting — uses the authenticated username if no name is provided"
},
{
name: "whoami",
description:
"Returns the authenticated user's profile (userId, username, email)"
}
];
const ENDPOINTS = [
{
path: "/mcp",
description: "MCP server endpoint (requires Bearer token)"
},
{
path: "/.well-known/oauth-authorization-server",
description: "OAuth server metadata (discovery)"
},
{
path: "/oauth/register",
description: "Dynamic client registration"
},
{ path: "/authorize", description: "OAuth authorization" },
{ path: "/oauth/token", description: "Token exchange" }
];
function App() {
return (
Authenticated MCP Server
This MCP server is protected by OAuth 2.1 using{" "}
@cloudflare/workers-oauth-provider
. Clients register dynamically, complete the authorization
flow, and use a Bearer token to call tools. Inside tool
handlers, the auth context is available via{" "}
getMcpAuthContext()
. Use the MCP Inspector to test the full OAuth flow.
Tools
{TOOLS.length}
{TOOLS.map((tool) => (
{tool.name}
{tool.description}
))}
Endpoints
{ENDPOINTS.map((ep) => (
{ep.path}
{ep.description}
))}
Testing
Connect using the{" "}
MCP Inspector
:
npx @modelcontextprotocol/inspector
Set the transport to Streamable HTTP and URL to{" "}
http://localhost:5173/mcp
. The inspector will handle the OAuth flow automatically.
);
}
createRoot(document.getElementById("root")!).render(
);