Skip to content

Latest commit

 

History

History
101 lines (70 loc) · 3.89 KB

File metadata and controls

101 lines (70 loc) · 3.89 KB

Simple Calculator - FastMCP

Complexity: 🟢 Beginner

This example demonstrates how to run the NVIDIA NeMo Agent Toolkit as an MCP server using the FastMCP server runtime and use those tools from a Model Context Protocol (MCP) client workflow.

This example mirrors the simple_calculator_mcp workflow, but it uses the FastMCP server command and defaults to port 9902. The FastMCP server integration comes from nvidia-nat-fastmcp, and the MCP client commands and configuration use nvidia-nat-mcp.

Prerequisites

  • Agent toolkit: Ensure you have the NVIDIA NeMo Agent Toolkit installed. If you have not already done so, follow the instructions in the Install Guide to create the development environment and install the toolkit.
  • Base workflow: This example builds upon the Getting Started Simple Calculator example. Make sure you are familiar with the example before proceeding.

Installation and Setup

If you have not already done so, follow the instructions in the Install Guide to create the development environment and install the toolkit.

Install this Workflow

Install this example:

uv pip install -e examples/MCP/simple_calculator_fastmcp

Run the Workflow

  1. Start the MCP server using the FastMCP server runtime:
nat fastmcp server run --config_file examples/getting_started/simple_calculator/configs/config.yml

This starts an MCP server on port 9902 with endpoint /mcp and uses streamable-http transport.

  1. Inspect the tools available on the MCP server using the MCP client:
nat mcp client tool list --url http://localhost:9902/mcp

Sample output:

calculator__add
calculator__subtract
calculator__multiply
calculator__divide
calculator__compare
  1. Run the workflow:

If you installed this example using uv pip install -e examples/MCP/simple_calculator_fastmcp, the mcp-server-time dependency is already available. If you did not install the example package, install it manually:

uv pip install mcp-server-time
nat run --config_file examples/MCP/simple_calculator_fastmcp/configs/config-mcp-client.yml --input "Is the product of 2 * 4 greater than the current hour of the day?"

The client configuration is in examples/MCP/simple_calculator_fastmcp/configs/config-mcp-client.yml.

Expose Selected Tools

To expose only specific tools from the workflow, use --tool_names when starting the server:

nat fastmcp server run --config_file examples/getting_started/simple_calculator/configs/config.yml \
  --tool_names calculator__multiply \
  --tool_names calculator__divide

Related Examples

  • examples/MCP/simple_calculator_fastmcp_protected/: Protected FastMCP calculator example

References

  • FastMCP Server - Learn about running the FastMCP server runtime
  • MCP Client - Learn about using the MCP client to interact with the MCP server