What Is MCP? From Tool Calls to the Protocol Internals

March 21, 2025

In March 2025 MCP was everywhere. Alongside PromptPulse, I studied MCP source code to understand how a chat program discovers tools and lets a model call them. After reading the official TypeScript SDK, I distilled its core logic into a JavaScript Lite MCP SDK. The projects overlapped: building the client prompted questions about the protocol, and the protocol work fed back into the client.1

Start with a concrete need: let a chat assistant read project notes and answer a question. The model needs to know which notes exist, how to read them and how to use the content. MCP standardizes discovery, invocation and message exchange between an application and external capabilities. The application still organizes the conversation, chooses the model and decides whether to execute an operation.2

First we will trace one tool call, then unpack the messages, connections and SDK behind it. For transport I use the 2024-11-05 protocol I implemented at the time and explain how it differs from Streamable HTTP in 2025-03-26.

How does a chat assistant acquire external capabilities?

Suppose I tell the assistant, “Read the project notes and summarize the unresolved issues.” No matter how good the model is at summarizing, saying this does not automatically grant access to my files. The application must connect it to a note reader and place the retrieved content back in the conversation.

Three roles are easy to confuse:2

RoleJob in this example
HostSupplies the chat UI, organizes context, calls the model and decides which operations are allowed
ClientCreated by the host to connect to one MCP server and exchange protocol messages
ServerProvides capabilities such as reading notes, actually accessing files, databases or other services

In everyday speech “an MCP client application” often means the whole host. In source code Client usually refers to the object maintaining one server connection. A host can create multiple clients for file, browser or other services. A server can also be a locally launched process.2

Relationship between MCP host, client, server and model invocation

Diagram redrawn from the 2024-11-05 specification. The host integrates the model API. The MCP connection is between client and server, and the model need not run locally.2

This explains why MCP and model function calling often appear together. An application can convert tool descriptions discovered from an MCP server into definitions accepted by a model API. Once the model proposes a call, the app executes it via MCP. They meet at the host. MCP transport cannot replace provider-specific representations of tool calls or the model’s ability to choose a suitable tool.

Follow one complete tool call

Assume the connection is initialized and the server supplies read_note. Through tools/list, the application receives its name, description and inputSchema, a JSON Schema for arguments. The description says what the tool does. The structure says how to call it.3

A typical call proceeds like this:

  1. The client lists tools and the host gives their definitions and parameters to the model.
  2. The user asks to read a note, and the model proposes read_note with a note name.
  3. The host applies its execution rules and instructs the client to send tools/call.
  4. The server finds the handler, reads the note and returns its result.
  5. The host hands the result to the model, which answers the user.

These protocol examples are illustrative messages rather than historical logs. read_note is the example tool name:

{
  "jsonrpc": "2.0",
  "id": 7,
  "method": "tools/call",
  "params": {
    "name": "read_note",
    "arguments": { "name": "project-notes" }
  }
}

The server returns the same id so the client can match it to the call:

{
  "jsonrpc": "2.0",
  "id": 7,
  "result": {
    "content": [
      { "type": "text", "text": "待处理:离线资源路径、连接断开后的状态更新。" }
    ],
    "isError": false
  }
}

tools/call can be executed without a model. Developers can supply the arguments by hand. That makes a debugger such as Inspector useful: check the protocol path first, then investigate why a model chose the wrong tool or arguments. Successful execution on the server completes only step four. The application must receive the result and return it to the right conversation.34

How does the application connect the model and MCP?

While searching how to let an LLM use MCP, I read Philipp Schmid’s How to use Anthropic MCP Server with open LLMs, OpenAI or Google Gemini. Published January 17, 2025, it shows the connection through a command-line assistant calling a SQLite MCP server. Its instructions say:

Convert tools into LLM-compatible function calling tools

—Excerpt from step 4 of “How to use…”5

“Convert” has a specific meaning. MCP tools/list gives the application descriptions, while the model API has its own format. For the OpenAI-compatible interface in the article, map the fields as follows:

MCP descriptionModel API fieldPurpose
namefunction.nameLets the model specify which tool to call
descriptionfunction.descriptionHelps decide which tasks fit the tool
inputSchemafunction.parametersSupplies parameter names, types and required fields

After conversion the application sends definitions to the model. This excerpt is from agent_loop in Philipp Schmid’s tutorial:5

first_response = await client.chat.completions.create(
    model=MODEL_ID,
    messages=messages,
    tools=([t["schema"] for t in tools.values()] if len(tools) > 0 else None),
    max_tokens=4096,
    temperature=0,
)

The model may return a tool name and arguments. The application must parse and check them, find the matching MCP client and send tools/call. On return it appends the model’s original tool request and corresponding result in the model API’s required format, then requests another answer. The model-side tool-call identifier and MCP’s JSON-RPC id associate calls on their respective sides. The application connects the two paths.35

For the full client implementation process, see the official tutorial, Build an MCP client.

The model needs no SSE address and need not construct JSON-RPC. It needs clear tool descriptions. The app needs to know how to execute calls, process results and decide whether to continue. Multiple calls also require controlling later rounds and stopping conditions. These are the host’s responsibilities.2

The example separated two questions for me: how the model connects to MCP, and how the model is deployed. Llama 3.3 70B ran on Hugging Face hosted inference, while the SQLite MCP server used Docker and stdio. It demonstrates non-Claude models using MCP tools. Local inference and zero-configuration distribution in PromptPulse remained separate tasks.5

Tool calling and direct MCP support are different

At the time I felt few models supported tool calling, so I browsed Ollama’s Tools model category. That tag indicates whether a model can produce tool-call output through Ollama’s inference API. It does not mean the model itself implements MCP. Ollama’s July 2024 introduction said:

Supported models will now answer with a tool_calls response.

—“Tool calling” section.6

This is a proposed call returned by the model. The application still executes the tool and returns its result. The tool might be an ordinary function, an HTTP API or something supplied by an MCP server. MCP standardizes discovery and invocation for the last case. Conversely, an app that connects to an MCP server still has to join descriptions, model output and execution results.236

In PromptPulse I used tool-capable Qwen2.5 to test browsing and interacting with web pages. The March 19 code specified qwen2.5:3b and sent frontend-defined Puppeteer tool descriptions through Ollama’s OpenAI-compatible API. When the model returned tool_calls, the client read names and arguments, issued MCP tools/call and passed results back to the model. The model proposed calls, the client connected the protocol, and the server performed browser operations.7

I was therefore checking two conditions: could the chosen model and inference API propose suitable calls, and could my client complete the MCP exchange? MCP mandates neither a specific model nor any provider’s function-calling API.2

Letting the model decide when to call MCP tools, which tool to use and what arguments to supply genuinely requires tool-use ability. That is why I filtered for Tools models. An MCP client handles connectivity and execution but cannot supply that judgment on the model’s behalf.23

The call interface itself is replaceable. Without native tool_calls, the app can list tools and arguments in the prompt and ask the model for agreed text or JSON, then parse, validate and send the MCP request. The model still must understand and choose the tool and supply appropriate arguments. Prompts and parsers provide adaptation, without making a poor tool user reliable.

Alternatively, a user or fixed workflow can read material through MCP first and give it to a model for summarization. This does not require the model to choose a call, nor does it constitute autonomous tool use. Ordinary chat models can benefit from MCP-provided context without independently selecting tools.8

What do Tools, Resources and Prompts provide?

Reading material can be a tool or an exposed resource. MCP offers distinct interfaces for distinct purposes, without having to put everything in the tool list.389

CapabilityPrimary purposeExamplesMethods
ToolsExecute an operation with argumentsSearch notes, open a pagetools/list, tools/call
ResourcesSupply readable contextual dataA note, database schemaresources/list, resources/read
PromptsSupply reusable prompts, optionally parameterizedReview code along specified dimensionsprompts/list, prompts/get

The old specification described these interaction models as model-controlled, application-driven and user-controlled respectively. For example, the model picks a tool for a task, the application selects resources for context, and the user chooses a prompt from a menu. These descriptions guide interaction design without mandating a particular UI layout.

If notes are already resources, the host can read them into context directly without a preceding model tool call. Getting a prompt returns prompt content without automatically triggering model generation. Distinguishing responsibility helps decide what belongs on the server and what belongs in the chat app.

How does JSON-RPC associate messages?

Seeing JSON-RPC requests in the MCP SDK made me wonder why MCP chose JSON-RPC and what a solution such as gRPC would do differently. That led to my March 24 search for “json rpc和grpc区别” (difference between JSON-RPC and gRPC).

RPC means remote procedure call: in our example the client asks another program to read a note and return the result. JSON-RPC specifies how the messages look. The client states the operation in method, and the server echoes id so the client can match the result.10 A Stack Overflow question I found asked what gRPC contributes if HTTP/2 already carries messages. Richard Belleville cited integrated framework facilities such as authentication and call tracing.11

Reading the SDK, I initially got distracted by the many types and schemas. On March 27, 2025 I pasted some SDK schema code into Cursor and asked how it related to JSON-RPC. Returning to the messages made the source easier: MCP uses JSON-RPC 2.0 message structures and specifies the semantics of initialization, tools, resources and other methods.12

The JSON-RPC specification defines a notification directly:

A Notification is a Request object without an "id" member.

—JSON-RPC 2.0 Specification, §4.1.10

Distinguish three kinds of MCP messages:

MessageKey fieldsReceiver behavior
Requestmethod, id, optional paramsFind a handler and return a response with the matching id
Responseid and either result or errorFind the call waiting for that result
Notificationmethod, no idHandle the event without returning a JSON-RPC response

A success response contains result, an error response error. They cannot coexist. jsonrpc: "2.0" versions the message format. MCP’s protocolVersion belongs to a separate protocol layer.1013

id matters particularly with concurrent calls. Of two reads sent in succession, the later may complete first. The client cannot assign results by arrival order. Lite MCP SDK’s Protocol stores each request’s handler in _responseHandlers, looks it up by id on response, removes it and resolves or rejects the waiting Promise.14

This helps diagnose “the server finished but the UI keeps waiting.” Check the business function, whether a valid response returned, whether its id matches, and whether the client is still waiting on that connection. Business logs, HTTP completion and JSON-RPC call completion are different signals.

Why initialize after connecting?

Opening a network connection establishes the transport. The two ends still need to agree on protocol version and capabilities. The old MCP sequence was:13

Client → Server    initialize (protocol version, client capabilities, implementation info)
Server → Client    matching response (protocol version, server capabilities, implementation info)
Client → Server    notifications/initialized
Both               begin normal operation

