mcp-server-example
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-server-exampleroll a dice"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-server-example
A minimal, well-commented MCP server that connects to the Connext platform.
It demonstrates everything you need to build your own MCP server that your users can connect to from Connext:
🔐 Its own login & OAuth — the server is its own OAuth 2.1 provider, with a simple username/password login page. A Connext user clicks "Connect", signs in to your server, and Connext receives an access token on their behalf.
🛠️ An example tool (
roll_dice) — an ordinary tool that returns text.🎨 An example MCP App (
greeting_card) — a tool that returns a small HTML UI which Connext renders inline in the chat.👤 Per-user identity — tools know which of your users is calling.
It is built on FastMCP, which handles the MCP protocol and the standard OAuth plumbing, so the only code you have to understand is the ~150 lines that are specific to your application: your users, your login page, and your tools.
How it works
When a user connects this server in Connext, this is the flow (all standard OAuth 2.1 — Connext drives it automatically):
Connext platform This MCP server
──────────────── ───────────────
1. discover ─────────────────────────▶ GET /.well-known/oauth-protected-resource/mcp
GET /.well-known/oauth-authorization-server
2. register (RFC 7591) ──────────────▶ POST /register ← no manual client setup
3. send user to log in ──────────────▶ GET /authorize
└▶ redirects the user's browser to:
4. user signs in ────────────────────▶ GET/POST /login ← YOUR login page
5. get a token ──────────────────────▶ POST /token
6. call tools (Authorization: Bearer)▶ POST /mcp ← your tools runYou only write step 4 (the login page) and step 6 (the tools). FastMCP gives you 1, 2, 3 and 5 for free.
Related MCP server: Hello World MCP Server
Quick start
Requires Python 3.11+.
# 1. install
python -m venv .venv && source .venv/bin/activate
pip install -e .
# 2. run the server
python server.py
# -> serving on http://localhost:8000 (MCP endpoint: http://localhost:8000/mcp/)
# 3. in another terminal, connect to it like a real client would
python examples/connect_with_client.py
# -> opens your browser to the login page; sign in as alice / password123Demo users live in auth.py:
username | password |
|
|
|
|
Connecting it to Connext
Expose the server on a public HTTPS URL. Connext must be able to reach your server's OAuth discovery endpoints, and for security it rejects private/loopback addresses for those endpoints. For a quick test, tunnel your local server:
# example with cloudflared / ngrok — any tunnel works ngrok http 8000Then run the server with
PUBLIC_URLset to the tunnel URL, because every OAuth endpoint it advertises is built fromPUBLIC_URL:PUBLIC_URL=https://your-tunnel.example.com python server.pyRegister it in Connext (Admin → MCP Servers → Add):
URL:
https://your-tunnel.example.com/mcpTransport:
HTTPAuth:
OAuthLeave client id/secret blank — this server supports Dynamic Client Registration, so Connext registers itself automatically.
To let the
greeting_cardMCP App render, enable Allow UI on the server.
Connect as a user. Each user clicks Connect, signs in on your login page, and Connext stores their token. Now the agent can call
roll_diceandgreeting_cardas that user.
The files
File | What it does |
| Entry point. Reads config, builds the FastMCP server, wires in auth + tools, runs it. |
| The OAuth provider. Subclasses FastMCP's in-memory provider and adds one thing: a real login page ( |
| The two example tools and the |
| A standalone client that runs the same OAuth flow Connext does — handy for testing. |
| Configuration ( |
What an MCP App is
An MCP App is just a tool whose result includes a ui:// resource carrying
HTML. Connext renders that HTML in a sandboxed iframe inside the chat. The two
pieces (see tools.py):
# 1. mark the tool as having a UI
@mcp.tool(meta={"ui": {"resourceUri": "ui://acme/greeting-card", ...}})
async def greeting_card(message: str) -> ToolResult:
return ToolResult(
content=[
TextContent(text="..."), # what the model reads
EmbeddedResource(resource=TextResourceContents( # what the user sees
uri="ui://acme/greeting-card",
mimeType="text/html;profile=mcp-app",
text="<!doctype html>...")),
],
structured_content={"username": ..., "message": ...},
)
# 2. also serve the template via resources/read
@mcp.resource("ui://acme/greeting-card", mime_type="text/html;profile=mcp-app", ...)
async def greeting_card_template() -> str:
return "<!doctype html>..."Keep the HTML self-contained (inline CSS, no external scripts) so it works under
the iframe's strict Content-Security-Policy. Use the var(--mcp-color-*) CSS
variables to match the host's light/dark theme.
Taking it to production
This example keeps everything in memory so it's easy to read. For a real server:
Users: replace the
DEMO_USERSdict inauth.pywith your real user database, and store hashed passwords (bcrypt/argon2) — or delegate to your existing SSO/identity provider.Tokens:
InMemoryOAuthProviderkeeps tokens in memory, so they are lost on restart (users would re-connect). For production, persist them or issue signed JWTs (fastmcp.server.auth.providers.jwt).HTTPS: terminate TLS in front of the server and set
PUBLIC_URLto thehttps://URL.Scopes: this example uses a single
readscope. Add scopes and enforce them per-tool via FastMCP'srequired_scopes/authoptions.
Verified flow
This example was tested end-to-end: dynamic client registration → login (wrong
password rejected, correct password accepted) → token exchange → authenticated
tools/list and tools/call → token refresh → rejection of unauthenticated
calls. Tools correctly see the signed-in user via get_access_token().subject.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/connextai/mcp-server-example'
If you have feedback or need assistance with the MCP directory API, please join our Discord server