Domain 4 of 4 · Chapter 3 of 5

Building an MCP Server with FastMCP

Unlock the complete study guide + 1,040 practice questions across 16 full exams.

Bundled into the existing Designing, Deploying and Managing Network Automation Systems premium course — no separate purchase.

14-day money-back guarantee — no questions asked.

Included in this chapter:

  • MCP: one protocol, any tool
  • Three primitives: tools act, resources read
  • Standing up a FastMCP server
  • Defining a tool: the decorator wires it up
  • Resources and prompts: read-only data and templates
  • Choosing a transport: stdio local, HTTP remote
  • Reading the stem: exam patterns and traps

MCP primitives: tool vs resource vs prompt

AspectToolResourcePrompt
What it isModel-invoked actionRead-only data sourceReusable message template
Who controls itThe model calls itThe application supplies itThe user selects it
Side effectsPossible (it acts)None (GET-like read)None (returns text)
FastMCP decorator@mcp.tool@mcp.resource("uri")@mcp.prompt
JSON-RPC methodtools/callresources/readprompts/get
Net-automation exampleget_interface_status()device://{hostname}/statustroubleshoot_interface

Decision tree

Perform an action (side effect)?the agent DOES somethingTool@mcp.toolRead-only data to fetch?the agent reads contextResource@mcp.resourceReusable user template?a canned instructionPrompt@mcp.promptPlain functionnot an MCP primitiveYesYesYesNoNoNo

Cheat sheet

  • MCP standardizes how agents connect to tools and data
  • MCP defines host, client, and server roles
  • MCP messages are JSON-RPC 2.0 over a transport
  • MCP servers expose tools, resources, and prompts
  • Create a FastMCP server object
  • mcp.run() starts the server on stdio by default
  • FastMCP registers capabilities via decorators, not a manifest
  • A FastMCP tool returns ordinary Python objects
  • FastMCP tools may be async
  • @mcp.tool registers a function as an agent tool
  • Tool name comes from the function, description from the docstring
  • Type hints generate the tool's input schema
  • A tool can request a Context parameter
  • Example: exposing device interface status as a tool
  • @mcp.resource exposes read-only data at a URI
  • Resources are read-only data; tools are invokable actions
  • Resource URI templates bind path segments to parameters
  • @mcp.prompt registers a reusable prompt template
  • stdio is the default local transport
  • Use HTTP transport for a remote server
  • Transport is selected at run time without changing tool code

Unlock with Premium — includes all practice exams and the complete study guide.

References

  1. Model Context Protocol — Architecture overview
  2. FastMCP — Welcome / Getting Started
  3. FastMCP — Running Your Server (transports)
  4. FastMCP — Tools
  5. FastMCP — Context
  6. FastMCP — Resources & Templates
  7. FastMCP — Prompts