Skip to content

Commit fc4002e

Browse files
authored
Merge pull request #160 from ShivamGoyal03/main
Adding case studies on learn mcp
2 parents 25d0685 + 6d2feeb commit fc4002e

17 files changed

+689
-36
lines changed

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,4 +483,9 @@ Thumbs.db
483483

484484
# Environments
485485
.env
486-
.venv
486+
.venv
487+
488+
# Chainlit and related files
489+
.chainlit/
490+
.files/
491+
chainlit.md

09-CaseStudy/README.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,45 @@ This case study demonstrates a practical application of MCP for automating workf
4141

4242
This example illustrates how even relatively simple MCP implementations can provide significant efficiency gains by automating routine tasks and improving data consistency across systems.
4343

44+
### 3. [Real-Time Documentation Retrieval with MCP](./docs-mcp/README.md)
45+
46+
This case study guides you through connecting a Python console client to a Model Context Protocol (MCP) server to retrieve and log real-time, context-aware Microsoft documentation. You'll learn how to:
47+
48+
- Connect to an MCP server using a Python client and the official MCP SDK
49+
- Use streaming HTTP clients for efficient, real-time data retrieval
50+
- Call documentation tools on the server and log responses directly to the console
51+
- Integrate up-to-date Microsoft documentation into your workflow without leaving the terminal
52+
53+
The chapter includes a hands-on assignment, a minimal working code sample, and links to additional resources for deeper learning. See the full walkthrough and code in the linked chapter to understand how MCP can transform documentation access and developer productivity in console-based environments.
54+
55+
### 4. [Interactive Study Plan Generator Web App with MCP](./docs-mcp/README.md)
56+
57+
This case study demonstrates how to build an interactive web application using Chainlit and the Model Context Protocol (MCP) to generate personalized study plans for any topic. Users can specify a subject (such as "AI-900 certification") and a study duration (e.g., 8 weeks), and the app will provide a week-by-week breakdown of recommended content. Chainlit enables a conversational chat interface, making the experience engaging and adaptive.
58+
59+
- Conversational web app powered by Chainlit
60+
- User-driven prompts for topic and duration
61+
- Week-by-week content recommendations using MCP
62+
- Real-time, adaptive responses in a chat interface
63+
64+
The project illustrates how conversational AI and MCP can be combined to create dynamic, user-driven educational tools in a modern web environment.
65+
66+
### 5. [In-Editor Docs with MCP Server in VS Code](./docs-mcp/README.md)
67+
68+
This case study demonstrates how you can bring Microsoft Learn Docs directly into your VS Code environment using the MCP server—no more switching browser tabs! You'll see how to:
69+
70+
- Instantly search and read docs inside VS Code using the MCP panel or command palette
71+
- Reference documentation and insert links directly into your README or course markdown files
72+
- Use GitHub Copilot and MCP together for seamless, AI-powered documentation and code workflows
73+
- Validate and enhance your documentation with real-time feedback and Microsoft-sourced accuracy
74+
- Integrate MCP with GitHub workflows for continuous documentation validation
75+
76+
The implementation includes:
77+
- Example `.vscode/mcp.json` configuration for easy setup
78+
- Screenshot-based walkthroughs of the in-editor experience
79+
- Tips for combining Copilot and MCP for maximum productivity
80+
81+
This scenario is ideal for course authors, documentation writers, and developers who want to stay focused in their editor while working with docs, Copilot, and validation tools—all powered by MCP.
82+
4483
## Conclusion
4584

4685
These case studies highlight the versatility and practical applications of the Model Context Protocol in real-world scenarios. From complex multi-agent systems to targeted automation workflows, MCP provides a standardized way to connect AI systems with the tools and data they need to deliver value.
@@ -52,4 +91,5 @@ By studying these implementations, you can gain insights into architectural patt
5291
- [Azure AI Travel Agents GitHub Repository](https://github.com/Azure-Samples/azure-ai-travel-agents)
5392
- [Azure DevOps MCP Tool](https://github.com/microsoft/azure-devops-mcp)
5493
- [Playwright MCP Tool](https://github.com/microsoft/playwright-mcp)
94+
- [Microsoft Docs MCP Server](https://github.com/MicrosoftDocs/mcp)
5595
- [MCP Community Examples](https://github.com/microsoft/mcp)

09-CaseStudy/docs-mcp/README.md

Lines changed: 181 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,181 @@
1+
# Case Study: Connecting to the Microsoft Learn Docs MCP Server from a Client
2+
3+
Have you ever found yourself juggling between documentation sites, Stack Overflow, and endless search engine tabs, all while trying to solve a problem in your code? Maybe you keep a second monitor just for docs, or you’re constantly alt-tabbing between your IDE and a browser. Wouldn’t it be better if you could bring the documentation right into your workflow—integrated into your apps, your IDE, or even your own custom tools? In this case study, we’ll explore how to do exactly that by connecting directly to the Microsoft Learn Docs MCP server from your own client application.
4+
5+
## Overview
6+
7+
Modern development is more than just writing code—it’s about finding the right information at the right time. Documentation is everywhere, but it’s rarely where you need it most: inside your tools and workflows. By integrating documentation retrieval directly into your applications, you can save time, reduce context switching, and boost productivity. In this section, we’ll show you how to connect a client to the Microsoft Learn Docs MCP server, so you can access real-time, context-aware documentation without ever leaving your app.
8+
9+
We’ll walk through the process of establishing a connection, sending a request, and handling streaming responses efficiently. This approach not only streamlines your workflow but also opens the door to building smarter, more helpful developer tools.
10+
11+
## Learning Objectives
12+
13+
Why are we doing this? Because the best developer experiences are those that remove friction. Imagine a world where your code editor, chatbot, or web app can answer your documentation questions instantly, using the latest content from Microsoft Learn. By the end of this chapter, you’ll know how to:
14+
15+
- Understand the basics of MCP server-client communication for documentation
16+
- Implement a console or web application to connect to the Microsoft Learn Docs MCP server
17+
- Use streaming HTTP clients for real-time documentation retrieval
18+
- Log and interpret documentation responses in your application
19+
20+
You’ll see how these skills can help you build tools that are not just reactive, but truly interactive and context-aware.
21+
22+
## Scenario 1 - Real-Time Documentation Retrieval with MCP
23+
24+
In this scenario, we’ll show you how to connect a client to the Microsoft Learn Docs MCP server, so you can access real-time, context-aware documentation without ever leaving your app.
25+
26+
Let’s put this into practice. Your task is to write an app that connects to the Microsoft Learn Docs MCP server, invokes the `microsoft_docs_search` tool, and logs the streaming response to the console.
27+
28+
### Why this approach?
29+
Because it’s the foundation for building more advanced integrations—whether you want to power a chatbot, an IDE extension, or a web dashboard.
30+
31+
You'll find the code and instructions for this scenario in the [`solution`](./solution/README.md) folder within this case study. The steps will guide you through setting up the connection:
32+
- Use the official MCP SDK and streamable HTTP client for connection
33+
- Call the `microsoft_docs_search` tool with a query parameter to retrieve documentation
34+
- Implement proper logging and error handling
35+
- Create an interactive console interface to allow users to enter multiple search queries
36+
37+
This scenario demonstrates how to:
38+
- Connect to the Docs MCP server
39+
- Send a query
40+
- Parse and print the results
41+
42+
Here’s what running the solution might look like:
43+
44+
```
45+
Prompt> What is Azure Key Vault?
46+
Answer> Azure Key Vault is a cloud service for securely storing and accessing secrets. ...
47+
```
48+
49+
Below is a minimal sample solution. The full code and details are available in the solution folder.
50+
51+
<details>
52+
<summary>Python</summary>
53+
54+
```python
55+
import asyncio
56+
from mcp.client.streamable_http import streamablehttp_client
57+
from mcp import ClientSession
58+
59+
async def main():
60+
async with streamablehttp_client("https://learn.microsoft.com/api/mcp") as (read_stream, write_stream, _):
61+
async with ClientSession(read_stream, write_stream) as session:
62+
await session.initialize()
63+
result = await session.call_tool("microsoft_docs_search", {"query": "Azure Functions best practices"})
64+
print(result.content)
65+
66+
if __name__ == "__main__":
67+
asyncio.run(main())
68+
```
69+
70+
- For the complete implementation and logging, see [`scenario1.py`](./solution/python/scenario1.py).
71+
- For installation and usage instructions, see the [`README.md`](./solution/python/README.md) file in the same folder.
72+
</details>
73+
74+
75+
## Scenario 2 - Interactive Study Plan Generator Web App with MCP
76+
77+
In this scenario, you’ll learn how to integrate Docs MCP into a web development project. The goal is to enable users to search Microsoft Learn documentation directly from a web interface, making documentation instantly accessible within your app or site.
78+
79+
You’ll see how to:
80+
- Set up a web app
81+
- Connect to the Docs MCP server
82+
- Handle user input and display results
83+
84+
Here’s what running the solution might look like:
85+
86+
```
87+
User> I want to learn about AI102 - so suggest the roadmap to get it started from learn for 6 weeks
88+
89+
Assistant> Here’s a detailed 6-week roadmap to start your preparation for the AI-102: Designing and Implementing a Microsoft Azure AI Solution certification, using official Microsoft resources and focusing on exam skills areas:
90+
91+
---
92+
## Week 1: Introduction & Fundamentals
93+
- **Understand the Exam**: Review the [AI-102 exam skills outline](https://learn.microsoft.com/en-us/credentials/certifications/exams/ai-102/).
94+
- **Set up Azure**: Sign up for a free Azure account if you don't have one.
95+
- **Learning Path**: [Introduction to Azure AI services](https://learn.microsoft.com/en-us/training/modules/intro-to-azure-ai/)
96+
- **Focus**: Get familiar with Azure portal, AI capabilities, and necessary tools.
97+
98+
....more weeks of the roadmap...
99+
100+
Let me know if you want module-specific recommendations or need more customized weekly tasks!
101+
```
102+
103+
Below is a minimal sample solution. The full code and details are available in the solution folder.
104+
105+
<details>
106+
<summary>Python (Chainlit)</summary>
107+
108+
Chainlit is a framework for building conversational AI web apps. It makes it easy to create interactive chatbots and assistants that can call MCP tools and display results in real time. It’s ideal for rapid prototyping and user-friendly interfaces.
109+
110+
```python
111+
import chainlit as cl
112+
import requests
113+
114+
MCP_URL = "https://learn.microsoft.com/api/mcp"
115+
116+
@cl.on_message
117+
def handle_message(message):
118+
query = {"question": message}
119+
response = requests.post(MCP_URL, json=query)
120+
if response.ok:
121+
result = response.json()
122+
cl.Message(content=result.get("answer", "No answer found.")).send()
123+
else:
124+
cl.Message(content="Error: " + response.text).send()
125+
```
126+
127+
- For the complete implementation, see [`scenario2.py`](./solution/python/scenario2.py).
128+
- For setup and running instructions, see the [`README.md`](./solution/python/README.md).
129+
</details>
130+
131+
132+
## Scenario 3: In-Editor Docs with MCP Server in VS Code
133+
134+
If you want to get Microsoft Learn Docs directly inside your VS Code (instead of switching browser tabs), you can use the MCP server in your editor. This allows you to:
135+
- Search and read docs in VS Code without leaving your coding environment.
136+
- Reference documentation and insert links directly into your README or course files.
137+
- Leverage GitHub Copilot and MCP together for a seamless, AI-powered documentation workflow.
138+
139+
**You'll see how to:**
140+
- Add a valid `.vscode/mcp.json` file to your workspace root (see example below).
141+
- Open the MCP panel or use the command palette in VS Code to search and insert docs.
142+
- Reference documentation directly in your markdown files as you work.
143+
- Combine this workflow with GitHub Copilot for even greater productivity.
144+
145+
Here’s a example of how to set up the MCP server in VS Code:
146+
147+
```json
148+
{
149+
"servers": {
150+
"LearnDocsMCP": {
151+
"url": "https://learn.microsoft.com/api/mcp"
152+
}
153+
}
154+
}
155+
```
156+
157+
</details>
158+
159+
> For a detailed walkthrough with screenshots and step-by-step guide, see [`README.md`](./solution/scenario3/README.md).
160+
161+
This approach is ideal for anyone building technical courses, writing documentation, or developing code with frequent reference needs.
162+
163+
## Key Takeaways
164+
165+
Integrating documentation directly into your tools isn’t just a convenience—it’s a game changer for productivity. By connecting to the Microsoft Learn Docs MCP server from your client, you can:
166+
167+
- Eliminate context switching between your code and documentation
168+
- Retrieve up-to-date, context-aware docs in real time
169+
- Build smarter, more interactive developer tools
170+
171+
These skills will help you create solutions that are not only efficient, but also delightful to use.
172+
173+
## Additional Resources
174+
175+
To deepen your understanding, explore these official resources:
176+
177+
- [Microsoft Learn Docs MCP Server (GitHub)](https://github.com/MicrosoftDocs/mcp)
178+
- [Get started with Azure MCP Server (mcp-python)](https://learn.microsoft.com/en-us/azure/developer/azure-mcp-server/get-started#create-the-python-app)
179+
- [What is the Azure MCP Server?](https://learn.microsoft.com/en-us/azure/developer/azure-mcp-server/)
180+
- [Model Context Protocol (MCP) Introduction](https://modelcontextprotocol.io/introduction)
181+
- [Add plugins from a MCP Server (Python)](https://learn.microsoft.com/en-us/semantic-kernel/concepts/plugins/adding-mcp-plugins)
23.8 KB
Loading
Loading
Loading
Loading
Loading
Loading
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Here's the solutions for each runtime:
2+
- [Python](./python/README.md)
3+
4+
For in-editor documentation and Copilot integration, see [Scenario 3: In-Editor Docs with MCP Server in VS Code](./scenario3/README.md) (works with any runtime).
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
# Study Plan Generator with Chainlit & Microsoft Learn Docs MCP
2+
3+
## Prerequisites
4+
5+
- Python 3.8 or higher
6+
- pip (Python package manager)
7+
- Internet access to connect to the Microsoft Learn Docs MCP server
8+
9+
## Installation
10+
11+
1. Clone this repository or download the project files.
12+
2. Install the required dependencies:
13+
14+
```bash
15+
pip install -r requirements.txt
16+
```
17+
18+
## Usage
19+
20+
### Scenario 1: Simple Query to Docs MCP
21+
A command-line client that connects to the Docs MCP server, sends a query, and prints the result.
22+
23+
1. Run the script:
24+
```bash
25+
python scenario1.py
26+
```
27+
2. Enter your documentation question at the prompt.
28+
29+
### Scenario 2: Study Plan Generator (Chainlit Web App)
30+
A web-based interface (using Chainlit) that allows users to generate a personalized, week-by-week study plan for any technical topic.
31+
32+
1. Start the Chainlit app:
33+
```bash
34+
chainlit run scenario2.py
35+
```
36+
2. Open the local URL provided in your terminal (e.g., http://localhost:8000) in your browser.
37+
3. In the chat window, enter your study topic and the number of weeks you want to study (e.g., "AI-900 certification, 8 weeks").
38+
4. The app will respond with a week-by-week study plan, including links to relevant Microsoft Learn documentation.
39+
40+
**Environment Variables Required:**
41+
42+
To use Scenario 2 (the Chainlit web app with Azure OpenAI), you must set the following environment variables in a `.env` file in the `python` directory:
43+
44+
```
45+
AZURE_OPENAI_CHAT_DEPLOYMENT_NAME=
46+
AZURE_OPENAI_API_KEY=
47+
AZURE_OPENAI_ENDPOINT=
48+
AZURE_OPENAI_API_VERSION=
49+
```
50+
51+
Fill in these values with your Azure OpenAI resource details before running the app.
52+
53+
> **Tip:** You can easily deploy your own models using [Azure AI Foundry](https://ai.azure.com/).
54+
55+
### Scenario 3: In-Editor Docs with MCP Server in VS Code
56+
57+
Instead of switching browser tabs to search documentation, you can bring Microsoft Learn Docs directly into your VS Code using the MCP server. This enables you to:
58+
- Search and read docs inside VS Code without leaving your coding environment.
59+
- Reference documentation and insert links directly into your README or course files.
60+
- Use GitHub Copilot and MCP together for a seamless, AI-powered documentation workflow.
61+
62+
**Example Use Cases:**
63+
- Quickly add reference links to a README while writing a course or project documentation.
64+
- Use Copilot to generate code and MCP to instantly find and cite relevant docs.
65+
- Stay focused in your editor and boost productivity.
66+
67+
> [!IMPORTANT]
68+
> Ensure you have a valid [`mcp.json`](../scenario3/mcp.json) configuration in your workspace (location is `.vscode/mcp.json`).
69+
70+
## Why Chainlit for Scenario 2?
71+
72+
Chainlit is a modern open-source framework for building conversational web applications. It makes it easy to create chat-based user interfaces that connect to backend services like the Microsoft Learn Docs MCP server. This project uses Chainlit to provide a simple, interactive way to generate personalized study plans in real time. By leveraging Chainlit, you can quickly build and deploy chat-based tools that enhance productivity and learning.
73+
74+
## What This Does
75+
76+
This app allows users to create a personalized study plan by simply entering a topic and a duration. The app parses your input, queries the Microsoft Learn Docs MCP server for relevant content, and organizes the results into a structured, week-by-week plan. Each week’s recommendations are displayed in the chat, making it easy to follow and track your progress. The integration ensures you always get the latest, most relevant learning resources.
77+
78+
## Sample Queries
79+
80+
Try these queries in the chat window to see how the app responds:
81+
82+
- `AI-900 certification, 8 weeks`
83+
- `Learn Azure Functions, 4 weeks`
84+
- `Azure DevOps, 6 weeks`
85+
- `Data engineering on Azure, 10 weeks`
86+
- `Microsoft security fundamentals, 5 weeks`
87+
- `Power Platform, 7 weeks`
88+
- `Azure AI services, 12 weeks`
89+
- `Cloud architecture, 9 weeks`
90+
91+
These examples demonstrate the flexibility of the app for different learning goals and timeframes.
92+
93+
## References
94+
95+
- [Chainlit Documentation](https://docs.chainlit.io/)
96+
- [MCP Documentation](https://github.com/MicrosoftDocs/mcp)
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
chainlit
2+
mcp
3+
semantic-kernel

0 commit comments

Comments
 (0)