[PR #299] feat: header metadata support #245

Open
opened 2026-10-18 21:12:58 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/mcpo/pull/299
Author: @Hsienz
Created: 6/17/2026
Status: 🔄 Open

Base: dev ← Head: streamable-http-metadata-support


📝 Commits (6)

  • 788ff92 Merge pull request #287 from open-webui/dev
  • 410e672 chore: udpate mcp 1.17.0 to 1.28.0
  • bf2bc62 feat: send metadata when enable client-header-forwarding
  • 9938344 feat: add client-header-forwarding to cli
  • bdb0a48 refactor: change server name placeholder
  • 7e99ed1 feat: metadata support

📊 Changes

5 files changed (+90 additions, -27 deletions)

View changed files

📝 src/mcpo/__init__.py (+5 -1)
📝 src/mcpo/main.py (+11 -0)
📝 src/mcpo/utils/headers.py (+1 -2)
📝 src/mcpo/utils/main.py (+4 -4)
📝 uv.lock (+69 -20)

📄 Description

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

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/mcpo/pull/299 **Author:** [@Hsienz](https://github.com/Hsienz) **Created:** 6/17/2026 **Status:** 🔄 Open **Base:** `dev` ← **Head:** `streamable-http-metadata-support` --- ### 📝 Commits (6) - [`788ff92`](https://github.com/open-webui/mcpo/commit/788ff92e5288a899a743a252edd5748f4ad4ab1f) Merge pull request #287 from open-webui/dev - [`410e672`](https://github.com/open-webui/mcpo/commit/410e672cbe0d8b00fc86cb46003d6b836e63de04) chore: udpate mcp 1.17.0 to 1.28.0 - [`bf2bc62`](https://github.com/open-webui/mcpo/commit/bf2bc6220d324becfc98daa3ada0b6acd0bddb70) feat: send metadata when enable client-header-forwarding - [`9938344`](https://github.com/open-webui/mcpo/commit/99383447b0aa6f1ea091cb1a94c3fa18b6139b99) feat: add client-header-forwarding to cli - [`bdb0a48`](https://github.com/open-webui/mcpo/commit/bdb0a48a291b80e72a08fe01d9b0dec4ad42be11) refactor: change server name placeholder - [`7e99ed1`](https://github.com/open-webui/mcpo/commit/7e99ed1dfca444a5568ff38ffcc596b58eee5d87) feat: metadata support ### 📊 Changes **5 files changed** (+90 additions, -27 deletions) <details> <summary>View changed files</summary> 📝 `src/mcpo/__init__.py` (+5 -1) 📝 `src/mcpo/main.py` (+11 -0) 📝 `src/mcpo/utils/headers.py` (+1 -2) 📝 `src/mcpo/utils/main.py` (+4 -4) 📝 `uv.lock` (+69 -20) </details> ### 📄 Description # Pull Request Checklist **Before submitting, make sure you've checked the following:** - [x] **Target branch:** Please verify that the pull request targets the `dev` branch. - [x] **Description:** Provide a concise description of the changes made in this pull request. - [x] **Changelog:** Ensure a changelog entry following the format of [Keep a Changelog](https://keepachangelog.com/) is added at the bottom of the PR description. - [ ] **Dependencies:** Are there any new dependencies? Have you updated the dependency versions in the documentation? - [x] **Testing:** Have you written and run sufficient tests to validate the changes? - [x] **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? - [x] **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: ```sh mcpo --port 8001 --type streamable-http --client-header-forwarding '{"enabled":true,"whitelist":["*"]}' -- http://localhost:8000/mcp ``` ```sh mcpo --port 8001 --config config.json ``` See [here](https://github.com/open-webui/mcpo/pull/251/changes#diff-4e26a9bda74f3a6533df6aef91c81f92b0757e82278daafa22c7c8e4f3483dbd) 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. ```cs // 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"); ``` ```cs // 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 <img width="1918" height="1077" alt="image" src="https://github.com/user-attachments/assets/6c9a56bf-1565-4b03-aa85-9c27f241b956" /> --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
open-webui/mcpo#245
No description provided.