A server declaring tools provides the tool interface. A client declaring sampling supports model-generation requests from servers. Subcapabilities can describe resource subscriptions, list-change notifications and more.

Declaring capabilities says what a side implements. It does not grant permissions. A file tool declaration provides no automatic access to every user file. A client advertising sampling need not blindly execute each model request. The implementing applications still decide permissions.213

In the retained Lite MCP SDK, Client.connect() follows this sequence: connect the transport, send initialize, check the returned protocol version, store server capabilities and send the initialized notification. Its supported version constant is 2024-11-05, a more precise scope than “supports MCP.”15

One easy-to-miss server detail is that the method name registered for the notification must match the complete name sent by the client. The protocol dispatches by exact name. The client can receive an initialization response even if the server callback does not run. Checking only whether connect() returned misses the final handshake step.16

If SSE is one-way, how does MCP communicate both ways?

I spent a lot of time studying SSE, which made it easy to associate MCP with EventSource. Transport is only one layer. The 2024-11-05 protocol defined stdio and HTTP+SSE as standard transports. Message semantics can be understood separately from the channel.17

stdio between local processes

With stdio the client launches an MCP server child process, writes protocol messages to its standard input and reads messages from its standard output. Newlines delimit messages. Debug logs belong on standard error, separate from protocol stdout. An ordinary log line there can otherwise break JSON parsing at the peer.17

An MCP server can therefore be a local command-line program without an HTTP service. Choosing Node.js, Python or another language is a runtime decision. MCP requires no particular language installation.

Reviewing the transports in June I read a translation by 二师兄说 AI with two Cline examples. For searching local files, Cline can launch a local search tool and send the query through stdio. To share a database across users, place the query tool and credentials on a server and connect each user’s Cline through old HTTP+SSE. The query tool then needs updating in one place.18

The two channels in old HTTP+SSE

The old transport split directions. The client receives server messages over SSE and sends messages over HTTP POST. After connection the server first sends an endpoint event telling the client which URI to POST to. Subsequent server protocol messages arrive as SSE message events.17

Client ── establish SSE connection ───────────→ Server
Client ←─ endpoint event specifies POST URI ─── Server
Client ── HTTP POST carrying JSON-RPC ────────→ Server
Client ←─ SSE message carrying JSON-RPC ─────── Server

The SSE channel streams one way, server to client. SSE plus POST carry bidirectional MCP message exchange. A client-sent message is not necessarily a request: answering server-initiated sampling sends a response. The server can likewise send responses, requests or notifications through SSE.

A successful HTTP status on the POST does not imply that the tool result sits in that POST’s response body. In old SSE, JSON-RPC results return via the SSE channel. Watching only one HTTP request can miss the actual response path.

The official SDK’s src/server/sse.ts that I saved shows this path in code. The March 15, 2025 SSEServerTransport divides the work as follows:19

MethodRole
start()Write SSE headers, send an endpoint event with sessionId and listen for closure
handlePostMessage()Read the POST body, pass it to message processing and return HTTP 202 Accepted on successful receipt
handleMessage()Validate with JSONRPCMessageSchema and invoke onmessage to hand it to the upper protocol layer
send()Encode JSON-RPC as an SSE message event and write it to the still-open stream

This shows onmessage at the transport/protocol boundary and why 202 Accepted does not mean the tool is finished. The transport accepts and passes on the message. An upper layer handles the request and eventually sends the result through send(). This was a core path to understand when distilling Lite MCP SDK.19

In Streamable HTTP, where does a tool result come back?

The transport I implemented in Lite MCP SDK in March 2025 was old HTTP+SSE. On March 26 MCP introduced Streamable HTTP. When I searched “Streamable HTTP和sse区别” (difference between Streamable HTTP and SSE) on June 9, the new transport was only two and a half months old. The specification I read said:2021

This replaces the HTTP+SSE transport from protocol version 2024-11-05.

Why replace it? Even a read-note tool capable of returning a line immediately required a long-lived SSE connection first. On receiving the POST the server had to locate that connection to write back the result. If the connection broke, the old specification did not define how to resume from a missed message. The transport proposal lists these practical burdens. The new version lets simple tools complete a call with one ordinary HTTP request and response and retains SSE for tools needing multiple messages.2220

SSE is a way for a server to send successive events through one HTTP response. Streamable HTTP specifies the MCP exchange as a whole, including the request destination and allowed response formats. After initialization, which request should I open in the network panel to see the note? The table uses Christian Posta’s sample paths for the old transport and the spec’s example /mcp for the new one.231720

Client taskHTTP+SSE (2024-11-05)Streamable HTTP (2025-03-26)
Find send addressOpen /sse with GET and wait for endpoint to identify the POST URIPOST directly to configured /mcp
Find the read-note resultAfter 202 Accepted on POST, look on the already-open SSE stream for a matching request IDInspect this POST’s response. It can be direct JSON or an SSE stream carrying the result.
Stream breaks before resultNo replay of missed messages defined by the transportIf the server assigns event IDs and supports replay, the client can GET with Last-Event-ID to resume after the last received event.20

A fast read may need only one JSON response. When processing many files individually, the client can supply a progress token and the server can choose an SSE response, send progress notifications and then the result. Streaming means data can arrive incrementally in one HTTP response and be processed before it finishes. The client may additionally GET the same endpoint to listen for server messages. A server can reply 405 Method Not Allowed if it does not provide that independent stream.2024

PubNub also uses “streaming” for adaptive video. Its explanation describes a player fetching a manifest and choosing media segments by bandwidth, without specifying concrete HTTP messages.25 In HLS (HTTP Live Streaming), assuming each segment is a separate file, after selecting a quality you might see these three ordinary HTTP requests. Each GET identifies the resource by URL and needs no request body.26

Player request (example path)Body of that HTTP response
GET /720p/index.m3u8Text playlist listing segment addresses and durations in playback order
GET /720p/001.tsAudio/video bytes of the first segment
GET /720p/002.tsAudio/video bytes of the second segment

The player can play received segments while downloading later ones. In the MCP example, the client sends one POST /mcp with a JSON-RPC tool call in the body. If the server streams its response, both progress and result appear as SSE events in that response (Content-Type: text/event-stream).20

Knowing which connection carries results still leaves two separate questions. Can one call return messages incrementally? Must the next call reuse session state from its predecessor? A request may include every filename needed, report progress per file and release all call resources afterward. Chen Mingyong calls this a “stateless server supporting streaming output.” EulerBlind explains stateless configuration in terms of whether the server generates a session ID.27 Chinese-language articles discussed the change in March. Buzige’s introduction appeared March 18, eight days before the formal March 26 specification.28

I wanted others to connect JavaScript apps to a remote MCP service. What I most lacked when researching was an SSE example covering everything from opening a connection to calling a tool. Lite MCP SDK therefore focused on 2024-11-05 HTTP+SSE and left stdio outside project scope. The April 3 README still records this choice.152129

Heartbeats, progress and sampling serve different purposes

A persistent connection does not turn every message into a heartbeat. These features answer different questions.

Ping checks whether the peer can still respond. The old specification defines an optional mechanism initiated by either client or server, with a prompt empty result from the receiver. It recommends periodic checks and configurable frequency, without prescribing a universal heartbeat interval.30

Progress reports how far a request has run. A UI can use it for a long task, but it does not replace the final response. Repeated SSE messages do not establish token-by-token model output: transport events, task progress and model output belong to different layers.24

Sampling lets a server ask the client to call a model. After retrieving a document, a server might send sampling/createMessage to analyze a passage. The host decides whether to accept, which model to use and how to review the request and return value. The server providing tools need not hold a model provider key when the host centrally manages model access.31

The http://localhost:5173/#sampling I remember visiting was Inspector’s Sampling tab. In my March 2025 Inspector version, server sampling requests appeared in a pending list with Approve and Reject. Approve in that version returns a fixed stub-model and This is a stub response. without invoking a real model in the handler. It tests request and response delivery but does not prove real model generation is connected.4

My SDK server also has createMessage() delegating to shared request(). Method presence, client capability declaration and an application actually handling a model request all require separate checks. Reverse requests also illustrate that client and server are architectural roles: either can initiate requests.1531

Inside the SDK: where does the core logic live?

I recall that Cursor’s coding model at the time was unreliable on MCP call details. To get these right I found official code and examples myself, traced the calls and told Cursor more precisely what and where to change. Reading implementations such as SSEServerTransport was both protocol study and a concrete reference for checking generated code for missed steps.32

With the message flow in mind, you need not start the SDK from every type definition. In Cursor I worked through properties, arguments and relationships of SSEClientTransport, Client extends Protocol, Server extends Protocol and SSEServerTransport. Lite MCP SDK retained these main boundaries.12

I remember also reading the Python SDK’s shared/session.py. I found its execution path easier to follow and used it to understand the core. Python uses Pydantic for models and validation, while TypeScript uses Zod. Pydantic declares classes and annotated field types, validates using model_validate() and serializes with model_dump(). Zod composes schemas with z.object() and similar functions and infers types. Python felt more intuitive to me while retaining runtime validation.3334

In the March Python SDK v1.4.1, BaseSession brings request/response association together. send_request() allocates an ID, saves a waiting channel for the ID and writes the message to the output stream. On a response, _receive_loop() finds the channel by ID and wakes the waiter. Requests and notifications follow their own paths. Its description summarizes this layer:33

Implements an MCP "session" on top of read/write streams, including features like request/response linking, notifications, and progress.

The core idea is “remember who is waiting when sending; find that waiter when the response arrives.” Python uses AnyIO memory streams between wait and receive. JavaScript can associate requests through Promises and callbacks. Following this flow first makes types and transport easier to study. This version still marked progress callbacks in send_request() as TODO, and send_progress_notification() had only a docstring. Understanding the core path does not establish implementation of every supporting capability.33

With SSE I checked more than connection success: how the endpoint is conveyed, who receives the POST, how results return via SSE and how the upper layers learn of closure. Understanding these behaviors helped me guide edits and validate them against Inspector results. This was one way I controlled code quality and invocation details.1932

LayerLocation in Lite MCP SDKMain responsibility
Protocol messagesshared/protocol.jsAllocate IDs, retain response callbacks, dispatch requests and notifications, handle cancellation and closure
Client and serverclient/client.js, server/server.jsInitialization, capability declarations and methods for tools, resources, sampling and more
TransportclientTransport.js, serverTransport.jsOpen SSE, send POSTs, parse incoming messages, report disconnects and errors
Application wrapperlitemcpjsPackage connections and common calls into convenient application interfaces

