feat(mcp-server): add server-level default authentication and MCP proxy server support #3096
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.
higress-group/wasm-go#25
✨ Key Features
1. Server-Level Default Authentication
defaultDownstreamSecurity: Configure default client-to-gateway authentication for all tools andtools/listrequestsdefaultUpstreamSecurity: Configure default gateway-to-backend authentication for all backend requests2. MCP Proxy Server Type
mcp-proxy: Proxy client MCP requests to backend MCP serversmcpServerURLfield for specifying backend MCP server endpointtimeoutfield for controlling request timeouts3. Authentication Code Refactoring
auth_utils.goSecurityScheme,SecurityRequirement, andAuthRequestContextstructs4. Configuration Structure Improvements
mcpServerURL,timeout,defaultDownstreamSecurity,defaultUpstreamSecurityare now direct server properties🔧 Technical Changes
Core Implementation
pkg/mcp/server/auth_utils.go: New shared authentication utilitiespkg/mcp/server/proxy_server.go: Enhanced with default security and direct field supportpkg/mcp/server/rest_server.go: Updated to use shared auth utilities and support default securitypkg/mcp/server/proxy_tool.go: Refactored authentication parameter passing using dedicated structsConfiguration Updates
pkg/mcp/server/plugin.go: Updated to parse new configuration fields directly from server objecttools/listrequests and non-tool-specific interfacesTest Coverage
📚 Documentation
Updated Documentation
New Examples
🔒 Security Enhancements
Two-Tier Authentication
Authentication Priority
🧪 Testing
New Test Coverage
Test Improvements
🎯 Use Cases
MCP Proxy Server
Perfect for scenarios where you need to:
Server-Level Authentication
Ideal for:
tools/listand other protocol operations🔍 Files Changed
examples/mcp-server/README.md- Updated Chinese documentationexamples/mcp-server/README_EN.md- New English documentationexamples/mcp-server/main_test.go- Enhanced authentication testspkg/mcp/server/auth_utils.go- New shared authentication utilitiespkg/mcp/server/plugin.go- Updated configuration parsingpkg/mcp/server/proxy_server.go- Enhanced proxy server implementationpkg/mcp/server/rest_server.go- Updated to use shared auth utilitiespkg/mcp/server/proxy_tool.go- Refactored authentication handling✅ Validation
Note
Introduces an MCP proxy server with HTTP/SSE transport, server-level default auth (downstream/upstream), shared auth utilities, enhanced REST server, dynamic tool allow-listing, and comprehensive docs/tests.
mcp-proxytype withtransport(http/sse),mcpServerURL,timeout, andpassthroughAuthHeaderinpkg/mcp/server/proxy_server.go.pkg/mcp/server/sse_proxy.gowith response-body interception inplugin.go.defaultDownstreamSecurityanddefaultUpstreamSecurityparsed inpkg/mcp/server/plugin.go; applied in both proxy and REST servers.SecurityScheme,SecurityRequirement,AuthRequestContext,ExtractAndRemoveIncomingCredential,ApplySecurityinpkg/mcp/server/auth_utils.go(used by REST/proxy).pkg/mcp/server/plugin.goand proxy handlers.pkg/mcp/server/rest_server.go.CtxNeedPauseinpkg/mcp/utils/json_rpc.go.transport,mcpServerURL, defaults, schemes) inpkg/mcp/server/plugin.goandconfig_validator_test.go.examples/mcp-server/README*.md).examples/mcp-server/*.pkg/mcp/server/*_test.goandexamples/mcp-server/main_test.go..gitignore; addexamples/mcp-server/go.mod.Written by Cursor Bugbot for commit 707b07eb955aae3f25921aaba2e5b6f71a0778e7. This will update automatically on new commits. Configure here.