Skip to content

Token team_id extraction and usage for APIs#1460

Merged
madhav165 merged 14 commits intomainfrom
token_team_extraction
Nov 19, 2025
Merged

Token team_id extraction and usage for APIs#1460
madhav165 merged 14 commits intomainfrom
token_team_extraction

Conversation

@kevalmahajan
Copy link
Copy Markdown
Member

@kevalmahajan kevalmahajan commented Nov 18, 2025

🐛 Bug-fix PR

📌 Summary

Closes #1453

Instead of manually providing the team_id in the API requests, if the token has a team-level scope, extract the team_id directly from the token and use it for the relevant API calls.

🔁 Reproduction Steps

  1. Add an MCP server to the gateway using the POST /gateways API, but do not include the team_id as a parameter in the request.
  2. Use a team-level scoped token for the API call.
  3. Currently, the server is added to the default team of the user, rather than the team associated with the token.

After this change:
The added server will be created under the team corresponding to the token used for the API call.
This is implemented for MCP servers, virtual servers, tools, prompts, resources.

🐞 Root Cause

When team_id is not provided, the team for the added resource is defaulted to the default personal team of the user, which should not happen as the token is used only for a specific team.

💡 Fix Description

Major changes in create and list APIs for all resources.

🧪 Verification

Check Command Status
Lint suite make lint
Unit tests make test
Coverage ≥ 90 % make coverage
Manual regression no longer fails steps / screenshots

📐 MCP Compliance (if relevant)

  • Matches current MCP spec
  • No breaking change to MCP clients

✅ Checklist

  • Code formatted (make black isort pre-commit)
  • No secrets/credentials committed

@kevalmahajan kevalmahajan marked this pull request as draft November 18, 2025 10:30
@kevalmahajan kevalmahajan marked this pull request as ready for review November 18, 2025 14:16
@kevalmahajan kevalmahajan added the wxo wxo integration label Nov 18, 2025
@rakdutta rakdutta self-requested a review November 19, 2025 05:06
Copy link
Copy Markdown
Collaborator

@rakdutta rakdutta left a comment

Choose a reason for hiding this comment

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

Registration for the gateway, virtual server, tools, prompts, and resources works as expected, and the team ID is correctly populated from the token. However, during REST tool creation, the API response still shows team = null, even though the team ID is correct.

Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
Signed-off-by: Keval Mahajan <mahajankeval23@gmail.com>
@madhav165 madhav165 force-pushed the token_team_extraction branch from d881808 to a0fe6de Compare November 19, 2025 11:14
Copy link
Copy Markdown
Collaborator

@madhav165 madhav165 left a comment

Choose a reason for hiding this comment

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

Merging after rebase. It allows team_id to be read from the JWT as requested by WxO team.

@madhav165 madhav165 merged commit 4925d59 into main Nov 19, 2025
45 checks passed
@madhav165 madhav165 deleted the token_team_extraction branch November 19, 2025 11:32
kcostell06 pushed a commit to kcostell06/mcp-context-forge that referenced this pull request Feb 24, 2026
Token team_id extraction and usage for APIs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wxo wxo integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Gateway creation under team scope returns team id as null

3 participants