MCP Server + Asgardeo

by sagara-gunathunga

Not rated
GitHub

About

A sample MCP server that uses Asgardeo for client authentication and connection.

Details

Author
sagara-gunathunga
Categories
Developer Tools, Security, API

Setup

Install MCP Server + Asgardeo in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/sagara-gunathunga/cloudflare-mcp-asgardeo

Follow the installation instructions in the repository README, then restart your MCP client.

A sample MCP server that uses Asgardeo for client authentication and connection.

Model Context Protocol (MCP) Server + Asgardeo

This is a sampleModel Context Protocol (MCP)server that supports remote MCP clients to connect and authenticate usingAsgardeo.

Asgardeo authenticates users accessing the MCP server and allows you to control tool access based on application-level and organization-level permissions defined for each user.

The MCP server is powered byCloudflare Workers:

- Acts as OAuthServerto your MCP clients
- Acts as OAuth/OIDCClientto your Asgardeo organization

Before you start make sure you have the following prerequisites:

- Asgardeo account.
- Install
Node.jsversion 18.x or higher on your system.
- A
Cloudflareaccount for deployment

Then, select Traditional Web Application and complete the wizard popup by providing the following given name and the authorized redirect URL.(Ensure that the protocol remains set to OpenID Connect (OIDC).)

- Application Name: CloudflareMCPServer
- Authorized redirect URL:
http://localhost:8788/callback

Note-Thehttp://localhost:8788/callbackis only used during the local testing, the callback URL from Cloudflare deployment will be added at a later stage.

Make a note of the following values from theProtocolandInfotabs of the registered application.

- client-idfrom theProtocoltab.
- client-secretfrom theProtocoltab.
- YourAsgardeo organization name

Clone the repo directly & install dependencies using the following given instructions.

# Clone the repository git clone https://github.com/sagara-gunathunga/cloudflare-mcp-asgardeo # Move to the demo project directory cd demo-mcp-server ## Install dependencies npm install

Next, create a.dev.varsfile in your project root with the following values.

# .dev.vars ASGARDEO_CLIENT_ID=<client-id from the previous step> ASGARDEO_CLIENT_SECRET=<client-secret from the previous step> ASGARDEO_BASE_URL=https://api.asgardeo.io/t/<Asgardeo organization name> ASGARDEO_SCOPE=openid profile email roles

Run the server locally to make it available athttp://localhost:8788

To authenticate with Asgardeo, you must first have a user account created. If you haven’t done so already, follow thisguideto create a user in Asgardeo.

Next, start MCPInspectorlocally using the following command.

To test the local server, switch the Transport Type toSSEand enterhttp://localhost:8788/ssein the Inspector and hit connect. Once you follow the prompts, you’ll be able to authenticate with Asgardeo and use features such as “List Tools” in the Inspector. When you invoke the userInfo tool, you should see results similar to the example shown in the screenshot below.

Alternatively, you can test using theCloudflare Workers AI LLM Playground. Simply enterhttp://localhost:8787/sseas the MCP server URL and clickConnect. This will redirect you to the Asgardeo login page. Once you've completed the login process, you’ll be able to interact with the LLM in the Playground and use the tools defined in your MCP server.

For example, try asking the LLM:“Who am I?”

First, create a KV namespace in Cloudflare using the following command.

npx wrangler kv namespace create OAUTH_KV

Make sure to updatewrangler.jsoncfile with theidvalue received after running the above command.

"kv_namespaces": [ { "binding": "OAUTH_KV", "id": "<your-kv-id>" } ],

Then, set the following secrets via Wrangler by running the following commands.

You can use the values stored in.dev.varsfile with the above command.

Deploy the MCP server to make it available on your workers.dev domain.

Make a note of the newly createdCloudflare Worker URL, which is printed as output when you run the deployment command. You can also find this URL by logging into theCloudflare web console. The Worker URL typically follows this format:https://remote-mcp-asgardeo.<your-subdomain>.workers.dev

Next, you need toconfigure a callback URLusing the above Worker URL. The complete callback URL should take the following format.

https://remote-mcp-asgardeo.<your-subdomain>.workers.dev/callback

