remote-mcp

scampcat/remote-mcp

3.3

If you are the rightful owner of remote-mcp and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

A production-ready remote Model Context Protocol (MCP) server built with C# and ASP.NET Core, featuring comprehensive reflection tools for dynamic introspection and self-documentation.

Tools
16
Resources
0
Prompts
0

Remote MCP Server with Azure AD OAuth

A production-ready remote Model Context Protocol (MCP) server built with C# and ASP.NET Core, featuring OAuth 2.1 authentication with mandatory PKCE via Microsoft Azure AD and comprehensive MCP tools.

โœจ Key Features

  • ๐Ÿ” OAuth 2.1 Authentication: Full authorization server with Microsoft Azure AD integration and mandatory PKCE
  • ๐Ÿ”‘ Dynamic Client Registration: RFC 7591 compliant for MCP clients
  • ๐Ÿ–๏ธ WebAuthn Biometric Support: Face ID, Touch ID, and security key authentication
  • ๐ŸŒ Stateless Operation: Works with stateless MCP clients using memory cache
  • 16 Tools across 4 categories (Math, Utility, Data, Reflection)
  • ๐Ÿ” Self-Documenting with 5 powerful reflection tools
  • ๐ŸŒ Network Ready - accepts connections from any IP with proper security
  • โšก Production Grade - built with ASP.NET Core and enterprise patterns
  • ๐Ÿ”Œ Universal MCP Client Support - works with Claude Code, Cursor, VS Code
  • ๐Ÿ› ๏ธ Professional UI - Bootstrap-styled authentication and registration pages

๐Ÿ“‹ Tool Categories

Math Tools (4)

  • Add - Adds two numbers together
  • Subtract - Subtracts the second number from the first
  • Multiply - Multiplies two numbers together
  • Divide - Divides the first number by the second (with zero-division protection)

Utility Tools (3)

  • Echo - Echoes input messages back to the client
  • GetCurrentTime - Returns current server time in UTC
  • GenerateRandomNumber - Generates random numbers with configurable range

Data Tools (4)

  • FormatJson - Converts JSON strings to formatted, indented JSON
  • ToUpperCase - Converts text to uppercase
  • ToLowerCase - Converts text to lowercase
  • ReverseText - Reverses input text

Reflection Tools (5) โญ

  • ListAllTools - Complete inventory of all available tools with metadata
  • GetToolInfo - Detailed analysis of specific tools including parameters
  • ListToolsByCategory - Filter tools by category (Math, Utility, Data, Reflection)
  • SearchTools - Intelligent keyword search across tool names and descriptions
  • GetServerMetadata - Server introspection including .NET version and capabilities

๐Ÿš€ Quick Start

Prerequisites

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/remote-mcp.git
    cd remote-mcp
    
  2. Restore packages

    dotnet restore
    
  3. Build the project

    dotnet build
    
  4. Run the server

    dotnet run
    

    The server will start on http://0.0.0.0:3001 with enterprise authentication enabled.

๐Ÿ” Authentication Setup

Azure AD Configuration

Option 1: Automated Setup (Recommended)
# Sets up Azure AD app registration automatically
./setup-azure-ad.sh

# The script will:
# 1. Create/update Azure AD app registration
# 2. Configure redirect URIs
# 3. Update appsettings.json automatically
# 4. Optionally create a client secret (for confidential client mode)
Option 2: Manual Setup
  1. Register an Azure AD Application:

    • Go to Azure Portal > Azure Active Directory > App registrations
    • Create new registration
    • Add redirect URI: http://localhost:3001/oauth/callback
    • Optionally create a client secret for confidential client mode
  2. Configure Authentication: The application supports two authentication modes:

    Public Client with PKCE (Default - no secret needed):

    {
      "Authentication": {
        "ExternalIdP": {
          "ClientSecret": ""
        }
      }
    }
    

    Confidential Client (Recommended for production):

    # Set client secret via environment variable (never hardcode!)
    export Authentication__ExternalIdP__ClientSecret="your-secret-here"
    
    # Or use Azure Key Vault for production
    ./setup-azure-secrets.sh
    

For Testing (Disable Authentication)

Set Mode to "Disabled" in appsettings.json to bypass authentication

See for detailed enterprise configuration options.

OAuth Flow

