Skip to content

mcp: support auth provider by HTTP basic auth #2886

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

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

lambochen
Copy link

Support a way to auth client-server connection by request params.
I think it's necessary, such as, When using Claude Desktop to connect to a remote MCP Server, only one URL can be filled in. If identity authentication and authorization are implemented, passing information from the request parameters is a good choice.


Thank you for taking time to contribute this pull request!
You might have already read the [contributor guide][1], but as a reminder, please make sure to:

  • Sign the contributor license agreement
  • Rebase your changes on the latest main branch and squash your commits
  • Add/Update unit tests as needed
  • Run a build and make sure all tests pass prior to submission

@lambochen
Copy link
Author

lambochen commented Apr 25, 2025

Issue: #2888

@lambochen
Copy link
Author

lambochen commented Apr 27, 2025

McpServerAuthProvider example

McpServerAuthProvider implement example

import io.modelcontextprotocol.server.McpServerAuthParam;
import io.modelcontextprotocol.server.McpServerAuthProvider;
import org.springframework.stereotype.Component;

@Component
public class CustomMcpServerAuthProvider implements McpServerAuthProvider {

	@Override
	public boolean authenticate(McpServerAuthParam param) {
		// example: get token param
		String token = param.getParams().get("token");
		// TODO do something
		return true;
	}

}

MCP Client(eg: Claude) config

{
  "mcpServers": {
    "mcp-remote-server-example": {
      "url": "http://{your mcp server}/sse?token=xxx"
    }
  }
}

@lambochen lambochen marked this pull request as draft April 28, 2025 02:16
@lambochen lambochen changed the title mcp: support auth provider by request params mcp: support auth provider by HTTP basic auth Apr 28, 2025
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.

1 participant