MCP vs API: Why traditional APIs are failing AI agents

por Google Cloud Tech

Inglês · Intermediário · 12:25 · 562 palavras únicas

MCPs explained → https://goo.gle/4wjeLka Google MCP repo → https://goo.gle/4aeGUA5 Model Context Protocol (MCP) → https://goo.gle/4uQk3D8 MCP vs API: What's the difference and why does it matter for AI developers? In this video, Smitha Kolan breaks down how Model Context Protocol (MCP) works, how it's different from traditional APIs, and why it's becoming the new standard for connecting AI agents to tools, data, and systems. For decades, APIs have been the universal handshake between softw

Transcrição e tradução

Cada frase em Inglês seguido da tradução em português.

If you've ever built an app that talks to an AI model,

Se você já desenvolveu um aplicativo que se comunica com um modelo de IA,

MCP changes everything.

o MCP muda tudo.

Because the way AI connects to your tools, data,

Porque a forma como a IA se conecta às suas ferramentas, aos seus dados,

and systems is being completely rewritten.

e os sistemas estão sendo completamente reescritos.

For years, APIs used to be the glue that held everything

Durante anos, as APIs costumavam ser a cola que mantinha tudo

together.

juntos.

But now there's a new standard rising fast,

Mas agora tem um novo padrão surgindo rápido,

and that something is called the model context protocol, or MCP.

e isso se chama protocolo de contexto do modelo, ou MCP.

And it might just be the biggest shift since APIs themselves.

E essa pode muito bem ser a maior mudança desde o surgimento das próprias APIs.

So what exactly is MCP, and why are people

Então, o que exatamente é o MCP, e por que as pessoas

saying it could replace the way we integrate AI

dizendo que isso poderia substituir a maneira como integramos a IA

with everything around it.

com tudo o que vem junto.

Let's break it down clearly so that by the end of this video,

Vamos explicar isso direitinho para que, ao final deste vídeo,

you'll understand how MCP actually works

você vai entender como o MCP realmente funciona

and how it's different from APIs,

e como isso é diferente das APIs,

and why it's reshaping how we build agents and applications

e é por isso que está remodelando a forma como criamos agentes e aplicativos

that use large language models.

que use grandes modelos de linguagem.

For decades, API were the universal handshake

Por décadas, as APIs foram o “aperto de mão” universal

between systems.

entre sistemas.

You define an endpoint, you send a request

Você define um endpoint, manda uma solicitação

and you got a response back.

e você recebe uma resposta de volta.

It's clean and predictable, and for traditional software,

É simples e previsível, e para o software tradicional,

that is perfect.

que é perfeita.

But when large language models enter the picture,

Mas quando grandes modelos de linguagem entram em cena,

everything changed.

tudo mudou.

Models don't just call one endpoint,

Os modelos não se limitam a chamar um único endpoint,

they might talk to 10 endpoints.

podem se comunicar com 10 endpoints.

They want to chain them together or even interpret

Eles querem encadeá-las ou até mesmo interpretá-las

unstructured data and also ask follow up questions.

dados não estruturados e também fazer perguntas complementares.

And that means they don't just need access to a tool,

E isso significa que elas não precisam apenas de acesso a uma ferramenta,

they also need context.

mas também precisam de contexto.

But here's the problem APIs are built for programs

Mas eis o problema: as APIs são feitas para programas

talking to programs.

se comunicam com programas.

They are not built for models.

Elas não foram feitas para modelos.

Reasoning over messy real world data and API

Raciocínio sobre dados confusos do mundo real e API

is like a locked cabinet.

é como um armário trancado.

You need to know exactly what drawer to open

Você precisa saber exatamente qual gaveta abrir

and what shape the key is.

e qual é o formato da chave.

But a model is trying to understand

Mas um modelo está tentando entender

what's inside the cabinet without clear labels

o que tem dentro do armário sem etiquetas claras

so it doesn't know which function to call

Então ele não sabe qual função chamar

or which parameters to pass until you tell it.

ou quais parâmetros passar, até você dizer a ele.

And you have to hardcode it sometimes.

E, às vezes, você tem que fazer a codificação manual.

And oftentimes have to keep explaining over and over again.

E muitas vezes você tem que ficar explicando isso de novo e de novo.

That's where MCP comes in.

É aí que entra o MCP.

It was designed to make models autonomously discover and use

Ele foi projetado para fazer com que os modelos descubram e usem de forma autônoma

tools without the constant hand-holding

ferramentas sem precisar ficar sempre na cola

that we've been doing in prompt engineering.

É isso que a gente vem fazendo na engenharia de prompts.

So before we dive deeper, let's define both sides.

Então, antes de nos aprofundarmos, vamos definir os dois lados.

Clearly, APIs are the traditional way software

Claro, as APIs são a maneira tradicional de software

communicates.

comunica-se.

They expose specific endpoints.

Elas expõem endpoints específicos.

