MCP: Model Context ProtocolBeginnerModule 05 — Understanding MCP tools
What is an MCP tool?
Question 37 of 43 · Updated
On this page
- Direct answer
- 1. The mental model: an operation rather than an integration
- 2. What makes a tool an MCP tool?
- 3. Anatomy of a tool definition
- 4. Discovery is not execution
- 5. Tools are often model-controlled, not model-owned
- 6. Tool, resource and prompt are different primitives
- 7. Tested Python example: a small tool contract
- Step-by-step explanation
- Deliberate limitations
- 8. Designing a useful operation boundary
- 9. Error handling and observability at the tool boundary
- 10. Practical interview checks and common mistakes
- Interview-ready answer
Direct answer#
An MCP tool is a named, callable capability exposed by a Model Context Protocol server. It describes an operation that a compatible client can discover and invoke using a standardized protocol contract. The operation can retrieve information, perform computation or request a permitted change in an external system.
For example, a shipping server could expose a shipping_quote tool that accepts a destination zone and package weight, then returns a price estimate. The tool is not the language model, the entire MCP server, the HTTP endpoint or a copy of the shipping database. It is the explicit operation contract at the boundary between the client and the server's implementation.
In the historical MCP 2025-06-18 specification, a server advertises the tools capability; clients discover tool definitions through tools/list and invoke a selected tool through tools/call. The server owns execution, input validation and resource-level authorization. A host may let a model propose tool use, but a deterministic application can also call a tool without an LLM.
Learning continuity: Module 05 begins here. Q18 introduced tools alongside resources and prompts as server primitives; Q30 distinguished protocol methods from application operation names; Q39–41 established capability declarations and outbound gating. This lesson focuses specifically on what constitutes a tool: its contract, implementation boundary, invocation semantics and observable business result. Q47–54 develop discovery, calls, schemas, descriptions, content types, structured outputs, annotations and side effects in depth. Q44 remains deferred under the user's authorized source-order exception.
Verification scope: The historical 2025-06-18 specification is the reference baseline under the authorized offline research and changelog exceptions. Official documents could not be retrieved live; no later-revision behavior is claimed. The Python 3.13.5 standard-library example was compiled and actually executed with warnings treated as errors: all nine unittest tests passed, including subtests. It is a local operation-contract fixture, not a full MCP implementation. No real MCP SDK, carrier API or network was used. The MCP SDK and Mermaid CLI were unavailable locally; real interoperability and diagram/frontend rendering remain unverified.
1. The mental model: an operation rather than an integration#
Imagine a commerce assistant helping a customer estimate delivery charges. Without a callable integration, the assistant might only produce a plausible guess. With an approved shipping_quote tool, it can supply the customer's zone and package weight to an authoritative implementation.
The client does not need to know how the shipping service stores its tariffs, which programming language its server uses, or how it queries a carrier. It needs the supported operation contract and a trusted route to that server.
The diagram separates the optional model from actual execution. The host and server enforce their respective policies; the model's proposed arguments do not carry authority. The server's implementation might calculate a quote locally or consult an approved backend. The standardized operation boundary does not require a particular storage or deployment architecture.
A single shipping MCP server could expose multiple tools: shipping_quote, track_shipment and book_shipment. Each is a separate operation with a different input, result and side-effect contract. They should not be collapsed into one arbitrary execute command that accepts unrestricted instructions.
2. What makes a tool an MCP tool?#
A local function is ordinary implementation code. A remote REST endpoint is an application network interface. Neither is automatically an MCP tool just because it can perform work.
An MCP tool is exposed through the applicable MCP tool contract. It has a discoverable identity and input schema, and the server maps the named invocation to its implementation.
| Concept | Example | Responsibility |
|---|---|---|
| Tool family capability | tools: {} | Declares that the server supports the base tool feature |
| Tool definition | shipping_quote and its inputSchema | Describes one callable operation |
| Tool call | tools/call with name and arguments | Requests one invocation |
| Handler | A Python function or service adapter | Implements the operation |
| Backend | Pricing engine, carrier API or database | Supplies authoritative computation or state |
| Tool result | A typed content array | Returns the operation's observable outcome |
The tool descriptor is not executable source code downloaded to the host. A model can see a representation of the operation without gaining access to the server's underlying database or implementation.
A server does not become trustworthy simply because it exposes valid MCP tool definitions. Hosts should enable only approved server relationships and operations. Tool definitions and annotations are external data, not privileged instructions.
3. Anatomy of a tool definition#
Here is an illustrative descriptor using the historical 2025-06-18 tools contract.
JSON{ "name": "shipping_quote", "description": "Estimate shipping in INR for a zone and weight; does not book shipment.", "inputSchema": { "type": "object", "properties": { "zone": { "type": "string", "enum": ["local", "regional"] }, "weight_grams": { "type": "integer", "minimum": 1, "maximum": 5000 } }, "required": ["zone", "weight_grams"], "additionalProperties": false } }
The name identifies the operation on the particular server. A host that connects to two servers should not assume that identical tool names refer to identical business actions. The trusted originating server and operation identity matter.
The description tells the consumer what the operation does, when it is relevant and what it does not do. The description in this example explicitly says that it estimates a price rather than booking a shipment. A model can use that information in selecting a candidate, but it should not override the host's policies or infer additional permissions.
The inputSchema describes the expected JSON arguments. The sample contract requires two named fields, restricts zones to known values, and limits supported weights. In this example the server chooses to reject unknown properties. Not every MCP tool is required to use these particular fields or additionalProperties settings.
The historical tool schema also permits applicable optional metadata such as a human-readable title, annotations and outputSchema. Q49 explains schema design, Q50 description design, Q52 structured output and Q53 annotations. This introduction intentionally uses a small required contract rather than demonstrating all optional features.
Do not confuse the implementation's Python function signature with the published JSON Schema. SDKs may derive a descriptor from typed functions, but the resulting public contract still needs review. A parameter named weight could be ambiguous if its unit is not specified; weight_grams is a clearer business contract.
4. Discovery is not execution#
The following simplified JSON-RPC exchanges assume an initialized historical relationship that advertises tools support and permits the requested operation.
A client can request the catalog:
JSON{"jsonrpc":"2.0","id":1,"method":"tools/list"}
The server returns the available tool descriptors in result.tools, possibly with a pagination cursor. The shipping_quote descriptor above could be one member of that array.
Discovery does not invoke shipping_quote or prove that the current actor may use every discovered operation. The server may expose only a limited catalog, and authorization may depend on individual input values and current business state.
Once the appropriate tool is selected, a client can send an invocation:
JSON{ "jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": { "name": "shipping_quote", "arguments": { "zone": "local", "weight_grams": 500 } } }
Notice that the JSON-RPC method is tools/call; shipping_quote is the application tool name. The ID identifies this particular exchange, not the tool definition or a durable business operation. Q29 and Q30 already established those distinctions.
An illustrative matching successful result is:
JSON{ "jsonrpc": "2.0", "id": 2, "result": { "content": [ { "type": "text", "text": "{\"currency\":\"INR\",\"amount_paise\":5000,\"estimate_only\":true}" } ] } }
In this fictional pricing example, the estimate is 50 INR. The outer result contains MCP typed content; the text block contains serialized business data. JSON encoded inside a text block is still text content, not the historical structuredContent field. Q51–52 cover richer content and explicit structured results.
The result does not prove that a shipment was booked. The business contract deliberately returns an estimate only. A caller must not convert an estimate into a receipt or claim the user has been charged.
The diagram omits initialization already covered in Module 04. The model, when used, proposes a candidate to the host; it does not directly gain the server's credentials. The server independently enforces its own execution policy.
5. Tools are often model-controlled, not model-owned#
The historical MCP tools interaction pattern is often described as model-controlled. That means tools can be selected by a model based on the user's task and the exposed operation descriptions. It does not mean that the model itself executes the server code, controls all server permissions or must approve its own actions.
A normal application can use a tool in three different ways:
| Invocation style | Example |
|---|---|
| Model-assisted | The model proposes shipping_quote after reading the customer's question |
| Deterministic | A checkout workflow calls shipping_quote after validating package details |
| Human-initiated | A user presses a button to calculate an estimate |
All three can use the same server-side operation contract. The host must decide whether the requested action is authorized and appropriate; the client handles the protocol exchange; the server executes the approved operation under its own policy. Q13 established that MCP does not require an LLM.
For a model-assisted workflow, expose a suitable subset of the approved catalog. Treat model output as a proposed name and argument object. Resolve it against trusted routing metadata, validate the actual inputs and enforce approval where needed.
Do not pass arbitrary credentials or unrestricted destination URLs as model-selected tool arguments. The actor identity and authorization context should originate from trusted application mechanisms rather than a model declaring itself an administrator.
6. Tool, resource and prompt are different primitives#
A beginner may ask why a shipping estimate should be a tool rather than a resource or prompt.
| Primitive | Main question | Example |
|---|---|---|
| Tool | What operation can I invoke with these arguments? | Calculate a shipping estimate |
| Resource | What identified information can I retrieve? | Read a published tariff document |
| Prompt | What reusable message template can I obtain? | Retrieve a template for explaining shipping policies |
Tools can return information and therefore do not have to mutate state. Resources can be dynamically generated, so the distinction is not simply static versus dynamic data. Choose the interaction contract that best matches the task.
In this example, a tariff document could be a resource, while the operation of estimating a charge for a specified zone and weight is naturally a tool. A reusable explanatory template might be a prompt. The host can combine those primitives without treating one as a substitute for another.
Q55–74 develop these distinctions and combined workflows further. The present learning objective is to recognize the callable operation boundary.
7. Tested Python example: a small tool contract#
The following executable example represents a shipping_quote descriptor and its underlying callable operation. It uses fictional tariffs: 40 INR base for local shipping, 70 INR for regional shipping, plus 10 INR for each started block of 500 grams. The integer amount is returned in paise to avoid floating-point currency rounding. These are invented training values, not actual carrier prices.
The invoke function models resolving a known tool name, checking a trusted permission decision, executing its handler and returning text content. It does not implement a network server or complete tools/call request handling. Save as mcp_q45.py.
PYTHONimport json import unittest DESCRIPTOR = { 'name': 'shipping_quote', 'description': 'Estimate shipping in INR for a zone and weight; does not book shipment.', 'inputSchema': { 'type': 'object', 'properties': { 'zone': {'type': 'string', 'enum': ['local', 'regional']}, 'weight_grams': {'type': 'integer', 'minimum': 1, 'maximum': 5000}, }, 'required': ['zone', 'weight_grams'], 'additionalProperties': False, }, } def quote(args): if type(args) is not dict or set(args) != {'zone', 'weight_grams'}: raise ValueError('invalid arguments') zone, weight = args['zone'], args['weight_grams'] if type(zone) is not str or zone not in ('local', 'regional'): raise ValueError('invalid zone') if type(weight) is not int or not 1 <= weight <= 5000: raise ValueError('invalid weight') base = {'local': 4000, 'regional': 7000}[zone] blocks = (weight + 499) // 500 return {'currency': 'INR', 'amount_paise': base + 1000 * blocks, 'estimate_only': True} def invoke(name, args, permitted): if name != DESCRIPTOR['name']: raise LookupError('unknown tool') if permitted is not True: raise PermissionError('denied') result = quote(args) return {'content': [{'type': 'text', 'text': json.dumps(result)}]} class Tests(unittest.TestCase): def test_local_quote(self): self.assertEqual(quote({'zone': 'local', 'weight_grams': 500}), {'currency': 'INR', 'amount_paise': 5000, 'estimate_only': True}) def test_round_up(self): self.assertEqual(quote({'zone': 'local', 'weight_grams': 501})['amount_paise'], 6000) def test_regional(self): self.assertEqual(quote({'zone': 'regional', 'weight_grams': 5000})['amount_paise'], 17000) def test_missing_extra_and_wrong_shape(self): for args in ({}, {'zone': 'local', 'weight_grams': 1, 'book': True}, []): with self.subTest(args=args), self.assertRaises(ValueError): quote(args) def test_invalid_weight(self): for weight in (True, 0, 5001, 1.5, '500'): with self.subTest(weight=weight), self.assertRaises(ValueError): quote({'zone': 'local', 'weight_grams': weight}) def test_invalid_zone(self): for zone in ('other', []): with self.subTest(zone=zone), self.assertRaises(ValueError): quote({'zone': zone, 'weight_grams': 500}) def test_unknown_tool(self): with self.assertRaises(LookupError): invoke('book_shipment', {}, True) def test_denied(self): with self.assertRaises(PermissionError): invoke('shipping_quote', {'zone': 'local', 'weight_grams': 500}, False) def test_content_contract(self): args = {'zone': 'regional', 'weight_grams': 1} result = invoke('shipping_quote', args, True) self.assertEqual(result['content'][0]['type'], 'text') self.assertEqual(json.loads(result['content'][0]['text']), quote(args)) if __name__ == '__main__': unittest.main(verbosity=2)
Run:
BASHpython -m py_compile mcp_q45.py python -W error mcp_q45.py
Actual local output summary on Python 3.13.5:
Ran 9 tests in 0.001s
OKStep-by-step explanation#
The descriptor is a declarative description of the operation. quote is the local business implementation. invoke is the small adapter that accepts a known name, checks the supplied permission decision, executes the operation and represents the result as a text content block.
The calculation rounds weight upward into started 500-gram blocks using integer arithmetic. At 500 grams, a local quote consists of a 4000-paise base plus 1000 paise, totaling 5000 paise. At 501 grams it uses two blocks, totaling 6000 paise. The maximum 5000-gram regional example uses ten blocks and totals 17000 paise.
The tests verify ordinary pricing, boundary rounding, upper supported weight, malformed inputs, unauthorized use, unknown names and the output representation. The validation rejects Python booleans as weights even though bool is a subclass of int. Invalid extra properties cannot silently turn an estimate into a booking.
Deliberate limitations#
This is not an official SDK server or JSON Schema engine. The manually coded validator is narrower than a full JSON Schema validator: in particular, it requires a Python int, whereas JSON Schema integer can include an integral-valued JSON number such as 1.0. The local fixture rejects that representation. A real implementation should align advertised schema semantics with the chosen runtime validator and document any additional constraints.
The permission flag is a trusted fixture input, not an authentication mechanism or proof of actor authority. Exceptions are local test outcomes, not actual JSON-RPC errors or MCP isError results. There is no initialize exchange, tools/list handler, transport, real authorization, downstream API, outputSchema validation or booking. The example emits the content fragment, not a full correlated JSON-RPC response.
No real carrier rates were fetched and no shipment was created. The tests establish the local contract and calculation, not live protocol conformance. Use a compatible SDK and test real discovery, invocation and failure mapping before deployment. Q97–104 cover SDK implementation and testing.
8. Designing a useful operation boundary#
The value of an MCP tool is not that every internal function becomes a remotely callable operation. The tool should represent a meaningful, constrained task.
For the commerce workflow, consider separating the following:
| Tool | Input contract | Business effect |
|---|---|---|
| shipping_quote | Zone, weight and supported service options | Returns an estimate |
| track_shipment | Approved tracking reference | Returns a shipment status |
| book_shipment | Validated destination, service and approved quote reference | May create a shipment and incur charges |
A quote can be used to help a user decide. A booking changes business state, so it needs a separate authority and approval boundary. Even if both call the same carrier API, combining them under an unrestricted instruction parameter would make validation and policy enforcement harder.
Choose stable names, clear units, explicit required fields and bounded input sizes. Describe what the result means, including uncertainty or expiry. A real pricing tool might return a tariff version, timestamp and expiry time so an old estimate is not mistaken for a guaranteed current charge.
Avoid embedding the carrier's private credentials in the descriptor. Keep implementation details behind the server boundary. If the carrier switches APIs, a compatible tool contract can remain stable while the handler adapts. When semantics change incompatibly, use an appropriate versioning and migration plan rather than silently changing the operation's meaning.
This introductory design guidance sets up Q54 on side effects and Q254 on business-oriented tool design, without prescribing a full authorization or idempotency implementation.
9. Error handling and observability at the tool boundary#
A tool can fail even when the protocol relationship is healthy. A malformed request, unsupported operation, invalid business argument, denied permission, downstream timeout and rejected business action belong to different failure categories.
The historical tool result can include isError to communicate an applicable tool execution error; protocol-level failures use their relevant JSON-RPC error semantics. Exact mapping depends on the applicable specification and actual failure. Q31 and Q166–168 develop those distinctions.
A host should not treat every successful JSON-RPC result as proof of a successful business action. For instance, an accepted quote is not a booked shipment. A timed-out booking might have committed despite the absent receipt. Report uncertain outcomes and reconcile through the authorized business contract.
Record controlled diagnostics such as the originating tool name and server, latency, validation outcome, authorization outcome and business status. Avoid dumping private shipment addresses, tokens or payment details into logs. Do not pass arbitrary server-returned text into trusted system instructions.
The operation boundary is also a useful place to apply quotas, deadlines and concurrency limits. The shipping-quote example uses a constant-size calculation; that tells us nothing about the latency or scalability of a real carrier API. Test actual execution under expected load.
10. Practical interview checks and common mistakes#
| Misconception | Correct mental model |
|---|---|
| An MCP tool is an AI model | It is a callable operation exposed by a server |
| Every REST endpoint is automatically a tool | The server must expose the appropriate MCP contract |
| tools capability contains the full catalog | It declares family support; discovery returns descriptors |
| Tool name is a JSON-RPC method | tools/call is the method; name identifies the operation |
| Discovering a tool executes it | Discovery and invocation are separate |
| A tool must change external state | Tools may retrieve data or compute results |
| A model can authorize its own tool calls | Authorization is independent of model selection |
| Tool descriptions prove safety | Descriptions and annotations are external claims |
| A successful quote is a successful booking | Business result semantics must be interpreted correctly |
When interviewing, explain a concrete operation before diving into framework syntax. Identify the contract, the actual server implementation, the consumer's input, the resulting business evidence and the authorization boundary. Then describe how an MCP client discovers and invokes that contract. This demonstrates that MCP standardizes integration rather than replacing application logic.
Interview-ready answer#
An MCP tool is a named, discoverable and callable operation exposed by an MCP server through a standardized contract. It has an input schema and can return information, perform computation or initiate an authorized side effect. In the historical 2025-06-18 revision, a compatible client discovers tools using tools/list and invokes an operation using tools/call with its name and arguments. The server owns the handler and its authorization and validation logic. A model can propose a tool call, but an LLM is not required and discovery does not grant permission. Tool results must be interpreted according to their actual business semantics.
Next lesson: Q47 explains how tools/list advertises the actual descriptors and paginated discovery results, how the client builds its trusted catalog and how discovery differs from capability declaration.
References
- 1.MCP historical specification (2025-06-18)modelcontextprotocol.io
- 2.MCP tools (2025-06-18)modelcontextprotocol.io
- 3.MCP resources (2025-06-18)modelcontextprotocol.io
- 4.MCP prompts (2025-06-18)modelcontextprotocol.io
- 5.MCP lifecycle (2025-06-18)modelcontextprotocol.io
- 6.MCP base protocol (2025-06-18)modelcontextprotocol.io
- 7.JSON-RPC 2.0 specificationjsonrpc.org
- 8.JSON Schema numeric typesjson-schema.org
- 9.Official MCP Python SDKgithub.com
- 10.Python unittest documentationdocs.python.org
Related questions
Explore other topics:Forward Deployed EngineeringAI AgentsLarge Language ModelsRetrieval-Augmented Generation