Create

Sign in to ReadmeX

or

How we handle your data: Privacy Policy

ReadmeX

Your AI reading companion

What would you like to catch up on?

Pick a briefing, or ask your own question.

Your community and people briefings stay personal to you.

Story

Engineering Three Internal MCP Servers for AI Clients

AI summary

An engineering team deployed three MCP Servers for ticket queries, release records, and configuration data, after which they ran for two weeks with roughly 200 calls per day, according to a Juejin AI engineering retrospective. The team recommends reserving stdout exclusively for JSON-RPC messages, sending logs to stderr, trimming tool responses, paginating list results, setting timeouts below 30 seconds, and returning structured errors with actionable hints. The article’s deployment figures and before-and-after results are self-reported and have not been independently verified.

In-depth insight

The retrospective provides concrete implementation guidance for MCP deployments, including process isolation, output shaping, timeout handling, and error contracts that determine whether AI clients can use internal tools reliably.

上个月我们组接了个需求:让 AI 客户端能直接查工单、看发布记录、读配置中心。听起来像是写几个 HTTP 客户端就完事,实际做下来,真正花时间的部分是"进程被谁启动、在什么环境下启动、失败了怎么告诉模型"这三件事。三个 Server 上线两周,日均调用 200 次左右,我把踩坑和最终的设计取舍整理成这篇复盘,重点放在工程侧而不是协议介绍。

一、MCP 的进程模型决定了大部分设计约束

MCP 是基于 JSON-RPC 2.0 的通信协议,客户端以子进程方式拉起 Server,通过 stdin/stdout 交换消息。这个模型有三个直接后果,每个都影响架构决策。

第一,stdout 被协议独占。任何 print 都会污染消息流,导致客户端解析失败。我们统一在项目模板里加了一条 lint 规则,禁止在 server.py 及其依赖模块里出现裸 print,日志一律走 stderr:

import sys

def log(level: str, msg: str) -> None:
    print(f"[{level}] {msg}", file=sys.stderr, flush=True)

#Model Context Protocol#JSON-RPC 2.0#FastMCP#Redis

Original · 6 min readRead the original
Group chat

No comments yet. Start the conversation.