MCP ExplorerExplorer

Fast Mcp Middleware

@lloydhamiltonon a month ago
1 MIT
FreeCommunity
AI Systems
FastMCP middleware for JWT-based user authentication using AWS Cognito.

Overview

What is Fast Mcp Middleware

fast_mcp_middleware is a simple authentication middleware for FastMCP that utilizes JWT tokens for user authentication, integrating with AWS Cognito as the identity provider.

Use cases

Use cases include securing APIs, managing user sessions in web applications, and enabling single sign-on (SSO) functionalities.

How to use

To use fast_mcp_middleware, set up an AWS Cognito user pool and client, create a .env file with the necessary credentials, and start the server by activating the virtual environment and running the server script.

Key features

Key features include JWT token-based authentication, integration with AWS Cognito for user management, and easy setup with environment variables.

Where to use

fast_mcp_middleware can be used in web applications and services that require secure user authentication and authorization, particularly in cloud-based environments.

Content

FastMCP Authentication Middleware

This is a simple authentication middleware for FastMCP that uses JWT tokens for user
authentication.

AWS Cognito is used as the identity provider, from which users authenticate and receive
a JWT token. The requested token is then passed in the Authorization header
of the request to the FastMCP server. The server then verifies the token using
the public key from AWS Cognito.

oauth_flow.drawio.png

Pre-requisites

You will need to create a Cognito user pool and a user pool client in AWS then set
the following environment variables:

Create a .env file in the root directory with the following variables:

USER_POOL_CLIENT_ID=<YOUR_USER_POOL_CLIENT_ID>
USER_POOL_CLIENT_SECRET=<YOUR_USER_POOL_CLIENT_SECRET>
COGNITO_USER_POOL_ID=<YOUR_USER_POOL_ID>

Starting the server

uv sync
source .venv/bin/activate

This will create a virtual environment and install all the required packages.

python src/mcp_services/auth_mcp/server.py

Testing the server

python src/test.py

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers