Skip to content

fix(microsoft-teams): align tools with live Graph API docs, add missing endpoints#5477

Merged
waleedlatif1 merged 2 commits into
stagingfrom
msteams-validate-integration
Jul 7, 2026
Merged

fix(microsoft-teams): align tools with live Graph API docs, add missing endpoints#5477
waleedlatif1 merged 2 commits into
stagingfrom
msteams-validate-integration

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • Ran a full validate-integration audit of Microsoft Teams against live Microsoft Graph API docs
  • Fixed list_channel_members/list_team_members incorrectly falling back to a raw userId GUID when a member's email was missing
  • Added $top=50 pagination to read_channel for parity with read_chat (previously silently capped at Graph's default page size of 20)
  • Added 4 new tools so agents can discover ids without relying on UI-only selectors: microsoft_teams_list_teams, microsoft_teams_list_chats, microsoft_teams_list_channels, microsoft_teams_list_chat_members
  • All new tools use only the currently granted OAuth scopes (Team.ReadBasic.All, Chat.ReadBasic, Channel.ReadBasic.All) — no new scopes requested
  • Wired new operations into the block's dropdown, tools.access, tools.config, outputs, and added a discover-teams-chats-channels BlockMeta skill

Type of Change

  • Bug fix
  • New feature (non-breaking)

Testing

Tested manually; bun run lint and tsc --noEmit both clean (no new errors vs. staging baseline)

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

…ng endpoints

- fix list_channel_members/list_team_members falling back to userId when email is missing
- add $top=50 pagination to read_channel for parity with read_chat
- add list_teams, list_chats, list_channels, list_chat_members tools so agents can discover ids without the UI selectors
- all new tools use only existing granted scopes (Team.ReadBasic.All, Chat.ReadBasic, Channel.ReadBasic.All) — no new OAuth scopes requested
@vercel

vercel Bot commented Jul 7, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 7, 2026 5:12pm

Request Review

@cursor

cursor Bot commented Jul 7, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Additive read-only Graph calls using existing OAuth scopes; behavior change is limited to member email formatting and a larger default page size for channel reads.

Overview
Extends the Microsoft Teams integration so workflows and agents can discover teams, chats, channels, and chat members via Graph, not only use UI selectors.

New operations: List Teams, List Chats, List Channels, and List Chat Members are implemented as tools (/me/joinedTeams, /me/chats, team channels, chat members), registered in the tool registry, and exposed on the Teams block with param wiring and outputs (teams, chats, channels, counts, hasMore). A discover-teams-chats-channels block skill documents the discovery flow.

Fixes and parity: Team/channel member listing no longer puts a raw userId GUID into email when email is missing. Read channel messages now requests $top=50 (was Graph’s default 20) to match read-chat behavior. New list tools surface hasMore from @odata.nextLink where applicable.

Reviewed by Cursor Bugbot for commit c8127a6. Configure here.

Comment thread apps/sim/tools/microsoft_teams/list_teams.ts
Comment thread apps/sim/tools/microsoft_teams/list_channels.ts
Comment thread apps/sim/tools/microsoft_teams/list_chats.ts
@greptile-apps

greptile-apps Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR audits the Microsoft Teams integration against live Graph API docs, fixes two member-listing bugs, and adds four new discovery tools (list_teams, list_chats, list_channels, list_chat_members). All new tools correctly use already-granted OAuth scopes and are wired into the block's dropdown, params routing, tool registry, and output schema.

  • Bug fixes: removed the erroneous || member.userId fallback on the email field in list_channel_members and list_team_members, and raised the read_channel message fetch to $top=50 (matching read_chat).
  • New tools: four discovery tools allow agents to enumerate teams, chats, and channels without UI selectors; each exposes a hasMore field derived from @odata.nextLink to signal truncation, respecting documented Graph API pagination behavior.
  • Types and block config: types.ts defines typed response interfaces for all new tools; microsoft_teams.ts correctly routes params, conditionally renders input fields, and exposes the new outputs.

Confidence Score: 5/5

Safe to merge — all changes are additive (new tools) or targeted correctness fixes with no breaking surface.

The email-field bug fix is a strict improvement (a GUID is not an email address), the $top=50 addition to read_channel aligns it with the existing read_chat behavior, and the four new tools are self-contained with correct params routing, typed responses, and hasMore pagination signals. The block config correctly gates field visibility for each new operation, and no existing tool contracts are broken.

No files require special attention.

Important Files Changed

Filename Overview
apps/sim/blocks/blocks/microsoft_teams.ts Adds 4 new operations to the dropdown, correctly gates field visibility (teamId for list_channels, chatId for list_chat_members, no extra fields for list_teams/list_chats), updates the tool-selector switch, and expands the outputs schema with teams/chats/channels/hasMore fields.
apps/sim/tools/microsoft_teams/list_channel_members.ts One-line bug fix: removes the incorrect userId-as-email fallback; email now defaults to empty string.
apps/sim/tools/microsoft_teams/list_team_members.ts Same one-line email fix as list_channel_members; behavior is now consistent with the other member-listing tools.
apps/sim/tools/microsoft_teams/read_channel.ts Adds $top=50 to the channel messages URL, raising the default page size from 20 to 50 for parity with read_chat.
apps/sim/tools/microsoft_teams/list_teams.ts New tool calling GET /me/joinedTeams; correctly omits $top (unsupported by this endpoint per Graph docs) and exposes hasMore for forward-compatibility.
apps/sim/tools/microsoft_teams/list_chats.ts New tool calling GET /me/chats?$top=50 (documented Graph maximum); maps chat shape correctly and returns hasMore.
apps/sim/tools/microsoft_teams/list_channels.ts New tool listing channels for a given teamId via GET /teams/{id}/channels; maps channel shape with membershipType and exposes hasMore for pagination detection.
apps/sim/tools/microsoft_teams/list_chat_members.ts New tool listing members of a chat via GET /chats/{chatId}/members; correctly reuses MicrosoftTeamsListMembersResponse type and includes hasMore and chatId in metadata.
apps/sim/tools/microsoft_teams/types.ts Adds typed response interfaces for the four new tools, makes hasMore optional on the existing MicrosoftTeamsListMembersResponse, and extends the union type.
apps/sim/tools/microsoft_teams/index.ts Re-exports the four new tools under their canonical names; follows existing naming conventions.
apps/sim/tools/registry.ts Registers the four new microsoft_teams tools in the global registry; no issues.

Sequence Diagram

%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
    participant Agent
    participant Block as MicrosoftTeams Block
    participant Tool as Tool Registry
    participant Graph as Microsoft Graph API

    Note over Agent,Graph: Discovery flow (new tools)
    Agent->>Block: "operation = list_teams"
    Block->>Tool: microsoft_teams_list_teams
    Tool->>Graph: GET /me/joinedTeams
    Graph-->>Tool: "{ value: [...teams], @odata.nextLink? }"
    Tool-->>Block: "{ teams, teamCount, hasMore }"
    Block-->>Agent: teams array + hasMore flag

    Agent->>Block: "operation = list_channels (teamId)"
    Block->>Tool: microsoft_teams_list_channels
    Tool->>Graph: "GET /teams/{teamId}/channels"
    Graph-->>Tool: "{ value: [...channels], @odata.nextLink? }"
    Tool-->>Block: "{ channels, channelCount, hasMore }"
    Block-->>Agent: channels array + hasMore flag

    Agent->>Block: "operation = list_chats"
    Block->>Tool: microsoft_teams_list_chats
    Tool->>Graph: "GET /me/chats?$top=50"
    Graph-->>Tool: "{ value: [...chats], @odata.nextLink? }"
    Tool-->>Block: "{ chats, chatCount, hasMore }"
    Block-->>Agent: chats array + hasMore flag

    Agent->>Block: "operation = list_chat_members (chatId)"
    Block->>Tool: microsoft_teams_list_chat_members
    Tool->>Graph: "GET /chats/{chatId}/members"
    Graph-->>Tool: "{ value: [...members], @odata.nextLink? }"
    Tool-->>Block: "{ members, memberCount, hasMore }"
    Block-->>Agent: members array + hasMore flag
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
sequenceDiagram
    participant Agent
    participant Block as MicrosoftTeams Block
    participant Tool as Tool Registry
    participant Graph as Microsoft Graph API

    Note over Agent,Graph: Discovery flow (new tools)
    Agent->>Block: "operation = list_teams"
    Block->>Tool: microsoft_teams_list_teams
    Tool->>Graph: GET /me/joinedTeams
    Graph-->>Tool: "{ value: [...teams], @odata.nextLink? }"
    Tool-->>Block: "{ teams, teamCount, hasMore }"
    Block-->>Agent: teams array + hasMore flag

    Agent->>Block: "operation = list_channels (teamId)"
    Block->>Tool: microsoft_teams_list_channels
    Tool->>Graph: "GET /teams/{teamId}/channels"
    Graph-->>Tool: "{ value: [...channels], @odata.nextLink? }"
    Tool-->>Block: "{ channels, channelCount, hasMore }"
    Block-->>Agent: channels array + hasMore flag

    Agent->>Block: "operation = list_chats"
    Block->>Tool: microsoft_teams_list_chats
    Tool->>Graph: "GET /me/chats?$top=50"
    Graph-->>Tool: "{ value: [...chats], @odata.nextLink? }"
    Tool-->>Block: "{ chats, chatCount, hasMore }"
    Block-->>Agent: chats array + hasMore flag

    Agent->>Block: "operation = list_chat_members (chatId)"
    Block->>Tool: microsoft_teams_list_chat_members
    Tool->>Graph: "GET /chats/{chatId}/members"
    Graph-->>Tool: "{ value: [...members], @odata.nextLink? }"
    Tool-->>Block: "{ members, memberCount, hasMore }"
    Block-->>Agent: members array + hasMore flag
Loading

Reviews (2): Last reviewed commit: "fix(microsoft-teams): surface pagination..." | Re-trigger Greptile

Comment thread apps/sim/tools/microsoft_teams/list_teams.ts
Comment thread apps/sim/tools/microsoft_teams/list_chats.ts
- add hasMore output (derived from @odata.nextLink presence) to list_teams, list_chats, list_channels, list_chat_members so agents can detect truncated results instead of trusting the count field as a total
- do NOT add $top to list_teams' joinedTeams request — Graph docs explicitly state this endpoint does not support OData query parameters, so it would silently no-op
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile review

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit c8127a6. Configure here.

@waleedlatif1 waleedlatif1 merged commit 03462b9 into staging Jul 7, 2026
18 checks passed
@waleedlatif1 waleedlatif1 deleted the msteams-validate-integration branch July 7, 2026 17:26
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.

1 participant