|
| 1 | +# Microsoft Agent 365 Tooling Extensions - Agent Framework |
| 2 | +[](https://badge.fury.io/py/microsoft-agents-a365-tooling-extensions-agentframework) |
| 3 | + |
| 4 | +Agent Framework integration tools and MCP tool registration services for AI agent applications built with the Microsoft Agent 365 SDK. Provides specialized tooling for integrating MCP (Model Context Protocol) servers with Agent Framework agents and projects. |
| 5 | + |
| 6 | +## What is this? |
| 7 | + |
| 8 | +This library is part of the Microsoft Agent 365 SDK for Python - a comprehensive framework for building enterprise-grade conversational AI agents. The Agent Framework tooling extensions specifically provide integration with Microsoft Agent Framework, enabling seamless registration and management of MCP tool servers within the Agent Framework ecosystem. |
| 9 | + |
| 10 | +## Key Features |
| 11 | + |
| 12 | +✅ **Agent Framework Integration** - Native integration with Microsoft Agent Framework |
| 13 | +✅ **MCP Tool Registration** - Automatic registration of MCP servers with Agent Framework agents |
| 14 | +✅ **Azure Identity Support** - Built-in Azure authentication with DefaultAzureCredential |
| 15 | +✅ **Tool Resource Management** - Comprehensive management of tool definitions and resources |
| 16 | +✅ **Multi-Environment Support** - Support for development and production deployment scenarios |
| 17 | +✅ **Enterprise Ready** - Production-grade tooling for Agent Framework-based agent deployments |
| 18 | + |
| 19 | +## Installation |
| 20 | + |
| 21 | +```bash |
| 22 | +pip install microsoft-agents-a365-tooling-extensions-agentframework |
| 23 | +``` |
| 24 | + |
| 25 | +### Prerequisites |
| 26 | + |
| 27 | +The Agent Framework tooling extensions require the Agent Framework Core package: |
| 28 | + |
| 29 | +```bash |
| 30 | +# Core Agent Framework (includes Azure OpenAI and OpenAI support by default) |
| 31 | +# also includes workflows and orchestrations |
| 32 | +pip install agent-framework-core --pre |
| 33 | +``` |
| 34 | + |
| 35 | +**Optional Agent Framework packages:** |
| 36 | +```bash |
| 37 | +# Core + Azure AI integration |
| 38 | +pip install agent-framework-azure-ai --pre |
| 39 | + |
| 40 | +# Core + Microsoft Copilot Studio integration |
| 41 | +pip install agent-framework-copilotstudio --pre |
| 42 | + |
| 43 | +# Core + both Microsoft Copilot Studio and Azure AI integration |
| 44 | +pip install agent-framework-microsoft agent-framework-azure-ai --pre |
| 45 | +``` |
| 46 | + |
| 47 | +## Quick Start |
| 48 | + |
| 49 | +### Basic Concepts |
| 50 | + |
| 51 | +The Microsoft Agent 365 Agent Framework Tooling Extensions enable seamless integration between MCP tool servers and Agent Framework agents. Key concepts include: |
| 52 | + |
| 53 | +- **MCP Tool Registration**: Automatic registration of tool definitions with Agent Framework |
| 54 | +- **Agent Resource Management**: Management of agent resources and configurations |
| 55 | +- **Tool Discovery**: Dynamic discovery and registration of available tools |
| 56 | +- **Service Integration**: Integration with various service providers and backends |
| 57 | + |
| 58 | +### Basic Usage |
| 59 | + |
| 60 | +```python |
| 61 | +import asyncio |
| 62 | +from agent_framework import ChatAgent |
| 63 | +from agent_framework.azure import AzureOpenAIChatClient |
| 64 | +from microsoft_agents_a365.tooling.extensions.agentframework import ( |
| 65 | + McpToolRegistrationService, |
| 66 | +) |
| 67 | + |
| 68 | +async def main(): |
| 69 | + # Initialize the MCP tool registration service |
| 70 | + service = McpToolRegistrationService() |
| 71 | + |
| 72 | + # Create Azure OpenAI chat client |
| 73 | + chat_client = AzureOpenAIChatClient( |
| 74 | + api_key='', |
| 75 | + endpoint='', |
| 76 | + deployment_name='', |
| 77 | + api_version='', |
| 78 | + ) |
| 79 | + |
| 80 | + # Create agent with MCP tools from all configured servers |
| 81 | + agent = await service.add_tool_servers_to_agent( |
| 82 | + chat_client=chat_client, |
| 83 | + agent_instructions="You are a helpful assistant that can provide weather and restaurant information.", |
| 84 | + initial_tools=[], # Your existing tools |
| 85 | + agent_user_id="user-123", |
| 86 | + environment_id="prod", |
| 87 | + auth_token="your-auth-token" |
| 88 | + ) |
| 89 | + |
| 90 | +if __name__ == "__main__": |
| 91 | + asyncio.run(main()) |
| 92 | +``` |
| 93 | + |
| 94 | +### Advanced Configuration |
| 95 | + |
| 96 | +```python |
| 97 | +import asyncio |
| 98 | +from agent_framework import ChatAgent |
| 99 | +from agent_framework.azure import AzureOpenAIChatClient |
| 100 | +from microsoft_agents_a365.tooling.extensions.agentframework import ( |
| 101 | + McpToolRegistrationService, |
| 102 | +) |
| 103 | + |
| 104 | +async def main(): |
| 105 | + # Initialize with custom logger and credentials |
| 106 | + import logging |
| 107 | + from azure.identity import DefaultAzureCredential |
| 108 | + |
| 109 | + logger = logging.getLogger("my-agent") |
| 110 | + credential = DefaultAzureCredential() |
| 111 | + |
| 112 | + service = McpToolRegistrationService( |
| 113 | + logger=logger, |
| 114 | + credential=credential |
| 115 | + ) |
| 116 | + |
| 117 | + # Create Azure OpenAI chat client |
| 118 | + chat_client = AzureOpenAIChatClient( |
| 119 | + api_key='', |
| 120 | + endpoint='', |
| 121 | + deployment_name='', |
| 122 | + api_version='', |
| 123 | + ) |
| 124 | + |
| 125 | + # Define existing tools (if any) |
| 126 | + existing_tools = [ |
| 127 | + # Your existing tools go here |
| 128 | + ] |
| 129 | + |
| 130 | + # Create agent with comprehensive instructions and all MCP tools |
| 131 | + agent = await service.add_tool_servers_to_agent( |
| 132 | + chat_client=chat_client, |
| 133 | + agent_instructions=""" |
| 134 | + You are a helpful AI assistant with access to various tools and services. |
| 135 | + |
| 136 | + Guidelines: |
| 137 | + 1) Always be helpful and accurate |
| 138 | + 2) Use available tools when appropriate to provide better assistance |
| 139 | + 3) Explain your reasoning when using tools |
| 140 | + |
| 141 | + You have access to MCP (Model Context Protocol) tools that are automatically |
| 142 | + loaded from configured servers. Use these tools to enhance your capabilities. |
| 143 | + """, |
| 144 | + initial_tools=existing_tools, |
| 145 | + agent_user_id="user-123", |
| 146 | + environment_id="production", |
| 147 | + auth_token="your-auth-token" |
| 148 | + ) |
| 149 | + |
| 150 | + # The agent now has all MCP tools from configured servers |
| 151 | + print(f"Agent created with {len(agent.tools)} total tools") |
| 152 | + |
| 153 | +if __name__ == "__main__": |
| 154 | + asyncio.run(main()) |
| 155 | +``` |
| 156 | + |
| 157 | +## Configuration |
| 158 | + |
| 159 | +The library supports various configuration options through environment variables: |
| 160 | + |
| 161 | +- `AGENT_FRAMEWORK_ENDPOINT`: The Agent Framework endpoint URL |
| 162 | +- `AGENT_FRAMEWORK_API_KEY`: API key for Agent Framework authentication |
| 163 | +- `MCP_TOOLS_DIRECTORY`: Directory containing MCP tool definitions |
| 164 | +- `AGENT_ENVIRONMENT`: Deployment environment (development, staging, production) |
| 165 | + |
| 166 | +## Agent Framework Integration |
| 167 | + |
| 168 | +This library provides deep integration with Microsoft Agent Framework using the `ChatAgent` pattern: |
| 169 | + |
| 170 | +### MCP Tool Server Registration |
| 171 | + |
| 172 | +Automatically register MCP tools from all configured servers with your Agent Framework agents: |
| 173 | + |
| 174 | +```python |
| 175 | +from agent_framework import ChatAgent |
| 176 | +from agent_framework.azure import AzureOpenAIChatClient |
| 177 | +from microsoft_agents_a365.tooling.extensions.agentframework import ( |
| 178 | + McpToolRegistrationService, |
| 179 | +) |
| 180 | + |
| 181 | +service = McpToolRegistrationService() |
| 182 | + |
| 183 | +# Create Azure OpenAI chat client |
| 184 | +chat_client = AzureOpenAIChatClient( |
| 185 | + api_key='', |
| 186 | + endpoint='', |
| 187 | + deployment_name='', |
| 188 | + api_version='', |
| 189 | +) |
| 190 | + |
| 191 | +# Register all MCP tools from configured servers |
| 192 | +agent = await service.add_tool_servers_to_agent( |
| 193 | + chat_client=chat_client, |
| 194 | + agent_instructions="You are a helpful assistant with access to various tools.", |
| 195 | + initial_tools=[], # Your existing tools |
| 196 | + agent_user_id="user-123", |
| 197 | + environment_id="prod", |
| 198 | + auth_token="your-token" |
| 199 | +) |
| 200 | +``` |
| 201 | + |
| 202 | +### How It Works |
| 203 | + |
| 204 | +The `add_tool_servers_to_agent` method: |
| 205 | + |
| 206 | +1. **Discovers MCP Servers**: Uses the MCP server configuration service to find all configured servers |
| 207 | +2. **Retrieves Tools**: Connects to each server and retrieves available tool definitions |
| 208 | +3. **Combines Tools**: Merges your existing tools with the MCP tools |
| 209 | +4. **Creates New Agent**: Returns a new `ChatAgent` instance with all tools configured |
| 210 | + |
| 211 | +### Agent Configuration |
| 212 | + |
| 213 | +Configure agents with different chat clients: |
| 214 | + |
| 215 | +```python |
| 216 | +# Using Azure OpenAI (recommended) |
| 217 | +from agent_framework.azure import AzureOpenAIChatClient |
| 218 | + |
| 219 | +chat_client = AzureOpenAIChatClient( |
| 220 | + api_key='', |
| 221 | + endpoint='', |
| 222 | + deployment_name='', |
| 223 | + api_version='', |
| 224 | +) |
| 225 | + |
| 226 | +# Alternative: Using OpenAI directly |
| 227 | +from agent_framework.openai import OpenAIChatClient |
| 228 | +chat_client = OpenAIChatClient() |
| 229 | +``` |
| 230 | + |
| 231 | +## Development |
| 232 | + |
| 233 | +### Prerequisites |
| 234 | + |
| 235 | +- Python 3.11 or higher |
| 236 | +- Agent Framework Core SDK (`agent-framework-core`) |
| 237 | +- Azure Identity (for authentication) |
| 238 | + |
| 239 | +### Development Setup |
| 240 | + |
| 241 | +1. Clone the repository |
| 242 | +2. Install development dependencies: |
| 243 | + ```bash |
| 244 | + pip install -e ".[dev]" |
| 245 | + ``` |
| 246 | +3. Run tests: |
| 247 | + ```bash |
| 248 | + pytest |
| 249 | + ``` |
| 250 | + |
| 251 | +### Code Style |
| 252 | + |
| 253 | +This project uses: |
| 254 | +- **Black** for code formatting |
| 255 | +- **Ruff** for linting |
| 256 | +- **MyPy** for type checking |
| 257 | + |
| 258 | +Run the formatter and linter: |
| 259 | +```bash |
| 260 | +black microsoft_agents_a365/ |
| 261 | +ruff check microsoft_agents_a365/ |
| 262 | +mypy microsoft_agents_a365/ |
| 263 | +``` |
| 264 | + |
| 265 | +## Contributing |
| 266 | + |
| 267 | +We welcome contributions! Please see our [Contributing Guide](../../CONTRIBUTING.md) for details. |
| 268 | + |
| 269 | +## License |
| 270 | + |
| 271 | +This project is licensed under the MIT License. See the [LICENSE](../../LICENSE.md) file for details. |
| 272 | + |
| 273 | +## Support |
| 274 | + |
| 275 | +For support and questions: |
| 276 | +- File issues on [GitHub Issues](https://github.com/microsoft/Agent365/issues) |
| 277 | +- Check the [documentation](https://github.com/microsoft/Agent365/tree/main/python) |
| 278 | +- Join the community discussions |
| 279 | + |
| 280 | +## Related Libraries |
| 281 | + |
| 282 | +This library is part of the Microsoft Agent 365 SDK ecosystem: |
| 283 | + |
| 284 | +- `microsoft-agents-a365-runtime` - Core runtime and utilities |
| 285 | +- `microsoft-agents-a365-tooling` - Base tooling framework |
| 286 | +- `microsoft-agents-a365-tooling-extensions-openai` - OpenAI integration |
| 287 | +- `microsoft-agents-a365-tooling-extensions-semantickernel` - Semantic Kernel integration |
| 288 | +- `microsoft-agents-a365-observability-core` - Observability and monitoring |
0 commit comments