ory-mcp-oauth-provider

ory-mcp-oauth-provider is a TypeScript library that provides authentication and authorization based on the OAuth 2.0 protocol. This library emphasizes security and features a simple, extensible design. Developers can easily implement an OAuth provider and securely manage user credentials.

GitHub Stars

0

User Rating

Not Rated

Favorites

0

Views

17

Forks

0

Issues

0

README
Ory MCP OAuth Provider

A TypeScript implementation of an OAuth provider for Ory MCP that supports both Ory Network and Ory Hydra as backend providers.

Installation
npm install ory-mcp-oauth-provider
Usage
Basic Setup
import { OryProvider, OryOptions } from 'ory-mcp-oauth-provider';

// Initialize with Ory Network
const networkProvider = new OryProvider({
  providerType: 'network',
  networkProjectUrl: 'https://your-project.projects.oryapis.com',
  networkProjectApiKey: 'your-api-key',
  endpoints: {
    authorizationUrl: 'https://your-project.projects.oryapis.com/oauth2/auth',
    tokenUrl: 'https://your-project.projects.oryapis.com/oauth2/token',
    revocationUrl: 'https://your-project.projects.oryapis.com/oauth2/revoke',
    registrationUrl: 'https://your-project.projects.oryapis.com/admin/clients',
  },
});

// Or initialize with Ory Hydra
const hydraProvider = new OryProvider({
  providerType: 'hydra',
  hydraAdminUrl: 'https://hydra.example.com/admin',
  hydraApiKey: 'your-hydra-api-key',
  endpoints: {
    authorizationUrl: 'https://hydra.example.com/oauth2/auth',
    tokenUrl: 'https://hydra.example.com/oauth2/token',
    revocationUrl: 'https://hydra.example.com/oauth2/revoke',
    registrationUrl: 'https://hydra.example.com/admin/clients',
  },
});
MCP Server Integration

Here's how to use the provider with an MCP server:

import { OryProvider } from 'ory-mcp-oauth-provider';
import { MCPServer } from '@modelcontextprotocol/sdk/server';

// Initialize the Ory provider
const oryProvider = new OryProvider({
  providerType: 'network',
  networkProjectUrl: 'https://your-project.projects.oryapis.com',
  networkProjectApiKey: 'your-api-key',
  endpoints: {
    authorizationUrl: 'https://your-project.projects.oryapis.com/oauth2/auth',
    tokenUrl: 'https://your-project.projects.oryapis.com/oauth2/token',
    revocationUrl: 'https://your-project.projects.oryapis.com/oauth2/revoke',
    registrationUrl: 'https://your-project.projects.oryapis.com/admin/clients',
  },
});

// Create MCP server with the Ory provider
const server = new MCPServer({
  auth: {
    provider: oryProvider,
  },
});

// Start the server
server.listen(3000);
Key Features
  • Supports both Ory Network and Ory Hydra as backend providers
  • Handles OAuth2 authorization code flow with PKCE
  • Manages client registration and token operations
  • Provides token introspection and verification
  • Integrates seamlessly with MCP server
Development
  1. Clone the repository
  2. Install dependencies:
    npm install
    
  3. Build the project:
    npm run build
    
  4. Run tests:
    npm test
    
License

Copyright 2025 Ory Corp

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.