Skip to content

feat: header metadata support#299

Open
Hsienz wants to merge 6 commits into
open-webui:devfrom
Hsienz:streamable-http-metadata-support
Open

feat: header metadata support#299
Hsienz wants to merge 6 commits into
open-webui:devfrom
Hsienz:streamable-http-metadata-support

Conversation

@Hsienz

@Hsienz Hsienz commented Jun 17, 2026

Copy link
Copy Markdown

Pull Request Checklist

Before submitting, make sure you've checked the following:

  • Target branch: Please verify that the pull request targets the dev branch.
  • Description: Provide a concise description of the changes made in this pull request.
  • Changelog: Ensure a changelog entry following the format of Keep a Changelog is added at the bottom of the PR description.
  • Dependencies: Are there any new dependencies? Have you updated the dependency versions in the documentation?
  • Testing: Have you written and run sufficient tests to validate the changes?
  • Code review: Have you performed a self-review of your code, addressing any coding standard issues and ensuring adherence to the project's coding standards?
  • Prefix: To clearly categorize this pull request, prefix the pull request title using one of the following:
    • BREAKING CHANGE: Significant changes that may affect compatibility
    • build: Changes that affect the build system or external dependencies
    • ci: Changes to our continuous integration processes or workflows
    • chore: Refactor, cleanup, or other non-functional code changes
    • docs: Documentation update or addition
    • feat: Introduces a new feature or enhancement to the codebase
    • fix: Bug fix or error correction
    • i18n: Internationalization or localization changes
    • perf: Performance improvement
    • refactor: Code restructuring for better maintainability, readability, or scalability
    • style: Changes that do not affect the meaning of the code (white space, formatting, missing semi-colons, etc.)
    • test: Adding missing tests or correcting existing tests
    • WIP: Work in progress, a temporary label for incomplete or ongoing work

Changelog Entry

Description

Update mcp package so that ClientSession.tool_call() function support meta parameter.

So we can pass unused meta to tool call from exist client-header-forwarding functionality.

Also, implementing the client-header-forwarding to cli command ONLY for streamable-http because I rarely use other type and not able to testing

Added

  • Send unused meta from client-header-forwarding functionality to tool_call

  • Add client-header-forwarding to cli command for streamable-http type

    usage:

    mcpo --port 8001 --type streamable-http --client-header-forwarding '{"enabled":true,"whitelist":["*"]}' -- http://localhost:8000/mcp
    mcpo --port 8001 --config config.json

    See here for format of config.json

Changed

  • Update mcp package from 0.17.0 to 0.28.0 for meta suporting

Additional Information

You need to add something like middleware to get meta field
e.g.

// in Programs.cs
builder
    .Services.AddMcpServer()
    .WithHttpTransport(options =>
    {
        options.Stateless = true;
    })
    .WithToolsFromAssembly();

builder.Services.AddHttpContextAccessor();

var app = builder.Build();
app.Use(
    async (ctx, next) =>
    {
        ctx.Request.EnableBuffering();

        using var reader = new StreamReader(ctx.Request.Body, leaveOpen: true);

        var body = await reader.ReadToEndAsync();
        var bodyObject = JObject.Parse(body);

        var auth = bodyObject?["params"]?["_meta"]?["headers"]?["authorization"]?.ToString();
        if (auth != null)
        {
            Console.WriteLine(body);
            ctx.Request.Headers.TryAdd("Authorization", auth);
        }

        ctx.Request.Body.Position = 0;

        await next();
    }
);
app.MapMcp("/mcp");
// in Tool.cs
[McpServerToolType]
internal class HeaderTest
{
    [McpServerTool, Description("this function is use for test, if header is sent to server")]
    public static async Task<string> HeaderTesting(IHttpContextAccessor accessor)
    {
        var request = accessor.HttpContext?.Request;


        foreach (var header in accessor.HttpContext!.Request.Headers)
        {
            Console.WriteLine($"{header.Key}: {header.Value}");
        }
        return "OK";
    }
}

Screenshots or Videos

Left panel is mcpo log
Right panel is MCP server log
You can see Authorization appear in the MCP server log

image

@Hsienz Hsienz changed the title feat: streamable-http header metadata support feat: header metadata support Jun 17, 2026
@Hsienz Hsienz force-pushed the streamable-http-metadata-support branch from 6fff050 to 50054c3 Compare June 17, 2026 10:03
@Hsienz Hsienz force-pushed the streamable-http-metadata-support branch from 50054c3 to 7e99ed1 Compare June 17, 2026 10:08
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.

3 participants