Learning by Patrik

Integrate MCP tools with Azure AI agents | AI-103 | Episode 9

Model Context Protocol (MCP) standardizes how AI agents discover and invoke external tools. An MCP server publishes its available tools; an MCP client discovers them and makes them usable by an agent.

Remote MCP — direct integration

If the MCP server is remotely accessible, it can be registered directly with the Foundry agent using MCPTool.

# Define the remote MCP server
mcp_tool = MCPTool(
    server_label="docs",
    server_url="https://.../mcp",
    require_approval="always"
)

# Give it to the agent
agent = project_client.agents.create_version(
    ...,
    tools=[mcp_tool]
)

The agent can discover and use tools from that server. If approval is required:

for item in response.output:
    if item.type == "mcp_approval_request":
        approval = McpApprovalResponse(
            approval_request_id=item.id,
            approve=True
        )

💡 Key point: Remote MCP can be registered directly with the agent. Approval can provide a control point before a requested MCP tool is executed.

Local MCP — your application is the bridge

A cloud-hosted agent cannot directly reach an MCP server running on your machine. Your application therefore connects to the server as the MCP client.

# MCP SERVER — expose tools
@mcp.tool()
def get_inventory(product):
    return ...

# MCP CLIENT — discover & call tools
session = ClientSession(...)

tools = await session.list_tools()
result = await session.call_tool(...)

# AGENT — expose tools as functions
agent_tool = FunctionTool(...)

💡 Key point: Local MCP requires your application to perform the MCP communication. The discovered tools are exposed to the agent as FunctionTools.

How to remember it

Ask one question: Can the agent reach the MCP server directly?

Remote MCP: Yes → register it with MCPTool.
Agent → MCPTool → Remote MCP Server

Local MCP: No → your application bridges the connection.
Agent → FunctionTool → Your App → Local MCP Server

⭐ In short: Remote = agent talks to MCP directly. Local = your application acts as the bridge.

MCP
Agents
Azure
Foundry
Tools

Comments