The server method initiating sampling is short. Here is the source at the time:15

async createMessage(
  params,
  options,
) {
  return this.request(
    { method: "sampling/createMessage", params },
    options,
  );
}

This method does not implement another network stack. It selects a method name and passes parameters to shared protocol logic, which sends them via the transport. The receiver finds the handler by method and returns the original request ID when done.

In the README I explained my choice of JavaScript:

Because I want the project to condense on the running logics, rather than distracted by the types.

—Lite MCP SDK README, “Why javascript?”1

I wanted a clearer view of the execution flow. Two kinds of checks still matter: TypeScript types check code during development, while runtime schemas check data actually received. Switching to JavaScript and removing Zod does not make network JSON valid.

Abridged translation. Implementation-specific details of incomplete validation and error handling, together with references pinpointing them, are omitted here. Making the central path easier to read does not replace validation of message structures, tool arguments and results. Following a request through a round trip is still some distance from a complete, reliable protocol implementation.

On March 28 I asked how to supply a default validator. The following evening, while debugging SSE, I investigated server-side request handling and dispatch. A transport may receive JSON as text or as an already parsed object. After decoding, the protocol layer uses the method to find a handler. Unknown methods should return MethodNotFound, and error reporting itself needs testing.

Timeout and cancellation also span two layers. The time limit advertised by a client and the timer that stops a local wait are distinct. When the timer fires, the protocol may send a cancellation notification. A client timing out does not by itself guarantee that a tool on the server stopped executing.

Registering tools with decorators

While reading Python’s MCP implementation I considered similar decorator-style registration in JavaScript. On May 4 I also read SitePoint’s introduction to JavaScript decorators.35

The Python SDK’s FastMCP supplied such an interface. tool() is described as “Decorator to register a tool.” Its returned decorator calls add_tool(fn, ...), then returns the original function. Registration uses function name, docstring and parameters to build the definition. Decorators put registration next to the function, while the underlying code still maintains a tool list and looks up handlers on invocation.36

My retained JavaScript implementation takes a tool array through MCPServerInit(). Each item has name, description, inputSchema and method. It builds descriptions for tools/list and a function map for tools/call. This centralizes registration using explicit configuration. Decorators were an alternate interface I considered. MCP specifies messages and interactions and leaves registration interfaces to SDKs.37

What does the frontend receive on disconnect?

To handle interruptions I read GreatFrontEnd’s SSE introduction and searched “if evensource connecting is lost what can we receive on frontend”. I wanted to know what actually reached the frontend and whether to keep waiting or end the current call.3839

I also searched for handling abnormal EventSource closure and read a Q&A about whether EventSource should reconnect indefinitely. I was probably considering which cases could rely on automatic reconnection and when to close explicitly and let the application decide about retry.4041

An error event can precede a retry or indicate failure without further retries. Inspect readyState. The HTML standard describes CONNECTING as:42

The connection has not yet been established, or it was closed and the user agent is reconnecting.

CONNECTING (0) covers initial connection and reconnection. CLOSED (2) means no connection and no automatic retries. Explicit close() enters the latter state. Standard EventSource has open, message and error events but no standard close event directly corresponding to WebSocket’s.42

In the Q&A, redrockzee suggested closing the old object on error, creating a connection after a delay and lengthening retry intervals. The code says “Double every attempt to avoid overwhelming server”. This illustrates application-managed retries. Observations about Chrome 35 and Firefox 30 are specific to those historical versions. My code contains error reporting and close cleanup, without implementing that backoff scheme.4341

My March transport already distinguished several paths. EventSource errors called reject(error) and notified the upper onerror. An invalid endpoint also triggered close(). A JSON parsing error in an ordinary message was reported and the message skipped. It used npm’s eventsource implementation. Its event.code and event.message cannot be assumed present on every native browser event.4342

Once a connection Promise has resolved, subsequent calls to its reject() cannot change the result. Errors can still be reported through onerror, but reject() alone does not fail pending tool calls. Reconnecting the network also does not automatically restore the previous MCP session or unfinished requests. The protocol and application layers must handle those.43

What happens to pending requests after SSE closes?

I also checked MDN on EventSource.close(), probably while writing connection cleanup. It closes the connection and sets readyState to 2 (CLOSED). MDN explicitly says:44

If the connection is already closed, the method does nothing.

Closing SSE is only part of cleanup. In my March code, transport close() aborts related POSTs through AbortController, calls _eventSource.close() and explicitly invokes its own onclose callback. This enters Protocol._onclose(), clears response and progress handlers and fails outstanding requests with Connection closed. Here onclose is an SDK-defined callback between layers.43

Tracing the path shows who closes the network connection and who ends protocol-layer waits. The browser API does not clean up the SDK’s request table or automatically cancel server-side tool work.4443

From protocol to SDK

The March 21 repository initially contained only a license. By the afternoon of March 29 a local copy contained my first JavaScript client. At 23:52 that evening a separate copy committed protocol code on both ends and integration scripts.45 The client script connected, listed tools and called puppeteer_navigate. It still had to construct a Client, configure SSEClientTransport and assemble tools/call. On March 30 I added litemcpjs above the lite-mcp-sdk package. Applications could call MCPClient.callTool(name, args) directly. Servers could hand definitions and handlers to MCPServerInit(), which registered Express /sse and /messages routes.46

I also tried a Python port. From late March 29 to the morning of March 30, I asked Cursor to help rewrite the protocol class, client and SSE transport. Local editor history contains a draft client sending and receiving via aiohttp and a test.py connecting, listing tools and invoking browser navigation. The README still listed a Python SDK as future work and there is no verifiable successful test result. The JavaScript wrapper was what eventually joined PromptPulse.4746

While developing Lite MCP SDK I also encountered package entry and runtime issues, discussed separately:

References

Footnotes

  1. CaiBorui [S2thend]. (2025, April 3). Lite MCP SDK [README, historical version 8622627, “Why javascript?”]. GitHub. https://github.com/S2thend/Lite_MCP_sdk/blob/86226278b74207dd773928911f55c11bacd80749/README.md The project initially committed LICENSE on March 21, 2025. See 26a58e5. ↩ ↩2

  2. Model Context Protocol. (2024, November 5). Architecture [protocol version 2024-11-05, “Core Components” and “Design Principles,” pinned snapshot]. GitHub. https://github.com/modelcontextprotocol/modelcontextprotocol/blob/bb8f4b7323693910328f72f244352cd71a0689e6/docs/specification/2024-11-05/architecture/_index.md Also retaining the supplied Message exchange documentation entry; this now points to the 2026 docs. Historical mechanisms follow the pinned version above. ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9

  3. Model Context Protocol. (2024, November 5). Tools [protocol version 2024-11-05, “Protocol Messages” and “Message Flow”]. GitHub. https://github.com/modelcontextprotocol/modelcontextprotocol/blob/bb8f4b7323693910328f72f244352cd71a0689e6/docs/specification/2024-11-05/server/tools.md ↩ ↩2 ↩3 ↩4 ↩5 ↩6

  4. Model Context Protocol. (2025, March 15). MCP Inspector: SamplingTab.tsx [source, cedf02d, handleApprove]. GitHub. https://github.com/modelcontextprotocol/inspector/blob/cedf02d1520daf5680ee9b7af785feccafa8be5b/client/src/components/SamplingTab.tsx For purpose and startup see the same version’s README; Inspector repository. ↩ ↩2

  5. Schmid, P. (2025, January 17). How to use Anthropic MCP Server with open LLMs, OpenAI or Google Gemini [“How to use…” step 4, tool definition conversion and agent_loop example]. Philipp Schmid. https://www.philschmid.de/mcp-example-llama ↩ ↩2 ↩3 ↩4

  6. Ollama. (2024, July 25). Tool support [“Tool calling,” explanation after code example]. Ollama Blog. https://ollama.com/blog/tool-support Also retaining the Tools model category I visited. The current list is not treated as a 2025 catalog snapshot. ↩ ↩2

  7. CaiBorui [S2thend]. (2025, March 19). PromptPulse MCPChatView [historical source, commit 286488c, model request and tool loop]. GitHub. https://github.com/S2thend/PromptPulse/blob/286488c7819a7f6e8e9dd4ecf005c99c42d41dc5/web/src/views/MCPChatView.jsx Requests pass definitions via tools. Response handling reads tool_calls and invokes the corresponding tools through the MCP client. ↩

  8. Model Context Protocol. (2024, November 5). Resources [protocol version 2024-11-05, “User Interaction Model” and “Protocol Messages”]. GitHub. https://github.com/modelcontextprotocol/modelcontextprotocol/blob/bb8f4b7323693910328f72f244352cd71a0689e6/docs/specification/2024-11-05/server/resources.md ↩ ↩2

  9. Model Context Protocol. (2024, November 5). Prompts [protocol version 2024-11-05, “User Interaction Model” and “Getting a Prompt”]. GitHub. https://github.com/modelcontextprotocol/modelcontextprotocol/blob/bb8f4b7323693910328f72f244352cd71a0689e6/docs/specification/2024-11-05/server/prompts.md ↩

  10. JSON-RPC Working Group. (2013, January 4). JSON-RPC 2.0 specification [§4 Request object, §4.1 Notification, §5 Response object]. JSON-RPC. https://www.jsonrpc.org/specification#notification ↩ ↩2 ↩3

  11. Kondaurov, A. (2019, November 8). What the difference between JSON RPC with HTTP2 vs grpc? Stack Overflow. Final two paragraphs of the question. Belleville, R. (2019, November 13). Answer to “What the difference between JSON RPC with HTTP2 vs grpc?” Stack Overflow. Reply, paragraphs 2–3. ↩

  12. CaiBorui. (2025, March–April). Conversations on MCP source and SDK debugging [Cursor work records retained by author]. SDK classes and relationships discussed March 25–26, JSON-RPC schemas in MCP_Lite on March 27, and litemcpjs browser imports on April 2. The discussions document questions and debugging. Implementations are based on repository source. ↩ ↩2

  13. Model Context Protocol. (2024, November 5). Lifecycle [protocol version 2024-11-05, “Initialization” and “Capability Negotiation”]. GitHub. https://github.com/modelcontextprotocol/modelcontextprotocol/blob/bb8f4b7323693910328f72f244352cd71a0689e6/docs/specification/2024-11-05/basic/lifecycle.md ↩ ↩2 ↩3

  14. CaiBorui [S2thend]. (2025, April 3). Lite MCP SDK: Protocol [historical source snapshot]. GitHub. ↩

  15. CaiBorui [S2thend]. (2025, April 3). Lite MCP SDK: Client and Server [historical source snapshot]. GitHub. Client.connect() and version constant; Server.createMessage(). ↩ ↩2 ↩3 ↩4

  16. CaiBorui [S2thend]. (2025, April 3). Lite MCP SDK initialization notifications and dispatch. GitHub. Checked locally with the corresponding server and an in-memory transport on November 20, 2026. ↩

  17. Model Context Protocol. (2024, November 5). Transports [protocol version 2024-11-05, “stdio” and “HTTP with SSE”]. GitHub. https://github.com/modelcontextprotocol/modelcontextprotocol/blob/bb8f4b7323693910328f72f244352cd71a0689e6/docs/specification/2024-11-05/basic/transports.md ↩ ↩2 ↩3 ↩4

  18. 二师兄说 AI. (2025, April 4). MCP Transports: Stdio and SSE (Translation). Zhihu column “100 MCP Examples.” See the two practical examples of local file search and centralized database queries in “Local vs Hosted: Deployment Considerations.” ↩

  19. Model Context Protocol contributors. (2025, March 15). SSEServerTransport [TypeScript SDK source, historical snapshot 3c0081f, start, handlePostMessage, handleMessage, send]. GitHub. https://github.com/modelcontextprotocol/typescript-sdk/blob/3c0081f2ecd8bb9b117330783ad25c2ec127ef60/src/server/sse.ts The previously saved main URL became unavailable, so the historical file is cited. ↩ ↩2 ↩3

  20. Model Context Protocol contributors. (2025, March 26). Transports [protocol version 2025-03-26, opening of “Streamable HTTP,” “Sending Messages to the Server” and “Listening for Messages from the Server”]. Model Context Protocol. https://modelcontextprotocol.io/specification/2025-03-26/basic/transports ↩ ↩2 ↩3 ↩4 ↩5 ↩6

  21. Model Context Protocol. (2025, March 26). Key changes [protocol version 2025-03-26, “Major changes,” item 2]. https://modelcontextprotocol.io/specification/2025-03-26/changelog ↩ ↩2

  22. jspahrsummers. (2025, March 17). RFC: Replace HTTP+SSE with new “Streamable HTTP” transport [proposal #206]. GitHub. See “Motivation” and “Benefits.” For optional resumption conditions see “Resumability and redelivery” in the specification. ↩

  23. Posta, C. (2025, March 27). Understanding MCP recent change around HTTP+SSE. Christian Posta. See the connection sequence and sample endpoints in “HTTP + SSE.” ↩

  24. Model Context Protocol. (2024, November 5). Progress [protocol version 2024-11-05]. GitHub. https://github.com/modelcontextprotocol/modelcontextprotocol/blob/bb8f4b7323693910328f72f244352cd71a0689e6/docs/specification/2024-11-05/basic/utilities/progress.md ↩ ↩2

  25. Campbell, D. (2023, November 27). What is HTTP streaming?. PubNub, DEV Community. See the playlist-to-segment request example under “Adaptive Streaming.” ↩

  26. Pantos, R., & May, W. (2017, August). HTTP Live Streaming (RFC 8216). RFC Editor. Table adapted from the media playlist example in §8.1. ↩

  27. 陈明勇. (2025, April 18). MCP Protocol Update: From HTTP+SSE to Streamable HTTP. Tencent Cloud Developer Community. Quotation from the second subheading under “MCP Server Examples.” EulerBlind. (2025, July 2). Why Use Streamable HTTP for MCP: Advantages over SSE and Practical Guidance. Euler’s Blog. See sessionIdGenerator in the stateless example. On June 9 I visited the community edition under the same title. July 2 is the date shown by the author’s blog. ↩

  28. 步子哥. (2025, March 18). What Is Streamable HTTP in the Latest MCP Update?. CSDN. See “Initial Release” and “Background and Motivation for Streamable HTTP.” ↩

  29. CaiBorui [S2thend]. (2025, April 3). Lite MCP SDK [README, “Fully SSE solution”]. GitHub. Rationale for SSE and documentation examples saved at the time. ↩

  30. Model Context Protocol. (2024, November 5). Ping [protocol version 2024-11-05, “Behavior Requirements” and “Implementation Considerations”]. GitHub. https://github.com/modelcontextprotocol/modelcontextprotocol/blob/bb8f4b7323693910328f72f244352cd71a0689e6/docs/specification/2024-11-05/basic/utilities/ping.md ↩

  31. Model Context Protocol. (2024, November 5). Sampling [protocol version 2024-11-05, “Creating Messages” and “Model Preferences”]. GitHub. https://github.com/modelcontextprotocol/modelcontextprotocol/blob/bb8f4b7323693910328f72f244352cd71a0689e6/docs/specification/2024-11-05/client/sampling.md ↩ ↩2

  32. CaiBorui. (2026, November 17). Additional recollection of reading MCP source and working with Cursor [author’s note]. Assessment of the coding model and motivation for reading source are recollections. The March Cursor work records document class relationships and parameters. ↩ ↩2

  33. Model Context Protocol contributors. (2025, March 14). Python SDK v1.4.1: BaseSession and protocol models [historical version, BaseSession description, send_request, _receive_loop and Pydantic model declarations]. GitHub. session.py; types.py. Original browsing entry: https://github.com/modelcontextprotocol/python-sdk/blob/main/src/mcp/shared/session.py The implementation is explained using the March release. Reading impressions come from later recollection. ↩ ↩2 ↩3

  34. Model Context Protocol contributors. (2025, March 15). TypeScript SDK protocol schemas [historical snapshot 3c0081f, Zod schemas and type declarations]. GitHub. https://github.com/modelcontextprotocol/typescript-sdk/blob/3c0081f2ecd8bb9b117330783ad25c2ec127ef60/src/types.ts ↩

  35. Anyebe, B. E. (2023, October 23; updated 2024, January 17). JavaScript Decorators: An In-depth Guide. SitePoint. https://www.sitepoint.com/javascript-decorators-what-they-are/ The idea of adopting Python’s registration style in JavaScript comes from my November 17, 2026 recollection. ↩

  36. Model Context Protocol contributors. (2025, March 14). Python SDK v1.4.1: FastMCP tool registration [historical version, FastMCP.tool docstring and implementation, Tool.from_function]. GitHub. server.py; tools/base.py. ↩

  37. CaiBorui [S2thend]. (2025, April 3). litemcpjs server initialization [historical snapshot 8622627, MCPServerInit, tool list and handler mapping]. GitHub. https://github.com/S2thend/Lite_MCP_sdk/blob/86226278b74207dd773928911f55c11bacd80749/litemcpjs/litemcp.js ↩

  38. GreatFrontEnd. (n.d.). What are server-sent events? [SSE concepts and examples, page visited by the author]. GreatFrontEnd. https://www.greatfrontend.com/questions/quiz/what-are-server-sent-events ↩

  39. Google. (n.d.). if evensource connecting is lost what can we receive on frontend [search retained by the author]. https://www.google.com/search?q=if+evensource+connecting+is+lost+what+can+we+receive+on+frontend&oq=if+evensource+connecting+is+lost+what+can+we+receive+on+frontend&gs_lcrp=EgZjaHJvbWUyBggAEEUYOdIBCTE4ODM4ajBqN6gCALACAA&sourceid=chrome&ie=UTF-8 ↩

  40. Google. (n.d.). how properlly handle exceptionally closed eventsource on frontend [search retained by the author]. https://www.google.com/search?q=how+properlly+handle+exceptionally+closed+eventsource+on+frontend&oq=how+properlly+handle+exceptionally+closed+eventsource+on+frontend&gs_lcrp=EgZjaHJvbWUyBggAEEUYOdIBCTIxNTM0ajBqN6gCALACAA&sourceid=chrome&ie=UTF-8 ↩

  41. rhyek. (2014, July 3). Is an EventSource (SSE) supposed to try to reconnect indefinitely? [question, observations on browser version differences]. Stack Overflow. https://stackoverflow.com/questions/24564030/is-an-eventsource-sse-supposed-to-try-to-reconnect-indefinitely See also redrockzee. (2019, January 27). answer to the same question, specifically reconnectFunc and setupEventSource. The quotation is from the comment preceding the doubled retry interval. ↩ ↩2

  42. WHATWG. (n.d.). HTML Standard: Server-sent events [§9.2.2, readyState and events; §9.2.3, reconnection and failure handling]. https://html.spec.whatwg.org/multipage/server-sent-events.html#the-eventsource-interface Used to check API behavior on November 17, 2026. ↩ ↩2 ↩3

  43. CaiBorui [S2thend]. (2025, March 29). Lite MCP SDK: Transport and protocol cleanup [historical source snapshot 3026728, _start, close, send and _onclose]. GitHub. clientTransport.js; protocol.js. ↩ ↩2 ↩3 ↩4 ↩5

  44. MDN contributors. (2024, October 8). EventSource: close() method [opening explanation and Note; date is the page’s stated last-modified date]. MDN Web Docs. https://developer.mozilla.org/en-US/docs/Web/API/EventSource/close ↩ ↩2

  45. CaiBorui [S2thend]. (2025, March 21–29). Two March Development Snapshots of Lite MCP SDK [Git records]. Local client snapshot 527624a (15:39:36) and evening version 3026728 both have initial commit 26a58e5 as their parent. The afternoon copy also had uncommitted changes. The comparison uses commit objects. ↩

  46. CaiBorui [S2thend]. (2025, March 29–April 3). Lite MCP SDK Integration Scripts and Application Wrapper [source code]. GitHub. March 29 client script, March 30 wrapper package, April 3 application wrapper, PromptPulse frontend integration. ↩ ↩2

  47. CaiBorui. (2025, March 29–30). JavaScript to Python Code Translation; JavaScript SSEClientTransport to Python Translation [Cursor discussions and local file history retained by the author]. Files saved March 30 included protocol.py, client.py, client_transport.py and testpy/test.py. Scope in the contemporary README roadmap. ↩

© 2025 borui. All rights reserved. This content may be freely reproduced, displayed, modified, or distributed with proper attribution to borui and a link to the article: borui (2025-03-21). What Is MCP? From Tool Calls to the Protocol Internals. https://caiborui.com/blog/2025-03-21-zh-what-is-mcp-entrans

@misc{borui2025-bb75a370,
  author = {borui},
  title = {{What Is MCP? From Tool Calls to the Protocol Internals}},
  year = {2025},
  publisher = {borui's blog},
  url = {https://caiborui.com/blog/2025-03-21-zh-what-is-mcp-entrans}
}