What is a tool in MCP, and how does a server expose one?

4 minbeginnermcptoolsfundamentals

Quick Answer

A tool is a named, executable function a server exposes so the LLM can decide to call it — think "send an email," "run a SQL query," or "create a GitHub issue." A server exposes tools by responding to tools/list with an array of tool definitions, each with a name, a human/model-readable description, and an inputSchema (JSON Schema) describing its arguments. The host fetches this list, converts it into whatever format its LLM's function-calling API expects, and the model decides at runtime whether and how to call it. Actual execution happens through a separate tools/call request naming the tool and supplying arguments matching its schema.

Detailed Answer

Tools are the primitive most people mean when they say "MCP lets the model do things."

Minimal tool definition

{
  "name": "get_weather",
  "description": "Get current weather for a given city.",
  "inputSchema": {
    "type": "object",
    "properties": {
      "city": { "type": "string", "description": "City name, e.g. 'Austin'" }
    },
    "required": ["city"]
  }
}

Server-side implementation (Python SDK example)

from mcp.server.fastmcp import FastMCP

mcp = FastMCP("weather-server")

@mcp.tool()
def get_weather(city: str) -> str:
    """Get current weather for a given city."""
    data = fetch_weather(city)
    return f"{city}: {data.temp_f}F, {data.condition}"

The SDK derives the JSON Schema from the function signature and docstring automatically, and exposes it through tools/list without you hand-writing the schema.

The two-step flow

  1. Discovery: client calls tools/list, gets back every tool's name/description/schema. This, and nothing else, is what the model has to decide when to use a tool.
  2. Invocation: the model decides to use one, the host issues tools/call with {"name": "get_weather", "arguments": {"city": "Austin"}}, and the server executes the actual function, returning a CallToolResult.

Related Resources