Authentication and Authorization Proxy for MCP Servers
Find a file
Thilina Shashimal Senarath 06f0aeb461 add --asgardeo
2025-04-02 22:37:01 +05:30
cmd/proxy add --asgardeo 2025-04-02 22:37:01 +05:30
internal add --asgardeo 2025-04-02 22:37:01 +05:30
.gitignore improve readme 2025-04-02 18:22:36 +05:30
config.yaml add --asgardeo 2025-04-02 22:37:01 +05:30
go.mod improve readme 2025-04-02 18:22:36 +05:30
issue_template.md Add Issue Template 2025-04-02 10:47:50 +05:30
LICENSE Initial commit 2025-04-02 10:45:59 +05:30
pull_request_template.md Add Pull Request Template 2025-04-02 10:47:51 +05:30
README.md Update README.md 2025-04-02 18:35:17 +05:30

open-mcp-auth-proxy

Overview

OpenMCPAuthProxy is a security middleware that implements the Model Context Protocol (MCP) Authorization Specification (2025-03-26). It functions as a proxy between clients and MCP servers, providing robust authentication and authorization capabilities. The proxy intercepts incoming requests, validates authentication tokens, and forwards only authorized requests to the underlying MCP server, enhancing the security posture of your MCP deployment.

Setup and Installation

Prerequisites

  • Go 1.20 or higher
  • A running MCP server (SSE transport supported)

Installation

git clone https://github.com/wso2/open-mcp-auth-proxy
cd open-mcp-auth-proxy
go build -o openmcpauthproxy ./cmd/proxy

Configuration

Create a configuration file config.yaml with the following parameters:

mcp_server_base_url: "http://localhost:8000"  # URL of your MCP server
listen_address: ":8080"                       # Address where the proxy will listen

Usage Example

1. Start the MCP Server

Create a file named echo_server.py:

from mcp.server.fastmcp import FastMCP

mcp = FastMCP("Echo")


@mcp.resource("echo://{message}")
def echo_resource(message: str) -> str:
    """Echo a message as a resource"""
    return f"Resource echo: {message}"


@mcp.tool()
def echo_tool(message: str) -> str:
    """Echo a message as a tool"""
    return f"Tool echo: {message}"


@mcp.prompt()
def echo_prompt(message: str) -> str:
    """Create an echo prompt"""
    return f"Please process this message: {message}"

if __name__ == "__main__":
    mcp.run(transport="sse")

Run the server:

python3 echo_server.py

2. Start the Auth Proxy

./openmcpauthproxy --demo

The --demo flag enables a demonstration mode with pre-configured authentication with Asgardeo.

3. Connect Using an MCP Client

You can use the MCP Inspector to test the connection:

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.