Discover how to build an MCP (Model Context Protocol) server by wrapping Microsoft Learn’s API for enhanced AI-powered search capabilities. This guide walks you through creating tools for free-text search, filters, and topic-based queries, integrating with Visual Studio Code for seamless testing and usage. Unique :

Building an MCP Server for Microsoft Learn: A Developer’s Guide
If you’re deep into AI apps or developer tools, Microsoft Learn is a goldmine. It offers tons of filtered search options, making it perfect for wrapping into an MCP server. But what exactly is MCP? Let’s break it down.
What’s New: Understanding MCP and Its Potential
MCP stands for Model Context Protocol, a fresh standard for building AI applications. It bundles features like prompts, tools, and resources into a shareable format. This means you can run MCP servers locally or remotely, then connect them with agentic clients like Visual Studio Code or Claude Desktop to create powerful AI agents.
“Because it’s a standard, you can easily share these features with others.”
In this project, we “wrap” Microsoft Learn’s API to build an MCP server that supports keyword searches, filters, and topic-based queries. This lets you tap into Microsoft Learn’s vast training content programmatically.
Major Updates: Building the Server and Tools
The server uses Server-Sent Events (SSE) for simple HTTP-based interaction. The core code leverages FastMCP and Starlette frameworks to create an MCP server with three main tools:
- learn_filter: Retrieves search filters like roles, products, and levels.
- free_text: Performs keyword-based searches across Microsoft Learn content.
- topic_search: Searches content by specific categories and topics.
Each tool calls the Microsoft Learn API, processes JSON responses, and returns structured data models using Pydantic. For example, the Filter
model captures filter type, value, and count, while the Result
model handles search results with titles, URLs, and summaries.
Sample Code Snippet
from mcp.server.fastmcp import FastMCP
from starlette.applications import Starlette
from starlette.routing import Mount
mcp = FastMCP("Microsoft Learn Search", "0.0")
@mcp.tool()
def free_text(query: str) -> list[Result]:
# Implementation calls Microsoft Learn API
pass
app = Starlette(routes=[Mount('/', app=mcp.sse_app())])
What’s Important to Know: Testing and Running Your MCP Server
Testing is straightforward with Visual Studio Code’s Agent mode. Just create a mcp.json
file pointing to your local server and start it using Uvicorn:
uvicorn server:app
Once running, you can interact with the server via VS Code’s search box. For instance, type “Do a free text search on JavaScript, use a tool” and watch the server fetch results live from Microsoft Learn.
“Congrats, if you’ve done all the steps so far, you’ve managed to build an MCP server and solve a very practical problem.”
Summary
This project showcases how to wrap a rich API like Microsoft Learn into an MCP server, making it agentic and easily accessible. It’s a practical way to leverage AI standards and developer tools for enhanced learning and automation.
Ready to dive deeper? Check out the full repo and start experimenting with MCP servers yourself!
From the Microsoft Developer Community Blog articles