AI

MCP (Model Context Protocol) Basics

Standard way to plug tools, data sources, and IDEs into LLM clients — one protocol, many servers.

Interview tip MCP = USB-C for AI tools. Host (Cursor, Claude) connects to MCP servers (GitHub, DB, filesystem).

① What you must know (30 sec)

MCP (Model Context Protocol) is an open standard connecting hosts (Cursor, Claude Desktop, custom apps) to MCP servers that expose tools (actions) and resources (readable data). One server implementation works across any MCP-compatible host — like USB-C for AI integrations.
Analogy: MCP is USB-C for AI tools: one port on the host (IDE), many peripherals (servers) that plug in without custom drivers per app.

② How it works

MCP architecture
MCP Host↔ protocolMCP ServerTools + Resources
Host — LLM client (Cursor, Claude Desktop) that runs the agent loop
Server — process exposing tools (run query) and resources (read file, fetch doc)
Discovery — host lists available tools/resources at connection time
Invocation — model selects tool; host routes call to correct server
Transports — stdio (local) or SSE/HTTP (remote servers)
Community servers exist for GitHub, Postgres, Slack, Brave Search — check official MCP registry before building custom.

③ Step-by-step (hands-on)

Step 1 — Identify host and needs

Cursor or Claude Desktop — list data sources and actions the agent needs (repo, DB, tickets).

Step 2 — Install community servers

Configure mcp.json with server command, args, and env vars. Restart host to discover tools.

Step 3 — Authenticate safely

Pass API tokens via env — not committed. Use read-only DB credentials where possible.

Step 4 — Test tool discovery

Ask agent "what tools do you have?" Verify expected tools appear before real tasks.

Step 5 — Build custom server (optional)

Use MCP SDK (TypeScript/Python) to wrap internal API as tools with JSON schemas.

Step 6 — Harden for team rollout

Allowlist approved servers; document each tool capability; audit logs on sensitive tools.

④ Code / config patterns

ConceptDescriptionExample
HostRuns LLM + connects serversCursor IDE
ServerExposes capabilitiesgithub-mcp-server
ToolAction with side effectscreate_issue, run_query
ResourceReadable data URIfile://, db schema
TransportConnection channelstdio, SSE
// ~/.cursor/mcp.json (conceptual)
{
  "mcpServers": {
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": { "GITHUB_TOKEN": "${GITHUB_TOKEN}" }
    },
    "postgres": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-postgres"],
      "env": { "DATABASE_URL": "${DATABASE_URL}" }
    }
  }
}

⑤ Production & pitfalls

PitfallWhy it hurtsFix
Over-permissioned serversAgent deletes prod dataRead-only creds; separate write tools with approval
Unvetted community serversMalicious code in server processAllowlist; review server source
Secrets in mcp.json committedToken leak in gitEnv var references only; .gitignore config
Too many tools enabledModel picks wrong toolEnable minimal set per project
No transport security (remote)MITM on SSETLS, auth tokens, private network
Confusing MCP with function callingMCP is cross-app standard; function calling is per-APIUse MCP for reusable integrations
Production tips:
  • Central IT-approved server catalog for enterprise
  • Per-team mcp.json templates with least privilege
  • Log every tool invocation with user and args (redacted)
  • Sandbox custom servers before org-wide deploy

⑥ Interview / on-the-job Q&A

QuestionAnswer
What is MCP?Open protocol for LLM hosts to connect to external tools and data via MCP servers.
Host vs server?Host runs the AI client; server exposes tools/resources the host can call.
Tool vs resource?Tool performs an action; resource is addressable read-only data.
Why not custom plugins?Write once, use in Cursor, Claude, and other MCP hosts.
stdio vs SSE?stdio for local subprocess servers; SSE/HTTP for remote networked servers.
Security concern?Servers run with your credentials — treat like installing software with API access.

⑦ Tools & ecosystem

  • Hosts: Cursor, Claude Desktop, custom MCP clients
  • SDK: @modelcontextprotocol/sdk (TS), mcp Python
  • Servers: GitHub, Postgres, filesystem, Brave Search, Slack
  • Registry: MCP server directory (official/community)
mcptoolscursorintegrationprotocol

⑧ Revision checklist

  • MCP host configured (Cursor mcp.json or Claude config)
  • Only required servers enabled
  • Credentials via environment variables
  • Read-only access for exploratory DB tools
  • Tool list verified after host restart
  • Custom servers code-reviewed before use
  • Team allowlist of approved MCP servers
  • Sensitive tool calls audit-logged
  • Understand difference from in-app function calling