2025-10
Autor: woakas — CTO @ Ubidots
Model Context Protocol (MCP)

Tomado de https://modelcontextprotocol.io/docs/getting-started/intro
MCP
- Statefull
- Initialization
- Operation
- Shutdown

Motivación / Contexto
- Problema: Integraciones ad-hoc con herramientas externas.
- Solución: MCP estandariza acceso a herramientas y datos.
- Objetivo: Reducir acoplamiento, crear “USB-C para IA”.
Prompts
- Plantillas con variables que permiten guiar al LLM
- Facilitan la comunicación entre usuarios y el MCP.
Resources
- Datos y servicios necesarios para el funcionamiento del MCP.
- Incluyen APIs, bases de datos y servicios externos.
- Importancia técnica: Proporciona “memoria” o “contexto adicional” para el LLM
Tools
- Herramientas para implementar y gestionar el MCP.
- Ejemplos: SDKs, plataformas de desarrollo y entornos de prueba.
Prompts
Guían la generación de textual del LLM
Resources
Aportan datos/contexto
Tools
Permiten ejecutar acciones
Modelo
Aplicación
Usuario
Arquitectura general MCP
Componentes: Host (cliente) ↔ Servidor MCP
Funciones clave: Tools, Resources, Prompts
Flujo base: handshake → discovery → tool invocation → streaming → close

JSON-RPC
Protocolo ligero para comunicación remota.
Mensajes: request, response, error handling.
JSON-RPC
{
"jsonrpc": "2.0",
"method": "sumar",
"params": [5, 3],
"id": 1
}{
"jsonrpc": "2.0",
"result": 8,
"id": 1
}{
"jsonrpc": "2.0",
"error": {
"code": -32602,
"message": "Parámetros inválidos"
},
"id": 1
}Request
Response (OK)
Response (Error)
Server-Sent Events (SSE)
Flujo continuo de datos desde servidor a cliente.
Ideal para aplicaciones en tiempo real.
Content-type: text/event-stream
https://html.spec.whatwg.org/multipage/server-sent-events.html#server-sent-events
Server-Sent Events (SSE)
event: progress
data: {"jsonrpc":"2.0","method":"notifications/progress","params":{"id":101}}
event: message
data: HOLA
event: result
data: {}
id: 23
data: {}
event: done
data: {"id":101}Langbase stream
curl https://api.langbase.com/v1/pipes/run \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer TOKEN' \
-d '{"threadId": "THREAD",
"messages": [{
"role": "user",
"content": "Say this is a demo request"
}],
"stream": true
}' -vdata: {"id":"chatcmpl-CWl5GuhAVuEnmnOK0CUVcTffP0Lkr","object":"chat.completion.chunk","created":1761923522,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_560af6e559","choices":[{"index":0,"delta":{"role":"assistant","content":"","refusal":null},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"zU5k19vZF"}
data: {"id":"chatcmpl-CWl5GuhAVuEnmnOK0CUVcTffP0Lkr","object":"chat.completion.chunk","created":1761923522,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_560af6e559","choices":[{"index":0,"delta":{"content":"Would"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"kcfXxG"}
data: {"id":"chatcmpl-CWl5GuhAVuEnmnOK0CUVcTffP0Lkr","object":"chat.completion.chunk","created":1761923522,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_560af6e559","choices":[{"index":0,"delta":{"content":" you"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"ohhutF4"}
data: {"id":"chatcmpl-CWl5GuhAVuEnmnOK0CUVcTffP0Lkr","object":"chat.completion.chunk","created":1761923522,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_560af6e559","choices":[{"index":0,"delta":{"content":" like"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"VohU6O"}
data: {"id":"chatcmpl-CWl5GuhAVuEnmnOK0CUVcTffP0Lkr","object":"chat.completion.chunk","created":1761923522,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_560af6e559","choices":[{"index":0,"delta":{"content":" me"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"nAwg3fFN"}
data: {"id":"chatcmpl-CWl5GuhAVuEnmnOK0CUVcTffP0Lkr","object":"chat.completion.chunk","created":1761923522,"model":"gpt-4o-mini-2024-07-18","service_tier":"default","system_fingerprint":"fp_560af6e559","choices":[{"index":0,"delta":{"content":" to"},"logprobs":null,"finish_reason":null}],"usage":null,"obfuscation":"CySPkgjK"}
MCP
- Statefull
- Initialization
- Operation
- Shutdown

MCP
Initialization
curl -X POST https://mcp.ubidots.com/mcp \
-H "Content-Type: application/json" -H 'Accept: application/json, text/event-stream' \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "initialize",
"params": {
"protocolVersion": "2025-06-18",
"capabilities": {
"tools": {},
"resources": {},
"prompts": {}
},
"clientInfo": {
"name": "mi-cliente",
"version": "1.0"
}
}
}' -vMCP
Initialized
curl -i -X POST https://mcp.ubidots.com/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json,text/event-stream" \
-H "Mcp-Session-Id: fb56dfa63a2a487c8ea8ca5c09897151" \
-d '{
"jsonrpc": "2.0",
"method": "notifications/initialized",
"params": {}
}'MCP
SSE Stream
curl -i -X GET https://mcp.ubidots.com/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json,text/event-stream" \
-H "Mcp-Session-Id: fb56dfa63a2a487c8ea8ca5c09897151"MCP
tools/list
curl -X POST https://mcp.ubidots.com/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json,text/event-stream" \
-H "Mcp-Session-Id: fb56dfa63a2a487c8ea8ca5c09897151" \
-d '{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/list",
"params": {}
}'MCP
tools/call
curl -X POST https://mcp.ubidots.com/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json,text/event-stream" \
-H "Mcp-Session-Id: fb56dfa63a2a487c8ea8ca5c09897151" \
-d '{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {"name": "list_devices"}
}'MCP
tools/call
curl -X POST https://mcp.ubidots.com/mcp \
-H "Content-Type: application/json" \
-H "Accept: application/json,text/event-stream" \
-H "Mcp-Session-Id: fab1f1b03ff347de9804db1665ca584e" \
-d '{
"jsonrpc": "2.0",
"id": 3,
"method": "tools/call",
"params": {
"name": "list_devices",
"arguments": {
"fields": "id,label"
}
}
}'MCP
- Modular
- Versiones
- Json-rpc, simple
- HTTP No reinventar la ruida
- Estandar?
Gracias
Copy of Algo de DevOps
By Gustavo Angulo
Copy of Algo de DevOps
- 30