They accept requests in structured formats like JSON,

Elas aceitam solicitações em formatos estruturados como JSON,

and they return predictable outputs.

E elas retornam resultados previsíveis.

Developers document them, secure them, and version them.

Os desenvolvedores as documentam, protegem e controlam suas versões.

But they assume one thing that both sides

Mas elas partem de uma suposição que ambos os lados

knows exactly what to expect.

Ele sabe exatamente o que esperar.

MCP flips that assumption.

O MCP inverte essa suposição.

Instead of the model needing to be manually thought

Em vez de o modelo precisar ser configurado manualmente

about each endpoint, MCP gives the model a standardized way

Sobre cada endpoint, o MCP oferece ao modelo uma maneira padronizada

to discover what a tool can do.

para descobrir o que uma ferramenta pode fazer.

What kind of inputs it expects, and what kind of outputs

que tipo de entradas ele espera e que tipo de saídas

it returns all through context.

que ele retorna tudo com base no contexto.

Think of it like giving a model a live, machine readable

Pense nisso como se fosse dar ao modelo uma descrição em tempo real, legível por máquina

map of your API instead of a static instruction manual.

um mapa da sua API em vez de um manual de instruções estático.

Now that sounds abstract, so let's make it real.

Isso parece meio abstrato, então vamos colocar na prática.

Imagine you're building an AI agent that

Imagina que você está criando um agente de IA que

manages support tickets.

gerencia os tickets de suporte.

You give it access to Gmail, notion, and Jira.

Você dá a ele acesso ao Gmail, ao Notion e ao Jira.

With APIs.

Com as APIs.

You'd write custom code for each integration,

Você teria que escrever código personalizado para cada integração,

handle issues like pagination, auth tokens, error cases,

lidar com questões como paginação, tokens de autenticação, casos de erro,

rate limits, and also teach the model through long prompts

limites de taxa e também ensinar o modelo por meio de prompts longos

like when you want to create a Jira ticket.

, como quando você quer criar um ticket no Jira.

Call this endpoint with these fields when

Chame esse endpoint com esses campos quando

you want to reply to an email, call Gmail with this payload,

se quiseres responder a um e-mail, chama o Gmail com essa carga útil,

but with MCP you don't need to do any of that.

mas, com o MCP, você não precisa fazer nada disso.

Each service like Gmail, notion, Jira exposes and MCP

Cada serviço, como o Gmail, o Notion e o Jira, expõe um MCP

compatible interface.

interface compatível.

The model discovers these tools automatically

O modelo descobre essas ferramentas automaticamente

and understands their functions as part of its environment.

e entende as funções deles como parte do seu ambiente.

You don't tell it how to do it, you give the context

Você não diz a ele como fazer isso, você fornece o contexto

and it figures it out dynamically.

e ele descobre isso dinamicamente.

That's the core difference between APIs,

Essa é a principal diferença entre as APIs,

which are code level contracts between two applications,

que são contratos no nível do código entre dois aplicativos,

and MCP, which is a semantic protocol between a model

e o MCP, que é um protocolo semântico entre um modelo

and its environment.

e seu ambiente.

So you're no longer teaching the model which endpoint to hit,

Então, você não precisa mais ensinar ao modelo qual endpoint acessar,

but you're giving it a structured description of what's

mas você está fornecendo a ele uma descrição estruturada do que está

available and letting it reason about which tool to use

disponível e deixando que ele decida qual ferramenta usar

and when.

e quando.

It's like giving the model a toolbox instead

É como dar ao modelo uma caixa de ferramentas em vez de

of forcing it to memorize how each tool works.

de forçá-lo a memorizar como cada ferramenta funciona.

This shift might sound small, but it's actually

Essa mudança pode parecer pequena, mas na verdade é

massive for developers building agentic systems with APIs.

Isso é incrível para desenvolvedores que estão criando sistemas baseados em agentes com APIs.

The logic of what to call and when to call it

A lógica de o que chamar e quando chamar

lived in your app code.

que está no código do seu app.

With MCP, that logic can actually

Com o MCP, essa lógica pode, na verdade,

move into the model's reasoning layer itself.

Vamos dar uma olhada na própria camada de raciocínio do modelo.

You can now build a general purpose agent

Agora você pode criar um agente de uso geral

that can plug into any tool that supports the protocol,

podes conectar a qualquer ferramenta que suporte o protocolo,

without having to rewrite code for each integration.

sem precisar reescrever código para cada integração.

That's the magic here, and it's standardization the same way

Essa é a mágica aqui, e é a padronização da mesma forma

HTTP made websites interoperable,

o HTTP tornou os sites interoperáveis,

allowing them to share and use data

permitindo que elas compartilhem e usem dados

with each and other systems, and letting them work together

com cada um dos outros sistemas, e fazer com que funcionem juntos

to perform tasks with minimal human intervention.

