Thanks to visit codestin.com
Credit goes to github.com

Skip to content

feat(cli): make MCP server work without user authentication #17688

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

ThomasK33
Copy link
Member

@ThomasK33 ThomasK33 commented May 6, 2025

Part of #17649


Allow MCP server to run without authentication

This PR enhances the MCP server to operate without requiring authentication, making it more flexible for environments where authentication isn't available or necessary. Key changes:

  • Replaced InitClient with TryInitClient to allow the MCP server to start without credentials
  • Added graceful handling when URL or authentication is missing
  • Made authentication status visible in server logs
  • Added logic to skip user-dependent tools when no authenticated user is present
  • Made the coder_report_task tool available with just an agent token (no user token required)
  • Added comprehensive tests to verify operation without authentication

These changes allow the MCP server to function in more environments while still using authentication when available, improving flexibility for CI/CD and other automated environments.

Copy link
Member Author

ThomasK33 commented May 6, 2025

@ThomasK33 ThomasK33 force-pushed the thomask33/05-06-feat_mcp_add_support_for_running_mcp_server_without_user_authentication branch 2 times, most recently from a0e7857 to 5ffda26 Compare May 6, 2025 16:01
@ThomasK33 ThomasK33 changed the title feat(cli): make MCP server work without authentication feat(cli): make MCP server work without user authentication May 6, 2025
@ThomasK33 ThomasK33 requested a review from Copilot May 6, 2025 16:15
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR enables the MCP server to run without user authentication.

  • Replaces the mandatory coder client check in the dependencies with support for a nil client for unauthenticated operation.
  • Introduces a new TryInitClient middleware and updates logging and tool filtering for tools that don’t require an authenticated user.
  • Updates tests to verify that the server runs correctly without user authentication while still supporting tools that rely solely on an agent token.

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

File Description
codersdk/toolsdk/toolsdk.go Updated dependency initialization and added a flag (UserClientOptional) to mark tools that can run without a user client.
cli/root.go Introduced TryInitClient to allow initialization without errors when credentials are missing.
cli/exp_mcp_test.go Updated error expectations in tests and added a new test to confirm operation with just an agent token.
cli/exp_mcp.go Modified middleware usage and adjusted authentication logging and tool filtering logic.
Files not reviewed (1)
  • flake.nix: Language not supported

@ThomasK33 ThomasK33 force-pushed the thomask33/05-06-feat_mcp_add_support_for_running_mcp_server_without_user_authentication branch 5 times, most recently from 937e55a to 4deeaf3 Compare May 7, 2025 09:56
@ThomasK33 ThomasK33 marked this pull request as ready for review May 7, 2025 10:16
@ThomasK33 ThomasK33 force-pushed the thomask33/05-06-feat_mcp_add_support_for_running_mcp_server_without_user_authentication branch 2 times, most recently from 5582625 to 6cc32e3 Compare May 7, 2025 13:37
…tion

Change-Id: Iab480d38764eddee294a4e8cd35a9dc52add6010
Signed-off-by: Thomas Kosiewski <[email protected]>
@ThomasK33 ThomasK33 force-pushed the thomask33/05-06-feat_mcp_add_support_for_running_mcp_server_without_user_authentication branch from 6cc32e3 to bc33d16 Compare May 7, 2025 19:36
@ThomasK33 ThomasK33 merged commit 29bce8d into main May 7, 2025
37 checks passed
@ThomasK33 ThomasK33 deleted the thomask33/05-06-feat_mcp_add_support_for_running_mcp_server_without_user_authentication branch May 7, 2025 19:53
@github-actions github-actions bot locked and limited conversation to collaborators May 7, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants