Skip to content

Comments

Add MCP server with OAuth 2.1 authentication#323

Merged
239573049 merged 1 commit intoAIDotNet:mainfrom
keboola:feature/mcp-server-upstream
Feb 21, 2026
Merged

Add MCP server with OAuth 2.1 authentication#323
239573049 merged 1 commit intoAIDotNet:mainfrom
keboola:feature/mcp-server-upstream

Conversation

@manana2520
Copy link
Contributor

Summary

Adds a Model Context Protocol (MCP) server that exposes DeepWiki repository documentation to MCP-compatible clients like Claude.ai.

MCP Tools

  • ListRepositories - Browse accessible repositories with owner, name, and status
  • GetDocumentCatalog - Get the table of contents for a repository
  • ReadDocument - Read documentation content with pagination (max 200 lines per request)
  • SearchDocuments - Full-text search across repository documentation (top 10 results)

OAuth 2.1 Authorization Server

  • Wraps Google OAuth for MCP client authentication (proxies through Google, issues internal JWTs)
  • Implements RFC 8414 (Authorization Server Metadata) at /.well-known/oauth-authorization-server
  • Implements RFC 9728 (Protected Resource Metadata) at /.well-known/oauth-protected-resource
  • PKCE (S256) required for all authorization requests
  • Allowed redirect URIs: claude.ai, claude.com, www.claude.ai

Access Control

  • Department-based access: users see repositories assigned to their departments
  • Public repositories visible to their owners
  • User resolution from both Google OAuth tokens and internal JWTs

Infrastructure

  • SSE keep-alive middleware (25s interval) prevents client disconnections during long operations
  • Next.js frontend proxy routes for /.well-known/* and /oauth/* (bridges browser requests to backend)
  • MCP server registration is conditional on GOOGLE_CLIENT_ID and GOOGLE_CLIENT_SECRET env vars being set - the application starts normally without MCP when these aren't configured
  • Auth tab auto-closes after successful authentication

Configuration

Required environment variables (only when MCP is desired):

  • GOOGLE_CLIENT_ID - Google OAuth client ID
  • GOOGLE_CLIENT_SECRET - Google OAuth client secret

MCP 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 metadata
  • web/app/oauth/[...path]/route.ts - Frontend proxy for OAuth flow
  • Directory.Packages.props - MCP SDK dependency
  • src/OpenDeepWiki/OpenDeepWiki.csproj - MCP package reference

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
@239573049 239573049 merged commit 0ff5336 into AIDotNet:main Feb 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants