Module 3 · AI ENGINEERING ENGLISH
🔥 19 day streak

Lesson 20: Model Context Protocol (MCP) Integration

2026-06-21 · ~20 min · B1 → C1 · Section 1 / 8
Section 1 Today's Scenario
#TKT-5102 P1 · Critical Investigating

CLAUDE CODE CLI / MCP SERVER

MCP Server Tool Call Intermittent Failures

We are integrating our custom MSP automation platform with the Claude Code CLI via a local MCP server. However, the client is occasionally failing to parse the tool execution results, returning an "Invalid JSON-RPC response" error during high-concurrency tool calls.

我们正在将自定义的MSP自动化平台与Claude Code CLI通过本地MCP服务器进行集成。但是在高并发调用工具时,客户端偶尔无法解析工具执行结果,并返回“Invalid JSON-RPC response”错误。

Section 2 Core Vocabulary Click gray bar to reveal Chinese
Context Window /ˈkɒn.tekst ˈwɪn.dəʊ/ 上下文窗口

The maximum total amount of text (tokens) an AI model can process in a single request.

"We need to truncate the tool output to ensure it doesn't exceed the model's maximum context window."

Context Injection /ˈkɒn.tekst ɪnˈdʒek.ʃən/ 上下文注入

The process of dynamically loading relevant external data directly into the LLM's prompt.

"The MCP server handles context injection by exposing local file systems as URIs."

Tool Calling /tuːl ˈkɔːl.ɪŋ/ 工具调用

The mechanism allowing an LLM to request the execution of a specific function via structured JSON.

"The new Claude model supports parallel tool calling, which heavily speeds up our automation workflows."

Sampling /ˈsɑːm.plɪŋ/ 采样 / 生成参数控制

The logic governing how tokens are generated from the model's output distribution (e.g., temperature, top-p).

"We delegate the sampling parameters to the client orchestrator rather than hardcoding them in the MCP server."

Bi-directional /ˌbaɪ.dɪˈrek.ʃən.əl/ 双向的

Allowing data to flow actively in both directions between the client and the server.

"MCP establishes a bi-directional communication channel over standard input/output streams."

Stateless /ˈsteɪt.ləs/ 无状态的

A protocol design where no session information is retained by the server between requests.

"Although the transport is persistent, the MCP tool execution requests themselves are entirely stateless."

Section 3 Native Engineer Expressions
JG

"The MCP server is failing to parse the tool arguments."

MCP服务器无法解析工具参数。 · Use when debugging schema validation errors

JG

"Let's expose this database query as an MCP tool."

把这个数据库查询暴露为MCP工具。 · Use during architecture design for agent capabilities

JG

"We are blowing past the context limit with these logs."

这些日志让我们的上下文超限了。 · Use when the injected resource payload is too large

JG

"Can we verify if the server is emitting the correct JSON-RPC payload?"

能确认下服务器发送的JSON-RPC payload是否正确吗? · Use when troubleshooting transport layer issues

JG

"The agent is getting stuck in an infinite tool-calling loop."

Agent陷入了无限的工具调用循环中。 · Use when LLM orchestration logic fails repeatedly

Section 4 Technical Reading

The Model Context Protocol (MCP) standardizes how AI models interact with external data sources and tools. When the Claude Code CLI initializes an MCP connection, it negotiates capabilities using a bi-directional JSON-RPC protocol over standard input/output (Stdio) or Server-Sent Events (SSE).

Once connected, the MCP server can expose resources, which allow for seamless context injection directly into the model's prompt. Furthermore, the server can register specific schemas for tool calling. A common pitfall is returning a massive payload that blows past the LLM's context window. To prevent this, developers should implement pagination for resource URIs or summarize the tool output before returning it to the client.

Because MCP requests are inherently stateless, the server does not remember previous interactions. Therefore, the orchestrator client must retain the conversation history and control the sampling logic.

Comprehension Check

1. What is the primary purpose of exposing resources in MCP?

To handle load balancing for the Stdio transport.
To negotiate client capabilities during initialization.
To allow seamless context injection into the model's prompt.
To bypass the standard JSON-RPC protocol.

2. What is a recommended practice to avoid exceeding the context window?

Switch from Stdio to the SSE transport layer.
Implement pagination for resource URIs or summarize outputs.
Make the MCP requests stateful instead of stateless.
Delegate token sampling back to the MCP server.

3. Because the MCP server is stateless, which entity is responsible for maintaining the conversation history?

The MCP server's database.
The exposed Resource URI.
The JSON-RPC payload.
The client orchestrator.
Section 5 Writing Task

Write a brief Slack update explaining the root cause of the MCP integration bug and your proposed solution.

  • 1.Mention that the JSON-RPC payload is too large.
  • 2.Explain that it exceeds the LLM's context window limit.
  • 3.Propose implementing pagination or truncating the tool output.
  • 4.Keep it under 80 words.
0 words
Section 6 AI Review Rubric
Grammar / 20 pts
Correct tense usage when explaining the bug and proposing the solution.
Vocabulary / 20 pts
Accurately uses terms like "payload", "context window", or "pagination".
Clarity / 20 pts
The root cause (size limit) and action item (pagination) are stated immediately.
Professionalism / 20 pts
Tone is direct, factual, and solution-oriented for a fast-paced engineering team.
Native-like Expression / 20 pts
Uses phrases like "blowing past", "truncating", or "I propose we...".
Total 100 pts
Section 7 Spaced Repetition Review Tap card to flip

3 Words from Previous Lessons

Subprocess

子进程

An independently running process launched by the main app.

Pagination

分页

Dividing large data sets into smaller, discrete chunks.

Prompt Template

提示词模板

A structured blueprint injected with variables before generation.

2 Expressions from Previous Lessons

"The SSE connection is timing out during the handshake phase."

"Let's mock the MCP client to isolate the tool execution logic."

Section 8 Challenge Zone ⚡ Above current level

When designing an MCP server that exposes sensitive database queries as tools, how do you handle authentication and authorization, given that the protocol itself operates locally over Stdio?

Answer in English. Use technical vocabulary from this lesson. No word limit.