Add MCP server with OAuth 2.1 authentication#323
Merged
239573049 merged 1 commit intoAIDotNet:mainfrom Feb 21, 2026
Merged
Conversation
Implements a Model Context Protocol (MCP) server that exposes DeepWiki repository documentation to MCP-compatible clients like Claude.ai. ## MCP Tools - ListRepositories: Browse accessible repositories - GetDocumentCatalog: Get table of contents for a repo - ReadDocument: Read documentation content (paginated) - SearchDocuments: Full-text search across repo docs ## OAuth 2.1 Authorization Server - Wraps Google OAuth for MCP client authentication - Issues internal JWTs after Google authentication - Implements RFC 8414 (Authorization Server Metadata) - Implements RFC 9728 (Protected Resource Metadata) - PKCE (S256) required for all authorization requests ## Access Control - Department-based: users see repos in their departments - Public repos visible to their owners - User resolution from both Google tokens and internal JWTs ## Infrastructure - SSE keep-alive middleware prevents client disconnections - Frontend proxy routes for /.well-known/* and /oauth/* - MCP registration conditional on GOOGLE_CLIENT_ID/SECRET env vars - Auto-closing browser tab after authentication
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a Model Context Protocol (MCP) server that exposes DeepWiki repository documentation to MCP-compatible clients like Claude.ai.
MCP Tools
OAuth 2.1 Authorization Server
/.well-known/oauth-authorization-server/.well-known/oauth-protected-resourceclaude.ai,claude.com,www.claude.aiAccess Control
Infrastructure
/.well-known/*and/oauth/*(bridges browser requests to backend)GOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRETenv vars being set - the application starts normally without MCP when these aren't configuredConfiguration
Required environment variables (only when MCP is desired):
GOOGLE_CLIENT_ID- Google OAuth client IDGOOGLE_CLIENT_SECRET- Google OAuth client secretMCP endpoint:
/api/mcp(requires OAuth authentication)Files Changed
src/OpenDeepWiki/MCP/- All MCP server code (OAuth, tools, user resolver, SSE middleware)src/OpenDeepWiki/Program.cs- Service and endpoint registration (conditional)web/app/.well-known/[...path]/route.ts- Frontend proxy for OAuth metadataweb/app/oauth/[...path]/route.ts- Frontend proxy for OAuth flowDirectory.Packages.props- MCP SDK dependencysrc/OpenDeepWiki/OpenDeepWiki.csproj- MCP package reference