Looking to build a modern, scalable MCP server on Azure? This repository is a great starting point. It demonstrates deploying an MCP server with Azure Container Apps and includes three example clients, each using a different agent framework to interact with the server.
Authors: Joel Borellis, Mohamad Al Jazaery, Hwasu Kim, Kira Soderstrom
Github Link
This repository is a great starting point. It demonstrates deploying an MCP server with Azure Container Apps and includes three example clients, each using a different agent framework to interact with the server.
What’s Inside
- MCP Server with Sport News Tools
The sample server, built using the fastmcp package, exposes tools like “Get NFL News”. It supports API key authentication and is designed to be easily extended with additional tools or data sources. You can run it locally or deploy it to Azure Container Apps for scalable, cloud-native hosting.
- Three Client Samples
Each example demonstrates how different agent frameworks can consume tools from the MCP server. All the examples use Azure-OpenAI as a chat client:
-
- OpenAI Agents SDK
azure_openai_client = await get_azure_openai_client() agent = Agent( name="Assistant", instructions=INSTRUCTIONS, model=OpenAIResponsesModel( model=os.getenv("AZURE_OPENAI_DEPLOYMENT_NAME"), openai_client=azure_openai_client, ), mcp_servers=[mcp_server], model_settings=ModelSettings(tool_choice="required"), )
- Autogen
news_server_params = StreamableHttpServerParams( url=os.getenv("MCP_URL"), headers={ "x-api-key": os.getenv("MCP_API_KEYS") } ) # Initialize the MCP tool adapter mcp_news_server_tools = await mcp_server_tools(news_server_params) print(f"Tools: {[tool.name for tool in mcp_news_server_tools]}") # Initialize the Azure OpenAI client AZURE_OPENAI_KEY=os.getenv("AZURE_OPENAI_KEY") AZURE_API_VERSION=os.getenv("AZURE_API_VERSION") AZURE_ENDPOINT=os.getenv("AZURE_ENDPOINT") AZURE_OPENAI_DEPLOYMENT_NAME=os.getenv("AZURE_OPENAI_DEPLOYMENT_NAME") az_model_client = AzureOpenAIChatCompletionClient( azure_deployment=AZURE_OPENAI_DEPLOYMENT_NAME, model=AZURE_OPENAI_DEPLOYMENT_NAME, api_version=AZURE_API_VERSION, azure_endpoint=AZURE_ENDPOINT, api_key=AZURE_OPENAI_KEY, # For key-based authentication. ) # Create the agent # # The system message instructs the agent via natural language. agent = AssistantAgent( name="sport_news_agent", model_client=az_model_client, tools=mcp_news_server_tools, system_message="You are a helpful assistant.", reflect_on_tool_use=True, model_client_stream=True, # Enable streaming tokens from the model client. ) result = await agent.run(task="get NFL news")
- Semantic Kernel
# Initialize the kernel kernel = Kernel() # Add an Azure OpenAI service with function calling enabled AZURE_OPENAI_API_KEY = os.getenv("AZURE_OPENAI_KEY") AZURE_OPENAI_ENDPOINT = os.getenv("AZURE_ENDPOINT") AZURE_OPENAI_DEPLOYMENT_NAME = os.getenv("AZURE_OPENAI_DEPLOYMENT_NAME") api_version = os.getenv("AZURE_API_VERSION") chat_service = AzureChatCompletion( service_id="azure_openai", api_key=AZURE_OPENAI_API_KEY, deployment_name=AZURE_OPENAI_DEPLOYMENT_NAME, endpoint=AZURE_OPENAI_ENDPOINT ) kernel.add_service(chat_service) # api key this is to connect to the mcp server # Configure and use the MCP plugin using SSE via async context manager async with MCPStreamableHttpPlugin( name="sport_news_server", url=os.getenv("MCP_URL"), # URL where the MCP SSE server is listening headers={"x-api-key": os.getenv("MCP_API_KEYS")} ) as mcp_plugin: # Register the MCP plugin with the kernel after connecting try: kernel.add_plugin(mcp_plugin, plugin_name="sport_news_server") except Exception as e: print(f"Error: Could not register the MCP plugin: {str(e)}") return settings = OpenAIChatPromptExecutionSettings() settings.function_choice_behavior = FunctionChoiceBehavior.Auto() # Create a chat history with system instructions history = ChatHistory() history.add_system_message( "You are a sport news assistant. " ) # Define a simple chat function chat_function = kernel.add_function( plugin_name="chat", function_name="respond", prompt="{{$chat_history}}" ) # Add the user message to history history.add_user_message("latest news for NFL") # Prepare arguments with history and settings arguments = KernelArguments( chat_history=history, settings=settings ) try: # Stream the response response_chunks = [] async for message in kernel.invoke_stream( chat_function, arguments=arguments ): chunk = message[0] if isinstance(chunk, StreamingChatMessageContent) and chunk.role == AuthorRole.ASSISTANT: print(str(chunk), end="", flush=True) response_chunks.append(chunk) except Exception as e: print(f"\nError: {str(e)}") print("Make sure the MCP Streamable Http server")
- Semantic Kernel
Why Use This MCP Template?
- Cloud-Native Hosting: Deploy the MCP server on Azure Container Apps for scalable, managed infrastructure.
- Framework Flexibility: Start with the agent framework you prefer—Autogen, OpenAI SDK, or Semantic Kernel.
- Secure by Design: API key authentication ensures that only authorized clients can access your tools.
Keywords & Tags:
MCP server deployment, Azure Container Apps, fastmcp package, Azure OpenAI integration, Deploy MCP to cloud, API key authentication MCP, Semantic Kernel MCP server, Autogen agent framework MCP, cloud-native agent tools, Azure, MCPServer, AzureContainerApps, Azure OpenAI, FastMCP, SemanticKernel, Autogen, OpenAIAgents, CloudNative, AIIntegration, APIAuthentication, AgentFramework, ServerlessHosting, scalable MCP infrastructure, serverless container hosting, deploy AI tools with Azure, secure agent tool deployment, MCP client samples, using Azure OpenAI with agents, hosting NLP services on Azure, integrating agents with APIs