Share: Facebook LinkedIn X
Interactive MCP Tutorial

Understanding MCP

Learn how Model Context Protocol connects AI apps to tools, resources, prompts, and real-world systems without building a custom integration for every single assistant.

HostThe AI app, like an IDE or desktop assistant.
ClientThe connection manager inside the host.
ServerThe program exposing tools, data, or prompts.
mcp-tool-call.json
// MCP tool invocation over JSON-RPC
{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "tools/call",
  "params": {
    "name": "github_create_issue",
    "arguments": {
      "repo": "lida/rag-demo",
      "title": "Fix retrieval threshold docs"
    }
  }
}
The integration problem

Why MCP exists

Without a shared protocol, every AI application needs custom glue code for every data source and every external action. MCP gives AI applications a common, standardized way to discover tools, read resources, and use reusable prompts across the entire development ecosystem.

🔌

Before MCP

Every assistant needs one-off integrations: a GitHub adapter here, a database adapter there, a filesystem connector somewhere else. Development is fragmented, and every new AI tool requires reinventing the wheel to access your data.

🧭

With MCP

A host connects to one or more MCP servers. The host discovers capabilities, then routes requests through a standard JSON-RPC protocol. You write an integration once, and any MCP-compatible AI assistant can immediately utilize it.

🛡️

The catch

MCP makes tool access incredibly easy, which means permissions, user approvals, strict scoping, comprehensive logging, and prompt-injection defenses become absolutely critical to safe operation.

Mental model

MCP architecture in one picture

Think of MCP as a client-server protocol built around an AI host. The host manages the underlying model and the user experience. MCP servers expose specific capabilities. The client connection handles discovery, calls, and results.

1
User asksThe human asks for an action or answer: "Create a GitHub issue" or "Summarize this schema."
2
Host decidesThe AI app decides whether it needs a tool, resource, or prompt from an MCP server to fulfill the request.
3
Client routesThe MCP client securely sends standard JSON-RPC requests to the relevant MCP server.
4
Server respondsThe server executes the request and returns structured content, data, or action results.
5
LLM continuesThe host feeds the result back into the conversation context so the model can answer or continue its task.
Interactive sandbox

MCP Call Simulator

Choose a scenario and watch how initialization, discovery, permission checks, tool calls, and results work. Everything here is deterministic demo logic. No external API is called.

Local demo • No API keys
Initialize Discover Plan Guardrails Call Result
Available primitives
JSON-RPC exchange
Security decisionBalanced
Host-facing result
Lifecycle

What actually happens during an MCP session

The protocol flow is simple but vitally important. Initialization negotiates capabilities between client and server. Discovery tells the host what exactly exists. Tool calls execute structured operations. Notifications keep the host continuously updated about state changes.

🤝

Initialize

Client and server exchange protocol versions, identities, and supported capabilities to establish a valid connection.

🔎

List

The client calls list methods (like tools/list, resources/list, or prompts/list) to discover exactly what the server exposes.

⚙️

Call or read

The client invokes tools/call or reads resources dynamically after the host evaluates and chooses what it needs.

🔔

Notify

Servers can spontaneously notify clients when available tools, resources, or other capabilities change over time.

Core concepts

Tools, resources, and prompts

Most confusion around MCP disappears completely when these three server-side primitives are clearly understood and separated.

Primitive What it is Example When to use it
Tool An executable action with a strictly defined input schema that the model can invoke. create_issue, query_database, send_slack_message When the AI needs to perform an active task, change state, or dynamically compute a result.
Resource Readable contextual data or files exposed safely by a server. file contents, DB schema, application logs, internal docs When the AI simply needs to read information to gain context without changing state.
Prompt A reusable template or workflow instruction provided by the server. debug_api_error, review_pr_template When you want to enforce a repeatable, domain-specific workflow or predefined instruction set.
Guardrails

Security is not optional

MCP gives models unprecedented access to real tools and real data. That is powerful, but it means bad tool descriptions, overly broad permissions, or prompt injection can rapidly become real operational risks.

🔐

Scope every tool

A tool vaguely named run_sql is extremely dangerous. A tool specifically named read_customer_by_id with a strict validation schema is safe, predictable, and easier to reason about.

👁️

Require approval for writes

Read-only tools can often be automated safely. However, destructive or external write actions (like sending emails or deleting records) should always require explicit human-in-the-loop confirmation.

🧼

Treat tool output as untrusted

Documents, web pages, support tickets, and issue bodies can contain malicious prompt injection. Do not blindly follow instructions found in tool output, and isolate untrusted data.

Production readiness checklist

Use extremely clear tool names and descriptive prompts
Enforce narrow input schemas with strict server-side validation
Always require user approval for writes and destructive actions
Ensure tokens and secrets are never returned to the model context
Implement per-user authorization and the principle of least privilege
Add rate limits, timeouts, and automatic retries for stability
Maintain comprehensive audit logs for all tool invocations
Build observability for failures, latency, and permission denials
Engineering patterns

