Skip to main content

MCP server card

An MCP server as a card: its address, the scopes it asks for, and whether this client is connected.

PatternReadyView source
Works with
Reactshadcn/ui
Standards
RFC 9728
Runs on sample data, with the neutral theme of shadcn/ui.

For a product that lets its users connect MCP servers. The card reads the protected resource metadata of the server: its address, the authorization server that it trusts, and its scopes.

Installation​

The command adds the file to your project, with the shadcn/ui components that it uses. Your project needs shadcn/ui.

pnpm dlx shadcn@latest add https://examples.lumoauth.dev/r/mcp-server-card.json

Usage​

fromProtectedResourceMetadata maps the metadata document of the server. Your MCP client owns the connection state.

app/settings/mcp-server.tsx
'use client';

import { McpServerCard, fromProtectedResourceMetadata, type McpConnectionState } from '@/components/mcp-server-card';

export function Server({ metadata, state, granted, missing, connect, disconnect }: {
metadata: Record<string, unknown>; // the document at /.well-known/oauth-protected-resource
state: McpConnectionState;
granted: string[];
missing: string[]; // from an insufficient_scope challenge
connect: () => void; // starts the authorization flow of your MCP client
disconnect: () => void;
}) {
return (
<McpServerCard
server={fromProtectedResourceMetadata(metadata)}
state={state}
grantedScopes={granted}
missingScopes={missing}
onConnect={connect}
onDisconnect={disconnect}
/>
);
}

When a tool call answers 403 insufficient_scope, set the state to needs_scope and pass the scopes of the challenge as missingScopes. "Give access" then starts the flow again for those scopes only.

Where the data comes from​

What the pattern showsCall
Address, authorization server and scopesThe document at /.well-known/oauth-protected-resource of the MCP server (RFC 9728)
Where to find that documentThe resource_metadata address in the WWW-Authenticate header of a 401 answer
The servers of your own organizationGET /mcp/servers
More scopeThe scope of an insufficient_scope challenge

States​

Runs on sample data, with the neutral theme of shadcn/ui.
  • More access needed. The missing scope is marked, and the card says what the tool needs.
  • Connecting, for a server that accepts only tokens that are bound to a key.

Props​

PropTypeDescription
serverrequiredMcpServerDataThe server: name, resource, authorizationServers, scopes and dpopRequired.
staterequired'disconnected' | 'connecting' | 'connected' | 'needs_scope'The state of the connection.
grantedScopesstring[]The scopes that this client holds now.
missingScopesstring[]The scopes that the server asked for with an insufficient_scope challenge.
onConnect() => voidStart the authorization flow.
onDisconnect() => voidDrop the connection.
classNamestringClass name for the card.