para realizar tarefas com intervenção humana mínima.

MCP is trying to make AI environments interoperable.

o MCP está tentando tornar os ambientes de IA interoperáveis.

But let's talk about what's actually

Mas vamos falar sobre o que realmente

happening under the hood.

isso tudo acontece nos bastidores.

And MCP server is a lightweight process that sits next

E o servidor MCP é um processo leve que fica ao lado

to your service or data source.

ao seu serviço ou fonte de dados.

It describes what it can do and what functions it exposes,

ele descreve o que pode fazer e quais funções expõe,

all using JSON schemas.

todas usando esquemas JSON.

The model connects to this server

o modelo se conecta a esse servidor

through a standardized interface like WebSocket or HTTP,

por meio de uma interface padronizada como WebSocket ou HTTP,

and receives metadata about the available resources.

e recebe metadados sobre os recursos disponíveis.

Once connected, the model can call these functions directly,

Uma vez conectado, o modelo pode chamar essas funções diretamente,

not by guessing, but by using the metadata.

não por adivinhação, mas usando os metadados.

It knows what inputs are required

ele sabe quais entradas são necessárias

and what each field means and what type of output to expect.

e o que cada campo significa e que tipo de resultado esperar.

The beauty is that everything is self-describing.

O legal é que tudo é autoexplicativo.

You don't have to prompt engineer the schema or reformat

Você não precisa se preocupar em projetar o esquema ou reformatar

responses.

respostas da API.

It's all standardized.

Tudo é padronizado.

Compare that to an API where every single integration

Compare isso com uma API em que cada integração

is bespoke.

é feito sob medida.

You need a developer to read the docs, map the payloads,

Você precisa de um desenvolvedor para ler a documentação, mapear as cargas úteis,

and manually wrap the endpoints so MCP abstracts that away.

e envolver manualmente os endpoints, então o MCP abstrai isso.

This means instead of building 100 custom integrations,

Isso significa que, em vez de criar 100 integrações personalizadas,

you build one MCP interface and every compatible model

Você cria uma interface MCP e todos os modelos compatíveis

can use it instantly.

Você pode usar isso na hora.

That's why people are calling MCP the plug and play

É por isso que as pessoas estão chamando o MCP de “plug and play”

layer for AI systems.

para sistemas de IA.

Now, this doesn't mean APIs are going away.

Agora, isso não significa que as APIs vão desaparecer.

APIs are still the foundation.

As APIs continuam sendo a base.

They're how your systems actually function.

É assim que seus sistemas realmente funcionam.

But MCP changes how models access those APIs.

Mas o MCP muda a forma como os modelos acessam essas APIs.

Think of it like this.

Pense nisso assim.

MCP doesn't replace your backend.

O MCP não substitui seu back-end.

It replaces the middleware between the model and the API.

Ele substitui o middleware entre o modelo e a API.

The MCP server acts like a translator,

O servidor MCP age como um tradutor,

converting your existing APIs into a format

convertendo suas APIs existentes para um formato

that models can understand automatically.

que os modelos possam compreender automaticamente.

So instead of saying MCP versus API, it's more like MCP

Então, em vez de dizer MCP versus API, é mais como MCP

on top of APIs.

sobre as APIs.

This distinction is key.

Essa distinção é fundamental.

MCP doesn't compete with APIs.

O MCP não compete com as APIs.

It actually leverages them, but it changes

Na verdade, isso aproveita essas ferramentas, mas muda

who the client is with API.

quem é o cliente na API.

The client is another program or user with MCP,

O cliente é outro programa ou usuário com o MCP,

the client is the model itself.

o cliente é o próprio modelo.

And that subtle difference changes

E essa diferença sutil muda

everything about how we design integrations.

tudo sobre como nós projetamos integrações.

Let's Zoom out for a bit.

Vamos dar um passo atrás por um instante.

The rise of MCP is part of a bigger

A ascensão do MCP é parte de uma tendência maior

movement towards model native software architecture.

um movimento em direção à arquitetura de software nativa de modelos.

For decades, we've built systems for humans and for code.

Há décadas, a gente vem criando sistemas para humanos e para código.

Now we're building systems for models and models

Agora estamos criando sistemas para modelos e modelos

don't consume REST endpoints the way code does.

não consomem endpoints REST da mesma forma que o código.

Vocabulário (562 palavras)

hereserverresourcesneedslimitsweredocscontractspurposedeadbecameengineeringneedingwherepartmessyuniversalmomentnointegrationhadclienttheyrealalsoinventingticketscallingdataturningmanualmagicdescriptionsbeautytryingparametersnextteachingfiguresyou'vehumansfilebringcanintegrationsuserseeingdynamicallysitstoolsfinalaboutunifiedkeysocommunicatestoplanguagegeminiboth

Estude com a lição completa

Crie uma conta grátis e ganhe 15 novas palavras por dia.

Criar conta grátis

← Ver todas as lições