Common MCP server shapes

Different servers should expose different levels of power. A highly effective MCP server feels like a small, strongly-typed API specifically designed for an assistant, rather than a massive administrative console dumped into the model's context window.

📚

Resource gateway

A read-only context server dedicated to safely exposing docs, files, database schemas, application logs, or internal knowledge bases.

Low riskContext
🧩

Tool adapter

Wraps a single external service with a few highly focused tools. Examples include managing GitHub issues, querying Jira tickets, or resolving Sentry events.

Medium riskActions
🕹️

Workflow orchestrator

Combines multiple complex operations into one safe, high-level workflow, such as “gather logs, summarize errors, and open a bug report.”

Needs approvalWorkflow
Mistakes

MCP anti-patterns

Avoid these common pitfalls when designing tools and resources to ensure your AI assistants remain secure and reliable.

One giant tool

Providing an "execute_anything" tool forces the model to reason about far too much freedom, leading to hallucinations. Always split broad capabilities into smaller, safely scoped actions.

Vague schemas

If tool parameters are loose strings without constraints, the model will inevitably produce invalid calls. Always use strict enums, length constraints, clear descriptions, and robust server-side validation.

Too many tools

Dumping dozens of similar or overlapping tools into the context window confuses the model and makes tool selection harder. Prefer a highly curated, minimal tool surface.

Returning secrets

Never return authentication tokens, user credentials, private keys, or internal infrastructure secrets as part of a tool's output to the model.

No source boundaries

Resource servers must strictly enforce access control. They need to securely know which roots, folders, projects, users, or database tenants the current user is actually allowed to read.

No audit trail

Visibility is crucial. You always need to know precisely who asked for an action, what tool was invoked, with which exact parameters, and what the final outcome was.

Q&A

MCP FAQ

Is MCP the same as an API?
Not exactly. While MCP can wrap APIs, files, databases, and complex workflows, it primarily standardizes the discovery layer, schemas, resources, predefined prompts, and the overall client-server conversation specifically used by AI hosts.
Is MCP the same as function calling?
No. Function calling is typically a core LLM feature allowing models to output structured JSON. MCP is the overarching network protocol that dictates how an AI application discovers and invokes those tools from disparate external servers safely.
When should I expose a tool versus a resource?
Expose a tool when the assistant actively needs to perform an action, mutate state, or compute a dynamic result (e.g., search_database). If it only needs to read static context, exposing a resource is safer and vastly more efficient.
Should write actions be fully automatic?
Usually, no. Write actions that affect real external systems (like sending an email, dropping a table, or committing code) should be clearly scoped and almost always require an explicit user approval prompt before execution.
Can MCP connect safely to private or sensitive data?
Yes, absolutely. However, the MCP server itself must strictly enforce authentication, user authorization, tenant boundaries, and safe output handling to ensure the AI doesn't leak cross-tenant data.
Does using MCP automatically remove security risks?
No. While it standardizes the integration process, security still heavily depends on how you scope tools, validate inputs, enforce approvals, maintain audit logs, and how the host safely handles untrusted, potentially manipulated content.
What is the best way to start building a first MCP server?
Start extremely small: expose a single read-only resource or one highly constrained, safe tool. Excellent starting points include "list recent project notes," "search internal API docs," or "get current weather."
What is the primary difference between STDIO and HTTP transports?
STDIO (Standard Input/Output) is the most common transport for local servers directly launched by a desktop app or IDE host. Streamable HTTP (SSE) is used for remote, distributed servers that need to securely serve multiple clients over a network.
Glossary

Core MCP terms

MCP Host

The primary AI application (like an IDE or chat interface) that manages the user experience, controls the model context window, and enforces security boundaries.

MCP Client

The internal component living inside the host application that actively maintains a protocol connection to one or multiple MCP servers.

MCP Server

An external program or service that securely exposes tools, resources, and prompts to connected MCP clients over a standard transport.

Tool

An executable function accompanied by a strict JSON schema, allowing the model to perform actions like query_database or create_issue.

Resource

Safe, readable contextual data exposed to the model, such as file contents, application logs, internal documentation, or database schemas.

Prompt

A structured, reusable template provided by the server that guides a repeated interaction, best practice, or specific domain workflow.

JSON-RPC

The underlying, stateless message format utilized by MCP for all requests, responses, and real-time notifications between clients and servers.

Transport

The communication channel carrying the JSON-RPC messages. Most commonly STDIO for local, sandboxed servers or Server-Sent Events (HTTP) for remote servers.

Capability negotiation

The initial handshake step where the client and server exchange versions and declare exactly what features and capabilities they support.

Curated links

Learn more

A small set of official or practical references. Not a link dump.

📱 Contact via WhatsApp

Get in touch with us directly on WhatsApp for quick support and questions.

+40 753 358 749