A command-line interface for Microsoft Teams. List chats, read and send messages, search, view activity, and more β all from your terminal.
Uses the internal Teams Chat Service API (the same API the Teams web client uses), authenticated via a Playwright-based browser login flow. No Entra ID app registration or tenant-level admin setup required β just sign in with your browser.
This CLI can be used as a tool for AI agents (e.g. Claude Code, Codex, GitHub Copilot) to access Microsoft Teams on your behalf β without needing a direct Microsoft integration. Most Teams integrations require Entra ID app registrations and tenant admin approval. This doesn't.
An agent skill is included that teaches coding agents how to use the CLI β install it and your agent can read your messages, send DMs, search chats, and more:
# Install the skill
npx skills add https://github.com/mingnz/teams-cli
# Or copy skills/teams-cli/ into your project's .claude/skills/ directoryRequires Node.js 18+.
# Install globally from npm
npm install -g teams-cli
# Or run directly with npx
npx teams-cli --help
# Or clone and build from source
git clone https://github.com/mingnz/teams-cli.git
cd teams-cli
npm install
npm run buildLog in by launching a browser session. Sign in as you normally would (including MFA), and tokens are captured automatically from the browser:
teams loginTokens are stored in ~/.teams-cli/tokens.json. Token lifetimes vary by API (the chat token lasts ~24 hours, the search token ~1.5 hours). Expired tokens are refreshed automatically via a headless browser using your saved session cookies β no manual re-login needed unless the session itself has expired.
# List recent chats
teams chats
# Read messages (use short ID from `teams chats`)
teams messages a1b2
# Send a message
teams send a1b2 "Hello from the CLI"
# Find a person by name or email
teams find "Jane Smith"
# Send a direct message (creates 1:1 chat if needed)
teams dm "Jane Smith" "Hey, quick question"
teams dm "8:orgid:00000000-0000-..." "Hello via MRI"
# Search across all conversations
teams search "quarterly report"
# Watch a chat for new messages (Ctrl+C to stop)
teams watch a1b2
# Watch all chats for new messages
teams watch
# View activity feed
teams activity
teams activity --feed mentions
teams activity --feed calllogs
# List members of a chat
teams members a1b2Most commands accept --limit / -n to control how many results to fetch:
teams chats --limit 50
teams messages a1b2 --limit 40
teams search "budget" --limit 10Run teams --help or teams <command> --help for full details.
# Install dependencies
npm install
# Build
npm run build
# Run tests
npm test
# Run in dev mode (no build step)
npm run dev -- chatsteams loginopens Chromium via Playwright, navigates to Teams, and waits for you to complete sign-in- Auth tokens are extracted from the browser's
localStorage(three tokens: chat, search, presence) along with your region - CLI commands use these tokens to call the Teams Chat Service API (
teams.cloud.microsoft/api/chatsvc/) and the Substrate Search API (substrate.office.com) directly viafetch - The
teams chatscommand caches the conversation list locally so you can reference chats by short ID in subsequent commands - The
teams dmcommand searches for a user via the Substrate Suggestions API, creates a 1:1 thread viaPOST /threads, and sends the message β all in one step
src/ # CLI source β auth, API calls, formatting, commands
tests/ # Unit tests for all modules
skills/ # Agent skill for AI-assisted Teams interaction
docs/ # Architecture and security documentation
This project is not affiliated with, endorsed by, or associated with Microsoft. It uses undocumented internal APIs that Microsoft can change or restrict at any time without notice. Use at your own risk β this tool may break unexpectedly.