THE PROJECT One small server, every MCP concept
Build one local MCP server (FastMCP) that deliberately exposes every MCP feature — the three primitives (tools · resources · prompts), both transports (stdio & streamable HTTP), and the advanced client-facing features (sampling · roots · elicitation) — then connect it to a host (Claude Code / Claude Desktop). It's themed on Ops, so it also becomes the real MCP layer for G4 and G5. All data is mock; it's a few dozen lines.
WHICH PORTFOLIO PROJECTS USE MCP
MCP fits wherever an agent must reach external systems through standardized, reusable tools/resources. Best-fit first:
| Project | MCP fit | What becomes MCP |
|---|---|---|
| G4 · RCA Copilot | ★★★ (the showcase) | A Databricks MCP server (read-only tools) + a ServiceNow MCP server (draft ticket) + runbooks as resources + /rca as a prompt — uses all three primitives across two servers |
| G5 · Runbook Agent | ★★★ | Runbooks & past incidents exposed as resources; search as a tool |
| P4 · Support Agent | ★★★ | CRM / ticketing / knowledge-base via MCP servers (tools) |
| P0 · Text-to-SQL | ★★ | A database MCP server: run_sql tool + schema as a resource |
| G6/G8/G9/G10 | ★★ | Cost / DQ / Git-CI / Unity-Catalog MCP servers (read-only tools + resources) |
| G1 · Health Sentinel | ★ (optional) | Could consume a Databricks read-only MCP server for signals — but G1 is a single call, so MCP is optional |
| Second-Brain | ★ | Memory exposed as an MCP server (tools to write, resources to read) |
MENTAL MODEL Host · Client · Server
MCP is an open protocol (JSON-RPC 2.0) with a strict topology: a host (the LLM app) runs one client per server. Servers expose capabilities; the host decides what reaches the model.
tools · resources · prompts"] C2 <-->|"JSON-RPC"| S2["MCP server: servicenow"] LLM -.->|"reverse: sampling / elicitation"| C1 classDef s fill:#f3f0ff,stroke:#764ba2,color:#4a3b7a; class S1,S2 s;
On connect there's an initialization handshake with capability negotiation, then the client discovers
what the server offers (tools/list, resources/list, prompts/list) — dynamically,
so a server can add a tool and emit a list_changed notification without a client redeploy.
THE THREE PRIMITIVES …and who controls each
The single most-tested MCP fact: each primitive is controlled by a different party.
| Primitive | Controlled by | What it is | In this Ops server |
|---|---|---|---|
| Tools | MODEL | Actions the model chooses to call (like tool use). Can have side effects. | get_job_runs(), get_run_logs() (read-only) |
| Resources | APP / HOST | Read-only context data addressed by URI; the host decides when to load it. | runbook://schema-drift, incident://INC-1042 |
| Prompts | USER | Reusable templates / workflows, usually surfaced as slash commands. | /rca <run_id>, /weekly-brief |
TRANSPORTS Local (stdio) vs remote (streamable HTTP)
| stdio | Streamable HTTP | |
|---|---|---|
| Where the server runs | Local subprocess of the host | A remote service (its own URL) |
| Transport | JSON-RPC over stdin/stdout | JSON-RPC over HTTP (SSE for streaming) |
| Auth | OS process / local trust | OAuth 2.1 (authorization) |
| Use when | Personal/local tools, filesystem, dev | Shared/hosted servers, multi-user, SaaS |
ADVANCED — the reverse direction sampling · roots · elicitation
Beyond exposing capabilities, a server can call back into the client. These are the features people forget:
- Sampling — the server asks the client's LLM to generate something (
ctx.sample(...)). The server needs no API key of its own; the host stays in control and can require approval. - Elicitation — the server asks the user for structured input mid-operation (
ctx.elicit(...), with a JSON schema). E.g. "which environment — dev or prod?" - Roots — the client tells the server the filesystem/URI boundaries it may operate within (a scoping guardrail).
SECURITY the part the exam loves
- MCP tool/resource output is UNTRUSTED — it can carry prompt injection. Treat it as data, isolate it, least-privilege the tools. (Same lesson as GR-INJ.)
- Human approval on tool execution — the host should confirm before a server tool runs, especially write actions.
- Allow-list servers — only connect to trusted MCP servers; a malicious server is a supply-chain risk.
- Remote auth = OAuth 2.1 — don't hand a server long-lived secrets.
- Token pass-through is an anti-pattern — a server must not blindly forward the client's token to a downstream API (confused-deputy / privilege-escalation risk). Scope credentials per server.
BUILD IT the whole server (FastMCP, mock-first)
mcp Python package (FastMCP). 🗄️ Data — mock JSON (job runs, runbooks, incidents).
🖥️ Host — Claude Code or Claude Desktop via a tiny
.mcp.json. 🚫 No Docker — a local stdio subprocess.
# pip install mcp · run: python server.py · host connects via .mcp.json from mcp.server.fastmcp import FastMCP, Context import json mcp = FastMCP("lakehouse-ops") # 1) TOOL — MODEL-controlled action. The DESCRIPTION drives selection (D4). Read-only. @mcp.tool() def get_job_runs(window_min: int = 60) -> list[dict]: """Recent Databricks job runs (read-only). Use to check pipeline health.""" return json.load(open("mock/runs.json")) # 2) RESOURCE — APP/HOST-controlled context, addressed by URI. Read-only. @mcp.resource("runbook://{name}") def runbook(name: str) -> str: """A runbook the host can pull into context on demand.""" return open(f"mock/runbooks/{name}.md").read() # 3) PROMPT — USER-controlled template, surfaced as a slash command. @mcp.prompt() def rca(run_id: str) -> str: """/rca — investigate a failed run using the tools and runbook resources.""" return f"Investigate run {run_id}. Call get_job_runs, read the relevant runbook, cite evidence." # 4) SAMPLING — the server asks the CLIENT'S LLM (no server API key needed). @mcp.tool() async def summarize_health(ctx: Context) -> str: """One-line health summary — generated by the host's model via sampling.""" runs = json.load(open("mock/runs.json")) reply = await ctx.sample(f"Summarize pipeline health in one line:\n{runs}") return reply.text # 5) ELICITATION — the server asks the USER for structured input mid-call. @mcp.tool() async def health_check(ctx: Context) -> str: """Ask which environment, then report (human stays in the loop).""" answer = await ctx.elicit("Which environment?", schema={"type":"string", "enum":["dev","prod"]}) return f"Checked {answer} — all green (mock)." if __name__ == "__main__": mcp.run() # stdio (local). Remote: mcp.run(transport="streamable-http")
Connecting the host (.mcp.json)
# .mcp.json (Claude Code) — how a host discovers & launches the server { "mcpServers": { "lakehouse-ops": { "command": "python", "args": ["server.py"] } // remote instead: "lakehouse-ops": { "url": "https://ops.internal/mcp" } } }
tool_use block, a tool_result back. MCP is the standard packaging & discovery layer
around tools/resources/prompts, so many hosts can reuse one server. Everything you learned in
the Claude API tool loop (D4) still applies.CUSTOM TOOLS vs MCP when to use which
🔌 Reach for MCP when…
- The integration should be reusable across hosts (Claude Code, Desktop, your app)
- You want standard discovery, resources & prompts, not just functions
- It's a shared/hosted capability (a team Databricks or ServiceNow server)
- A vendor already ships an MCP server you can plug in
🛠️ Just define API tools when…
- The tools are internal to one app and won't be reused elsewhere
- You want the simplest path — the Messages API tool loop / Tool Runner
- No need for resources/prompts or cross-host sharing
tool_use/tool_result to the model. MCP adds a protocol &
ecosystem; custom tools add nothing to learn. The exam wants you to justify the choice.FAILURE POINTS
.mcp.json.CONCEPTS → CCA MAP
| You practised… | CCA domain |
|---|---|
| MCP primitives (tools/resources/prompts) & who controls each | D4 · Tool Design & MCP |
| Transports (stdio / streamable HTTP), discovery, capability negotiation | D4 |
| Sampling, elicitation, roots | D4 |
| MCP security (untrusted output, OAuth, approval, token pass-through) | D4 · D5 (guardrails) |
| MCP vs custom tools; tool descriptions drive selection | D4 · D2 (Claude Code config) |
LEVEL IT UP
- Second server → add a ServiceNow MCP server and watch the host route across two — namespacing in practice.
- Go remote → run it as streamable HTTP with OAuth; feel the local-vs-remote difference.
- Wire it into G4 → point the RCA Copilot's read-only tools at this server instead of local functions.
- Add
list_changed→ mutate the toolset at runtime and see dynamic re-discovery. - Approval hook → require host confirmation before any tool runs (guardrail in practice).