MCP: Model Context ProtocolBeginnerModule 03 — MCP messages and JSON-RPC
How are method names and parameters represented in MCP?
Question 24 of 43 · Updated
On this page
- Direct answer
- 1. A method name identifies a protocol contract
- 2. Protocol method versus application capability name
- 3. Params objects are method-specific contracts
- 4. Required, optional, absent and null are different
- Defaults and explicit values
- 5. Three nested contracts in one tool invocation
- 6. Resource and prompt parameters are not tool arguments
- Read a resource
- Retrieve a prompt
- Invoke a tool
- 7. Metadata belongs to the protocol boundary
- 8. Capability-dependent method availability
- 9. Safe dispatch: choose handlers explicitly
- 10. Extensibility and compatibility
- 11. Tested implementation: select the method contract before dispatch
- What the checks establish
- Deliberate limitations
- 12. Practical debugging and common mistakes
- Interview-ready answer
Direct answer#
MCP represents a protocol operation using a case-sensitive JSON-RPC method string and, when the operation needs input, a method-specific params object. The method selects the protocol operation; the parameters supply the values required by that operation. For a tool invocation, the protocol method is tools/call, while params.name identifies the advertised tool and params.arguments contains that tool's application-specific inputs.
For example, a client can request a stock lookup after establishing the appropriate lifecycle and capability state:
JSON{ "jsonrpc": "2.0", "id": "stock-21", "method": "tools/call", "params": { "name": "stock", "arguments": {"sku": "A12"} } }
The receiving implementation selects the tools/call handler using the exact method name, validates the method's parameter contract, resolves the registered stock tool, validates its arguments and checks the actor's authority before execution.
MCP method names are not automatically generated from tool names, HTTP paths or programming-language function names. They are protocol identifiers defined by the applicable specification or a supported extension.
Learning continuity: Q26 explained the outer request envelope; Q27–29 covered responses, notifications and identifiers. Q30 concentrates on the relationship between method selection, method-specific parameters and handler dispatch. Q31 covers error representation, Q32 separates protocol and business payloads, Q33 covers comprehensive incoming-message validation, and Q41 covers capability gating in depth. Q48–49 and Q102 develop tool invocation and argument schemas. Q280 covers extensibility in detail.
Verification scope: Prepared under the authorized offline research and changelog exceptions. The historical MCP 2025-06-18 specification is used as a reference baseline, not claimed to be the latest revision. Official references were not checked live. The standard-library Python example was syntax-compiled and executed locally on Python 3.13.5: all 18 checks passed (6 accepted, 12 rejected). The MCP SDK and Mermaid package were unavailable; actual SDK/transport interoperability and Mermaid parser/frontend rendering remain unverified. The example works on decoded method names and parameter objects rather than implementing JSON-RPC or an actual MCP server.
1. A method name identifies a protocol contract#
Think of a method name as a label for a defined operation and its input/output contract. A receiver must know what the method means, who may send it, under what lifecycle and capability conditions it is available, and what its result or error represents.
The following method names illustrate the historical protocol's operation families:
| Method | Purpose | Typical requestor |
|---|---|---|
| initialize | Establish compatible protocol behavior | Client |
| ping | Check responsiveness | Either participant |
| tools/list | Discover tools | Client |
| tools/call | Invoke a named tool | Client |
| resources/list | Discover resources | Client |
| resources/read | Read an identified resource | Client |
| prompts/list | Discover prompts | Client |
| prompts/get | Retrieve a named prompt | Client |
| roots/list | Retrieve supported client-provided roots | Server |
| sampling/createMessage | Request supported model generation | Server |
| elicitation/create | Request supported structured user input | Server |
This is an orientation to the 2025-06-18 baseline, not a complete registry or unconditional permission matrix. Server-to-client operations have their own capability and application-policy requirements. The actual availability of a method depends on the compatible revision and implementation.
Notice that related methods often share a slash-separated operation family, such as tools/list and tools/call. Some lifecycle and utility methods, such as initialize and ping, do not have that pattern. Slash-separated names are a convention used by many MCP methods; they are not an instruction to interpret every string as a filesystem path, HTTP URL or dynamically callable object.
A receiver should compare the exact method name. Tools/List, tools.list and /tools/list are not interchangeable with tools/list merely because they look similar. In generic JSON-RPC, names beginning with rpc. are reserved for RPC-internal methods.
2. Protocol method versus application capability name#
Suppose the retailer's inventory server advertises two business operations:
- stock: retrieve available units for a particular SKU.
- warehouse_availability: retrieve availability across authorized warehouses.
Both are invoked through the same protocol method, tools/call. Each has its own advertised tool name and input schema.
JSON{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"stock","arguments":{"sku":"A12"}}}
JSON{"jsonrpc":"2.0","id":2,"method":"tools/call","params":{"name":"warehouse_availability","arguments":{"sku":"A12"}}}
The outer protocol method remains unchanged. The registered tool name and its application arguments differ.
The diagram shows two levels of dispatch. First the implementation selects a protocol operation. Then the tools/call implementation selects a registered application capability. The two levels must remain separate.
A fictional request with method stock instead of tools/call is not a valid invocation of that advertised tool. A method named tools/delete is not automatically created just because a server advertises a tool named delete. Likewise, declaring a tool's input schema does not create a new protocol method.
This distinction also applies to prompts and resources. In prompts/get, params.name selects a prompt; in resources/read, params.uri selects an identified resource. Neither creates a new JSON-RPC method for each individual prompt or resource.
3. Params objects are method-specific contracts#
Generic JSON-RPC supports structured positional or named parameters. MCP defines typed parameter objects for its own methods, with requirements determined by the relevant schema.
The general params member may be absent when the selected method does not require a parameter object. When a method requires fields, their omission is not valid simply because params is optional in the general envelope.
| Method | Important parameter members | Example distinction |
|---|---|---|
| ping | No required business parameters | An omitted params member can be valid |
| initialize | protocolVersion, capabilities, clientInfo | Establishes lifecycle negotiation |
| tools/list | Optional cursor | Cursor is an opaque continuation token |
| tools/call | Required name, optional arguments | The selected tool may require business arguments |
| resources/read | Required uri | Identifies the resource |
| prompts/get | Required name, optional arguments | Prompt arguments are string-valued in this historical contract |
| resources/subscribe | Required uri | Requires the relevant subscription support |
This table omits other applicable metadata and optional fields for readability. It is not a substitute for the complete version-specific schemas.
The parameters for one operation cannot simply be moved into another operation. An object containing uri may be appropriate for resources/read but is not the expected input to tools/call. A cursor may be accepted by a paginated list method but is not a universal field that every tool invocation recognizes.
JSON object member order does not define the parameter semantics. The field names, types, allowed values, optionality and method contract do.
4. Required, optional, absent and null are different#
A required field must be present with a valid value according to the applicable schema. An optional field may be omitted, but that does not necessarily mean it accepts null.
Consider a fictional client discovering the inventory server's tool catalog.
JSON{"jsonrpc":"2.0","id":10,"method":"tools/list"}
The first page need not include a cursor. If the server returns a continuation token, a follow-up request may use it:
JSON{ "jsonrpc": "2.0", "id": 11, "method": "tools/list", "params": {"cursor": "opaque-page-token"} }
The cursor is an illustrative string. A real client should use the value returned by the server and must not invent pagination tokens or assume that the token represents a page number.
A request with params.cursor set to null is different from omission; the historical cursor contract expects a string when supplied. Sending a number because the application uses page indexes internally does not make that number a valid protocol cursor.
The same principle applies to tool arguments. The historical tools/call parameter contract allows arguments to be omitted, but a particular advertised stock tool may require sku. If the selected tool accepts no required input, omission or an empty arguments object may be appropriate. If it requires sku, an omitted arguments object cannot satisfy that input contract.
Optionality belongs to a particular layer. A field that is optional in the method schema may be required by the selected capability.
Defaults and explicit values#
A schema may describe a default value, and an implementation may apply a default according to its documented contract. Do not assume that every validator automatically inserts defaults. An application should distinguish a missing property from a property explicitly set to null, false, zero or an empty string.
For example, a fictional inventory-search tool may allow an optional limit with a documented default of 20. The value 0 should not silently become 20 just because a language's truthiness test treats zero as false. Whether zero is valid depends on the actual tool contract.
5. Three nested contracts in one tool invocation#
For tools/call, there are three relevant layers of validation.
| Layer | Example | Responsibility |
|---|---|---|
| Protocol message contract | method is tools/call | Select a supported MCP method |
| Method parameter contract | name is a string; arguments is an object when supplied | Resolve the selected capability and its input container |
| Tool input contract | sku is a required string for stock | Validate application-specific input |
The stock tool's fictional input schema might be:
JSON{ "type": "object", "properties": { "sku": {"type": "string", "minLength": 1}, "warehouse": {"type": "string"} }, "required": ["sku"], "additionalProperties": false }
This schema governs params.arguments for that particular tool. It does not govern the outer JSON-RPC id, the protocol method name or params._meta.
For instance, the argument object {"sku":"A12"} is acceptable under the illustrated shape. A warehouse value can be supplied if the actual tool implements it. An unexpected property such as tenant is rejected by this example's additionalProperties rule. These are fictional application constraints, not requirements shared by all MCP tools.
A schema-valid request is not necessarily authorized. The server must independently determine whether the authenticated actor may access A12 in the specified warehouse. A caller cannot select another tenant merely by providing a syntactically valid argument.
The schema may be expressed using the supported JSON Schema contract. The exact dialect, SDK behavior and business validation requirements need to be verified for a real integration. Q49 and Q102 cover detailed schema design and validation.
6. Resource and prompt parameters are not tool arguments#
The method family determines the meaning of a parameter object. Compare these three operations.
Read a resource#
JSON{ "jsonrpc": "2.0", "id": 21, "method": "resources/read", "params": {"uri": "policy://returns"} }
The URI identifies information according to the server's resource contract. It is not necessarily an externally accessible HTTP endpoint or local file path. The resource server interprets it and enforces access policy.
Retrieve a prompt#
JSON{ "jsonrpc": "2.0", "id": 22, "method": "prompts/get", "params": { "name": "stock_summary", "arguments": {"sku": "A12"} } }
The selected prompt may use string-valued arguments to construct reusable messages. This operation retrieves the prompt; it does not automatically send the prompt to an LLM or invoke a tool.
Invoke a tool#
JSON{ "jsonrpc": "2.0", "id": 23, "method": "tools/call", "params": { "name": "stock", "arguments": {"sku": "A12"} } }
Although the last two examples have similarly named members, the parameter contracts and semantics differ. Tool arguments can contain supported JSON values governed by the advertised tool input schema; the historical prompt argument mapping has its own string-value contract. A shared field name does not make the methods interchangeable.
7. Metadata belongs to the protocol boundary#
The historical MCP request parameter contract supports an optional _meta object for applicable metadata. For example:
JSON{ "jsonrpc": "2.0", "id": "scan-8", "method": "tools/call", "params": { "name": "scan_inventory", "arguments": {"warehouse": "central"}, "_meta": {"progressToken": "scan-progress-8"} } }
The warehouse argument belongs to the application tool. The progress token belongs to the supported protocol progress mechanism. Moving progressToken into arguments can violate the tool input schema or cause a handler to misinterpret the value.
A robust implementation keeps protocol metadata distinct from business arguments. It does not silently merge all nested objects and call an application function with the combined keys. A metadata field is not automatically a trusted user identity, approval decision or access token.
Follow the applicable revision's metadata naming, extension and interpretation rules. Unknown or unsupported metadata cannot be assumed to activate a feature. Supplying a progress token does not guarantee progress delivery.
Also keep transport-level credentials and connection configuration outside ordinary model-controlled tool arguments. A trusted host and server manage actual connection identity and authorization. The request carries only the information its capability contract permits.
8. Capability-dependent method availability#
Knowing a method's name and parameter contract does not establish that it can be used on a particular connection.
Suppose the inventory server advertises tools but not resources during the historical initialization exchange. A client may use the supported tool methods after the required lifecycle steps, but it should not assume that resources/read is supported.
The server may also advertise optional features within a capability family. Resource support does not automatically imply subscription support; tool support does not automatically imply list-change notifications.
For supported client features, the same principle applies in the opposite direction. A server should not assume that an MCP client supports sampling or elicitation merely because the JSON-RPC envelope can represent those methods.
Consider the distinction:
| Situation | Relevant decision |
|---|---|
| Method not defined or not implemented | Do not dispatch to an arbitrary handler |
| Method exists but required feature is unavailable | Do not assume capability support |
| Method has inappropriate lifecycle state | Follow applicable lifecycle rules |
| Method and feature available but params malformed | Reject invalid parameters |
| Method and params valid but tool unregistered | Resolve the capability failure appropriately |
| Method, feature and tool exist but actor lacks permission | Deny the operation |
The historical initialization rules allow specific interactions at defined lifecycle stages, so it is incorrect to claim that every method, including initialize and ping, is always prohibited before the ready state. The actual method-specific lifecycle rules govern. Q36–41 develop the details.
9. Safe dispatch: choose handlers explicitly#
A method dispatcher is an implementation component that maps a supported operation name to the corresponding handler. A small implementation may use a dictionary of known method names. An SDK may provide generated typed request handlers or another dispatch mechanism.
This is a conceptual dispatch pipeline for ordinary supported operations, not the complete normative validation order. Authentication, message classification and resource limits may happen earlier. Notifications and responses have separate semantics; a real implementation should not automatically treat every received message as an incoming request.
Avoid dynamic evaluation of a method name. Do not construct a Python attribute lookup, module import, shell command or SQL expression from an arbitrary request method. The method is an untrusted protocol selector, not executable source code.
When dispatching tools/call, resolve params.name against a trusted registry of the actual server's tools. The user's current authorization and the tool's business semantics still determine whether it may run.
Prefer explicit mappings to ambiguous prefix matching. For example, a prefix of tools/ is not permission to invoke all handlers with a similar name. Likewise, dispatching by the first component of a slash-separated method is insufficient unless the remainder is validated against the exact supported operation.
Error classification should preserve where the rejection occurred. An unknown RPC method and a known tools/call method with an unavailable tool name are not the same failure. Q31 and Q166–169 cover the exact protocol and tool-error mapping.
10. Extensibility and compatibility#
A general JSON-RPC implementation can support additional method names, but that does not mean any invented operation is interoperable MCP.
If an organization introduces an application-specific extension, both participants need a compatible agreement on its name, parameter and result schemas, availability, direction and security semantics. The design must follow the applicable MCP extension rules and use appropriately collision-resistant naming.
An extension should not silently redefine the meaning of a standard method. For example, changing resources/read to require an unrelated business action would break clients that implement the standard contract.
Often an additional application operation can be represented as a normal registered tool rather than a new protocol method. This keeps the existing discovery and invocation mechanism useful to compatible clients. For an inventory warehouse lookup, registering a warehouse_availability tool is usually more interoperable than requiring every client to implement a proprietary inventory/warehouseAvailability method.
This is a design recommendation, not a universal rule against extensions. If a genuinely new protocol-level feature is needed, verify the relevant revision's extension mechanism and explicitly agree on it with participating implementations.
Compatibility also depends on field semantics. Adding a genuinely optional, understood field may be easier to accommodate than renaming a required field or changing a parameter's type, but no schema change should be assumed compatible without testing. Later questions cover versioning and extensions.
11. Tested implementation: select the method contract before dispatch#
The following Python exercise operates on decoded method and params values. It registers four method handlers, applies a small lifecycle and capability gate, validates method-specific named fields, separates _meta, and performs a second-level lookup for the fictional stock tool.
The Context object represents trusted local application state. The tool permission set is an illustrative application policy, not an MCP standardized scope. The example intentionally limits methods to ordinary operations after readiness, including ping, and does not implement real MCP initialization or pre-initialization exceptions.
Save as mcp_q30.py:
PYTHONfrom dataclasses import dataclass @dataclass(frozen=True) class Context: ready: bool capabilities: frozenset[str] allowed_tools: frozenset[str] def fields(params, required=(), optional=()): if type(params) is not dict: raise ValueError('Expected parameter object') keys = set(params) if not set(required) <= keys or keys - set(required) - set(optional) - {'_meta'}: raise ValueError('Unexpected or missing parameter') if '_meta' in params and type(params['_meta']) is not dict: raise ValueError('Expected metadata object') return {k: v for k, v in params.items() if k != '_meta'} def ping(params, ctx): fields(params) return {} def list_tools(params, ctx): p = fields(params, optional=('cursor',)) if 'cursor' in p and p['cursor'] != 'page-2': raise ValueError('Unknown fixture cursor') return {'tools': ['stock'] if 'cursor' not in p else []} def call_tool(params, ctx): p = fields(params, required=('name',), optional=('arguments',)) if type(p['name']) is not str or p['name'] != 'stock': raise LookupError('Unknown tool') if p['name'] not in ctx.allowed_tools: raise PermissionError('Tool unavailable to actor') a = p.get('arguments', {}) if (type(a) is not dict or set(a) != {'sku'} or type(a['sku']) is not str or a['sku'] != 'A12'): raise ValueError('Invalid fixture stock arguments') return {'sku': a['sku'], 'units': 7} def read_resource(params, ctx): p = fields(params, required=('uri',)) if p['uri'] != 'policy://returns': raise LookupError('Unknown resource') return {'text': 'Returns within 30 days.'} ROUTES = {'ping': (None, ping), 'tools/list': ('tools', list_tools), 'tools/call': ('tools', call_tool), 'resources/read': ('resources', read_resource)} def dispatch(method, params, ctx): if type(method) is not str or method not in ROUTES: raise LookupError('Unknown method') cap, handler = ROUTES[method] if not ctx.ready or (cap is not None and cap not in ctx.capabilities): raise RuntimeError('Unavailable in this fixture state') return handler(params, ctx) def reject(fn, expected): try: fn() except expected: return raise AssertionError('Expected rejection') if __name__ == '__main__': ctx = Context(True, frozenset({'tools', 'resources'}), frozenset({'stock'})) tool = {'name': 'stock', 'arguments': {'sku': 'A12'}} assert dispatch('ping', {}, ctx) == {} assert dispatch('tools/list', {}, ctx) == {'tools': ['stock']} assert dispatch('tools/list', {'cursor': 'page-2'}, ctx) == {'tools': []} assert dispatch('tools/call', tool, ctx) == {'sku': 'A12', 'units': 7} assert dispatch('tools/call', {**tool, '_meta': {'progressToken': 'p1'}}, ctx) == {'sku': 'A12', 'units': 7} assert dispatch('resources/read', {'uri': 'policy://returns'}, ctx)['text'] == 'Returns within 30 days.' reject(lambda: dispatch('stock', tool, ctx), LookupError) reject(lambda: dispatch('Tools/List', {}, ctx), LookupError) reject(lambda: dispatch('tools/list', [], ctx), ValueError) reject(lambda: dispatch('tools/list', {'cursor': 2}, ctx), ValueError) reject(lambda: dispatch('tools/call', {'arguments': {'sku': 'A12'}}, ctx), ValueError) reject(lambda: dispatch('tools/call', {'name': 'stock'}, ctx), ValueError) reject(lambda: dispatch('tools/call', {'name': 'stock', 'arguments': {'sku': 'A12', 'progressToken': 'p1'}}, ctx), ValueError) reject(lambda: dispatch('tools/call', {**tool, '_meta': []}, ctx), ValueError) reject(lambda: dispatch('tools/call', tool, Context(True, frozenset({'tools'}), frozenset())), PermissionError) reject(lambda: dispatch('resources/read', {'uri': 'policy://returns'}, Context(True, frozenset({'tools'}), frozenset())), RuntimeError) reject(lambda: dispatch('tools/list', {}, Context(False, frozenset({'tools'}), frozenset())), RuntimeError) reject(lambda: dispatch('tools/call', {'name': 'unknown'}, ctx), LookupError) print('18 method dispatch checks passed (6 accepted, 12 rejected)')
Run:
BASHpython -m py_compile mcp_q30.py python mcp_q30.py
Actual local output on Python 3.13.5:
18 method dispatch checks passed (6 accepted, 12 rejected)What the checks establish#
The six accepted cases cover a parameterless utility operation, initial tool discovery, a fictional continuation page, a stock invocation, the same invocation with separated metadata, and a resource read.
The twelve rejected cases verify:
- An application tool name incorrectly used as the protocol method.
- Incorrect method capitalization.
- Array-shaped parameters.
- A numeric fixture cursor.
- Missing tool name.
- Missing required stock arguments.
- Protocol metadata misplaced inside business arguments.
- Non-object metadata.
- Tool permission denial.
- Unavailable resource capability.
- An ordinary discovery operation before fixture readiness.
- An unknown tool name within a recognized protocol method.
The fields helper validates the named parameter object's required and permitted members before returning business-relevant fields without _meta. The dispatcher chooses a known handler from ROUTES, and call_tool separately resolves the stock tool and checks permission. This is the primary distinction taught by the lesson.
Deliberate limitations#
This program is a restricted teaching fixture. Its outputs are internal domain values, not conformant MCP result objects: real tool discovery returns descriptors, real resources/read returns contents, and real tools/call returns the supported tool result representation. The fictional cursor page is an isolated test, not a real paginated catalog; no nextCursor is generated. The static stock lookup accepts only A12, and the resource is a shared fictional policy. These restrictions differ from the broader illustrative schema earlier in the lesson.
The fixture uses a strict local allowlist of parameter fields, does not implement the complete extension or metadata contract, and does not process progressToken beyond separating the metadata object. It assumes trusted decoded JSON-like input and a trusted Context; it does not establish actual authentication, resource ownership or server-side security. The permission test covers one tool only. Discovery intentionally exposes static metadata and does not perform identity-specific catalog filtering.
No actual MCP transport, message-envelope parser, response correlation, notification dispatcher, schema engine, network server, real authorization system, concurrent handler or downstream service was used. All exceptions are local Python failures, not generated JSON-RPC responses. The checks establish the specified behavior, not complete protocol conformance.
12. Practical debugging and common mistakes#
Imagine that a model proposes a call to stock and the host adapter incorrectly sends method stock. The receiver cannot find a supported protocol handler. Fix the adapter's operation mapping rather than changing the SKU.
If the host instead sends tools/call but puts sku directly under params, the method-specific parameter object does not identify the selected tool or its arguments correctly. Fix the nesting and validate both schemas.
If the request is valid but the server did not advertise the relevant capability, the host should not claim the method is available. If it is advertised but the actor lacks permission, the server must still refuse the operation.
| Mistake | Better approach |
|---|---|
| Use a tool name as method | Use tools/call and put the tool name in params.name |
| Send positional array params | Use the applicable MCP object contract |
| Treat every optional property as nullable | Check the exact type and optionality |
| Flatten params.arguments into the outer envelope | Preserve the method and tool schema boundaries |
| Forward _meta as ordinary function arguments | Interpret supported metadata separately |
| Assume all methods are available after connecting | Check lifecycle, direction and negotiated capabilities |
| Dynamically execute arbitrary method strings | Use explicit trusted dispatch |
| Treat a valid input schema as permission | Enforce resource and business authorization independently |
| Invent extension methods for ordinary tools | Prefer supported discovery and invocation where appropriate |
During diagnosis, record sanitized method names, relevant capability and revision information, selected handler identity and failure categories. Avoid exposing sensitive parameters, raw credentials or private business results. Test method-specific handlers with known inputs and separately run actual SDK interoperability tests.
Interview-ready answer#
MCP represents operation names as exact JSON-RPC method strings, such as tools/list, tools/call and resources/read. Each method defines its own named params object with required and optional fields. For tools/call, params.name selects an advertised tool and params.arguments must satisfy that tool's application input schema. Supported metadata belongs in its appropriate protocol field, such as params._meta. A receiver dispatches through a known method registry, checks lifecycle and capabilities, validates method parameters and capability-specific inputs, and independently enforces authorization. The standard method name is not the tool's name, and a syntactically valid method is not necessarily supported or permitted. Extensions require explicit compatible contracts rather than arbitrary invented method names.
Next lesson: Q31 explains the JSON-RPC error object, standardized codes, correlated error responses and the distinction from application and tool execution failures.
References
- 1.JSON-RPC 2.0 specificationjsonrpc.org
- 2.MCP historical specification (2025-06-18)modelcontextprotocol.io
- 3.MCP base protocolmodelcontextprotocol.io
- 4.MCP lifecyclemodelcontextprotocol.io
- 5.MCP toolsmodelcontextprotocol.io
- 6.MCP resourcesmodelcontextprotocol.io
- 7.MCP promptsmodelcontextprotocol.io
- 8.MCP progressmodelcontextprotocol.io
- 9.JSON Schema documentationjson-schema.org
- 10.Official MCP Python SDKgithub.com
Related questions
Explore other topics:Forward Deployed EngineeringAI AgentsLarge Language ModelsRetrieval-Augmented Generation