Skip to main content
MCP (Model Context Protocol) is a protocol for exposing tools and resources to AI agents. Read more here.

Basic MCP Usage

This example is available on GitHub: examples/01_standalone_sdk/07_mcp_integration.py
Here’s an example integrating MCP servers with an agent:
examples/01_standalone_sdk/07_mcp_integration.py
Running the Example

MCP Configuration

Configure MCP servers using a dictionary with server names and connection details following this configuration format

Tool Filtering

Use filter_tools_regex to control which MCP tools are available to the agent

MCP with OAuth

This example is available on GitHub: examples/01_standalone_sdk/08_mcp_with_oauth.py
For MCP servers requiring OAuth authentication:
examples/01_standalone_sdk/08_mcp_with_oauth.py
Running the Example

OAuth Configuration

  • Configure OAuth-enabled MCP servers by specifying the URL and auth type
  • The SDK automatically handles the OAuth flow when first connecting
  • When the agent first attempts to use an OAuth-protected MCP server’s tools, the SDK initiates the OAuth flow via FastMCP
  • User will be prompted to authenticate
  • Access tokens are securely stored and automatically refreshed by FastMCP as needed

Next Steps