Implements a Model Context Protocol server using Server-Sent Events for real-time communication with OAuth 2.1 integration via Ory Network, enabling secure AI model communication with authentication and client management.
This project implements a Model Context Protocol (MCP) server that uses Server-Sent Events (SSE) for communication and integrates with Ory Network for OAuth 2.1 functionality.
The server provides:
Create a .env
file with the following variables (see .example.env
for reference):
# Ory Network Configuration ORY_BASE_API_URL=https://api.console.ory.sh ORY_PROJECT_URL=https://yourprojectslug.projects.oryapis.com ORY_PROJECT_API_KEY=yourprojectapikey ORY_WORKSPACE_API_KEY=yourworkspaceapikey # Server Configuration MCP_SERVER_BASE_URL=http://localhost:4000 MCP_SERVER_DOCS_URL=https://ory.sh/docs MCP_SERVER_PORT=4000
npm install
Run the development server:
npm run dev
Build the TypeScript project:
npm run build
Start the production server:
npm run start
GET /mcp
- Establishes SSE connection for MCP communicationPOST /messages
- Handles MCP messages from clients/oauth2/auth
- Authorization endpoint/oauth2/token
- Token endpoint/oauth2/revoke
- Token revocation endpoint/oauth2/register
- Client registration endpointThe server implements graceful shutdown and proper error handling for:
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.
Discover shared experiences
Shared threads will appear here, showcasing real-world applications and insights from the community. Check back soon for updates!