Client

NAME

MCP::OAuth::Client - OAuth 2.1 client-side authorization handler

DESCRIPTION

Manages the client side of OAuth 2.1 authorization for MCP transports: metadata discovery, authorization code flow with PKCE, token exchange, refresh, and dynamic client registration.

CLASS

OAuthClientHandler

my $oauth = OAuthClientHandler.new(
        resource-url => 'https://mcp.example.com',
        client-id => 'my-app',
        redirect-uri => 'http://localhost:9999/callback',
    );

Key methods:

  • .discover-metadata(-- Promise)> — Fetch OAuth server metadata from well-known endpoint.

  • .authorization-url(-- Str)> — Build the authorization URL with PKCE challenge.

  • .exchange-code(Str $code -- Promise)> — Exchange authorization code for tokens.

  • .refresh-token(-- Promise)> — Refresh an expired access token.

  • .register-client(-- Promise)> — Perform dynamic client registration.

  • .access-token(-- Str)> — Get the current access token.

");
        @params.push("client_id={uri-encode($!client-id)}");
        @params.push("redirect_uri={uri-encode($!redirect-uri)}");
        @params.push("code_challenge={uri-encode($challenge)}");
        @params.push("code_challenge_method=S256");
        @params.push("resource={uri-encode($!resource-url)}");
        @params.push("state={uri-encode($state)}");
        @params.push("scope={uri-encode(@!scopes.join(' '))}") if @!scopes;

MCP v0.33.6

Model Context Protocol SDK for Raku - Build MCP servers and clients

Authors

  • Waclaw Kusnierczyk

License

MIT

Dependencies

JSON::FastCro::HTTPMIME::Base64

Provides

  • MCP
  • MCP::Client
  • MCP::JSONRPC
  • MCP::OAuth
  • MCP::OAuth::Client
  • MCP::OAuth::Server
  • MCP::Server
  • MCP::Server::Prompt
  • MCP::Server::Resource
  • MCP::Server::Tool
  • MCP::Transport::Base
  • MCP::Transport::SSE
  • MCP::Transport::Stdio
  • MCP::Transport::StreamableHTTP
  • MCP::Types

The Camelia image is copyright 2009 by Larry Wall. "Raku" is a trademark of the Yet Another Society. All rights reserved.

Built with Podlite — the markup and publishing tools behind this site.