liveBook · Manning

MCP server

As explained in Hugging Face in Action

An MCP server is a software service that implements the Model Context Protocol to expose data or executable capabilities to AI assistants and clients.

An MCP server is a standard application that implements the Model Context Protocol, connecting AI clients to external data and executable capabilities through a common interface. Clients communicate with servers using JSON-RPC 2.0, while services may expose tools, resources, and prompts. section 13.1.2 section 13.5

Use the three server components for different kinds of interaction:

  • Tools provide executable functions, such as searching the web, reading files, fetching weather, converting temperatures, or generating images. section 13.1.4
  • Resources expose external data, including local files, web pages, and database records, for the AI to retrieve and analyze. section 13.1.4
  • Prompts provide predefined templates for standardized LLM interactions. section 13.1.4

Choose deployment and transport according to the client arrangement:

  • Run locally beside the client and communicate through standard input and output streams. section 13.1.3
  • Run remotely on another machine, using HTTP POST from the client and server-sent events for responses; this supports multiple clients. section 13.1.3

Minimal Python server

Install the official SDK and supporting packages with `uv add "mcp[cli]" httpx PyMuPDF`, then create `server.py`:\n\n`from mcp.server.fastmcp import FastMCP\nimport httpx\nimport fitz\nimport os\n\nmcp = FastMCP("MCP Demo")\n\nif __name__ == "__main__":\n mcp.run(transport='stdio')`\n\nRun it with `uv run server.py`. A server can then be extended with resources, tools, and prompts. section 13.2.3 section 13.2.4

Validate and integrate the server with practical workflows:

  • Use the MCP Inspector to list resources, resource templates, prompts, and tools, then execute functions such as `fetch_weather`, `get_pdf`, `convert_temperature`, and `get_text`. section 13.2.9
  • Connect the server to Claude Desktop, which can use custom or prebuilt MCP servers for filesystem access, web search, coding, content creation, and data analysis. section 13.3
  • Keep credentials outside source code by reading `OPENWEATHER_API_KEY` from an environment variable and supplying it through the client configuration. section 13.3.5
Figure 13.3 How an MCP client communicates with an MCP server
A diagram of a service communication system

AI-generated content may be incorrect.

Trace the relationship between an MCP client and server before examining the server’s services. section 13.1.2

How Hugging Face in Action covers it

How deep it goes
Explains components, JSON-RPC communication, transports, Python construction, testing, configuration, and client integration without deeper protocol internals.
Examples
Demonstrates weather retrieval, file and PDF access, temperature conversion, prompts, location lookup, and Claude Desktop workflows.
What it assumes
Assumes basic application development and command-line setup while teaching MCP architecture, components, deployment, and integration directly.
What you can do after
Build an MCP server in Python, validate it with MCP Inspector, configure it for Claude Desktop, and connect third-party servers.
How it connects
Connects Model Context Protocol with JSON-RPC 2.0, AI assistants, tools, resources, prompts, APIs, and server-sent events.

Also explained in

Compare how 12 books explain MCP server →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Hugging Face in Action. The section links point to the parts of the book it draws on.