Published on

MCP (Model Context Protocol): the definitive guide to the protocol connecting AI to everything

Blog
  • Photo of Henrico Piubello
    Henrico Piubello
    Henrico Piubello
    IT Specialist - Grupo Voitto

    IT Specialist - Grupo Voitto

MCP is an open protocol that standardizes how AI applications reach external tools and data. Instead of writing an integration for every model-tool pair, you expose an MCP server and any compatible client automatically sees what it can do.

What problem does MCP actually solve?

MCP exists to eliminate the N×M cost of integration. With N AI applications and M tools, the pre-protocol world required up to N×M dedicated connectors — every IDE, every chat and every agent reimplementing access to the same Jira, the same Postgres, the same Google Drive.

With a common standard, the arithmetic becomes N+M: each tool publishes one server and each application implements one client. It is exactly the logic that LSP (Language Server Protocol) brought to code editors in 2016 — and the analogy is deliberate: Anthropic describes MCP as "the USB-C port of AI applications".

The secondary gain is subtler and more important: runtime discovery. An MCP server describes itself. The model asks "what can you do?" and receives the list of tools with names, descriptions and parameter schemas. That lets you add a new capability to an AI agent without touching its code.

Practical example: you maintain an internal orders system. Without MCP, integrating it with the support team's assistant, the developers' IDE and the WhatsApp bot is three projects. With MCP, it is one server consumed by all three.

How does the MCP architecture work?

MCP is client-server over JSON-RPC 2.0, with three well-defined roles:

  • Host — the application the user operates (Claude Desktop, an IDE, a custom agent). It owns the permission policy.
  • Client — the component inside the host that keeps a 1:1 connection to a server and translates its capabilities into the model's format.
  • Server — the process that exposes the capabilities: it hits the database, calls the API, reads the file.

On that base, the protocol defines three primitives a server can offer:

PrimitiveWhat it isWho controls itExample
ToolsExecutable actions with side effectsThe model decides to callcreate_issue, run_query
ResourcesReadable data addressed by URIThe application selectsfile://report.csv
PromptsReusable instruction templatesThe user triggers"review this PR"

The distinction between tool and resource is what confuses people most on first reading. The rule: if the call changes something or executes logic, it is a tool; if it merely delivers content to be read, it is a resource. A SELECT could be either — publish it as a resource if the set of queries is fixed, as a tool if the model needs to compose the query.

Practical example: a Git repository MCP server exposes list_commits and create_branch as tools, file contents as resources, and a ready-made prompt for "write a commit message following the project's convention".

How do you write an MCP server in practice?

The shortest path is the TypeScript or Python SDK. The minimal structure has three parts: declare the server, register tools with an input schema and choose the transport.

mcp-server.ts
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
import { z } from 'zod';

const server = new McpServer({ name: 'orders', version: '1.0.0' });

server.tool(
  'find_order',
  'Finds an order by its number and returns status, items and dates.',
  { number: z.string().describe('Order number, e.g. ORD-8842') },
  async ({ number }) => {
    const order = await db.orders.findOne({ number });
    if (!order) return { content: [{ type: 'text', text: `Order ${number} not found.` }] };
    return { content: [{ type: 'text', text: JSON.stringify(order, null, 2) }] };
  }
);

await server.connect(new StdioServerTransport());

Three decisions determine whether the server will be useful or frustrating:

  1. The tool description is the prompt. The model chooses what to call by reading that text. "Finds an order by its number" works; "Query endpoint" does not. Say what it does, when to use it and what it returns.
  2. Validate input with a schema. Zod in TypeScript, Pydantic in Python. The model will invent parameters eventually — the schema turns that into a clear error instead of strange behavior.
  3. Return little, and well formatted. Returning 5,000 lines of JSON consumes the context window and degrades the next decision. Truncate, summarize, paginate.

Practical example: a server that returned the full dump of an order spent 8,000 tokens per call. Reduced to a summary of 12 relevant fields, it dropped to 300 — and the agent's accuracy went up, because the model stopped getting lost in the noise.

Local or remote server: which should you choose?

The transport choice defines the entire security model:

AspectLocal (stdio)Remote (HTTP + streaming)
Where it runsThe user's machineA shared server
AuthenticationInherits the OS userOAuth 2.1, scoped tokens
Multi-userNoYes, isolation mandatory
LatencyMinimalNetwork-dependent
Best forDev tooling, file accessCorporate services, SaaS

Local servers are simple because they have no trust boundary — and that is exactly the trap: they run with your permissions. A malicious local MCP server has the same access you do. Install third-party ones with the same scrutiny you apply to a browser extension or an npm package.

Remote servers demand the full work of a public API: authentication, per-tool scopes, rate limiting and auditing. The specification recommends OAuth 2.1 for authorization, which solves identity — but not fine-grained authorization, which remains your application's responsibility.

Practical example: a corporate database MCP server should expose query_sales scoped by region, not run_sql. The first form limits the damage of a wrong model decision; the second turns any failure into an incident.

What are the security risks of MCP?

Three vectors deserve explicit attention, and none of them is hypothetical:

  1. Prompt injection through returned content. The server returns data the model reads as context. If that data contains instructions — a comment on an issue written by an attacker, for instance — the model may obey them. There is no complete fix; the mitigation is limiting what the tools can do, not trusting text filters.
  2. Excess permission. Ready-made servers tend to request broad access because it is easier to document. Review scopes before connecting, especially for servers with write access.
  3. Cross-server agent confusion. With several servers connected, one can influence calls meant for another through misleading tool descriptions. Connect only what the task at hand requires.

It is worth reading up on information security as applied to integrations: the principles have not changed, only who presses the button.

Practical example: a team connected an email MCP server with send permission to the same agent that read web pages. A page with embedded instructions managed to trigger outgoing messages. The fix was not a filter — it was removing the send permission and requiring human confirmation.

Is MCP worth adopting in 2026?

Yes, with one caveat about scope. Adoption is no longer a bet: OpenAI, Google DeepMind and Microsoft announced support through 2025, and the protocol became the common denominator across AI-enabled IDEs, desktop assistants and agent frameworks. Writing proprietary integrations today means redoing them later.

The caveat: MCP is integration infrastructure, not product strategy. It does not improve the quality of the model's decisions, does not reduce hallucination and does not replace the work of designing good tools. If an agent is going to use exactly three internal tools and nothing else, registering those tools directly in the model SDK is simpler and equally effective.

The tipping point is reuse: the moment the same capability needs to be consumed by more than one client, or you want to take advantage of third-party servers, MCP starts saving more than it costs.

Practical example: a company with an internal assistant, an IDE extension and a support bot maintained three integrations with the same ERP. Consolidated into one MCP server, they became a single codebase — and the fourth application was born already connected.

Conclusion

The Model Context Protocol solves an unglamorous and very expensive problem: the multiplication of integrations between AI models and the real world. Its architecture — client-server over JSON-RPC, with tools, resources and prompts — is deliberately simple, and that simplicity is why the entire ecosystem adopted it so quickly. For anyone building agents, the practical recommendation is to start with a small local server, few very well described tools and lean returns, measuring whether the model correctly picks what to call. From there, the path to remote servers is a known API engineering problem — authentication, scope, auditing — with one new complication: the client on the other side is a model that can be induced to err, which is why least privilege stopped being a best practice and became a requirement.

## faq

Frequently asked questions

What is MCP (Model Context Protocol)?

It is an open protocol that standardizes communication between AI applications and external sources of context and action — databases, APIs, file systems, SaaS services. It was published by Anthropic in November 2024 and works as a common layer: any compatible client talks to any compatible server, with no bespoke integration.

What is the difference between MCP and a regular REST API?

A REST API is designed for a program that already knows what it wants to call. MCP is designed for a model that needs to discover what exists: the server describes itself — listing its tools, parameters and return types — so the model can choose at runtime. In practice, MCP is usually a layer on top of existing REST APIs, not a replacement for them.

Do I need MCP to build an AI agent?

No. You can register tools directly in the model SDK. MCP pays off when the same tools need to serve several clients (an IDE, a chat, a pipeline) or when you want to consume ready-made third-party servers without writing integration code.

Is MCP secure?

The protocol itself defines transport and authorization, but real security depends on the implementation. The concrete risks are third-party servers with overly broad permissions, prompt injection through content returned by the server, and credentials shared across tools. The mitigations are the usual ones: least privilege, per-tool scopes, reviewing third-party server code and logging every call.

Which languages have an official MCP SDK?

There are official SDKs for TypeScript, Python, Java, Kotlin, C#, Go, Ruby, Rust, PHP and Swift, plus community implementations. TypeScript and Python account for most published servers.

What is the difference between a local and a remote MCP server?

A local server runs on your machine and communicates over stdio — no network, no authentication, with your user permissions. A remote one is reached over HTTP with streaming, serves multiple clients and requires authentication, scope control and isolation between users. Local is great for development tooling; remote is the model for shared services.

## continue lendo

Keep browsing

About the author

Photo of Henrico Piubello

Henrico Piubello

IT Specialist - Grupo Voitto · Grupo Voitto

See profile and all articles