- Log in to theAsgardeo Console.
- Navigate to the application you created.
- Go to theProtocoltab.
- Add above value intoAuthorized redirect URLsso that Asgardeo can recognize it as a valid redirect URL.

The connection URL of the MCP server that we deployed into Cloudflare take the following format.

https://remote-mcp-asgardeo.<your-subdomain>.workers.dev/sse

To test the remote server, switch the Transport Type toSSEand enterhttps://remote-mcp-asgardeo.<your-subdomain>.workers.dev/ssein the Inspector and hit connect. Once you follow the prompts, you’ll be able to authenticate with Asgardeo and use features such as “List Tools” in the Inspector. When you invoke the userInfo tool.

Alternatively, you can test using theCloudflare Workers AI LLM Playground. Simply enterhttps://remote-mcp-asgardeo.<your-subdomain>.workers.dev/sseas the MCP server URL and clickConnect. This will redirect you to the Asgardeo login page. Once you've completed the login process, you’ll be able to interact with the LLM in the Playground and use the tools defined in your MCP server.

For example, try asking the LLM:“Who am I?”

To connect Cursor with your MCP server, chooseType: "Command" and in theCommandfield, combine the command and args fields into one (e.g.npx mcp-remote https://<your-worker-name>.<your-subdomain>.workers.dev/sse).

Note that while Cursor supports HTTP+SSE servers, it doesn't support authentication, so you still need to usemcp-remote(and to use a STDIO server, not an HTTP one).

You can connect your MCP server to other MCP clients like Windsurf by opening the client's configuration file, adding the same JSON that was used for the Claude setup, and restarting the MCP client.

This MCP server usesAsgardeofor both authentication and access control.

- Allauthenticated usershave access to theuserInfotool.
- Users with themanagerrolecan access thegetDirectReporteestool. For others, this tool will not be visible.

To support this role-based access scenario, Asgardeo returns user roles for authenticated users, allowing the MCP server to evaluate permissions accordingly.
- Create a new role calledmanagerin Asgardeo.
- Assign the role to a user by following
this guide.
- Ensure that user roles are configured to be returned as attributes in the ID token or user info endpoint by following the relevant configuration instructions
here.

Access the remote MCP server from Claude Desktop

Open Claude Desktop and navigate to Settings -> Developer -> Edit Config. This opens the configuration file that controls which MCP servers Claude can access.

Replace the content with the following configuration. Once you restart Claude Desktop, a browser window will open showing your OAuth login page. Complete the authentication flow to grant Claude access to your MCP server. After you grant access, the tools will become available for you to use.

{ "mcpServers": { "math": { "command": "npx", "args": [ "mcp-remote", "https://mcp-github-oauth.<your-subdomain>.workers.dev/sse" ] } } }

Once the Tools (under 🔨) show up in the interface, you can ask Claude to use them.

This is a web browser that enables your coding agent, such as Claude Code, to visit websites on your behalf and assist you in identifying bugs or creating UI test cases.

Enterprise-grade authentication with secure credential management, multi-protocol support, and real-time threat detection.

Hosted OAuth 2.1 + Dynamic Client Registration (RFC 7591) for MCP servers

An MCP server for Keycloak administration, offering over 30 tools to manage users, realms, clients, roles, and more from AI assistants.

An OAuth 2.1 proxy for MCP servers that enables single sign-on with Google, domain validation, and per-user tokens.

ZeroID Agent Identity is a paid hosted remote MCP for ZeroID. It exposes Streamable HTTP tool calls, bearer-token access, public server-card metadata, usage logs, and receipt-oriented JSON f

A read-only MCP server that allows LLMs to query live PingOne data. Requires a separate CData JDBC Driver for PingOne.

Interact with Descope's Management APIs to search and retrieve project information.

Administer Keycloak users and realms using a Model Context Protocol server.

A RESTful API to programmatically interact with the Opal Security platform.

Salesforce integration using OAuth2. Write operations disabled by default per integration. 700+ tools covering SOQL, SOSL, REST, and CRUD, individually selectable. Requires a DataGrout account.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.