Skip to content

Commit f146a68

Browse files
Copilotheyitsaamir
andcommitted
Address feedback: Add ChatPrompt, functions, MCP server/client, A2A server/client examples and docs links
Co-authored-by: heyitsaamir <[email protected]>
1 parent 5c21554 commit f146a68

File tree

4 files changed

+84
-17
lines changed

4 files changed

+84
-17
lines changed

packages/a2aprotocol/README.md

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,44 @@ uv add microsoft-teams-a2a
2424

2525
## Usage
2626

27+
### A2A Server (Expose Agent)
28+
2729
```python
2830
from microsoft.teams.apps import App
2931
from microsoft.teams.a2a import A2APlugin, A2APluginOptions
3032
from a2a.types import AgentCard
3133

3234
app = App()
3335

36+
# Expose your Teams agent via A2A protocol
3437
agent_card = AgentCard(
3538
name="My Agent",
3639
description="A helpful agent",
3740
capabilities={}
3841
)
3942

40-
a2a_plugin = A2APlugin(A2APluginOptions(agent_card=agent_card))
41-
app.use(a2a_plugin)
43+
a2a_server = A2APlugin(A2APluginOptions(agent_card=agent_card))
44+
app.use(a2a_server)
45+
```
46+
47+
### A2A Client (Use Other Agents)
48+
49+
```python
50+
from microsoft.teams.a2a import A2AClientPlugin, A2APluginUseParams
51+
from microsoft.teams.ai import ChatPrompt
52+
from microsoft.teams.openai import OpenAICompletionsAIModel
53+
54+
model = OpenAICompletionsAIModel(api_key="your-api-key", model="gpt-4")
55+
56+
# Connect to another A2A agent
57+
a2a_client = A2AClientPlugin()
58+
a2a_client.on_use_plugin(
59+
A2APluginUseParams(
60+
key="weather-agent",
61+
base_url="http://localhost:4000/a2a",
62+
card_url=".well-known/agent-card.json"
63+
)
64+
)
65+
66+
prompt = ChatPrompt(model, plugins=[a2a_client])
4267
```

packages/ai/README.md

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212
AI-powered conversational experiences for Microsoft Teams applications.
1313
Provides prompt management, action planning, and model integration for building intelligent Teams bots.
1414

15-
<a href="https://microsoft.github.io/teams-ai" target="_blank">
16-
<img src="https://img.shields.io/badge/📖 Getting Started-blue?style=for-the-badge" />
17-
</a>
15+
[📖 Documentation](https://microsoft.github.io/teams-ai/python/in-depth-guides/ai/)
1816

1917
## Installation
2018

@@ -24,15 +22,39 @@ uv add microsoft-teams-ai
2422

2523
## Usage
2624

25+
### ChatPrompt
26+
2727
```python
28-
from microsoft.teams.ai import Agent
28+
from microsoft.teams.ai import ChatPrompt, Function
2929
from microsoft.teams.openai import OpenAICompletionsAIModel
30+
from pydantic import BaseModel
3031

3132
model = OpenAICompletionsAIModel(api_key="your-api-key", model="gpt-4")
32-
agent = Agent(model=model)
3333

34-
result = await agent.send(
34+
# Create a ChatPrompt
35+
prompt = ChatPrompt(model)
36+
37+
result = await prompt.send(
3538
input="Hello!",
3639
instructions="You are a helpful assistant."
3740
)
41+
```
42+
43+
### Function Calling
44+
45+
```python
46+
class GetWeatherParams(BaseModel):
47+
location: str
48+
49+
async def get_weather(params: GetWeatherParams) -> str:
50+
return f"The weather in {params.location} is sunny"
51+
52+
weather_function = Function(
53+
name="get_weather",
54+
description="Get weather for a location",
55+
parameter_schema=GetWeatherParams,
56+
handler=get_weather
57+
)
58+
59+
prompt = ChatPrompt(model, functions=[weather_function])
3860
```

packages/devtools/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@
1414

1515
Developer tools for locally testing and debugging Teams applications. Streamlines the development process by eliminating the need to deploy apps or expose public endpoints during development.
1616

17-
<a href="https://microsoft.github.io/teams-ai" target="_blank">
18-
<img src="https://img.shields.io/badge/📖 Getting Started-blue?style=for-the-badge" />
19-
</a>
17+
[📖 Documentation](https://microsoft.github.io/teams-ai/developer-tools/devtools/)
2018

2119
## Installation
2220

packages/mcpplugin/README.md

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@
1010
</p>
1111

1212
Model Context Protocol (MCP) integration for Microsoft Teams AI applications.
13-
Enables Teams bots to use MCP servers as tools and resources.
13+
Enables Teams bots to both expose tools as MCP servers and use MCP servers as clients.
1414

15-
<a href="https://microsoft.github.io/teams-ai" target="_blank">
16-
<img src="https://img.shields.io/badge/📖 Getting Started-blue?style=for-the-badge" />
17-
</a>
15+
[📖 Documentation](https://microsoft.github.io/teams-ai/python/in-depth-guides/ai/mcp/)
1816

1917
## Installation
2018

@@ -24,16 +22,40 @@ uv add microsoft-teams-mcpplugin
2422

2523
## Usage
2624

25+
### MCP Client (Use MCP Servers)
26+
2727
```python
2828
from microsoft.teams.apps import App
2929
from microsoft.teams.mcpplugin import McpClientPlugin
3030

3131
app = App()
3232

33-
mcp_plugin = McpClientPlugin(
33+
# Connect to an MCP server
34+
mcp_client = McpClientPlugin(
3435
server_command="uvx",
3536
server_args=["mcp-server-time"]
3637
)
3738

38-
app.use(mcp_plugin)
39+
app.use(mcp_client)
40+
```
41+
42+
### MCP Server (Expose Tools)
43+
44+
```python
45+
from microsoft.teams.apps import App
46+
from microsoft.teams.mcpplugin import McpServerPlugin
47+
from microsoft.teams.ai import Function
48+
from pydantic import BaseModel
49+
50+
app = App()
51+
52+
class EchoParams(BaseModel):
53+
message: str
54+
55+
async def echo_handler(params: EchoParams) -> str:
56+
return f"Echo: {params.message}"
57+
58+
# Expose app as MCP server
59+
mcp_server = McpServerPlugin(name="my-mcp-server")
60+
app.use(mcp_server)
3961
```

0 commit comments

Comments
 (0)