Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The Microsoft Learn CLI (mslearn) provides terminal-friendly access to the public Microsoft Learn Model Context Protocol (MCP) Server. You can use it to search Microsoft documentation, fetch Learn articles, search official code samples, and diagnose your connection.
By default, the CLI connects to the following endpoint:
https://learn.microsoft.com/api/mcp
Prerequisites
The Microsoft Learn CLI requires Node.js 22 or later. To check your installed version, run:
node --version
Install the CLI
You can run the CLI without installing it:
npx @microsoft/learn-cli search "azure functions timeout"
Or install it globally:
npm install -g @microsoft/learn-cli
mslearn search "azure functions timeout"
The remaining examples use the mslearn command, which is available after a global installation. If you run the CLI without installing it, replace mslearn with npx @microsoft/learn-cli.
Installing the npm package doesn't configure agent discovery. To make the CLI available as a fallback for supported coding agents, complete the steps in Configure agent discovery.
Configure agent discovery
The standalone CLI can install a CLI-first skill for GitHub Copilot, Claude Code, and Codex. The skill teaches the agent to run npx @microsoft/learn-cli@latest when Microsoft Learn MCP tools aren't available.
To install discovery for supported agents detected in your user profile, run:
mslearn setup --cli
To detect agents in the current repository and install discovery at the project level, run:
mslearn setup --cli --project
You can override automatic detection by specifying one or more agents:
mslearn setup --cli --copilot
mslearn setup --cli --claude
mslearn setup --cli --codex
mslearn setup --cli --copilot --claude --codex
Add --project to any of these commands to install discovery only in the current repository:
mslearn setup --cli --copilot --project
mslearn setup --cli --claude --project
mslearn setup --cli --codex --project
The setup command creates the following skill files:
| Agent | Scope | Skill file |
|---|---|---|
| GitHub Copilot | User | ~/.copilot/skills/microsoft-learn-cli/SKILL.md |
| GitHub Copilot | Project | .github/skills/microsoft-learn-cli/SKILL.md |
| Claude Code | User | ~/.claude/skills/microsoft-learn-cli/SKILL.md |
| Claude Code | Project | .claude/skills/microsoft-learn-cli/SKILL.md |
| Codex | User | ~/.agents/skills/microsoft-learn-cli/SKILL.md |
| Codex | Project | .agents/skills/microsoft-learn-cli/SKILL.md |
The --cli option is required. If you don't specify an agent, setup detects installed agents from their known user or project directories. Explicit targets (--copilot, --claude, and --codex) override detection and can be combined. Agents outside these plugin ecosystems, including Cursor, aren't installed by this workflow.
Re-running setup refreshes content managed by the Microsoft Learn CLI.
Remove agent discovery
To remove managed discovery files without changing unrelated agent configuration, run:
mslearn remove --cli
mslearn remove --cli --copilot
mslearn remove --cli --claude --codex --project
Without an explicit agent target, the remove command detects only discovery artifacts managed by the Microsoft Learn CLI.
Compare CLI-first and MCP-first integrations
| Mode | Installation | Agent behavior |
|---|---|---|
| Standalone CLI-first | Install or run the npm package, and then use mslearn setup --cli with an optional agent target. |
Detected or selected agents invoke the standalone CLI through npx when Learn MCP tools aren't available. No MCP configuration is added. |
| Repository plugin, MCP-first | Install the repository plugin for GitHub Copilot, Claude Code, or Codex. | The plugin supplies the Microsoft Learn MCP endpoint and MCP-oriented skills. |
When both integrations are installed, agents should prefer the Microsoft Learn MCP tools and use the standalone CLI skill only as a fallback.
Use CLI commands
The following examples show the available commands:
mslearn search "azure functions timeout"
mslearn fetch "https://learn.microsoft.com/azure/azure-functions/functions-versions"
mslearn fetch "https://learn.microsoft.com/azure/azure-functions/functions-versions" --section "Function app timeout duration"
mslearn fetch "https://learn.microsoft.com/azure/azure-functions/functions-versions" --max-chars 3000
mslearn code-search "cosmos db change feed processor"
mslearn code-search "cosmos db change feed processor" --language csharp
mslearn doctor
mslearn doctor --format json
The CLI supports these commands and options:
search <query> [--json]searches official Microsoft documentation.fetch <url>fetches a Learn page as Markdown-friendly output.fetch <url> --section <heading>returns a single section.fetch <url> --max-chars <number>truncates the output.code-search <query> --language <name> [--json]searches official code samples.doctor [--format text|json]checks the runtime and MCP server connectivity.setup --cli [--copilot|--claude|--codex] [--project]detects agents or installs discovery for explicit targets.remove --cli [--copilot|--claude|--codex] [--project]detects and removes only managed discovery content.
The search and code-search commands return human-readable text by default. Use --json to return the raw JSON response for processing with other command-line tools:
mslearn search "azure functions" --json | jq ".results[].title"
mslearn code-search "BlobServiceClient" --language python --json
Configure the endpoint
To use a different endpoint, set the MSLEARN_ENDPOINT environment variable or pass --endpoint <url> for an individual command.
For example, in PowerShell:
$env:MSLEARN_ENDPOINT = "https://learn.microsoft.com/api/mcp"
mslearn doctor
Next steps
To learn more about the Microsoft Learn MCP Server, visit the following articles:
- Get started with the Microsoft Learn MCP Server
- Learn MCP Server repository for source code, comments, and questions.