spring-projects / spring-projects/spring-ai

Add Headers (Authorization) to ToolContext to be used by tool call back method

Open
#3,476 1 comment 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

status: waiting-for-triage
Dominant language
Java
Stars
9.5k
Forks
2.9k
Avg merge
1d 7h
Merged PRs (30d)
6

Description

Currently in the MCP Server since the tool callback execution happens in a separate worker pool (boundedElastic scheduler) it loses any context including the headers being passed in the /mcp endpoint.

For most scenarios in the tool callback method there might be certain validations / authorizations that may be needed which can be achieved by having access to the original Authorization Bearer token.

What do you think ? @ThomasVitale / @markpollack

If you are ok with this I can work on a PR to include this in the framework. But let me know what you guys think.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the MCP server's /mcp endpoint and trace how the ToolContext reaches the tool callback on the boundedElastic scheduler. Determine how the original Authorization header could remain available to callback validation, then verify that the callback can access it without leaking unrelated request context.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
authentication, backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.