Agent Framework: MCP Servers

The general shape of MCP servers and clients in the Agent Framework - hosting tools and calling them.

Table of Contents

Hosting a Server

Consuming a Server

MCP (Model Context Protocol) is a standard way for an AI agent to discover and call tools exposed by a server. It's the flip side of the chat examples: instead of the model just producing text, it can decide to invoke a named, described operation and use the result.
This page is intentionally conceptual, not a walkthrough of any specific server. Exposing tools over MCP means granting a caller the ability to invoke real code - treat every tool like a public API endpoint: authenticate the caller, scope what it's allowed to do, and validate everything server-side, the same as you would for any other network-facing surface.

Hosting an MCP Server (Shape)

A class marked [McpServerToolType], with methods marked [McpServerTool] and a [Description], becomes a set of tools an agent can discover and call. Registration and mounting generally look like this:

Loading Monaco Editor...

In practice you'd put real authentication (not just an authorization filter comment) and rate limiting in front of the mounted endpoint before exposing it beyond your own process.

Consuming an MCP Server from an AIAgent

The other side of the protocol is an AIAgent that discovers tools from a remote MCP server and lets the model call them autonomously - the Agent Framework accepts MCP-discovered tools as regular AITools on ChatOptions:

Loading Monaco Editor...

References

For more detailed information and advanced scenarios, check out these helpful resources:

Model Context Protocol

The protocol spec: tools, resources, prompts, and transports.

MCP C# SDK

ModelContextProtocol.Server / ModelContextProtocol.Client, the packages an ASP.NET Core MCP server is built on.

Microsoft Agent Framework overview

Includes how AIAgent tool-calling and MCP tool integration fit together.
An unhandled error has occurred. Reload 🗙