The server implements a complete OAuth 2.1 authorization server with mandatory PKCE:

  1. Dynamic Client Registration: MCP clients register dynamically (RFC 7591)
  2. Microsoft Authentication: Users authenticate with their Microsoft account
  3. Token Issuance: Server issues its own JWT tokens after successful auth
  4. Stateless Operation: Uses memory cache for MCP clients that don't maintain cookies

๐ŸŒ OAuth Endpoints

Discovery

  • /.well-known/oauth-authorization-server - OAuth metadata
  • /.well-known/oauth-protected-resource - Resource metadata

OAuth Flow

  • /register - Dynamic client registration
  • /authorize - Authorization endpoint
  • /oauth/callback - Microsoft callback handler
  • /token - Token exchange endpoint

Testing the Server

Health Check:

curl http://localhost:3001/health
# Expected: {"status":"healthy","timestamp":"2025-XX-XX..."}

Server Info:

curl http://localhost:3001/info
# Returns server metadata and available endpoints

MCP Protocol Test:

curl http://localhost:3001/
# Expected: MCP protocol error (this confirms MCP is active)

๐Ÿ”— Claude Desktop/Claude.ai Integration

Using Claude Desktop

  1. Install Claude Desktop
  2. Use the /mcp command
  3. Enter server URL: http://localhost:3001
  4. Complete Microsoft authentication when prompted
  5. MCP tools are now available

Manual Configuration

Add to MCP settings:

Option 2: Manual Configuration

Add to your Claude Code MCP configuration:

{
  "mcpServers": {
    "remote-math-server": {
      "command": "npx",
      "args": ["mcp-remote", "http://localhost:3001/"],
      "description": "Remote MCP server with math, utility, data, and reflection tools"
    }
  }
}

Verification

claude mcp list
# Should show: remote-math-server: npx mcp-remote http://localhost:3001/ - โœ“ Connected

๐Ÿงช Testing Reflection Features

Try these commands in Claude Code:

Complete Tool Discovery:

"List all available tools"

Tool Analysis:

"Show me detailed information about the divide tool"

Category Filtering:

"What tools are in the Math category?"

Intelligent Search:

"Search for tools related to text processing"

System Information:

"What's the server metadata?"

๐Ÿ— Architecture

Core Components

  • Transport Layer: Streamable HTTP with CORS support
  • Tool Discovery: Attribute-based auto-registration using [McpServerToolType] and [McpServerTool]
  • Reflection System: .NET reflection APIs for runtime introspection
  • Error Handling: Comprehensive validation and graceful error responses
  • Security: Scoped assembly reflection with attribute-based filtering

Key Patterns

Tool Implementation:

[McpServerToolType]
public static class YourTools
{
    [McpServerTool, Description("What your tool does")]
    public static ReturnType YourMethod(
        [Description("Parameter description")] ParameterType param)
    {
        // Implementation with proper error handling
        return result;
    }
}

Reflection Safety:

// โœ… Safe: Scoped to current assembly only
Assembly.GetExecutingAssembly()

// โœ… Safe: Attribute-based filtering  
.Where(t => t.GetCustomAttribute<McpServerToolTypeAttribute>() != null)

// โœ… Safe: JSON-serializable responses
return new { found = true, data = structuredObject };

๐Ÿš€ Production Deployment

Network Configuration

The server binds to 0.0.0.0:3001 for network access. Configure your firewall to allow port 3001:

# macOS/Linux - allow port 3001
sudo ufw allow 3001

# Find your server's IP for remote connections
hostname -I

Docker Deployment

FROM mcr.microsoft.com/dotnet/aspnet:9.0
WORKDIR /app
COPY bin/Release/net9.0/publish/ .
EXPOSE 3001
ENTRYPOINT ["dotnet", "remote-mcp.dll"]

Environment Variables

# Production settings
export ASPNETCORE_ENVIRONMENT=Production
export ASPNETCORE_URLS=http://0.0.0.0:3001

๐Ÿ”ง Development

Project Structure

