AI & LLM

MCP Message (Model Context Protocol) JSON Example

A JSON example of a Model Context Protocol (MCP) message — JSON-RPC 2.0 tools/list and tools/call requests and responses. Copy-ready for building MCP servers and AI tool integrations.

{
  "jsonrpc": "2.0",
  "id": 2,
  "result": {
    "tools": [
      {
        "name": "get_weather",
        "description": "Get the current weather for a city.",
        "inputSchema": {
          "type": "object",
          "properties": {
            "location": {
              "type": "string",
              "description": "City and country"
            }
          },
          "required": [
            "location"
          ]
        }
      }
    ]
  }
}

Field Reference

jsonrpcrequiredstringProtocol version — always '2.0' for MCP (built on JSON-RPC 2.0)
idrequiredinteger | stringRequest id echoed in the response to correlate request/response pairs
resultrequiredobjectSuccess payload; present on responses (mutually exclusive with 'error')
result.tools[].namerequiredstringUnique tool name the model can call
result.tools[].inputSchemarequiredobjectJSON Schema describing the tool's arguments

Variants

tools/list requestThe client asks an MCP server which tools it exposes.
{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/list",
  "params": {}
}
tools/call requestInvoke a tool with arguments.
{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "tools/call",
  "params": {
    "name": "get_weather",
    "arguments": {
      "location": "Ahmedabad, IN"
    }
  }
}
Error responseJSON-RPC error object returned when a call fails.
{
  "jsonrpc": "2.0",
  "id": 3,
  "error": {
    "code": -32602,
    "message": "Invalid params: 'location' is required"
  }
}

Common Use Cases

  • Building an MCP server that exposes tools to Claude or other AI clients
  • Debugging JSON-RPC traffic between an AI host and an MCP server
  • Defining tool input schemas for model-driven tool calling
mcpmodel context protocoljson-rpcai toolsclaudeanthropic

Validate or format this JSON

One click loads this exact example into the tool — no copy-paste needed. Format it, validate it, explore the tree, or generate TypeScript types instantly.

Frequently Asked Questions

MCP is an open standard from Anthropic that lets AI applications connect to external tools and data sources through a uniform interface. It's built on JSON-RPC 2.0, so every message is JSON with jsonrpc, id, and either a method (requests) or a result/error (responses).

It follows JSON-RPC 2.0. Requests have 'method' and 'params'; responses have 'result' (success) or 'error' (failure), plus the matching 'id'. Notifications omit the id. Core methods include initialize, tools/list, tools/call, resources/list, and prompts/list.

It reuses JSON-RPC codes: -32700 parse error, -32600 invalid request, -32601 method not found, -32602 invalid params, and -32603 internal error. Servers may also define application-specific codes outside the reserved range.

Related JSON Examples