Skip to content

Conversation

@mjcarson
Copy link
Contributor

@mjcarson mjcarson commented Aug 26, 2025

This allows the streamable http client to send an authorization header when making requests.

Closes #387

This simply allows users to specify an auth header to use with the streamable http client.

    // build the config to use with this transport
    let config = StreamableHttpClientTransportConfig::with_uri("<MCP_SERVER>")
        // set our auth header
        .auth_header("<AUTH_HEADER>");
    // setup our transport
    let transport = StreamableHttpClientTransport::from_config(config);
    // build our client info
    let client_info = ClientInfo {
        protocol_version: Default::default(),
        capabilities: ClientCapabilities::default(),
        client_info: Implementation {
            name: "Example MCP Client".to_string(),
            version: "0.0.1".to_string(),
        },
    };
    // build our client
    client_info.serve(transport).await.unwrap()
    ```

## Motivation and Context
Prior to this it was not possible for this client to be used with MCP servers that use the authorization header for auth.

## How Has This Been Tested?
Yes, I tested this against a local MCP server.

## Breaking Changes
No, this should be a purely additive feature.

## Types of changes
<!-- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
- [ ] Bug fix (non-breaking change which fixes an issue)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
- [ ] Documentation update

## Checklist
<!-- Go over all the following points, and put an `x` in all the boxes that apply. -->
- [x] I have read the [MCP Documentation](https://modelcontextprotocol.io)
- [x] My code follows the repository's style guidelines
- [x] New and existing tests pass locally
- [ ] I have added appropriate error handling
- [ ] I have added or updated documentation as needed

## Additional context
<!-- Add any other context, implementation notes, or design decisions -->

@github-actions github-actions bot added T-core Core library changes T-transport Transport layer changes labels Aug 26, 2025
…client

This allows the streamable http client to send an authorization header
when making requests.

Closes modelcontextprotocol#387
@mjcarson mjcarson force-pushed the AuthHeaderSupportStreamableHttpClient branch from ee0e1e2 to 4c85e8c Compare August 29, 2025 04:12
Copy link
Collaborator

@4t145 4t145 left a comment

Choose a reason for hiding this comment

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

looks good

@4t145 4t145 merged commit 6853143 into modelcontextprotocol:main Aug 29, 2025
11 checks passed
@github-actions github-actions bot mentioned this pull request Aug 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

T-core Core library changes T-transport Transport layer changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Send Authorization header in client

2 participants