remote-mcp/
โ”œโ”€โ”€ Program.cs              # Server configuration and startup
โ”œโ”€โ”€ Authentication/         # Enterprise authentication system
โ”‚   โ”œโ”€โ”€ Controllers/       # Auth API endpoints
โ”‚   โ”œโ”€โ”€ Domain/            # DDD domain entities and services
โ”‚   โ”œโ”€โ”€ Middleware/        # Auth middleware (OAuth 2.1, rate limiting)
โ”‚   โ”œโ”€โ”€ OAuth/             # OAuth implementation
โ”‚   โ”œโ”€โ”€ Services/          # Auth services (token, multi-tenant, etc.)
โ”‚   โ””โ”€โ”€ WebAuthn/          # WebAuthn/Passkey support
โ”œโ”€โ”€ Configuration/          # App configuration and settings
โ”œโ”€โ”€ Data/                   # Data access layer
โ”œโ”€โ”€ Services/               # Core services (MCP lifecycle, etc.)
โ”œโ”€โ”€ Tools/                  # SOLID-compliant MCP tools
โ”‚   โ”œโ”€โ”€ MathTools.cs       # Math operations (Add, Subtract, Multiply, Divide)
โ”‚   โ”œโ”€โ”€ UtilityTools.cs    # Utility functions (Echo, Time, Random)
โ”‚   โ”œโ”€โ”€ DataTools.cs       # Data manipulation (JSON, Case, Reverse)
โ”‚   โ”œโ”€โ”€ ReflectionTools.cs # Introspection (5 reflection capabilities)
โ”‚   โ””โ”€โ”€ AuthenticationTools.cs # OAuth flow testing tools
โ”œโ”€โ”€ Properties/             # Launch settings and profiles
โ”œโ”€โ”€ documentation/          # Additional docs and guides
โ”œโ”€โ”€ remote-mcp.csproj       # Project configuration
โ”œโ”€โ”€ appsettings.json        # Server configuration
โ”œโ”€โ”€ setup-azure-ad.sh       # Azure AD setup script
โ”œโ”€โ”€ setup-azure-secrets.sh  # Secret management script
โ”œโ”€โ”€ implode.sh             # Cleanup script
โ”œโ”€โ”€ .mcp.json              # MCP client integration
โ”œโ”€โ”€ CLAUDE.md              # Development guide
โ”œโ”€โ”€ LICENSE                # MIT License
โ””โ”€โ”€ README.md              # This file

SOLID Principles Compliance

  • Single Responsibility: Each tool class has one focused purpose
  • Open/Closed: Add new tool categories without modifying existing code
  • Clean Separation: Server configuration separate from business logic
  • Maintainable: Easy to locate, test, and extend specific tool categories

Adding New Tools

  1. Create a new tool file in the Tools/ directory:
// Tools/MyCustomTools.cs
using ModelContextProtocol.Server;
using System.ComponentModel;

[McpServerToolType]
public static class MyCustomTools
{
    [McpServerTool, Description("Description of what your tool does")]
    public static string MyTool([Description("Parameter description")] string input)
    {
        // Your logic here
        return $"Processed: {input}";
    }
}
  1. Automatic Discovery: The tool will be automatically discovered via assembly scanning
  2. Verification: Use the reflection tools (ListAllTools()) to verify registration
  3. Organization: Follow the established patterns in existing tool files

Debugging

  • Health endpoint: http://localhost:3001/health
  • Server info: http://localhost:3001/info
  • MCP Inspector: npx @modelcontextprotocol/inspector@latest http://localhost:3001/
  • Reflection tools: Use ListAllTools() to verify your tools are registered

๐Ÿ“– Documentation

  • - Development commands and architecture
  • - Configuration, deployment, and customization guide
  • - Step-by-step implementation guide

๐Ÿ”’ Security Considerations

Safe Practices โœ…

  • Scoped reflection to executing assembly only
  • Attribute-based filtering prevents unintended exposure
  • No dynamic code execution
  • Comprehensive input validation
  • CORS configured for development (restrict for production)

Production Security

  • Add authentication middleware
  • Implement rate limiting
  • Use HTTPS in production
  • Restrict CORS origins
  • Configure firewall rules
  • Monitor for abuse

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Guidelines

  • Follow the established MCP architectural patterns
  • Add comprehensive descriptions to all tools
  • Include proper error handling
  • Update documentation for new features
  • Test with reflection tools to verify integration

๐Ÿ“„ License

This project is licensed under the MIT License - see the file for details.

๐Ÿ™ Acknowledgments

๐Ÿ“Š Stats

  • 16 Tools across 4 categories
  • 5 Reflection Tools for self-documentation
  • Production Ready with ASP.NET Core
  • Network Enabled for distributed access
  • Comprehensive Testing with health checks and MCP Inspector support