Skip to content

fix: make OAuth client_id optional to support Dynamic Client Registration - #116

Merged
Dumbris merged 2 commits into
mainfrom
fix/oauth-client-id-optional-issue-83
Nov 1, 2025
Merged

Dumbris merged 2 commits into
mainfrom
fix/oauth-client-id-optional-issue-83

Conversation

@Dumbris

@Dumbris Dumbris commented Nov 1, 2025

Copy link
Copy Markdown
Member

Summary

Fixes #83 - OAuth client_id validation error when using Dynamic Client Registration (DCR)

Problem

The validation code was incorrectly requiring client_id to be non-empty whenever the oauth configuration object was present, even though:

  • The documentation explicitly states client_id is optional
  • The OAuth implementation supports Dynamic Client Registration (RFC 7591) which works without a pre-registered client_id
  • The OAuthConfig struct uses omitempty JSON tags for all fields

This created a catch-22 for users trying to configure OAuth servers with DCR:

Error: failed to load configuration: invalid configuration: 
mcpServers[3].oauth.client_id: client_id is required when oauth is configured

Solution

  • ✅ Removed the mandatory client_id validation check in internal/config/config.go:612-622
  • ✅ Added explanatory comment about DCR support (RFC 7591)
  • ✅ Aligned validation logic with documentation and OAuth implementation

Testing

New test cases added (internal/config/validation_test.go):

  1. OAuth with empty client_id (DCR mode) - validates successfully
  2. OAuth with only scopes and pkce_enabled - validates successfully
  3. OAuth with client_id provided - validates successfully (regression test)

Manual verification:

Files Changed

  • internal/config/config.go - Removed client_id validation requirement
  • internal/config/validation_test.go - Added 3 OAuth validation test cases

Example Configurations Now Supported

DCR Mode (new, previously blocked):

{
  "name": "linear-mcp",
  "url": "https://api.linear.app/mcp",
  "protocol": "http",
  "oauth": {
    "scopes": ["mcp.read", "mcp.write"],
    "pkce_enabled": true
  }
}

Pre-registered Client (continues to work):

{
  "name": "test-server",
  "url": "https://api.example.com/mcp",
  "protocol": "http",
  "oauth": {
    "client_id": "my-client-id",
    "client_secret": "my-secret",
    "scopes": ["mcp.read"]
  }
}

References

🤖 Generated with Claude Code

…tion

Fixes #83

**Problem:**
- Documentation states client_id is optional (uses Dynamic Client Registration if empty)
- Validation code required client_id whenever oauth object was present
- Users couldn't configure OAuth servers to use DCR (RFC 7591)
- Error: "client_id is required when oauth is configured"

**Solution:**
- Removed mandatory client_id validation check
- Added comment explaining DCR support (RFC 7591)
- client_id is now truly optional as documented

**Testing:**
- Added 3 new test cases for OAuth validation:
  1. OAuth with empty client_id (DCR mode)
  2. OAuth with only scopes and pkce
  3. OAuth with client_id provided (regression test)
- All tests pass
- Verified with reproduction configs from issue #83
- Both DCR mode and pre-registered client mode work correctly

**Files Changed:**
- internal/config/config.go: Removed client_id validation
- internal/config/validation_test.go: Added OAuth test cases

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@github-actions

github-actions Bot commented Nov 1, 2025 •

Copy link
Copy Markdown
Contributor

📦 Build Artifacts for PR #116

Version: v0.9.22-dev-a686abb-pr116
Latest tag: v0.9.22

Available Artifacts

  • archive-linux-amd64 (9.4 MB)
  • archive-linux-arm64 (8.6 MB)
  • archive-windows-amd64 (17 MB)
  • archive-darwin-arm64 (16 MB)
  • installer-dmg-darwin-arm64 (18 MB)
  • archive-windows-arm64 (16 MB)
  • archive-darwin-amd64 (17 MB)
  • installer-dmg-darwin-amd64 (19 MB)

How to Download

Option 1: GitHub Web UI (easiest)

  1. Go to the workflow run page
  2. Scroll to the bottom "Artifacts" section
  3. Click on the artifact you want to download

Option 2: GitHub CLI

gh run download 18993286834 --repo smart-mcp-proxy/mcpproxy-go

# Or download a specific artifact:
gh run download 18993286834 --name dmg-darwin-arm64

Note: Artifacts expire in 14 days.

The previous commit left an empty if statement after removing the
client_id validation, which triggered staticcheck SA9003 (empty branch).

Changed to a comment explaining the OAuth validation policy instead.

Linter output: 0 issues
Tests: All pass
@Dumbris
Dumbris merged commit 9feb897 into main Nov 1, 2025
@Dumbris
Dumbris deleted the fix/oauth-client-id-optional-issue-83 branch November 1, 2025 07:30
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.

OAuth client id is required but documented as optional

1 participant