逐日AI

面试题库

共 328 题,当前筛选 1 题。

30 天从前端工程师到 Agent 工程师

D23 MCP 与 Skills:协议、server/client、与 function calling 区别;Claude Agent SDK 一览

  • 什么场景下应该考虑用 MCP,而不是直接写 function calling?不该用的时候硬上会付出什么代价?When should you reach for MCP instead of plain function calling, and what does it cost when you shouldn't?
    国内高频海外高频进阶#mcp#architecture#trade-offs

    分析过程 · 先想清楚再作答

    1. 题眼在后半句。只会说「MCP 更标准更解耦」的人,等于说「微服务更解耦」——听起来对,但没有判据,面试官会立刻追问「那你们所有工具都做成 MCP server 了吗」。
    2. 先给判据,而且要是可执行的三条:能力要被多个宿主复用、能力由另一个团队或第三方维护、需要不改宿主代码就能增删能力。命中任意一条才考虑,**一条都不命中就直接写本地函数**——把默认答案摆成「不上」,这条比三条判据本身更能体现工程判断。
    3. 每条判据配一句为什么:多宿主复用把 N 乘 M 变成 N 加 M;别人维护时进程边界就是责任边界,他们改他们的、你不用发版;热插拔让加一个内部工具从一次发布降级成一次配置变更。
    4. 然后老实说代价,这是区分「用过」和「读过」的地方:多一个进程要保活、多一次握手要处理超时与重连、排障链路从一段变三段——工具没被调用,现在可能是模型没选、可能是 schema 翻译时丢了字段、也可能是 server 压根没起来。stdio 的子进程还要你自己回收,否则留孤儿进程。
    5. 还有一条容易被忽略但很加分:MCP 不改变你的成本结构。工具描述照样每轮都进上下文,工具多了照样会让模型选错——D5 那条「工具超过一定数量就该合并描述」在接了 MCP 之后一字不变,甚至更需要,因为现在别人可以往你的工具列表里塞东西。
    6. 可以预期的追问:那内部工具一律不上 MCP 吗?不是。有一类值得例外——你希望它能被 IDE 里的助手和运维机器人一起用,那第一条判据就命中了,即使它是你自己维护的。

    How to reason about it · think before answering

    1. The hinge is the second half. Answering only 'MCP is more standard and decoupled' is like saying 'microservices are more decoupled' — true-sounding but with no criterion, and the interviewer will immediately ask whether you turned every tool into an MCP server.
    2. Give three actionable criteria: the capability must be reused by more than one host, owned by another team or a third party, or added and removed without changing host code. Any one of them justifies MCP; none of them means write a local function. Making 'no' the default answer shows more engineering judgment than the criteria themselves.
    3. Attach a reason to each: multi-host reuse turns N times M into N plus M; external ownership makes the process boundary the responsibility boundary, so their change is not your release; hot-swapping demotes adding an internal tool from a deployment to a config change.
    4. Then state the costs honestly, which is where shipped experience shows: another process to keep alive, another handshake with its own timeouts and reconnects, and a debugging path that went from one hop to three — a tool that never got called might mean the model did not pick it, the schema lost fields in translation, or the server never started. On stdio you also own reaping the child process.
    5. One more point that is easy to miss and scores well: MCP does not change your cost structure. Tool descriptions still enter the context every turn, and more tools still degrade tool selection. The rule that you should consolidate tools past a certain count survives MCP unchanged — arguably it matters more, because now other people can add entries to your tool list.
    6. Expect the follow-up: so internal tools never go through MCP? Not quite. If you want the same capability available to an IDE assistant and an ops bot as well, the first criterion is met even though you own the code.

    答题要点

    • 三条判据,命中任意一条才考虑 MCP:多宿主复用、由他人维护、需要不改代码增删能力
    • 默认答案是不上:三条都不命中就直接写本地函数,这是更好的工程决策
    • 代价是多一个进程要保活、多一次握手要处理超时、排障从一段链路变成三段
    • MCP 不改变成本结构:工具描述照样每轮进上下文,工具过多照样会让模型选错,该合并还是要合并
    • 第三方能力接进来之后,工具列表不再完全由你掌控,这本身就是需要设计的一件事

    Key points

    • Three criteria, any one justifies MCP: reuse across hosts, ownership by another team, or add/remove without touching host code
    • The default is no — if none of the three apply, a local function is the better engineering decision
    • Costs: another process to supervise, another handshake with timeouts, and a debug path that grows from one hop to three
    • MCP does not change your cost structure: descriptions still enter context every turn and too many tools still hurt selection
    • Once third-party capabilities are attached, your tool list is no longer fully under your control, which is itself a design problem