Skip to content

authentification gateway + profiles issue #119

@nmaisonneuve

Description

@nmaisonneuve

Hi again @seuros :)

I'm trying to connect to an MCP server via a JWT token with user-based profile switching (admin or basic user) using the MCP Inspector 0.15 development tool.

Current Issues:

  1. Without JWT: Can connect (but shouldn't be able to)
  2. With JWT (admin user): Can connect but capabilities list is empty (should show admin profile with all tools)

Code Implementation

Gateway Authentication Method

def authenticate!
  # Example using JWT:
  token = extract_bearer_token
  raise ActionMCP::UnauthorizedError, "Missing token" unless token
  payload = ActionMCP::JwtDecoder.decode(token)
  user = resolve_user(payload)
  raise ActionMCP::UnauthorizedError, "Unauthorized" unless user
  
  if user.admin?
    ActionMCP.configuration.use_profile(:admin)
  else
    ActionMCP.configuration.use_profile(:none)
  end
  
  # Return a hash with all identified_by attributes
  { user: user }
rescue ActionMCP::JwtDecoder::DecodeError => e
  raise ActionMCP::UnauthorizedError, e.message
end

MCP Configuration (mcp.yml)

shared:
  # MCP capability profiles
  profiles:
    # admin profile
    admin:
      tools:
        - all
      prompts:
        - all
      resources:
        - all
      options:
        list_changed: false
        logging_enabled: true
        resources_subscribe: false
    # basic user
    none:
      tools: []
      prompts: []
      resources: []
      options:
        list_changed: false
        logging_enabled: true
        logging_level: info
        resources_subscribe: false

# Development environment
development:
  authentication: ['jwt']
  adapter: solid_mcp
  polling_interval: 0.1
  batch_size: 100
  flush_interval: 0.05
  session_store_type: volatile

# Production environment
production:
  authentication: ['jwt']
  adapter: solid_mcp
  polling_interval: 0.5.seconds
  batch_size: 200 # Number of messages to write in a single batch
  flush_interval: 0.05 # Seconds between batch flushes
  session_store_type: active_record
  min_threads: 10 # Minimum number of threads in the pool
  max_threads: 20 # Maximum number of threads in the pool
  max_queue: 500 # Maximum number of tasks that can be queued

Expected Behavior

  • Without JWT: Connection should be rejected
  • With valid JWT (admin): Connection should succeed with admin profile capabilities visible

Need Help

Looking for assistance to resolve why:

  1. Authentication isn't properly blocking unauthenticated connections
  2. Profile switching isn't reflecting the correct capabilities in the MCP Inspector

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions