Skip to content

Commit f9bb5ee

Browse files
committed
add new language mcp module
1 parent e97468e commit f9bb5ee

14 files changed

Lines changed: 383 additions & 0 deletions
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.develop-text-analysis-agent-language-mcp.introduction
3+
title: Introduction
4+
metadata:
5+
title: Introduction
6+
description: Introduction to developing a text analysis agent with the Azure Language MCP server.
7+
author: ivorb
8+
ms.author: berryivor
9+
ms.date: 03/13/2026
10+
ms.topic: unit
11+
ai-usage: ai-generated
12+
durationInMinutes: 2
13+
content: |
14+
[!include[](includes/01-introduction.md)]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.develop-text-analysis-agent-language-mcp.understand-language-mcp
3+
title: Understand the Azure Language MCP server
4+
metadata:
5+
title: Understand the Azure Language MCP server
6+
description: Learn about the Model Context Protocol and the text analysis capabilities exposed by the Azure Language MCP server.
7+
author: ivorb
8+
ms.author: berryivor
9+
ms.date: 03/13/2026
10+
ms.topic: unit
11+
ai-usage: ai-generated
12+
durationInMinutes: 7
13+
content: |
14+
[!include[](includes/02-understand-language-mcp.md)]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.develop-text-analysis-agent-language-mcp.connect-use-language-mcp
3+
title: Connect and use the Language MCP server with an agent
4+
metadata:
5+
title: Connect and use the Language MCP server with an agent
6+
description: Learn how to connect the Azure Language MCP server to an agent in Microsoft Foundry and build a client application.
7+
author: ivorb
8+
ms.author: berryivor
9+
ms.date: 03/13/2026
10+
ms.topic: unit
11+
ai-usage: ai-generated
12+
durationInMinutes: 8
13+
content: |
14+
[!include[](includes/03-connect-use-language-mcp.md)]
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.develop-text-analysis-agent-language-mcp.exercise
3+
title: Exercise - Develop a text analysis agent
4+
metadata:
5+
title: Exercise - Develop a text analysis agent
6+
description: Use the Azure Language MCP server to create an AI agent that performs text analysis tasks.
7+
author: ivorb
8+
ms.author: berryivor
9+
ms.date: 03/13/2026
10+
ms.topic: unit
11+
ai-usage: ai-generated
12+
durationInMinutes: 30
13+
content: |
14+
[!include[](includes/04-exercise.md)]
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.develop-text-analysis-agent-language-mcp.knowledge-check
3+
title: Knowledge check
4+
metadata:
5+
title: Knowledge check
6+
description: Check your understanding of the Azure Language MCP server and agent integration.
7+
author: ivorb
8+
ms.author: berryivor
9+
ms.date: 03/13/2026
10+
ms.topic: unit
11+
ai-usage: ai-generated
12+
durationInMinutes: 3
13+
quiz:
14+
questions:
15+
- content: "What is the primary role of the Azure Language MCP server?"
16+
choices:
17+
- content: "To train and fine-tune custom language models for use by AI agents."
18+
isCorrect: false
19+
explanation: "Incorrect. The Azure Language MCP server exposes existing Azure Language NLP capabilities as tools for agents; it doesn't train custom models."
20+
- content: "To expose Azure Language text analysis capabilities as MCP tools for agents."
21+
isCorrect: true
22+
explanation: "Correct. The Azure Language MCP server makes NLP capabilities such as entity recognition, sentiment analysis, and summarization available as MCP tools."
23+
- content: "To deploy and manage large language models in an Azure subscription."
24+
isCorrect: false
25+
explanation: "Incorrect. The MCP server provides access to Azure Language NLP capabilities, not model deployment."
26+
- content: "How does an agent determine which Azure Language MCP tool to call when processing a user's prompt?"
27+
choices:
28+
- content: "The developer writes routing logic to direct each prompt to a specific tool."
29+
isCorrect: false
30+
explanation: "Incorrect. The agent selects tools autonomously based on tool descriptions received from the MCP server."
31+
- content: "The agent matches the prompt to tool descriptions received from the MCP server."
32+
isCorrect: true
33+
explanation: "Correct. Through dynamic tool discovery, the agent receives tool descriptions and uses them to determine which tool best matches the user's request."
34+
- content: "The MCP server analyzes the prompt and automatically routes it to a tool."
35+
isCorrect: false
36+
explanation: "Incorrect. The agent (not the MCP server) decides which tool to call based on the tool descriptions."
37+
- content: "When building a Python client application, how do you reference a Foundry agent when calling the OpenAI Responses API?"
38+
choices:
39+
- content: "By passing the agent's API key as a request header to the endpoint."
40+
isCorrect: false
41+
explanation: "Incorrect. The agent is referenced by name in the extra_body parameter, not through an API key header."
42+
- content: "By specifying the agent name in the agent_reference field in extra_body."
43+
isCorrect: true
44+
explanation: "Correct. You include an agent_reference with the agent's name and type in the extra_body parameter of the responses.create() call."
45+
- content: "By passing the agent's endpoint URL as the model parameter value."
46+
isCorrect: false
47+
explanation: "Incorrect. The agent is referenced by name in the extra_body parameter, not as a model endpoint."
48+
- content: "What authentication method is used when connecting the Azure Language MCP server to a Foundry agent?"
49+
choices:
50+
- content: "OAuth 2.0 authentication with a client certificate and tenant ID."
51+
isCorrect: false
52+
explanation: "Incorrect. The connection uses key-based authentication with the Ocp-Apim-Subscription-Key header."
53+
- content: "Key-based authentication using the Ocp-Apim-Subscription-Key credential."
54+
isCorrect: true
55+
explanation: "Correct. The Azure Language MCP server uses key-based authentication, where the resource key is provided in the Ocp-Apim-Subscription-Key header."
56+
- content: "Anonymous access that requires no authentication or credentials."
57+
isCorrect: false
58+
explanation: "Incorrect. Authentication is required to connect to the Azure Language MCP server."
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
### YamlMime:ModuleUnit
2+
uid: learn.wwl.develop-text-analysis-agent-language-mcp.summary
3+
title: Summary
4+
metadata:
5+
title: Summary
6+
description: Summary of developing a text analysis agent with the Azure Language MCP server.
7+
author: ivorb
8+
ms.author: berryivor
9+
ms.date: 03/13/2026
10+
ms.topic: unit
11+
ai-usage: ai-generated
12+
durationInMinutes: 2
13+
content: |
14+
[!include[](includes/06-summary.md)]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Azure Language in Foundry Tools provides a set of natural language processing (NLP) capabilities that you can use to analyze text. These capabilities include sentiment analysis, named entity recognition, key phrase extraction, summarization, and more.
2+
3+
While you can call these capabilities individually through REST APIs or SDKs, you can also make them available to an AI agent through the **Azure Language Model Context Protocol (MCP) server**. This approach lets the agent dynamically select and call the appropriate language tool based on a user's request, without you needing to write specific code for each capability.
4+
5+
For example, suppose you work for a company that needs to analyze customer feedback. Customers submit reviews in multiple languages, and your team needs to understand the overall sentiment, identify the people and places mentioned, and generate summaries of the feedback. Rather than building separate integrations for each of these tasks, you can create an AI agent that uses the Azure Language MCP server to perform all of them through a single tool connection.
6+
7+
In this module, you learn how the Azure Language MCP server works, how to connect it to an AI agent in Microsoft Foundry, and how to build a client application that interacts with the agent programmatically.
8+
9+
> [!NOTE]
10+
> The Azure Language MCP server is currently in public preview. Details described in this module are subject to change.
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
The Azure Language MCP server connects AI agents to Azure Language services through the **Model Context Protocol (MCP)**. Before exploring the Language MCP server itself, it helps to understand what MCP is and how it enables agents to use external tools.
2+
3+
## What is the Model Context Protocol?
4+
5+
The Model Context Protocol (MCP) is an open protocol that defines how AI agents interact with external tools, data sources, and services. MCP uses a client-server architecture with the following components:
6+
7+
- **Host**: The application that runs the agent (such as Microsoft Foundry or a custom app).
8+
- **Client**: A component within the host that manages connections to MCP servers and handles communication.
9+
- **Server**: A program that exposes tools, resources, and prompts that an agent can discover and call.
10+
11+
When an agent connects to an MCP server, it receives a catalog of available tools along with descriptions of what each tool does. The agent can then choose the right tool based on the user's request. This approach is called *dynamic tool discovery* — the agent doesn't need hardcoded knowledge of each tool. Instead, it queries the MCP server at runtime to find out what's available.
12+
13+
The key advantage of MCP for AI agents is flexibility. Tools can be added, updated, or removed on the server without modifying the agent itself. The agent always has access to the latest tool definitions, which makes MCP-based solutions easier to maintain and scale.
14+
15+
> [!TIP]
16+
> To learn more about MCP architecture and how to build custom MCP tool integrations, see the **[Integrate MCP Tools with Azure AI Agents](/training/modules/connect-agent-to-mcp-tools/)** module.
17+
18+
## Azure Language MCP server capabilities
19+
20+
The Azure Language MCP server exposes Azure Language NLP capabilities as tools that any MCP-compatible agent can call. The server supports the following text analysis capabilities:
21+
22+
| Capability | Description |
23+
|---|---|
24+
| **Named Entity Recognition** | Identifies and categorizes entities in text, such as people, places, organizations, dates, and quantities. |
25+
| **Sentiment Analysis** | Determines whether text expresses positive, negative, or neutral sentiment, and can extract opinions about specific aspects. |
26+
| **Summarization** | Generates concise summaries of longer text content. |
27+
| **Key Phrase Extraction** | Identifies the main concepts and key phrases in text. |
28+
| **PII Redaction** | Detects and redacts personally identifiable information such as names, addresses, and phone numbers. |
29+
| **Language Detection** | Identifies the language in which text is written. |
30+
| **Text Analytics for Health** | Extracts and labels medical entities (such as diagnoses, medications, and symptoms) from clinical text. |
31+
| **Conversational Language Understanding** | Interprets user utterances to identify intents and extract entities based on a trained custom model. |
32+
| **Custom Question Answering** | Returns curated answers to user questions from a configured knowledge base. |
33+
34+
When you connect the Language MCP server to an agent, the agent receives the full list of available tools. Based on the user's prompt, the agent's underlying model decides which tool (or combination of tools) to call. For example, if a user asks "Summarize this article and tell me what people are mentioned," the agent might call both the summarization tool and the named entity recognition tool in the same turn.
35+
36+
## How the agent selects tools
37+
38+
The tool selection process works as follows:
39+
40+
1. The user sends a prompt to the agent.
41+
1. The agent analyzes the prompt and determines which task (or tasks) need to be performed.
42+
1. The agent checks the available MCP tools and their descriptions to find the best match.
43+
1. The agent calls the selected tool through the MCP server, passing the relevant input text.
44+
1. The MCP server processes the request using the appropriate Azure Language capability and returns the results.
45+
1. The agent combines the results into a natural language response for the user.
46+
47+
This means you don't need to write routing logic to direct requests to specific tools. The agent handles tool selection autonomously, based on the tool descriptions it received from the MCP server.
48+
49+
## MCP server endpoint
50+
51+
The Azure Language MCP server is available as a remote endpoint with the following URL format:
52+
53+
```
54+
https://{foundry-resource-name}.cognitiveservices.azure.com/language/mcp?api-version=2025-11-15-preview
55+
```
56+
57+
Replace `{foundry-resource-name}` with the name of your Foundry resource (or Azure Language resource). This endpoint is what you configure when connecting the MCP server to your agent.
58+
59+
> [!NOTE]
60+
> Azure Language also provides a local MCP server that you can host in your own environment. For setup guidance, see the [Azure Language MCP Server quickstart](https://github.com/Azure-Samples/ai-language-samples) in the Azure Language samples repository.
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
After you understand the capabilities of the Azure Language MCP server, the next step is to connect it to an agent and start using it. This involves creating an agent in Microsoft Foundry, connecting the Language MCP tool, testing it in the agent playground, and optionally building a client application to interact with the agent programmatically.
2+
3+
## Create a Foundry project and agent
4+
5+
To use the Azure Language MCP server, you first need a Microsoft Foundry project with a deployed model.
6+
7+
1. In the [Microsoft Foundry portal](https://ai.azure.com), create a new project (or use an existing one).
8+
1. Deploy a model (such as **gpt-4.1**) that your agent will use for reasoning and generating responses.
9+
1. Create an agent and give it instructions that describe its purpose. For example:
10+
11+
```
12+
You are an AI agent that assists users by helping them analyze and summarize text.
13+
```
14+
15+
The agent is now ready to receive tool connections.
16+
17+
## Connect the Azure Language MCP server
18+
19+
You connect the Azure Language MCP server to your agent through the **Tools** page in the Foundry portal.
20+
21+
1. In the navigation pane, select the **Tools** page.
22+
1. Select **Connect a tool** and choose **Azure Language in Foundry Tools** from the catalog.
23+
1. Configure the connection with the following settings:
24+
- **Foundry resource name**: The name of your Foundry resource (for example, `myproject-resource`).
25+
- **Authentication**: Key-based.
26+
- **Credential** (`Ocp-Apim-Subscription-Key`): The key for your Foundry project.
27+
28+
1. Wait for the connection to be created, then select **Use in an agent** and choose your agent.
29+
30+
:::image type="content" source="../media/azure-language-tool-catalog.png" alt-text="Screenshot of the Tools catalog in the Foundry portal showing the Azure Language in Foundry Tools connection configuration.":::
31+
32+
The agent now has access to all the text analysis tools exposed by the Azure Language MCP server.
33+
34+
> [!TIP]
35+
> You can find the project key on the project home page in the Foundry portal.
36+
37+
## Update agent instructions
38+
39+
After connecting the Language MCP tool, update the agent's instructions to direct it to use the tool:
40+
41+
```
42+
You are an AI agent that assists users by helping them analyze and summarize text. Use the Azure Language tool to perform text analysis tasks.
43+
```
44+
45+
This instruction helps the agent understand that it should use the connected tool when processing text analysis requests.
46+
47+
## Test in the agent playground
48+
49+
The agent playground in the Foundry portal provides an interactive environment for testing your agent before deploying it in an application.
50+
51+
When you send a prompt that requires text analysis, the agent:
52+
53+
1. Identifies the tasks needed (for example, summarization and entity recognition).
54+
1. Calls the appropriate Azure Language MCP tool(s).
55+
1. Returns a combined response.
56+
57+
The first time the agent uses an MCP tool, you're prompted to **approve** the tool usage. You can approve the tool for a single use, or select **Always approve all Azure Language in Foundry Tools tools** to skip future approval prompts.
58+
59+
After the agent responds, you can review the **Logs** pane to verify which tools were used. The logs show each MCP tool call, the input that was sent, and the result that was returned.
60+
61+
## Build a client application
62+
63+
While the agent playground is useful for testing, you typically want to build a client application that uses the agent programmatically. The Microsoft Foundry SDK supports this through the OpenAI Responses API.
64+
65+
To build a client application, you use the `azure-ai-projects` and `azure-identity` packages. The general pattern is:
66+
67+
1. Create an `AIProjectClient` using your Foundry project endpoint and `DefaultAzureCredential` (which uses your Azure CLI credentials in development).
68+
1. Get an OpenAI client from the project client by calling `get_openai_client()`.
69+
1. Call `responses.create()` to send a user prompt to the agent.
70+
71+
The key part is how you reference the agent — you specify it by name in the `extra_body` parameter:
72+
73+
```python
74+
response = openai_client.responses.create(
75+
input=[{"role": "user", "content": user_prompt}],
76+
extra_body={
77+
"agent_reference": {
78+
"name": "Text-Analysis-Agent",
79+
"type": "agent_reference"
80+
}
81+
},
82+
)
83+
84+
print(response.output_text)
85+
```
86+
87+
The agent processes the prompt, calls the appropriate MCP tools, and returns the result in `output_text`. You can also inspect the full response JSON (using `response.model_dump_json()`) to see which tools the agent called — for example, `extract_named_entities_from_text` or `detect_sentiment_from_text` — along with the arguments and results for each tool call.
88+
89+
### Connect the MCP server in code
90+
91+
Instead of connecting the Azure Language MCP server through the Foundry portal, you can also define the MCP tool connection directly in code when you create an agent. Use the `MCPTool` class from the `azure-ai-projects` SDK to specify the server label, URL, and allowed tools:
92+
93+
```python
94+
from azure.ai.projects.models import MCPTool
95+
96+
mcp_tool = MCPTool(
97+
server_label="azure-language",
98+
server_url="https://{foundry-resource-name}.cognitiveservices.azure.com/language/mcp?api-version=2025-11-15-preview",
99+
require_approval="always",
100+
)
101+
```
102+
103+
You then pass the `mcp_tool` when creating the agent through the SDK. This approach is useful when you want to manage tool connections as part of your application code rather than configuring them manually in the portal. You can also use the `allowed_tools` property on `MCPTool` to restrict which specific Language tools the agent can call.
104+
105+
## Tool selection with multi-task prompts
106+
107+
When a user's prompt involves multiple text analysis tasks, the agent can call multiple tools in a single turn. For example, the prompt:
108+
109+
> "Tell me what entities and dates are mentioned in this review, and whether it is positive or negative."
110+
111+
This prompt requires both entity recognition and sentiment analysis. The agent identifies both tasks, calls the appropriate tools (`extract_named_entities_from_text` and `detect_sentiment_from_text`), and combines the results into a single response.
112+
113+
Each tool call goes through the MCP server independently, and the agent synthesizes the outputs into a coherent answer for the user.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Now it's your turn to build a text analysis agent using the Azure Language MCP server!
2+
3+
In this exercise, you create an AI agent in Microsoft Foundry, connect it to the Azure Language MCP server, test it in the agent playground, and build a Python client application that uses the agent to perform text analysis tasks such as entity recognition, sentiment analysis, and summarization.
4+
5+
> [!NOTE]
6+
> To complete this exercise, you need an **[Azure subscription](https://azure.microsoft.com/pricing/purchase-options/azure-account?cid=msft_learn)** in which you have administrative access.
7+
8+
Launch the exercise and follow the instructions.
9+
10+
[![Button to launch exercise.](../media/launch-exercise.png)](https://go.microsoft.com/fwlink/?linkid=2326052&azure-portal=true)

0 commit comments

Comments
 (0)