lab / agent framework mcp

Agent Framework: MCP Servers

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

Contents

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.
AIAgent MCP client MCP server Your tools

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:

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:

References

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

An unhandled error has occurred. Reload ๐Ÿ—™

Reconnecting… Still reconnecting… Connection lost Session paused Session expired

The connection to the server dropped. This usually only takes a moment.

No answer yet. Trying again in 0s.

Couldn't reach the server. Check your connection, then try again.

This tab sat idle, so the server set the session aside. Pick up where you left off.

The server no longer has this session. Reload the page to start fresh.