Skip to content

Conversation

heyitsaamir
Copy link
Collaborator

@heyitsaamir heyitsaamir commented Sep 3, 2025

Adds support for MCP clients in an MCP plugin. Makes use of the AI plugin system introduced in #121 .

  • Added new MCP package (packages/mcp/) with AI plugin and transport functionality
  • Updated chat prompt handling for MCP integration

This is roughly how the system works:

sequenceDiagram
      participant U as User
      participant CP as ChatPrompt
      participant P as MCP Plugin
      participant MCP as MCP Server
      participant M as AI Model

      U->>CP: send(input)

      CP->>P: on_build_functions(functions)
      P->>MCP: get_available_tools()
      MCP-->>P: tool_definitions
      P-->>CP: functions + mcp_tools

      CP->>M: generate_text(input, system, functions)

      alt Model calls MCP tool
          M-->>CP: function_call(mcp_tool, params)
          CP-->>M: function_result
      end

      M-->>CP: response
      CP-->>U: ChatSendResult
Loading

PR Dependency Tree

This tree was auto-generated by Charcoal

heyitsaamir added a commit that referenced this pull request Sep 3, 2025
1. Initializes an AI package (should we call it ai-core?)
2. Initializes some protocols for AI Models
3. Created ChatPrompt class
4. Built the models for Openai/AzureOpenai chat-completions
5. Add ai-test to test functionality
6. (Also added an "Agent" class that's basically ChatPrompt, but more
"stateful". ChatPrompt is stateless, but "Agent" isn't). Thinking
through if I like this approach or not.










#### PR Dependency Tree


* **PR #119** 👈
  * **PR #120**
    * **PR #121**
      * **PR #123**

This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)
@heyitsaamir heyitsaamir marked this pull request as ready for review September 4, 2025 04:43
@heyitsaamir heyitsaamir mentioned this pull request Sep 4, 2025
heyitsaamir added a commit that referenced this pull request Sep 4, 2025
Add support for OpenAI Responses API.
1. Adds a new OpenAI Model to itneract with Responses API
2. Move completions to its own file
3. Responses has a stateful and a stateless API. In this PR i have
support for both. (not streaming yet tho)
4. Responses stateful, required me to save the last message from the
model, so i had to make some minor changes to the ListStorage api.
















#### PR Dependency Tree


* **PR #120** 👈
  * **PR #121**
    * **PR #123**
      * **PR #126**

This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)
heyitsaamir added a commit that referenced this pull request Sep 4, 2025
Adds lifecycle methods for ChatPrompt which add support for AI Plugins.
This is needed to add plugins to augment the operation of the chat
prompt.













#### PR Dependency Tree


* **PR #121** 👈
  * **PR #123**
    * **PR #126**

This tree was auto-generated by
[Charcoal](https://github.com/danerwilliams/charcoal)
Base automatically changed from aamirj/aiplugins to main September 4, 2025 17:59
@heyitsaamir heyitsaamir requested a review from lilyydu September 4, 2025 22:15
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we offer this in external instead of packages?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmmm, good point. i think that's a good idea

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, idk, the external thing seems like overkill to me now. I say let's keep it in packages. Simpler to maintain. Thoughts?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @aacebo had it as external cause it's not apart of our 'core' offerings - that makes more sense to me, and easier to deal with if it eventually gets removed/deprecated/revised into a diff concept, etc

@Copilot Copilot AI review requested due to automatic review settings September 5, 2025 05:49
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds MCP (Model Context Protocol) client plugin support to the Teams AI SDK, enabling integration with MCP servers for enhanced AI agent capabilities.

  • Introduces a new MCP package with client plugin functionality for connecting to MCP servers
  • Updates function handling system to support both Pydantic models and raw JSON schemas
  • Refactors chat prompt function building to integrate plugin system architecture

Reviewed Changes

Copilot reviewed 14 out of 17 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/mcp/ Core MCP package with AI plugin and transport layer for MCP server communication
packages/openai/ Updated OpenAI models to handle flexible function schemas and improved function argument parsing
packages/ai/ Enhanced Function type to accept dict schemas and improved plugin integration in ChatPrompt
tests/mcp/ Test application demonstrating MCP client integration with Azure OpenAI
Configuration files Updated project configuration to include new MCP package

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

from microsoft.teams.common.logging import ConsoleLogger
from pydantic import BaseModel

from mcp import ClientSession
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: move external imports to top (mb we can add this into ruff?)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me do this in a separate PR. I'll run import reordering across all files

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://docs.astral.sh/ruff/settings/#lint_isort_sections going to use this (just so i remember)

self.refetch_timeout_ms = refetch_timeout_ms


class McpClientPlugin(BaseAIPlugin):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could we add a few tests for these files?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah good idea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants